Use BCrypt for get byte on windows (#86)
* Use BCrypt for get byte on windows
* Revert "Use BCrypt for get byte on windows"
This reverts commit e664b927f2
.
* Revert changes to method signature, move assert. remove mod operation
This commit is contained in:
Родитель
5054191902
Коммит
2d9d55d2ae
|
@ -5,6 +5,7 @@
|
|||
|
||||
#ifdef HAVE_BCRYPTGENRANDOM
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
#include <ntstatus.h>
|
||||
#include <bcrypt.h>
|
||||
#endif
|
||||
|
@ -63,9 +64,9 @@ uint8_t RandomSource_get_byte(RandomSource source)
|
|||
size_t item_count;
|
||||
uint8_t ret;
|
||||
#ifdef HAVE_BCRYPTGENRANDOM
|
||||
//NTSTATUS ntstatus =
|
||||
//BCryptGenRandom(NULL, &ret, 1, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
ret = 1;
|
||||
NTSTATUS ntstatus =
|
||||
BCryptGenRandom(NULL, &ret, 1, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
assert(ntstatus == STATUS_SUCCESS);
|
||||
#else
|
||||
fread(&ret, 1, 1, source->dev_random);
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,7 @@ void generate_keys(rsa_private_key* priv_key, rsa_public_key* pub_key)
|
|||
/* Select p */
|
||||
for(int i = 0; i < BUFFER_SIZE; i++)
|
||||
{
|
||||
buffer[i] = RandomSource_get_byte(source) % 0xFF;
|
||||
buffer[i] = RandomSource_get_byte(source);
|
||||
}
|
||||
|
||||
buffer[0] |= 0xC0; // Set the top two bits to 1 to ensure int(tmp) is relatively large
|
||||
|
|
Загрузка…
Ссылка в новой задаче