3
|
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis |
|
2 * |
|
3 * LibTomCrypt is a library that provides various cryptographic |
|
4 * algorithms in a highly modular and flexible manner. |
|
5 * |
|
6 * The library is free for all purposes without any express |
|
7 * guarantee it works. |
|
8 * |
|
9 * Tom St Denis, [email protected], http://libtomcrypt.org |
|
10 */ |
|
11 |
|
12 /* A secure PRNG using the RNG functions. Basically this is a |
|
13 * wrapper that allows you to use a secure RNG as a PRNG |
|
14 * in the various other functions. |
|
15 */ |
|
16 #include "mycrypt.h" |
|
17 |
|
18 #ifdef SPRNG |
|
19 |
|
20 const struct _prng_descriptor sprng_desc = |
|
21 { |
143
|
22 "sprng", 0, |
3
|
23 &sprng_start, |
|
24 &sprng_add_entropy, |
|
25 &sprng_ready, |
143
|
26 &sprng_read, |
|
27 &sprng_done, |
|
28 &sprng_export, |
|
29 &sprng_import, |
|
30 &sprng_test |
3
|
31 }; |
|
32 |
|
33 int sprng_start(prng_state *prng) |
|
34 { |
|
35 return CRYPT_OK; |
|
36 } |
|
37 |
|
38 int sprng_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng) |
|
39 { |
|
40 return CRYPT_OK; |
|
41 } |
|
42 |
|
43 int sprng_ready(prng_state *prng) |
|
44 { |
|
45 return CRYPT_OK; |
|
46 } |
|
47 |
|
48 unsigned long sprng_read(unsigned char *buf, unsigned long len, prng_state *prng) |
|
49 { |
|
50 _ARGCHK(buf != NULL); |
|
51 return rng_get_bytes(buf, len, NULL); |
|
52 } |
|
53 |
143
|
54 int sprng_done(prng_state *prng) |
|
55 { |
|
56 return CRYPT_OK; |
|
57 } |
|
58 |
|
59 int sprng_export(unsigned char *out, unsigned long *outlen, prng_state *prng) |
|
60 { |
|
61 _ARGCHK(outlen != NULL); |
|
62 |
|
63 *outlen = 0; |
|
64 return CRYPT_OK; |
|
65 } |
|
66 |
|
67 int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng) |
|
68 { |
|
69 return CRYPT_OK; |
|
70 } |
|
71 |
|
72 int sprng_test(void) |
|
73 { |
|
74 return CRYPT_OK; |
|
75 } |
|
76 |
3
|
77 #endif |
|
78 |
|
79 |
|
80 |