diff options
author | Werner Koch <wk@gnupg.org> | 2004-05-07 13:52:11 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2004-05-07 13:52:11 +0000 |
commit | 6605a26a913935f692c4ce270a13b2fc11bad67d (patch) | |
tree | cbf19438e496228b6a5f1545ad87d7322c14dc6c /src | |
parent | a29542578cb24fd6608586e87a42a9acef3b46dc (diff) | |
download | libgcrypt-6605a26a913935f692c4ce270a13b2fc11bad67d.tar.gz |
* random.c (initialize): Factored out some code to ..
(initialize_basics): .. new function.
(_gcry_random_initialize): Just call initialize_basics unless the
new arg FULL is set to TRUE.
(_gcry_fast_random_poll): Don't do anything unless the random
system has been really initialized.
* gcrypt.h: Added GCRYCTL_FAST_POLL.
(gcry_fast_random_poll): New.
* global.c (gcry_control) <INITIALIZATION_FINISHED>: Do only basic
random subsystem init.
(gcry_control) <FAST_POLL>: New.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 8 | ||||
-rw-r--r-- | src/gcrypt.h | 12 | ||||
-rw-r--r-- | src/global.c | 11 |
3 files changed, 28 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c8b25966..fef6cb3a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2004-05-07 Werner Koch <wk@gnupg.org> + + * gcrypt.h: Added GCRYCTL_FAST_POLL. + (gcry_fast_random_poll): New. + * global.c (gcry_control) <INITIALIZATION_FINISHED>: Do only basic + random subsystem init. + (gcry_control) <FAST_POLL>: New. + 2004-04-22 Marcus Brinkmann <marcus@g10code.de> * libgcrypt.m4: Quote first argument to AC_DEFUN. diff --git a/src/gcrypt.h b/src/gcrypt.h index 49ac53f9..07f0cc01 100644 --- a/src/gcrypt.h +++ b/src/gcrypt.h @@ -46,7 +46,7 @@ extern "C" { autoconf (using the AM_PATH_GCRYPT macro) check that this header matches the installed library. Note: Do not edit the next line as configure may fix the string here. */ -#define GCRYPT_VERSION "1.2.0" +#define GCRYPT_VERSION "1.3.0-cvs" /* Internal: We can't use the convenience macros for the multi precision integer functions when building this library. */ @@ -325,7 +325,8 @@ enum gcry_ctl_cmds GCRYCTL_ENABLE_QUICK_RANDOM = 44, GCRYCTL_SET_RANDOM_SEED_FILE = 45, GCRYCTL_UPDATE_RANDOM_SEED_FILE = 46, - GCRYCTL_SET_THREAD_CBS = 47 + GCRYCTL_SET_THREAD_CBS = 47, + GCRYCTL_FAST_POLL = 48 }; /* Perform various operations defined by CMD. */ @@ -1319,6 +1320,12 @@ void gcry_randomize (unsigned char *buffer, size_t length, gcry_error_t gcry_random_add_bytes (const void *buffer, size_t length, int quality); +/* If random numbers are used in an application, this macro should be + called from time to time so that new stuff gets added to the + internal pool of the RNG. */ +#define gcry_fast_random_poll() gcry_control (GCRYCTL_FAST_POLL, NULL) + + /* Return NBYTES of allocated random using a random numbers of quality LEVEL. */ void *gcry_random_bytes (size_t nbytes, enum gcry_random_level level) @@ -1342,6 +1349,7 @@ void gcry_create_nonce (unsigned char *buffer, size_t length); + /* Prime interface. */ /* Mode values passed to a gcry_prime_check_func_t. */ diff --git a/src/global.c b/src/global.c index 9e7165b2..3dd2c098 100644 --- a/src/global.c +++ b/src/global.c @@ -263,7 +263,9 @@ gcry_control (enum gcry_ctl_cmds cmd, ...) if (! init_finished) { global_init (); - _gcry_random_initialize (); + /* Do only a basic ranom initialization, i.e. inti the + mutexes. */ + _gcry_random_initialize (0); init_finished = 1; } break; @@ -272,6 +274,13 @@ gcry_control (enum gcry_ctl_cmds cmd, ...) err = ath_install (va_arg (arg_ptr, void *), any_init_done); break; + case GCRYCTL_FAST_POLL: + /* We need to do make sure that the random pool is really + initialized so that the poll fucntion is not a NOP. */ + _gcry_random_initialize (1); + _gcry_fast_random_poll (); + break; + default: err = GPG_ERR_INV_OP; } |