add ltc_rng function pointer
the idea is to be able to easily provide a plug-in rng for a specific platform without the need to touch the library.
This commit is contained in:
parent
a00aba8370
commit
fe7c4e3993
@ -193,6 +193,9 @@ unsigned long rng_get_bytes(unsigned char *out,
|
|||||||
|
|
||||||
int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
|
int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
|
||||||
|
|
||||||
|
extern unsigned long (*ltc_rng)(unsigned char *out, unsigned long outlen,
|
||||||
|
void (*callback)(void));
|
||||||
|
|
||||||
|
|
||||||
/* $Source$ */
|
/* $Source$ */
|
||||||
/* $Revision$ */
|
/* $Revision$ */
|
||||||
|
13
src/misc/crypt/crypt_prng_rng_descriptor.c
Normal file
13
src/misc/crypt/crypt_prng_rng_descriptor.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||||
|
*
|
||||||
|
* LibTomCrypt is a library that provides various cryptographic
|
||||||
|
* algorithms in a highly modular and flexible manner.
|
||||||
|
*
|
||||||
|
* The library is free for all purposes without any express
|
||||||
|
* guarantee it works.
|
||||||
|
*
|
||||||
|
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||||
|
*/
|
||||||
|
#include "tomcrypt.h"
|
||||||
|
|
||||||
|
unsigned long (*ltc_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
|
@ -135,6 +135,13 @@ unsigned long rng_get_bytes(unsigned char *out, unsigned long outlen,
|
|||||||
|
|
||||||
LTC_ARGCHK(out != NULL);
|
LTC_ARGCHK(out != NULL);
|
||||||
|
|
||||||
|
if (ltc_rng) {
|
||||||
|
x = ltc_rng(out, outlen, callback);
|
||||||
|
if (x != 0) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN32_WCE)
|
#if defined(_WIN32) || defined(_WIN32_WCE)
|
||||||
x = rng_win32(out, outlen, callback); if (x != 0) { return x; }
|
x = rng_win32(out, outlen, callback); if (x != 0) { return x; }
|
||||||
#elif defined(LTC_DEVRANDOM)
|
#elif defined(LTC_DEVRANDOM)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user