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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#ifndef H_RANDOM_INCLUDED
#define H_RANDOM_INCLUDED
struct webid_oidc_random_context;
typedef struct webid_oidc_random_context webid_oidc_random_context;
/* These functions allocate data, they are not reentrant. */
struct webid_oidc_random_context *webid_oidc_random_context_alloc (void);
void webid_oidc_random_context_free (struct webid_oidc_random_context *ctx);
enum webid_oidc_random_context_state
{
WEBID_OIDC_RANDOM_CONTEXT_READY = 0,
WEBID_OIDC_RANDOM_CONTEXT_WAIT_LOCK_FILE,
WEBID_OIDC_RANDOM_CONTEXT_WAIT_FILE_READ,
WEBID_OIDC_RANDOM_CONTEXT_WAIT_FILE_WRITE,
WEBID_OIDC_RANDOM_CONTEXT_WAIT_UNLOCK_FILE
};
typedef enum webid_oidc_random_context_state webid_oidc_random_context_state;
enum webid_oidc_random_context_state
webid_oidc_random_context_get_state (const struct webid_oidc_random_context
*ctx);
int webid_oidc_random_context_get_wait_bytes (const struct
webid_oidc_random_context *ctx,
size_t max, size_t start,
uint8_t * bytes,
size_t *n_bytes);
int webid_oidc_random_context_ok (struct webid_oidc_random_context *ctx);
int webid_oidc_random_context_bytes (struct webid_oidc_random_context *ctx,
size_t n_bytes, const uint8_t * bytes);
enum webid_oidc_random_context_spawn_flags
{
WEBID_OIDC_RANDOM_CONTEXT_THREAD_UNSAFE = 1
};
typedef enum webid_oidc_random_context_spawn_flags
webid_oidc_random_context_spawn_flags;
int webid_oidc_random_context_spawn (struct webid_oidc_random_context *parent,
struct webid_oidc_random_context *child,
enum
webid_oidc_random_context_spawn_flags
flags);
int webid_oidc_random_context_get (struct webid_oidc_random_context *ctx,
size_t request_size, uint8_t * data);
/* These functions set up and use a global state. Neither are
reentrant. */
void webid_oidc_random_init (void);
/* This function is thread-safe. */
void webid_oidc_random (size_t request_size, uint8_t * data);
#endif /* not H_RANDOM_INCLUDED */
|