libtomcrypt/mycrypt_prng.h

67 lines
2.1 KiB
C
Raw Normal View History

2003-03-03 00:59:24 +00:00
/* ---- PRNG Stuff ---- */
struct yarrow_prng {
int cipher, hash;
unsigned char pool[MAXBLOCKSIZE];
symmetric_CTR ctr;
};
struct rc4_prng {
int x, y;
unsigned char buf[256];
};
typedef union Prng_state {
struct yarrow_prng yarrow;
struct rc4_prng rc4;
} prng_state;
extern struct _prng_descriptor {
char *name;
int (*start)(prng_state *);
int (*add_entropy)(const unsigned char *, unsigned long, prng_state *);
int (*ready)(prng_state *);
unsigned long (*read)(unsigned char *, unsigned long len, prng_state *);
} prng_descriptor[];
#ifdef YARROW
2004-06-20 02:41:49 +00:00
int yarrow_start(prng_state *prng);
int yarrow_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng);
int yarrow_ready(prng_state *prng);
unsigned long yarrow_read(unsigned char *buf, unsigned long len, prng_state *prng);
extern const struct _prng_descriptor yarrow_desc;
2003-03-03 00:59:24 +00:00
#endif
#ifdef RC4
2004-06-20 02:41:49 +00:00
int rc4_start(prng_state *prng);
int rc4_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng);
int rc4_ready(prng_state *prng);
unsigned long rc4_read(unsigned char *buf, unsigned long len, prng_state *prng);
extern const struct _prng_descriptor rc4_desc;
2003-03-03 00:59:24 +00:00
#endif
#ifdef SPRNG
2004-06-20 02:41:49 +00:00
int sprng_start(prng_state *prng);
int sprng_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng);
int sprng_ready(prng_state *prng);
unsigned long sprng_read(unsigned char *buf, unsigned long len, prng_state *prng);
extern const struct _prng_descriptor sprng_desc;
2003-03-03 00:59:24 +00:00
#endif
2004-06-20 02:41:49 +00:00
int find_prng(const char *name);
int register_prng(const struct _prng_descriptor *prng);
int unregister_prng(const struct _prng_descriptor *prng);
int prng_is_valid(int idx);
2003-03-03 00:59:24 +00:00
/* 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
*/
2003-03-03 01:03:50 +00:00
/* ch2-02-1 */
2004-06-20 02:41:49 +00:00
unsigned long rng_get_bytes(unsigned char *buf,
2003-03-03 01:03:50 +00:00
unsigned long len,
void (*callback)(void));
/* ch2-02-1 */
2003-03-03 00:59:24 +00:00
2004-06-20 02:41:49 +00:00
int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
2003-03-03 00:59:24 +00:00