diff options
author | Matt Johnston <matt@ucc.asn.au> | 2017-06-24 17:50:50 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2017-06-24 17:50:50 +0800 |
commit | a79b61517bc7123250d0e2dc21dc18deccf0bb64 (patch) | |
tree | f95c80c6801abd286eaf370dd794859235d1be82 /libtomcrypt/src/prngs | |
parent | 99361f54ca77e0d1ff821c02d7d8df3a87aafde5 (diff) |
update to libtomcrypt 1.17 (with Dropbear changes)
Diffstat (limited to 'libtomcrypt/src/prngs')
-rw-r--r-- | libtomcrypt/src/prngs/fortuna.c | 54 | ||||
-rw-r--r-- | libtomcrypt/src/prngs/rc4.c | 16 | ||||
-rw-r--r-- | libtomcrypt/src/prngs/rng_get_bytes.c | 14 | ||||
-rw-r--r-- | libtomcrypt/src/prngs/rng_make_prng.c | 8 | ||||
-rw-r--r-- | libtomcrypt/src/prngs/sober128.c | 12 | ||||
-rw-r--r-- | libtomcrypt/src/prngs/sober128tab.c | 10 | ||||
-rw-r--r-- | libtomcrypt/src/prngs/sprng.c | 10 | ||||
-rw-r--r-- | libtomcrypt/src/prngs/yarrow.c | 76 |
8 files changed, 100 insertions, 100 deletions
diff --git a/libtomcrypt/src/prngs/fortuna.c b/libtomcrypt/src/prngs/fortuna.c index 159db52..d262a0b 100644 --- a/libtomcrypt/src/prngs/fortuna.c +++ b/libtomcrypt/src/prngs/fortuna.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" @@ -19,22 +19,22 @@ We deviate slightly here for reasons of simplicity [and to fit in the API]. First all "sources" in the AddEntropy function are fixed to 0. Second since no reliable timer is provided -we reseed automatically when len(pool0) >= 64 or every FORTUNA_WD calls to the read function */ +we reseed automatically when len(pool0) >= 64 or every LTC_FORTUNA_WD calls to the read function */ -#ifdef FORTUNA +#ifdef LTC_FORTUNA -/* requries SHA256 and AES */ -#if !(defined(RIJNDAEL) && defined(SHA256)) - #error FORTUNA requires SHA256 and RIJNDAEL (AES) +/* requries LTC_SHA256 and AES */ +#if !(defined(LTC_RIJNDAEL) && defined(LTC_SHA256)) + #error LTC_FORTUNA requires LTC_SHA256 and LTC_RIJNDAEL (AES) #endif -#ifndef FORTUNA_POOLS - #warning FORTUNA_POOLS was not previously defined (old headers?) - #define FORTUNA_POOLS 32 +#ifndef LTC_FORTUNA_POOLS + #warning LTC_FORTUNA_POOLS was not previously defined (old headers?) + #define LTC_FORTUNA_POOLS 32 #endif -#if FORTUNA_POOLS < 4 || FORTUNA_POOLS > 32 - #error FORTUNA_POOLS must be in [4..32] +#if LTC_FORTUNA_POOLS < 4 || LTC_FORTUNA_POOLS > 32 + #error LTC_FORTUNA_POOLS must be in [4..32] #endif const struct ltc_prng_descriptor fortuna_desc = { @@ -71,14 +71,14 @@ static int fortuna_reseed(prng_state *prng) ++prng->fortuna.reset_cnt; - /* new K == SHA256(K || s) where s == SHA256(P0) || SHA256(P1) ... */ + /* new K == LTC_SHA256(K || s) where s == LTC_SHA256(P0) || LTC_SHA256(P1) ... */ sha256_init(&md); if ((err = sha256_process(&md, prng->fortuna.K, 32)) != CRYPT_OK) { sha256_done(&md, tmp); return err; } - for (x = 0; x < FORTUNA_POOLS; x++) { + for (x = 0; x < LTC_FORTUNA_POOLS; x++) { if (x == 0 || ((prng->fortuna.reset_cnt >> (x-1)) & 1) == 0) { /* terminate this hash */ if ((err = sha256_done(&prng->fortuna.pool[x], tmp)) != CRYPT_OK) { @@ -135,7 +135,7 @@ int fortuna_start(prng_state *prng) LTC_ARGCHK(prng != NULL); /* initialize the pools */ - for (x = 0; x < FORTUNA_POOLS; x++) { + for (x = 0; x < LTC_FORTUNA_POOLS; x++) { if ((err = sha256_init(&prng->fortuna.pool[x])) != CRYPT_OK) { for (y = 0; y < x; y++) { sha256_done(&prng->fortuna.pool[y], tmp); @@ -149,7 +149,7 @@ int fortuna_start(prng_state *prng) /* reset bufs */ zeromem(prng->fortuna.K, 32); if ((err = rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey)) != CRYPT_OK) { - for (x = 0; x < FORTUNA_POOLS; x++) { + for (x = 0; x < LTC_FORTUNA_POOLS; x++) { sha256_done(&prng->fortuna.pool[x], tmp); } return err; @@ -198,7 +198,7 @@ int fortuna_add_entropy(const unsigned char *in, unsigned long inlen, prng_state if (prng->fortuna.pool_idx == 0) { prng->fortuna.pool0_len += inlen; } - if (++(prng->fortuna.pool_idx) == FORTUNA_POOLS) { + if (++(prng->fortuna.pool_idx) == LTC_FORTUNA_POOLS) { prng->fortuna.pool_idx = 0; } @@ -235,7 +235,7 @@ unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state LTC_MUTEX_LOCK(&prng->fortuna.prng_lock); /* do we have to reseed? */ - if (++prng->fortuna.wd == FORTUNA_WD || prng->fortuna.pool0_len >= 64) { + if (++prng->fortuna.wd == LTC_FORTUNA_WD || prng->fortuna.pool0_len >= 64) { if ((err = fortuna_reseed(prng)) != CRYPT_OK) { LTC_MUTEX_UNLOCK(&prng->fortuna.prng_lock); return 0; @@ -290,7 +290,7 @@ int fortuna_done(prng_state *prng) LTC_MUTEX_LOCK(&prng->fortuna.prng_lock); /* terminate all the hashes */ - for (x = 0; x < FORTUNA_POOLS; x++) { + for (x = 0; x < LTC_FORTUNA_POOLS; x++) { if ((err = sha256_done(&(prng->fortuna.pool[x]), tmp)) != CRYPT_OK) { LTC_MUTEX_UNLOCK(&prng->fortuna.prng_lock); return err; @@ -325,9 +325,9 @@ int fortuna_export(unsigned char *out, unsigned long *outlen, prng_state *prng) LTC_MUTEX_LOCK(&prng->fortuna.prng_lock); /* we'll write bytes for s&g's */ - if (*outlen < 32*FORTUNA_POOLS) { + if (*outlen < 32*LTC_FORTUNA_POOLS) { LTC_MUTEX_UNLOCK(&prng->fortuna.prng_lock); - *outlen = 32*FORTUNA_POOLS; + *outlen = 32*LTC_FORTUNA_POOLS; return CRYPT_BUFFER_OVERFLOW; } @@ -340,7 +340,7 @@ int fortuna_export(unsigned char *out, unsigned long *outlen, prng_state *prng) /* to emit the state we copy each pool, terminate it then hash it again so * an attacker who sees the state can't determine the current state of the PRNG */ - for (x = 0; x < FORTUNA_POOLS; x++) { + for (x = 0; x < LTC_FORTUNA_POOLS; x++) { /* copy the PRNG */ XMEMCPY(md, &(prng->fortuna.pool[x]), sizeof(*md)); @@ -360,7 +360,7 @@ int fortuna_export(unsigned char *out, unsigned long *outlen, prng_state *prng) goto LBL_ERR; } } - *outlen = 32*FORTUNA_POOLS; + *outlen = 32*LTC_FORTUNA_POOLS; err = CRYPT_OK; LBL_ERR: @@ -386,14 +386,14 @@ int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prn LTC_ARGCHK(in != NULL); LTC_ARGCHK(prng != NULL); - if (inlen != 32*FORTUNA_POOLS) { + if (inlen != 32*LTC_FORTUNA_POOLS) { return CRYPT_INVALID_ARG; } if ((err = fortuna_start(prng)) != CRYPT_OK) { return err; } - for (x = 0; x < FORTUNA_POOLS; x++) { + for (x = 0; x < LTC_FORTUNA_POOLS; x++) { if ((err = fortuna_add_entropy(in+x*32, 32, prng)) != CRYPT_OK) { return err; } @@ -422,6 +422,6 @@ int fortuna_test(void) #endif -/* $Source: /cvs/libtom/libtomcrypt/src/prngs/fortuna.c,v $ */ -/* $Revision: 1.12 $ */ -/* $Date: 2006/12/04 21:34:03 $ */ +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ diff --git a/libtomcrypt/src/prngs/rc4.c b/libtomcrypt/src/prngs/rc4.c index cf118ad..15c74e3 100644 --- a/libtomcrypt/src/prngs/rc4.c +++ b/libtomcrypt/src/prngs/rc4.c @@ -6,16 +6,16 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" /** @file rc4.c - RC4 PRNG, Tom St Denis + LTC_RC4 PRNG, Tom St Denis */ -#ifdef RC4 +#ifdef LTC_RC4 const struct ltc_prng_descriptor rc4_desc = { @@ -93,7 +93,7 @@ int rc4_ready(prng_state *prng) XMEMCPY(key, s, 256); keylen = prng->rc4.x; - /* make RC4 perm and shuffle */ + /* make LTC_RC4 perm and shuffle */ for (x = 0; x < 256; x++) { s[x] = x; } @@ -250,7 +250,7 @@ int rc4_test(void) if (XMEMCMP(dst, tests[x].ct, 8)) { #if 0 int y; - printf("\n\nRC4 failed, I got:\n"); + printf("\n\nLTC_RC4 failed, I got:\n"); for (y = 0; y < 8; y++) printf("%02x ", dst[y]); printf("\n"); #endif @@ -264,6 +264,6 @@ int rc4_test(void) #endif -/* $Source: /cvs/libtom/libtomcrypt/src/prngs/rc4.c,v $ */ -/* $Revision: 1.9 $ */ -/* $Date: 2006/11/16 00:32:18 $ */ +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ diff --git a/libtomcrypt/src/prngs/rng_get_bytes.c b/libtomcrypt/src/prngs/rng_get_bytes.c index 7d332b5..b8cc6f5 100644 --- a/libtomcrypt/src/prngs/rng_get_bytes.c +++ b/libtomcrypt/src/prngs/rng_get_bytes.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" @@ -15,7 +15,7 @@ portable way to get secure random bits to feed a PRNG (Tom St Denis) */ -#ifdef DEVRANDOM +#ifdef LTC_DEVRANDOM /* on *NIX read /dev/random */ static unsigned long rng_nix(unsigned char *buf, unsigned long len, void (*callback)(void)) @@ -47,7 +47,7 @@ static unsigned long rng_nix(unsigned char *buf, unsigned long len, #endif /* LTC_NO_FILE */ } -#endif /* DEVRANDOM */ +#endif /* LTC_DEVRANDOM */ /* on ANSI C platforms with 100 < CLOCKS_PER_SEC < 10000 */ #if defined(CLOCKS_PER_SEC) && !defined(WINCE) @@ -131,7 +131,7 @@ unsigned long rng_get_bytes(unsigned char *out, unsigned long outlen, LTC_ARGCHK(out != NULL); -#if defined(DEVRANDOM) +#if defined(LTC_DEVRANDOM) x = rng_nix(out, outlen, callback); if (x != 0) { return x; } #endif #ifdef WIN32 @@ -143,6 +143,6 @@ unsigned long rng_get_bytes(unsigned char *out, unsigned long outlen, return 0; } -/* $Source: /cvs/libtom/libtomcrypt/src/prngs/rng_get_bytes.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/06 02:01:29 $ */ +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ diff --git a/libtomcrypt/src/prngs/rng_make_prng.c b/libtomcrypt/src/prngs/rng_make_prng.c index 35631ab..6ba2cbe 100644 --- a/libtomcrypt/src/prngs/rng_make_prng.c +++ b/libtomcrypt/src/prngs/rng_make_prng.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" @@ -64,6 +64,6 @@ int rng_make_prng(int bits, int wprng, prng_state *prng, } -/* $Source: /cvs/libtom/libtomcrypt/src/prngs/rng_make_prng.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/03/31 14:15:35 $ */ +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ diff --git a/libtomcrypt/src/prngs/sober128.c b/libtomcrypt/src/prngs/sober128.c index 0361387..9bc7727 100644 --- a/libtomcrypt/src/prngs/sober128.c +++ b/libtomcrypt/src/prngs/sober128.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" @@ -16,7 +16,7 @@ Based on s128fast.c reference code supplied by Greg Rose of QUALCOMM. */ -#ifdef SOBER128 +#ifdef LTC_SOBER128 #include "sober128tab.c" @@ -481,7 +481,7 @@ int sober128_test(void) sober128_done(&prng); if (XMEMCMP(dst, tests[x].out, tests[x].len)) { #if 0 - printf("\n\nSOBER128 failed, I got:\n"); + printf("\n\nLTC_SOBER128 failed, I got:\n"); for (y = 0; y < tests[x].len; y++) printf("%02x ", dst[y]); printf("\n"); #endif @@ -495,6 +495,6 @@ int sober128_test(void) #endif -/* $Source: /cvs/libtom/libtomcrypt/src/prngs/sober128.c,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2006/11/05 00:11:36 $ */ +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ diff --git a/libtomcrypt/src/prngs/sober128tab.c b/libtomcrypt/src/prngs/sober128tab.c index b50c77b..a5754c7 100644 --- a/libtomcrypt/src/prngs/sober128tab.c +++ b/libtomcrypt/src/prngs/sober128tab.c @@ -2,7 +2,7 @@ @file sober128tab.c SOBER-128 Tables */ -/* $Id: sober128tab.c,v 1.2 2005/05/05 14:35:59 tom Exp $ */ +/* $ID$ */ /* @(#)TuringMultab.h 1.3 (QUALCOMM) 02/09/03 */ /* Multiplication table for Turing using 0xD02B4367 */ static const ulong32 Multab[256] = { @@ -72,7 +72,7 @@ static const ulong32 Multab[256] = { 0xEF72A3F1, 0x3F59E096, 0x0224253F, 0xD20F6658, }; -/* $Id: sober128tab.c,v 1.2 2005/05/05 14:35:59 tom Exp $ */ +/* $ID$ */ /* Sbox for SOBER-128 */ /* * This is really the combination of two SBoxes; the least significant @@ -157,6 +157,6 @@ static const ulong32 Sbox[256] = { 0xf9e6053f, 0xa4b0d300, 0xd499cbcc, 0xb95e3d40, }; -/* $Source: /cvs/libtom/libtomcrypt/src/prngs/sober128tab.c,v $ */ -/* $Revision: 1.2 $ */ -/* $Date: 2005/05/05 14:35:59 $ */ +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ diff --git a/libtomcrypt/src/prngs/sprng.c b/libtomcrypt/src/prngs/sprng.c index 190e33d..d86b081 100644 --- a/libtomcrypt/src/prngs/sprng.c +++ b/libtomcrypt/src/prngs/sprng.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" @@ -20,7 +20,7 @@ * in the various other functions. */ -#ifdef SPRNG +#ifdef LTC_SPRNG const struct ltc_prng_descriptor sprng_desc = { @@ -131,6 +131,6 @@ int sprng_test(void) -/* $Source: /cvs/libtom/libtomcrypt/src/prngs/sprng.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/03/31 14:15:35 $ */ +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ diff --git a/libtomcrypt/src/prngs/yarrow.c b/libtomcrypt/src/prngs/yarrow.c index 9fbd4f6..c94671f 100644 --- a/libtomcrypt/src/prngs/yarrow.c +++ b/libtomcrypt/src/prngs/yarrow.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ #include "tomcrypt.h" @@ -15,7 +15,7 @@ Yarrow PRNG, Tom St Denis */ -#ifdef YARROW +#ifdef LTC_YARROW const struct ltc_prng_descriptor yarrow_desc = { @@ -42,77 +42,77 @@ int yarrow_start(prng_state *prng) LTC_ARGCHK(prng != NULL); /* these are the default hash/cipher combo used */ -#ifdef RIJNDAEL -#if YARROW_AES==0 +#ifdef LTC_RIJNDAEL +#if LTC_YARROW_AES==0 prng->yarrow.cipher = register_cipher(&rijndael_enc_desc); -#elif YARROW_AES==1 +#elif LTC_YARROW_AES==1 prng->yarrow.cipher = register_cipher(&aes_enc_desc); -#elif YARROW_AES==2 +#elif LTC_YARROW_AES==2 prng->yarrow.cipher = register_cipher(&rijndael_desc); -#elif YARROW_AES==3 +#elif LTC_YARROW_AES==3 prng->yarrow.cipher = register_cipher(&aes_desc); #endif -#elif defined(BLOWFISH) +#elif defined(LTC_BLOWFISH) prng->yarrow.cipher = register_cipher(&blowfish_desc); -#elif defined(TWOFISH) +#elif defined(LTC_TWOFISH) prng->yarrow.cipher = register_cipher(&twofish_desc); -#elif defined(RC6) +#elif defined(LTC_RC6) prng->yarrow.cipher = register_cipher(&rc6_desc); -#elif defined(RC5) +#elif defined(LTC_RC5) prng->yarrow.cipher = register_cipher(&rc5_desc); -#elif defined(SAFERP) +#elif defined(LTC_SAFERP) prng->yarrow.cipher = register_cipher(&saferp_desc); -#elif defined(RC2) +#elif defined(LTC_RC2) prng->yarrow.cipher = register_cipher(&rc2_desc); -#elif defined(NOEKEON) +#elif defined(LTC_NOEKEON) prng->yarrow.cipher = register_cipher(&noekeon_desc); -#elif defined(ANUBIS) +#elif defined(LTC_ANUBIS) prng->yarrow.cipher = register_cipher(&anubis_desc); -#elif defined(KSEED) +#elif defined(LTC_KSEED) prng->yarrow.cipher = register_cipher(&kseed_desc); -#elif defined(KHAZAD) +#elif defined(LTC_KHAZAD) prng->yarrow.cipher = register_cipher(&khazad_desc); -#elif defined(CAST5) +#elif defined(LTC_CAST5) prng->yarrow.cipher = register_cipher(&cast5_desc); -#elif defined(XTEA) +#elif defined(LTC_XTEA) prng->yarrow.cipher = register_cipher(&xtea_desc); -#elif defined(SAFER) +#elif defined(LTC_SAFER) prng->yarrow.cipher = register_cipher(&safer_sk128_desc); -#elif defined(DES) +#elif defined(LTC_DES) prng->yarrow.cipher = register_cipher(&des3_desc); #else - #error YARROW needs at least one CIPHER + #error LTC_YARROW needs at least one CIPHER #endif if ((err = cipher_is_valid(prng->yarrow.cipher)) != CRYPT_OK) { return err; } -#ifdef SHA256 +#ifdef LTC_SHA256 prng->yarrow.hash = register_hash(&sha256_desc); -#elif defined(SHA512) +#elif defined(LTC_SHA512) prng->yarrow.hash = register_hash(&sha512_desc); -#elif defined(TIGER) +#elif defined(LTC_TIGER) prng->yarrow.hash = register_hash(&tiger_desc); -#elif defined(SHA1) +#elif defined(LTC_SHA1) prng->yarrow.hash = register_hash(&sha1_desc); -#elif defined(RIPEMD320) +#elif defined(LTC_RIPEMD320) prng->yarrow.hash = register_hash(&rmd320_desc); -#elif defined(RIPEMD256) +#elif defined(LTC_RIPEMD256) prng->yarrow.hash = register_hash(&rmd256_desc); -#elif defined(RIPEMD160) +#elif defined(LTC_RIPEMD160) prng->yarrow.hash = register_hash(&rmd160_desc); -#elif defined(RIPEMD128) +#elif defined(LTC_RIPEMD128) prng->yarrow.hash = register_hash(&rmd128_desc); -#elif defined(MD5) +#elif defined(LTC_MD5) prng->yarrow.hash = register_hash(&md5_desc); -#elif defined(MD4) +#elif defined(LTC_MD4) prng->yarrow.hash = register_hash(&md4_desc); -#elif defined(MD2) +#elif defined(LTC_MD2) prng->yarrow.hash = register_hash(&md2_desc); -#elif defined(WHIRLPOOL) +#elif defined(LTC_WHIRLPOOL) prng->yarrow.hash = register_hash(&whirlpool_desc); #else - #error YARROW needs at least one HASH + #error LTC_YARROW needs at least one HASH #endif if ((err = hash_is_valid(prng->yarrow.hash)) != CRYPT_OK) { return err; @@ -357,6 +357,6 @@ int yarrow_test(void) #endif -/* $Source: /cvs/libtom/libtomcrypt/src/prngs/yarrow.c,v $ */ -/* $Revision: 1.10 $ */ -/* $Date: 2006/11/14 04:21:17 $ */ +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ |