Skip to content

Commit

Permalink
Use a better seed source.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-anderson-sonarsource committed Mar 29, 2024
1 parent 85029fc commit 2443550
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rules/S4347/csharp/how-to-fix-it/bouncycastle.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ sr.NextBytes(random);
----

Use unpredictable values to seed `DigestRandomGenerator` and
`VmpcRandomGenerator` instances.
`VmpcRandomGenerator` instances. The `SecureRandom.GenerateSeed()` method is
designed for this purpose.

[source,csharp,diff-id=102,diff-type=compliant]
----
Expand All @@ -92,7 +93,7 @@ digest.AddSeedMaterial(SecureRandom.GenerateSeed(16));
digest.NextBytes(random);
IRandomGenerator vmpc = new VmpcRandomGenerator();
vmpc.AddSeedMaterial(Guid.NewGuid().ToByteArray());
vmpc.AddSeedMaterial(SecureRandom.GenerateSeed(16));
vmpc.NextBytes(random);
----

Expand Down

0 comments on commit 2443550

Please sign in to comment.