Move RC4 + SOBER128 to src/stream/
This commit is contained in:
@@ -939,7 +939,7 @@ LTC_MUTEX_PROTO(ltc_cipher_mutex)
|
||||
|
||||
/* ---- stream ciphers ---- */
|
||||
|
||||
#ifdef LTC_CHACHA
|
||||
#ifdef LTC_CHACHA_STREAM
|
||||
|
||||
typedef struct {
|
||||
ulong32 input[16];
|
||||
@@ -957,7 +957,41 @@ int chacha_keystream(chacha_state *st, unsigned char *out, unsigned long outlen)
|
||||
int chacha_done(chacha_state *st);
|
||||
int chacha_test(void);
|
||||
|
||||
#endif /* LTC_CHACHA */
|
||||
#endif /* LTC_CHACHA_STREAM */
|
||||
|
||||
#ifdef LTC_RC4_STREAM
|
||||
|
||||
typedef struct {
|
||||
int x, y;
|
||||
unsigned char buf[256];
|
||||
} rc4_state;
|
||||
|
||||
int rc4_setup(rc4_state *st, const unsigned char *key, unsigned long keylen);
|
||||
int rc4_crypt(rc4_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out);
|
||||
int rc4_keystream(rc4_state *st, unsigned char *out, unsigned long outlen);
|
||||
int rc4_stream_done(rc4_state *st);
|
||||
int rc4_test(void);
|
||||
|
||||
#endif /* LTC_RC4_STREAM */
|
||||
|
||||
#ifdef LTC_SOBER128_STREAM
|
||||
|
||||
typedef struct {
|
||||
ulong32 R[17], /* Working storage for the shift register */
|
||||
initR[17], /* saved register contents */
|
||||
konst, /* key dependent constant */
|
||||
sbuf; /* partial word encryption buffer */
|
||||
int nbuf; /* number of part-word stream bits buffered */
|
||||
} sober128_state;
|
||||
|
||||
int sober128_setup(sober128_state *st, const unsigned char *key, unsigned long keylen);
|
||||
int sober128_setiv(sober128_state *st, const unsigned char *iv, unsigned long ivlen);
|
||||
int sober128_crypt(sober128_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out);
|
||||
int sober128_keystream(sober128_state *st, unsigned char *out, unsigned long outlen);
|
||||
int sober128_stream_done(sober128_state *st);
|
||||
int sober128_test(void);
|
||||
|
||||
#endif /* LTC_SOBER128_STREAM */
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
|
||||
@@ -189,8 +189,11 @@
|
||||
#define LTC_KASUMI
|
||||
#define LTC_MULTI2
|
||||
#define LTC_CAMELLIA
|
||||
/* ChaCha is special (a stream cipher) */
|
||||
#define LTC_CHACHA
|
||||
|
||||
/* stream ciphers */
|
||||
#define LTC_CHACHA_STREAM
|
||||
#define LTC_RC4_STREAM
|
||||
#define LTC_SOBER128_STREAM
|
||||
|
||||
#endif /* LTC_NO_CIPHERS */
|
||||
|
||||
@@ -295,7 +298,7 @@
|
||||
/* a PRNG that simply reads from an available system source */
|
||||
#define LTC_SPRNG
|
||||
|
||||
/* The LTC_RC4 stream cipher */
|
||||
/* The RC4 stream cipher based PRNG */
|
||||
#define LTC_RC4
|
||||
|
||||
/* The ChaCha20 stream cipher based PRNG */
|
||||
@@ -304,7 +307,7 @@
|
||||
/* Fortuna PRNG */
|
||||
#define LTC_FORTUNA
|
||||
|
||||
/* Greg's LTC_SOBER128 PRNG ;-0 */
|
||||
/* Greg's SOBER128 stream cipher based PRNG */
|
||||
#define LTC_SOBER128
|
||||
|
||||
/* the *nix style /dev/random device */
|
||||
@@ -515,12 +518,20 @@
|
||||
#error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled
|
||||
#endif
|
||||
|
||||
#if defined(LTC_CHACHA20POLY1305_MODE) && (!defined(LTC_CHACHA) || !defined(LTC_POLY1305))
|
||||
#error LTC_CHACHA20POLY1305_MODE requires LTC_CHACHA + LTC_POLY1305
|
||||
#if defined(LTC_CHACHA20POLY1305_MODE) && (!defined(LTC_CHACHA_STREAM) || !defined(LTC_POLY1305))
|
||||
#error LTC_CHACHA20POLY1305_MODE requires LTC_CHACHA_STREAM + LTC_POLY1305
|
||||
#endif
|
||||
|
||||
#if defined(LTC_CHACHA20_PRNG) && !defined(LTC_CHACHA)
|
||||
#error LTC_CHACHA20_PRNG requires LTC_CHACHA
|
||||
#if defined(LTC_CHACHA20_PRNG) && !defined(LTC_CHACHA_STREAM)
|
||||
#error LTC_CHACHA20_PRNG requires LTC_CHACHA_STREAM
|
||||
#endif
|
||||
|
||||
#if defined(LTC_RC4) && !defined(LTC_RC4_STREAM)
|
||||
#error LTC_RC4 requires LTC_RC4_STREAM
|
||||
#endif
|
||||
|
||||
#if defined(LTC_SOBER128) && !defined(LTC_SOBER128_STREAM)
|
||||
#error LTC_SOBER128 requires LTC_SOBER128_STREAM
|
||||
#endif
|
||||
|
||||
#if defined(LTC_BLAKE2SMAC) && !defined(LTC_BLAKE2S)
|
||||
@@ -557,7 +568,7 @@
|
||||
|
||||
/* Debuggers */
|
||||
|
||||
/* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and LTC_RC4 work (see the code) */
|
||||
/* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and RC4 work (see the code) */
|
||||
/* #define LTC_VALGRIND */
|
||||
|
||||
#endif
|
||||
|
||||
+15
-21
@@ -4,14 +4,12 @@ struct yarrow_prng {
|
||||
int cipher, hash;
|
||||
unsigned char pool[MAXBLOCKSIZE];
|
||||
symmetric_CTR ctr;
|
||||
LTC_MUTEX_TYPE(prng_lock)
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LTC_RC4
|
||||
struct rc4_prng {
|
||||
int x, y;
|
||||
unsigned char buf[256];
|
||||
rc4_state s;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -20,7 +18,6 @@ struct chacha20_prng {
|
||||
chacha_state s; /* chacha state */
|
||||
unsigned char ent[40]; /* entropy buffer */
|
||||
unsigned long idx; /* entropy counter */
|
||||
short ready; /* ready flag 0-1 */
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -38,41 +35,38 @@ struct fortuna_prng {
|
||||
wd;
|
||||
|
||||
ulong64 reset_cnt; /* number of times we have reset */
|
||||
LTC_MUTEX_TYPE(prng_lock)
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LTC_SOBER128
|
||||
struct sober128_prng {
|
||||
ulong32 R[17], /* Working storage for the shift register */
|
||||
initR[17], /* saved register contents */
|
||||
konst, /* key dependent constant */
|
||||
sbuf; /* partial word encryption buffer */
|
||||
|
||||
int nbuf, /* number of part-word stream bits buffered */
|
||||
flag, /* first add_entropy call or not? */
|
||||
set; /* did we call add_entropy to set key? */
|
||||
|
||||
sober128_state s; /* sober128 state */
|
||||
unsigned char ent[40]; /* entropy buffer */
|
||||
unsigned long idx; /* entropy counter */
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef union Prng_state {
|
||||
char dummy[1];
|
||||
typedef struct {
|
||||
union {
|
||||
char dummy[1];
|
||||
#ifdef LTC_YARROW
|
||||
struct yarrow_prng yarrow;
|
||||
struct yarrow_prng yarrow;
|
||||
#endif
|
||||
#ifdef LTC_RC4
|
||||
struct rc4_prng rc4;
|
||||
struct rc4_prng rc4;
|
||||
#endif
|
||||
#ifdef LTC_CHACHA20_PRNG
|
||||
struct chacha20_prng chacha;
|
||||
struct chacha20_prng chacha;
|
||||
#endif
|
||||
#ifdef LTC_FORTUNA
|
||||
struct fortuna_prng fortuna;
|
||||
struct fortuna_prng fortuna;
|
||||
#endif
|
||||
#ifdef LTC_SOBER128
|
||||
struct sober128_prng sober128;
|
||||
struct sober128_prng sober128;
|
||||
#endif
|
||||
};
|
||||
short ready; /* ready flag 0-1 */
|
||||
LTC_MUTEX_TYPE(lock); /* lock */
|
||||
} prng_state;
|
||||
|
||||
/** PRNG descriptor */
|
||||
|
||||
Reference in New Issue
Block a user