From 5128c4817a9cc9032019bd0c3ed876435ac783d5 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Fri, 14 Jan 2005 03:27:51 +0000 Subject: [PATCH] * prng.c (krb5int_prng_init): Incorporate do_yarrow_init body. Don't check inited variable. (inited): Variable deleted. (krb5_c_random_make_octets, krb5int_prng_cleanup): Don't check it. (do_yarrow_init): Deleted. ticket: 2878 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17033 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/ChangeLog | 9 +++++++++ src/lib/crypto/prng.c | 38 ++++++++++---------------------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/lib/crypto/ChangeLog b/src/lib/crypto/ChangeLog index f77c170b2..feccaa791 100644 --- a/src/lib/crypto/ChangeLog +++ b/src/lib/crypto/ChangeLog @@ -1,3 +1,12 @@ +2005-01-13 Ken Raeburn + + * prng.c (krb5int_prng_init): Incorporate do_yarrow_init body. + Don't check inited variable. + (inited): Variable deleted. + (krb5_c_random_make_octets, krb5int_prng_cleanup): Don't check + it. + (do_yarrow_init): Deleted. + 2005-01-12 Tom Yu * prng.c (read_entropy_from_device): Use ssize_t, not size_t, so diff --git a/src/lib/crypto/prng.c b/src/lib/crypto/prng.c index 7371e974e..54a68e067 100644 --- a/src/lib/crypto/prng.c +++ b/src/lib/crypto/prng.c @@ -30,7 +30,7 @@ #include "yarrow.h" static Yarrow_CTX y_ctx; -static int inited, init_error; +static int init_error; #define yarrow_lock krb5int_yarrow_lock k5_mutex_t yarrow_lock = K5_MUTEX_PARTIAL_INITIALIZER; @@ -57,42 +57,27 @@ entropy_estimate (unsigned int randsource, size_t length) return (0); } -static void do_yarrow_init(void); int krb5int_prng_init(void) -{ - do_yarrow_init(); - if (init_error) - return KRB5_CRYPTO_INTERNAL; - return 0; -} - -static void do_yarrow_init(void) { unsigned i; int yerr; yerr = k5_mutex_finish_init(&yarrow_lock); - if (yerr) { - init_error = yerr; - return; - } + if (yerr) + return yerr; yerr = krb5int_yarrow_init (&y_ctx, NULL); - if ((yerr != YARROW_OK) && (yerr != YARROW_NOT_SEEDED)) { - init_error = yerr; - return; - } + if ((yerr != YARROW_OK) && (yerr != YARROW_NOT_SEEDED)) + return KRB5_CRYPTO_INTERNAL; for (i=0; i < KRB5_C_RANDSOURCE_MAX; i++ ) { unsigned source_id; - if (krb5int_yarrow_new_source (&y_ctx, &source_id) != YARROW_OK ) { - init_error = 17; - return; - } + if (krb5int_yarrow_new_source (&y_ctx, &source_id) != YARROW_OK ) + return KRB5_CRYPTO_INTERNAL; assert (source_id == i); } - inited=1; - init_error = 0; + + return 0; } krb5_error_code KRB5_CALLCONV @@ -124,7 +109,6 @@ krb5_error_code KRB5_CALLCONV krb5_c_random_make_octets(krb5_context context, krb5_data *data) { int yerr; - assert (inited); yerr = krb5int_yarrow_output (&y_ctx, data->data, data->length); if (yerr == YARROW_NOT_SEEDED) { yerr = krb5int_yarrow_reseed (&y_ctx, YARROW_SLOW_POOL); @@ -138,10 +122,8 @@ krb5_c_random_make_octets(krb5_context context, krb5_data *data) void krb5int_prng_cleanup (void) { - if (inited) - krb5int_yarrow_final (&y_ctx); + krb5int_yarrow_final (&y_ctx); k5_mutex_destroy(&yarrow_lock); - inited = 0; } -- 2.26.2