diff options
author | Werner Koch <wk@gnupg.org> | 2008-08-21 18:34:24 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2008-08-21 18:34:24 +0000 |
commit | 393d3b3b0cb80223cde9be75a6a10169e37c5778 (patch) | |
tree | c0b11bfebc8687f8fe888d6502fe1eede1857ade /src | |
parent | 2f818ed3f919a9f8f565b67007b194fa953e7d9b (diff) | |
download | libgcrypt-393d3b3b0cb80223cde9be75a6a10169e37c5778.tar.gz |
Finished the X9.31 RNG implementations.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/fips.c | 5 | ||||
-rw-r--r-- | src/g10lib.h | 3 | ||||
-rw-r--r-- | src/misc.c | 21 |
4 files changed, 32 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 85076b10..b811b6ed 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2008-08-21 Werner Koch <wk@g10code.com> + + * misc.c (_gcry_log_printhex): New. + 2008-08-20 Werner Koch <wk@g10code.com> * g10lib.h (gcry_assert): New. use this at almost all places @@ -422,6 +422,10 @@ run_pubkey_selftests (void) static int run_random_selftests (void) { + char buffer[8]; + + /* FIXME: For now we just try to get a few bytes. */ + gcry_randomize (buffer, sizeof buffer, GCRY_STRONG_RANDOM); return 0; } @@ -536,6 +540,7 @@ fips_new_state (enum module_states new_state) case STATE_ERROR: if (new_state == STATE_SHUTDOWN + || new_state == STATE_FATALERROR || new_state == STATE_INIT) ok = 1; break; diff --git a/src/g10lib.h b/src/g10lib.h index ed25a514..8670de4d 100644 --- a/src/g10lib.h +++ b/src/g10lib.h @@ -102,6 +102,7 @@ int _gcry_log_info_with_dummy_fp (FILE *fp, const char *fmt, ... ) JNLIB_GCC_A_PRINTF(2,3); void _gcry_log_debug( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); void _gcry_log_printf ( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); +void _gcry_log_printhex (const char *text, const void *buffer, size_t length); void _gcry_set_log_verbosity( int level ); int _gcry_log_verbosity( int level ); @@ -121,13 +122,13 @@ int _gcry_log_verbosity( int level ); #endif -#define log_hexdump _gcry_log_hexdump #define log_bug _gcry_log_bug #define log_fatal _gcry_log_fatal #define log_error _gcry_log_error #define log_info _gcry_log_info #define log_debug _gcry_log_debug #define log_printf _gcry_log_printf +#define log_printhex _gcry_log_printhex /*-- src/hwfeatures.c --*/ @@ -250,6 +250,7 @@ _gcry_log_debug( const char *fmt, ... ) va_end(arg_ptr); } + void _gcry_log_printf (const char *fmt, ...) { @@ -263,6 +264,26 @@ _gcry_log_printf (const char *fmt, ...) } } +/* Print a hexdump of BUFFER. With TEXT of NULL print just the raw + dump, with TEXT an empty string, print a trailing linefeed, + otherwise print an entire debug line. */ +void +_gcry_log_printhex (const char *text, const void *buffer, size_t length) +{ + if (text && *text) + log_debug ("%s ", text); + if (length) + { + const unsigned char *p = buffer; + log_printf ("%02X", *p); + for (length--, p++; length--; p++) + log_printf (" %02X", *p); + } + if (text) + log_printf ("\n"); +} + + void _gcry_burn_stack (int bytes) { |