Skip to content

Commit f7a6770

Browse files
authored
Enforcing thread safe implementation of RandomNumberGenerator for V3Hasher (#7238)
1 parent 548d05d commit f7a6770

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/NuGetGallery.Services/Authentication/V3Hasher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace NuGetGallery.Infrastructure.Authentication
1414
/// </summary>
1515
public static class V3Hasher
1616
{
17-
private static readonly RandomNumberGenerator DefaultRng = RandomNumberGenerator.Create(); // secure PRNG
17+
private static readonly RNGCryptoServiceProvider DefaultRng = new RNGCryptoServiceProvider();
1818

1919
private const int IterationCount = 10000;
2020

@@ -86,7 +86,7 @@ public static bool VerifyHash(string hashedData, string providedInput)
8686
return VerifyHash(Convert.FromBase64String(hashedData), providedInput);
8787
}
8888

89-
private static byte[] GenerateHashInternal(string input, RandomNumberGenerator rng, KeyDerivationPrf prf, int iterCount, int saltSize, int numBytesRequested)
89+
private static byte[] GenerateHashInternal(string input, RNGCryptoServiceProvider rng, KeyDerivationPrf prf, int iterCount, int saltSize, int numBytesRequested)
9090
{
9191
// Produce a version 3 (see comment above) text hash.
9292
byte[] salt = new byte[saltSize];

0 commit comments

Comments
 (0)