From 9dba89cde740d7c518a73b869d07d6247e0e7488 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 28 Aug 2006 09:40:39 +0000 Subject: Fixed a problem with shifting MPIs by 0. Add a way to check whether the RNG is in fake mode. --- NEWS | 1 + TODO | 7 ++++++- mpi/ChangeLog | 5 +++++ mpi/mpi-bit.c | 12 +++++++++++- src/ChangeLog | 4 ++++ src/gcrypt.h | 3 ++- src/global.c | 9 ++++++++- 7 files changed, 37 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index ca293d8e..fa1af5c4 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ Noteworthy changes in version 1.3.0 (unreleased) * Interface changes relative to the 1.2.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcry_fast_random_poll NEW + GCRYCTL_FAKED_RANDOM_P NEW gcry_pk_algo_name CHANGED (minor change in respect to return value) gcry_cipher_algo_name CHANGED (minor change in respect to return value) GCRY_MD_SHA224 NEW diff --git a/TODO b/TODO index 1cfc6dc1..4ea299e0 100644 --- a/TODO +++ b/TODO @@ -51,7 +51,7 @@ What's left to do -*- outline -*- to run that bunch of Unix utilities we don't waste their precious results. -* Out of memory handler for secure memory shopuld do proper logging +* Out of memory handler for secure memory should do proper logging There is no shortage of standard memory, so logging is most likely possible. @@ -59,5 +59,10 @@ What's left to do -*- outline -*- * signed vs. unsigned. Sync the code with 1.2 where we have fixed all these issues. +* mpi_print does not use secure memory + for internal variables. + +* gry_mpi_lshift is missing + diff --git a/mpi/ChangeLog b/mpi/ChangeLog index 176ccf22..c670967e 100644 --- a/mpi/ChangeLog +++ b/mpi/ChangeLog @@ -1,3 +1,8 @@ +2006-08-25 Werner Koch + + * mpi-bit.c (gcry_mpi_rshift): Don't shift if N == 0 but do a + plain copy. + 2006-08-04 Werner Koch * mpi-bit.c (gcry_mpi_rshift): Rewritten to remove the limitation diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c index d16eaae1..fe4895dc 100644 --- a/mpi/mpi-bit.c +++ b/mpi/mpi-bit.c @@ -256,7 +256,17 @@ gcry_mpi_rshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n ) x->nlimbs = xsize; if ( xsize ) - _gcry_mpih_rshift (x->d, a->d, x->nlimbs, nbits ); + { + if (nbits ) + _gcry_mpih_rshift (x->d, a->d, x->nlimbs, nbits ); + else + { + /* The rshift helper function is not specified for + NBITS==0, thus we do a plain copy here. */ + for (i=0; i < x->nlimbs; i++ ) + x->d[i] = a->d[i]; + } + } } MPN_NORMALIZE (x->d, x->nlimbs); } diff --git a/src/ChangeLog b/src/ChangeLog index ae9e9ea8..b2e8b7b8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2006-08-21 Werner Koch + + * gcrypt.h (GCRYCTL_FAKED_RANDOM_P): New. + 2006-07-29 Marcus Brinkmann * secmem.c (init_pool): Close FD after establishing the mapping. diff --git a/src/gcrypt.h b/src/gcrypt.h index 3d823f77..b46e97a2 100644 --- a/src/gcrypt.h +++ b/src/gcrypt.h @@ -348,7 +348,8 @@ enum gcry_ctl_cmds GCRYCTL_SET_THREAD_CBS = 47, GCRYCTL_FAST_POLL = 48, GCRYCTL_SET_RANDOM_DAEMON_SOCKET = 49, - GCRYCTL_USE_RANDOM_DAEMON = 50 + GCRYCTL_USE_RANDOM_DAEMON = 50, + GCRYCTL_FAKED_RANDOM_P = 51 }; /* Perform various operations defined by CMD. */ diff --git a/src/global.c b/src/global.c index f2faeb86..46a12be7 100644 --- a/src/global.c +++ b/src/global.c @@ -219,6 +219,13 @@ gcry_control (enum gcry_ctl_cmds cmd, ...) _gcry_quick_random_gen (1); break; + case GCRYCTL_FAKED_RANDOM_P: + /* Return an error if the RNG is faked one (i.e. enabled by + ENABLE_QUICK_RANDOM. */ + if (_gcry_random_is_faked ()) + err = GPG_ERR_GENERAL; + break; + case GCRYCTL_DUMP_RANDOM_STATS: _gcry_random_dump_stats (); break; @@ -329,7 +336,7 @@ gcry_control (enum gcry_ctl_cmds cmd, ...) 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. */ + initialized so that the poll function is not a NOP. */ _gcry_random_initialize (1); _gcry_fast_random_poll (); break; -- cgit v1.2.1