+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
#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;
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
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);
void krb5int_prng_cleanup (void)
{
- if (inited)
- krb5int_yarrow_final (&y_ctx);
+ krb5int_yarrow_final (&y_ctx);
k5_mutex_destroy(&yarrow_lock);
- inited = 0;
}