poser
A C framework for POsix SERvices
Loading...
Searching...
No Matches
random.h
Go to the documentation of this file.
1#ifndef POSER_CORE_RANDOM_H
2#define POSER_CORE_RANDOM_H
3
8#include <poser/decl.h>
9
10#include <stddef.h>
11#include <stdint.h>
12
31typedef enum PSC_RandomFlags
32{
34 PSC_RF_NONBLOCK = (1 << 0),
35 PSC_RF_WLOGPSEUDO = (1 << 1),
36 PSC_RF_ELOGPSEUDO = (1 << 2),
37 PSC_RF_SECURE = (1 << 3)
39
51DECLEXPORT size_t
52PSC_Random_bytes(uint8_t *buf, size_t count, PSC_RandomFlags flags)
53 ATTR_NONNULL((1)) ATTR_ACCESS((write_only, 1, 2));
54
66DECLEXPORT size_t
67PSC_Random_string(char *str, size_t size, PSC_RandomFlags flags)
68 ATTR_NONNULL((1)) ATTR_ACCESS((write_only, 1, 2));
69
80DECLEXPORT char *
81PSC_Random_createStr(size_t count, PSC_RandomFlags flags)
82 ATTR_MALLOC;
83
84#endif
size_t PSC_Random_bytes(uint8_t *buf, size_t count, PSC_RandomFlags flags)
Fill a buffer with random bytes.
PSC_RandomFlags
Flags controlling how random bytes are obtained.
Definition: random.h:32
@ PSC_RF_WLOGPSEUDO
Log a warning when using simple PRNG.
Definition: random.h:35
@ PSC_RF_ELOGPSEUDO
Log an error when using simple PRNG.
Definition: random.h:36
@ PSC_RF_NONBLOCK
Don't use methods that might block.
Definition: random.h:34
@ PSC_RF_ANY
Allow any method for random data.
Definition: random.h:33
@ PSC_RF_SECURE
Never use a simple PRNG.
Definition: random.h:37