summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2004-06-02 23:41:51 +0000
committerKen Raeburn <raeburn@mit.edu>2004-06-02 23:41:51 +0000
commit2727091fd6ca14b4c05b054ece24d141ff448556 (patch)
treeb51e2e33942614baf9b0224f517a22f8579951e5
parent97338a5a792e78c38242c4d76b4d4ecc8bc47102 (diff)
downloadkrb5-2727091fd6ca14b4c05b054ece24d141ff448556.tar.gz
krb5-2727091fd6ca14b4c05b054ece24d141ff448556.tar.xz
krb5-2727091fd6ca14b4c05b054ece24d141ff448556.zip
* prng.c (init_once): Variable deleted.
(krb5_c_random_add_entropy): Do the initialization once, using the yarrow_lock mutex instead of k5_once to protect it. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16392 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/lib/crypto/ChangeLog6
-rw-r--r--src/lib/crypto/prng.c16
2 files changed, 13 insertions, 9 deletions
diff --git a/src/lib/crypto/ChangeLog b/src/lib/crypto/ChangeLog
index 952aaa9a5..b30a22c92 100644
--- a/src/lib/crypto/ChangeLog
+++ b/src/lib/crypto/ChangeLog
@@ -1,3 +1,9 @@
+2004-06-02 Ken Raeburn <raeburn@mit.edu>
+
+ * prng.c (init_once): Variable deleted.
+ (krb5_c_random_add_entropy): Do the initialization once, using
+ the yarrow_lock mutex instead of k5_once to protect it.
+
2004-05-24 Ezra Peisach <epeisach@mit.edu>
* t_nfold.c (fold_kerberos): Change nbytes argument to unsigned.
diff --git a/src/lib/crypto/prng.c b/src/lib/crypto/prng.c
index be757d21c..f9ea8696d 100644
--- a/src/lib/crypto/prng.c
+++ b/src/lib/crypto/prng.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001, 2002 by the Massachusetts Institute of Technology.
+ * Copyright (C) 2001, 2002, 2004 by the Massachusetts Institute of Technology.
* All rights reserved.
*
*
@@ -30,7 +30,6 @@
#include "yarrow.h"
static Yarrow_CTX y_ctx;
-static k5_once_t init_once = K5_ONCE_INIT;
static int inited, init_error;
static k5_mutex_t yarrow_lock = K5_MUTEX_PARTIAL_INITIALIZER;
@@ -95,17 +94,16 @@ krb5_c_random_add_entropy (krb5_context context, unsigned int randsource,
yerr = krb5int_crypto_init();
if (yerr)
return yerr;
- /* Run the Yarrow init code, if not done already. */
- yerr = k5_once(&init_once, do_yarrow_init);
- if (yerr)
- return yerr;
- /* Return an error if the Yarrow initialization failed. */
- if (init_error)
- return KRB5_CRYPTO_INTERNAL;
/* Now, finally, feed in the data. */
yerr = k5_mutex_lock(&yarrow_lock);
if (yerr)
return yerr;
+ if (!inited)
+ do_yarrow_init();
+ if (init_error) {
+ k5_mutex_unlock(&yarrow_lock);
+ return KRB5_CRYPTO_INTERNAL;
+ }
yerr = krb5int_yarrow_input (&y_ctx, randsource,
data->data, data->length,
entropy_estimate (randsource, data->length));