|
|
@@ -48,31 +48,10 @@ struct sober128_prng {
|
|
|
};
|
|
|
#endif
|
|
|
|
|
|
-typedef struct {
|
|
|
- union {
|
|
|
- char dummy[1];
|
|
|
-#ifdef LTC_YARROW
|
|
|
- struct yarrow_prng yarrow;
|
|
|
-#endif
|
|
|
-#ifdef LTC_RC4
|
|
|
- struct rc4_prng rc4;
|
|
|
-#endif
|
|
|
-#ifdef LTC_CHACHA20_PRNG
|
|
|
- struct chacha20_prng chacha;
|
|
|
-#endif
|
|
|
-#ifdef LTC_FORTUNA
|
|
|
- struct fortuna_prng fortuna;
|
|
|
-#endif
|
|
|
-#ifdef LTC_SOBER128
|
|
|
- struct sober128_prng sober128;
|
|
|
-#endif
|
|
|
- } u;
|
|
|
- short ready; /* ready flag 0-1 */
|
|
|
- LTC_MUTEX_TYPE(lock) /* lock */
|
|
|
-} prng_state;
|
|
|
+typedef struct ltc_prng_state prng_state;
|
|
|
|
|
|
/** PRNG descriptor */
|
|
|
-extern struct ltc_prng_descriptor {
|
|
|
+struct ltc_prng_descriptor {
|
|
|
/** Name of the PRNG */
|
|
|
const char *name;
|
|
|
/** size in bytes of exported state */
|
|
|
@@ -124,7 +103,31 @@ extern struct ltc_prng_descriptor {
|
|
|
@return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled
|
|
|
*/
|
|
|
int (*test)(void);
|
|
|
-} prng_descriptor[];
|
|
|
+};
|
|
|
+
|
|
|
+struct ltc_prng_state {
|
|
|
+ union {
|
|
|
+ char dummy[1];
|
|
|
+#ifdef LTC_YARROW
|
|
|
+ struct yarrow_prng yarrow;
|
|
|
+#endif
|
|
|
+#ifdef LTC_RC4
|
|
|
+ struct rc4_prng rc4;
|
|
|
+#endif
|
|
|
+#ifdef LTC_CHACHA20_PRNG
|
|
|
+ struct chacha20_prng chacha;
|
|
|
+#endif
|
|
|
+#ifdef LTC_FORTUNA
|
|
|
+ struct fortuna_prng fortuna;
|
|
|
+#endif
|
|
|
+#ifdef LTC_SOBER128
|
|
|
+ struct sober128_prng sober128;
|
|
|
+#endif
|
|
|
+ } u;
|
|
|
+ short ready; /* ready flag 0-1 */
|
|
|
+ struct ltc_prng_descriptor desc;
|
|
|
+ LTC_MUTEX_TYPE(lock) /* lock */
|
|
|
+};
|
|
|
|
|
|
#ifdef LTC_YARROW
|
|
|
int yarrow_start(prng_state *prng);
|
|
|
@@ -135,7 +138,6 @@ int yarrow_done(prng_state *prng);
|
|
|
int yarrow_export(unsigned char *out, unsigned long *outlen, prng_state *prng);
|
|
|
int yarrow_import(const unsigned char *in, unsigned long inlen, prng_state *prng);
|
|
|
int yarrow_test(void);
|
|
|
-extern const struct ltc_prng_descriptor yarrow_desc;
|
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_FORTUNA
|
|
|
@@ -149,7 +151,6 @@ int fortuna_export(unsigned char *out, unsigned long *outlen, prng_state *prng);
|
|
|
int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prng);
|
|
|
int fortuna_update_seed(const unsigned char *in, unsigned long inlen, prng_state *prng);
|
|
|
int fortuna_test(void);
|
|
|
-extern const struct ltc_prng_descriptor fortuna_desc;
|
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_RC4
|
|
|
@@ -161,7 +162,6 @@ int rc4_done(prng_state *prng);
|
|
|
int rc4_export(unsigned char *out, unsigned long *outlen, prng_state *prng);
|
|
|
int rc4_import(const unsigned char *in, unsigned long inlen, prng_state *prng);
|
|
|
int rc4_test(void);
|
|
|
-extern const struct ltc_prng_descriptor rc4_desc;
|
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_CHACHA20_PRNG
|
|
|
@@ -173,7 +173,6 @@ int chacha20_prng_done(prng_state *prng);
|
|
|
int chacha20_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng);
|
|
|
int chacha20_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prng);
|
|
|
int chacha20_prng_test(void);
|
|
|
-extern const struct ltc_prng_descriptor chacha20_prng_desc;
|
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_SPRNG
|
|
|
@@ -185,7 +184,6 @@ int sprng_done(prng_state *prng);
|
|
|
int sprng_export(unsigned char *out, unsigned long *outlen, prng_state *prng);
|
|
|
int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng);
|
|
|
int sprng_test(void);
|
|
|
-extern const struct ltc_prng_descriptor sprng_desc;
|
|
|
#endif
|
|
|
|
|
|
#ifdef LTC_SOBER128
|
|
|
@@ -197,16 +195,8 @@ int sober128_done(prng_state *prng);
|
|
|
int sober128_export(unsigned char *out, unsigned long *outlen, prng_state *prng);
|
|
|
int sober128_import(const unsigned char *in, unsigned long inlen, prng_state *prng);
|
|
|
int sober128_test(void);
|
|
|
-extern const struct ltc_prng_descriptor sober128_desc;
|
|
|
#endif
|
|
|
|
|
|
-int find_prng(const char *name);
|
|
|
-int register_prng(const struct ltc_prng_descriptor *prng);
|
|
|
-int unregister_prng(const struct ltc_prng_descriptor *prng);
|
|
|
-int register_all_prngs(void);
|
|
|
-int prng_is_valid(int idx);
|
|
|
-LTC_MUTEX_PROTO(ltc_prng_mutex)
|
|
|
-
|
|
|
/* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this
|
|
|
* might not work on all platforms as planned
|
|
|
*/
|
|
|
@@ -214,7 +204,7 @@ unsigned long rng_get_bytes(unsigned char *out,
|
|
|
unsigned long outlen,
|
|
|
void (*callback)(void));
|
|
|
|
|
|
-int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
|
|
|
+int rng_make_prng(int bits, prng_state *prng, void (*callback)(void));
|
|
|
|
|
|
#ifdef LTC_PRNG_ENABLE_LTC_RNG
|
|
|
extern unsigned long (*ltc_rng)(unsigned char *out, unsigned long outlen,
|