* prng.c (krb5int_prng_init): Incorporate do_yarrow_init body. Don't check
authorKen Raeburn <raeburn@mit.edu>
Fri, 14 Jan 2005 03:27:51 +0000 (03:27 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 14 Jan 2005 03:27:51 +0000 (03:27 +0000)
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
src/lib/crypto/prng.c

index f77c170b25f47e46bf898218fe3eef1fb701e81a..feccaa79125db713373c0318d5edaf4d2f6eb167 100644 (file)
@@ -1,3 +1,12 @@
+2005-01-13  Ken Raeburn  <raeburn@mit.edu>
+
+       * 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  <tlyu@mit.edu>
 
        * prng.c (read_entropy_from_device): Use ssize_t, not size_t, so
index 7371e974e0a791857d29da4dc9eb88b395c4b5cf..54a68e06752bed222f0c258bb20393b5de559cd1 100644 (file)
@@ -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;
 }