Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
rand.c File Reference
#include "rand.h"
#include <openssl/rand.h>
Include dependency graph for rand.c:

Go to the source code of this file.

Functions

bool rand_generate (uint8_t *buf, size_t cb_buf)
 

Function Documentation

◆ rand_generate()

bool rand_generate ( uint8_t * buf,
size_t cb_buf )

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}
uint8_t buf[2048]
Here is the caller graph for this function: