I am currently trying to adapt the random number generators (both the non-cryptographic version and the cryptographic version) to Mono and stumbled upon two different versions of BCryptGenRandom():
There is the version in src/Common/src/CoreLib/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs, which is int BCryptGenRandom(byte*, int) - this class also defines GetRandomBytes(byte*, int).
And then there is the version in src/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs, which is NTSTATUS BCryptGenRandom(ref byte, int).
Looking at RandomNumberGeneratorImplementation.Windows.cs, this calls the ref byte version.
Then src/Common/src/CoreLib/System/HashCode.cs calls Interop.GetRandomBytes((byte*)&result, sizeof(uint)).
The problem is that both versions define BCRYPT_USE_SYSTEM_PREFERRED_RNG, so you cannot include both source files at the same time.
Before making a PR to remove / rename one of them, I would like to ask why the two versions exist in the first place and how you would feel about maybe unifying them into just one.
I am currently trying to adapt the random number generators (both the non-cryptographic version and the cryptographic version) to Mono and stumbled upon two different versions of
BCryptGenRandom():There is the version in src/Common/src/CoreLib/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs, which is
int BCryptGenRandom(byte*, int)- this class also definesGetRandomBytes(byte*, int).And then there is the version in src/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs, which is
NTSTATUS BCryptGenRandom(ref byte, int).Looking at RandomNumberGeneratorImplementation.Windows.cs, this calls the
ref byteversion.Then src/Common/src/CoreLib/System/HashCode.cs calls
Interop.GetRandomBytes((byte*)&result, sizeof(uint)).The problem is that both versions define
BCRYPT_USE_SYSTEM_PREFERRED_RNG, so you cannot include both source files at the same time.Before making a PR to remove / rename one of them, I would like to ask why the two versions exist in the first place and how you would feel about maybe unifying them into just one.