Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
rand.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
Include dependency graph for rand.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define YH_INTERNAL   __attribute__((visibility("hidden")))
 

Functions

bool YH_INTERNAL rand_generate (uint8_t *buf, size_t cb_buf)
 

Macro Definition Documentation

◆ YH_INTERNAL

#define YH_INTERNAL   __attribute__((visibility("hidden")))

Definition at line 34 of file rand.h.

Function Documentation

◆ rand_generate()

bool YH_INTERNAL 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: