summaryrefslogtreecommitdiff
path: root/examples/openssl/hf_rand_lib.h
blob: 349ecac88f7793b8455f154eb3f329f64333f85b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <openssl/rand.h>

#ifdef __cplusplus
extern "C" {
#endif

static int hf_rnd(unsigned char* buf, int num)
{
    for (size_t v = 0; v < num; v++) {
        buf[v] = v + 1;
    }
    return 1;
}

static int hf_stat(void)
{
    return 1;
}

static RAND_METHOD hf_method = {
    NULL,
    hf_rnd,
    NULL,
    NULL,
    hf_rnd,
    hf_stat,
};

void HFResetRand(void)
{
    RAND_set_rand_method(&hf_method);
}

#ifdef __cplusplus
} // extern "C"
#endif