#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
Go to the source code of this file.
|
#define | YH_INTERNAL __attribute__((visibility("hidden"))) |
|
◆ YH_INTERNAL
#define YH_INTERNAL __attribute__((visibility("hidden"))) |
◆ rand_generate()
Definition at line 27 of file rand.c.
27 {
28
29#ifdef _WIN32_BCRYPT
30 NTSTATUS status = STATUS_SUCCESS;
31
32 BCRYPT_ALG_HANDLE hAlg = 0;
33
34 if (!BCRYPT_SUCCESS(
35 status =
36 BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_RNG_ALGORITHM, NULL, 0))) {
37 return false;
38 }
39
40 status = BCryptGenRandom(hAlg,
buf, (ULONG) cb_buf, 0);
41 BCryptCloseAlgorithmProvider(hAlg, 0);
42
43 return BCRYPT_SUCCESS(status);
44
45#else
46 return (1 == RAND_bytes(
buf, cb_buf));
47
48#endif
49}