Mercurial > dropbear
comparison libtomcrypt/src/prngs/sprng.c @ 285:1b9e69c058d2
propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 20dccfc09627970a312d77fb41dc2970b62689c3)
to branch 'au.asn.ucc.matt.dropbear' (head fdf4a7a3b97ae5046139915de7e40399cceb2c01)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 08 Mar 2006 13:23:58 +0000 |
parents | |
children | 0cbe8f6dbf9e |
comparison
equal
deleted
inserted
replaced
281:997e6f7dc01e | 285:1b9e69c058d2 |
---|---|
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 #include "tomcrypt.h" | |
12 | |
13 /** | |
14 @file sprng.c | |
15 Secure PRNG, Tom St Denis | |
16 */ | |
17 | |
18 /* A secure PRNG using the RNG functions. Basically this is a | |
19 * wrapper that allows you to use a secure RNG as a PRNG | |
20 * in the various other functions. | |
21 */ | |
22 | |
23 #ifdef SPRNG | |
24 | |
25 const struct ltc_prng_descriptor sprng_desc = | |
26 { | |
27 "sprng", 0, | |
28 &sprng_start, | |
29 &sprng_add_entropy, | |
30 &sprng_ready, | |
31 &sprng_read, | |
32 &sprng_done, | |
33 &sprng_export, | |
34 &sprng_import, | |
35 &sprng_test | |
36 }; | |
37 | |
38 /** | |
39 Start the PRNG | |
40 @param prng [out] The PRNG state to initialize | |
41 @return CRYPT_OK if successful | |
42 */ | |
43 int sprng_start(prng_state *prng) | |
44 { | |
45 return CRYPT_OK; | |
46 } | |
47 | |
48 /** | |
49 Add entropy to the PRNG state | |
50 @param in The data to add | |
51 @param inlen Length of the data to add | |
52 @param prng PRNG state to update | |
53 @return CRYPT_OK if successful | |
54 */ | |
55 int sprng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng) | |
56 { | |
57 return CRYPT_OK; | |
58 } | |
59 | |
60 /** | |
61 Make the PRNG ready to read from | |
62 @param prng The PRNG to make active | |
63 @return CRYPT_OK if successful | |
64 */ | |
65 int sprng_ready(prng_state *prng) | |
66 { | |
67 return CRYPT_OK; | |
68 } | |
69 | |
70 /** | |
71 Read from the PRNG | |
72 @param out Destination | |
73 @param outlen Length of output | |
74 @param prng The active PRNG to read from | |
75 @return Number of octets read | |
76 */ | |
77 unsigned long sprng_read(unsigned char *out, unsigned long outlen, prng_state *prng) | |
78 { | |
79 LTC_ARGCHK(out != NULL); | |
80 return rng_get_bytes(out, outlen, NULL); | |
81 } | |
82 | |
83 /** | |
84 Terminate the PRNG | |
85 @param prng The PRNG to terminate | |
86 @return CRYPT_OK if successful | |
87 */ | |
88 int sprng_done(prng_state *prng) | |
89 { | |
90 return CRYPT_OK; | |
91 } | |
92 | |
93 /** | |
94 Export the PRNG state | |
95 @param out [out] Destination | |
96 @param outlen [in/out] Max size and resulting size of the state | |
97 @param prng The PRNG to export | |
98 @return CRYPT_OK if successful | |
99 */ | |
100 int sprng_export(unsigned char *out, unsigned long *outlen, prng_state *prng) | |
101 { | |
102 LTC_ARGCHK(outlen != NULL); | |
103 | |
104 *outlen = 0; | |
105 return CRYPT_OK; | |
106 } | |
107 | |
108 /** | |
109 Import a PRNG state | |
110 @param in The PRNG state | |
111 @param inlen Size of the state | |
112 @param prng The PRNG to import | |
113 @return CRYPT_OK if successful | |
114 */ | |
115 int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng) | |
116 { | |
117 return CRYPT_OK; | |
118 } | |
119 | |
120 /** | |
121 PRNG self-test | |
122 @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled | |
123 */ | |
124 int sprng_test(void) | |
125 { | |
126 return CRYPT_OK; | |
127 } | |
128 | |
129 #endif | |
130 | |
131 | |
132 | |
133 | |
134 /* $Source: /cvs/libtom/libtomcrypt/src/prngs/sprng.c,v $ */ | |
135 /* $Revision: 1.3 $ */ | |
136 /* $Date: 2005/05/05 14:35:59 $ */ |