Killed bcrypt, replaced with rand_s

This commit is contained in:
robert committed 2024-10-29 10:41:10 -04:00
1 parent 5ec26a5015
commit f394df840e
5 files changed
+12 -37

No files matched your search

+1 -11
View File
@@ -30,7 +30,7 @@ bool mg_random(void *buf, size_t len) {
if (initialised == true) {
success = CryptGenRandom(hProv, len, p);
}
#elif defined(_CRT_RAND_S)
#else
size_t i;
for (i = 0; i < len; i++) {
unsigned int rand_v;
@@ -41,16 +41,6 @@ bool mg_random(void *buf, size_t len) {
}
}
success = (i == len);
#else
// BCrypt is a "new generation" strong crypto API, so try it first
static BCRYPT_ALG_HANDLE hProv;
if (initialised == false &&
BCryptOpenAlgorithmProvider(&hProv, BCRYPT_RNG_ALGORITHM, NULL, 0) == 0) {
initialised = true;
}
if (initialised == true) {
success = BCryptGenRandom(hProv, p, (ULONG) len, 0) == 0;
}
#endif
#elif MG_ARCH == MG_ARCH_UNIX