disable ltc_rng by default

This commit is contained in:
Steffen Jaeckel 2017-03-15 22:12:49 +01:00
parent fcae7e2c49
commit cd08a8cec3
6 changed files with 18 additions and 0 deletions

View File

@ -304,6 +304,9 @@
/* rng_make_prng() */
#define LTC_RNG_MAKE_PRNG
/* enable the ltc_rng hook to integrate e.g. embedded hardware RNG's easily */
/* #define LTC_PRNG_ENABLE_LTC_RNG */
#endif /* LTC_NO_PRNGS */
#ifdef LTC_YARROW

View File

@ -193,8 +193,10 @@ unsigned long rng_get_bytes(unsigned char *out,
int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
#ifdef LTC_PRNG_ENABLE_LTC_RNG
extern unsigned long (*ltc_rng)(unsigned char *out, unsigned long outlen,
void (*callback)(void));
#endif
/* $Source$ */

View File

@ -371,6 +371,9 @@ const char *crypt_build_settings =
#if defined(LTC_RNG_MAKE_PRNG)
" LTC_RNG_MAKE_PRNG "
#endif
#if defined(LTC_PRNG_ENABLE_LTC_RNG)
" LTC_PRNG_ENABLE_LTC_RNG "
#endif
#if defined(LTC_HASH_HELPERS)
" LTC_HASH_HELPERS "
#endif

View File

@ -10,4 +10,6 @@
*/
#include "tomcrypt.h"
#ifdef LTC_PRNG_ENABLE_LTC_RNG
unsigned long (*ltc_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
#endif

View File

@ -135,12 +135,14 @@ unsigned long rng_get_bytes(unsigned char *out, unsigned long outlen,
LTC_ARGCHK(out != NULL);
#ifdef LTC_PRNG_ENABLE_LTC_RNG
if (ltc_rng) {
x = ltc_rng(out, outlen, callback);
if (x != 0) {
return x;
}
}
#endif
#if defined(_WIN32) || defined(_WIN32_WCE)
x = rng_win32(out, outlen, callback); if (x != 0) { return x; }

View File

@ -302,6 +302,8 @@ static void _unregister_all(void)
#endif
} /* _cleanup() */
#ifdef LTC_PRNG_ENABLE_LTC_RNG
static unsigned long my_test_rng_read;
static unsigned long my_test_rng(unsigned char *buf, unsigned long len,
@ -316,6 +318,8 @@ static unsigned long my_test_rng(unsigned char *buf, unsigned long len,
return n;
}
#endif
void reg_algs(void)
{
unsigned long before;
@ -456,6 +460,7 @@ register_prng(&rc4_desc);
register_prng(&sober128_desc);
#endif
#ifdef LTC_PRNG_ENABLE_LTC_RNG
ltc_rng = my_test_rng;
before = my_test_rng_read;
@ -470,6 +475,7 @@ register_prng(&sober128_desc);
}
ltc_rng = NULL;
#endif
if ((err = rng_make_prng(128, find_prng("yarrow"), &yarrow_prng, NULL)) != CRYPT_OK) {
fprintf(stderr, "rng_make_prng failed: %s\n", error_to_string(err));