File: csprng.h

package info (click to toggle)
libmath-prime-util-perl 0.73-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,800 kB
  • sloc: perl: 24,676; ansic: 11,471; python: 24; makefile: 18
file content (38 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download
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
#ifndef MPU_CSPRNG_H
#define MPU_CSPRNG_H

#include "ptypes.h"

/*****************************************************************************/

extern uint32_t csprng_context_size(void);

/* Seed and init if needed */
extern void csprng_seed(void *ctx, uint32_t bytes, const unsigned char* data);

/* Simple seed */
extern void csprng_srand(void *ctx, UV insecure_seed);

/* Fill buffer with this many bytes of random data */
extern void csprng_rand_bytes(void *ctx, uint32_t bytes, unsigned char* data);

extern uint32_t irand32(void *ctx);
extern UV       irand64(void *ctx);

/*****************************************************************************/

extern int is_csprng_well_seeded(void *ctx);

extern NV drand64(void *ctx);

extern uint32_t urandomm32(void* ctx, uint32_t n);   /* integer less than n */
extern UV       urandomm64(void* ctx, UV n);
extern UV       urandomb(void* ctx, int nbits);      /* integer with n bits */

/*****************************************************************************/

/* Very simple PRNG for other use. */
extern char* prng_new(uint32_t a, uint32_t b, uint32_t c, uint32_t d);
extern uint32_t prng_next(char* rng);

#endif