diff options
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | cipher/ChangeLog | 4 | ||||
-rw-r--r-- | cipher/random.h | 3 | ||||
-rw-r--r-- | cipher/rndegd.c | 36 | ||||
-rw-r--r-- | doc/gcrypt.texi | 20 | ||||
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/gcrypt.h.in | 3 | ||||
-rw-r--r-- | src/global.c | 26 |
8 files changed, 93 insertions, 11 deletions
@@ -50,14 +50,15 @@ Noteworthy changes in version 1.3.0 (unreleased) gcry_fast_random_poll NEW gcry_md_debug NEW gcry_sexp_nth_string NEW - GCRYCTL_FAKED_RANDOM_P NEW - GCRYCTL_DUMP_CONFIG NEW GCRY_MD_SHA224 NEW GCRY_PK_USAGE_CERT NEW GCRY_PK_USAGE_AUTH NEW GCRY_PK_USAGE_UNKN NEW GCRY_PK_ECDSA NEW - GCR_CIPHER_SEED NEW + GCRY_CIPHER_SEED NEW + GCRYCTL_FAKED_RANDOM_P NEW + GCRYCTL_DUMP_CONFIG NEW + GCRYCTL_SET_RNDEGD_SOCKET NEW. gcry_mpi_scan CHANGED: Argument BUFFER is now void*. gcry_pk_algo_name CHANGED: Returns "?" instead of NULL. gcry_cipher_algo_name CHANGED: Returns "?" instead of "". diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 98f22bee..0218c4b8 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,7 @@ +2007-04-30 Werner Koch <wk@g10code.com> + + * rndegd.c (_gcry_rndegd_set_socket_name): New. + 2007-04-30 Marcus Brinkmann <marcus@g10code.de> * ecc.c (ec2os): Fix relocation of short numbers. diff --git a/cipher/random.h b/cipher/random.h index 0eb26a2c..726a3794 100644 --- a/cipher/random.h +++ b/cipher/random.h @@ -37,6 +37,9 @@ void _gcry_update_random_seed_file (void); byte *_gcry_get_random_bits( size_t nbits, int level, int secure ); void _gcry_fast_random_poll( void ); +/*-- rndegd.c --*/ +gpg_error_t _gcry_rndegd_set_socket_name (const char *name); + /*-- random-daemon.c (only used from random.c) --*/ #ifdef USE_RANDOM_DAEMON void _gcry_daemon_initialize_basics (void); diff --git a/cipher/rndegd.c b/cipher/rndegd.c index f4a444c0..63a5e0f1 100644 --- a/cipher/rndegd.c +++ b/cipher/rndegd.c @@ -40,6 +40,10 @@ static int egd_socket = -1; +/* Allocated name of the socket if supplied at runtime. */ +static char *user_socket_name; + + /* Allocate a new filename from FIRST_PART and SECOND_PART and to tilde expansion for first_part. SECOND_PART might be NULL. */ @@ -115,6 +119,25 @@ do_read( int fd, void *buf, size_t nbytes ) } +/* Note that his fucntion is not thread-safe. */ +gpg_error_t +_gcry_rndegd_set_socket_name (const char *name) +{ + char *newname; + struct sockaddr_un addr; + + newname = my_make_filename (name, NULL); + if (strlen (newname)+1 >= sizeof addr.sun_path) + { + gcry_free (newname); + return gpg_error_from_syserror (); + } + gcry_free (user_socket_name); + user_socket_name = newname; + return 0; +} + + /* Connect to the EGD and return the file descriptor. Return -1 on error. With NOFAIL set to true, silently fail and return the error, otherwise print an error message and die. */ @@ -136,7 +159,18 @@ _gcry_rndegd_connect_socket (int nofail) #ifdef EGD_SOCKET_NAME bname = EGD_SOCKET_NAME; #endif - if ( !bname || !*bname ) + if (user_socket_name) + { + name = gcry_strdup (user_socket_name); + if (!name) + { + if (!nofail) + log_fatal ("error allocating memory in rndegd: %s\n", + strerror(errno) ); + return -1; + } + } + else if ( !bname || !*bname ) name = my_make_filename ("~/.gnupg", "entropy"); else name = my_make_filename (bname, NULL); diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index f69f284c..0bd37df3 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -535,7 +535,7 @@ logging stream. This command dumps secure memory manamgent related statistics to the librarys logging stream. -@item GCRYCTL_DUMP_CONFIG +@item GCRYCTL_DUMP_CONFIG; Arguments: none This command dumps information pertaining to the configuration of libgcrypt to the logging stream. It may be used before the intialization has been finished but not before a gcry_version_check. @@ -586,7 +586,23 @@ Write out the PRNG pool's content into the registered seed file. This command registers a thread-callback structure. See section ``multi threading'' for more information on this command. -@item GCRYCTL_FAST_POOL +@item GCRYCTL_FAST_POLL + +Run a fast random poll. + + +@item GCRYCTL_SET_RNDEGD_SOCKET; Arguments: const char *filename + +This command may be used to override the default name of the EGD socket +to connect to. It may be used only during initialization as it is not +thread safe. Changing the socket name again is not supported. The +function may return an error if the given filename is too long for a +local socket name. + +EGD is an alternative random gatherer, used only on a few systems. + + + @end table @end deftypefun diff --git a/src/ChangeLog b/src/ChangeLog index cc384aba..65bfe958 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,8 +1,9 @@ 2007-04-30 Werner Koch <wk@g10code.com> - * global.c (gcry_control): New. - * gcrypt.h.in (GCRYCTL_DUMP_CONFIG): New. + (GCRYCTL_SET_RNDEGD_SOCKET): New. + * global.c (gcry_control): Add GCRYCTL_DUMP_CONFIG and + GCRYCTL_SET_RNDEGD_SOCKET. 2007-04-18 Werner Koch <wk@g10code.com> diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index 3ddb1788..537462d7 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -356,7 +356,8 @@ enum gcry_ctl_cmds GCRYCTL_SET_RANDOM_DAEMON_SOCKET = 49, GCRYCTL_USE_RANDOM_DAEMON = 50, GCRYCTL_FAKED_RANDOM_P = 51, - GCRYCTL_DUMP_CONFIG = 52 + GCRYCTL_DUMP_CONFIG = 52, + GCRYCTL_SET_RNDEGD_SOCKET = 53 }; /* Perform various operations defined by CMD. */ diff --git a/src/global.c b/src/global.c index cbec9668..8350c09c 100644 --- a/src/global.c +++ b/src/global.c @@ -343,6 +343,14 @@ gcry_control (enum gcry_ctl_cmds cmd, ...) _gcry_fast_random_poll (); break; + case GCRYCTL_SET_RNDEGD_SOCKET: +#if USE_RNDEGD + err = _gcry_rndegd_set_socket_name (va_arg (arg_ptr, const char *)); +#else + err = gpg_error (GPG_ERR_NOT_SUPPORTED); +#endif + break; + case GCRYCTL_SET_RANDOM_DAEMON_SOCKET: _gcry_set_random_daemon_socket (va_arg (arg_ptr, const char *)); break; @@ -359,8 +367,22 @@ gcry_control (enum gcry_ctl_cmds cmd, ...) used before the intialization has been finished but not before a gcry_version_check. */ case GCRYCTL_DUMP_CONFIG: - log_info ("version=%s\n", VERSION); - log_info ("mpi-asm=%s\n", _gcry_mpi_get_hw_config ()); + log_info ("version:%s:\n", VERSION); + log_info ("mpi-asm:%s:\n", _gcry_mpi_get_hw_config ()); + log_info ("rnd-mod:" +#if USE_RNDEGD + "egd:" +#endif +#if USE_RNDLINUX + "linux:" +#endif +#if USE_RNDUNIX + "unix:" +#endif +#if USE_RNDW32 + "w32:" +#endif + "\n"); break; default: |