Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some dead RNG code paths #4378

Merged
merged 1 commit into from
Oct 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,39 +163,6 @@ internal static void FillRandomBytes(byte[] buffer)
RandomNumberGenerator.GetBytes(buffer);
}

/// <summary>
/// This generates the entropy using random number. This is usually used on the sending
/// side to generate the requestor's entropy.
/// </summary>
/// <param name="data">The array to fill with cryptographically strong random nonzero bytes.</param>
public static void GenerateRandomBytes(byte[] data)
{
RandomNumberGenerator.GetNonZeroBytes(data);
}

/// <summary>
/// This method generates a random byte array used as entropy with the given size.
/// </summary>
/// <param name="sizeInBits"></param>
/// <returns></returns>
public static byte[] GenerateRandomBytes(int sizeInBits)
{
int sizeInBytes = sizeInBits / 8;
if (sizeInBits <= 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(sizeInBits), SR.Format(SR.ID6033, sizeInBits)));
}
else if (sizeInBytes * 8 != sizeInBits)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.ID6002, sizeInBits), nameof(sizeInBits)));
}

byte[] data = new byte[sizeInBytes];
GenerateRandomBytes(data);

return data;
}

internal static RandomNumberGenerator RandomNumberGenerator
{
get
Expand Down