+2005-01-13 Ken Raeburn <raeburn@mit.edu>
+
+ * yarrow.c (yarrow_reseed_locked): Renamed from
+ krb5int_yarrow_reseed and made static.
+ (Yarrow_detect_fork, yarrow_input_maybe_locking,
+ krb5int_yarrow_output_Block): Call it.
+ (krb5int_yarrow_reseed): New function, grabs lock and calls the
+ old version.
+ (krb5int_yarrow_final): Hold the lock until after clearing the
+ Yarrow context data.
+
2005-01-13 Ezra Peisach <epeisach@mit.edu>
* yarrow.c: Declare yarrow_gate_locked static before first use.
}
}
+static int yarrow_reseed_locked( Yarrow_CTX* y, int pool );
+
/* if the program was forked, the child must not operate on the same
PRNG state */
#ifdef YARROW_DETECT_FORK
sizeof (newpid), 0));
TRY (yarrow_input_locked (y, 0, &newpid,
sizeof (newpid), 0));
- TRY (krb5int_yarrow_reseed (y, YARROW_FAST_POOL));
+ TRY (yarrow_reseed_locked (y, YARROW_FAST_POOL));
}
CATCH:
{
if (source->entropy[YARROW_FAST_POOL] >= y->fast_thresh)
{
- ret = krb5int_yarrow_reseed(y, YARROW_FAST_POOL);
+ ret = yarrow_reseed_locked(y, YARROW_FAST_POOL);
if ( ret != YARROW_OK && ret != YARROW_NOT_SEEDED )
{
THROW( ret );
if (y->slow_k_of_n >= y->slow_k_of_n_thresh)
{
y->slow_k_of_n = 0;
- ret = krb5int_yarrow_reseed(y, YARROW_SLOW_POOL);
+ ret = yarrow_reseed_locked(y, YARROW_SLOW_POOL);
if ( ret != YARROW_OK && ret != YARROW_NOT_SEEDED )
{
THROW( ret );
TRACE( printf( "OUTPUT LIMIT REACHED," ); );
- TRY( krb5int_yarrow_reseed( y, YARROW_SLOW_POOL ) );
+ TRY( yarrow_reseed_locked( y, YARROW_SLOW_POOL ) );
}
}
#endif
-int krb5int_yarrow_reseed(Yarrow_CTX* y, int pool)
+static int yarrow_reseed_locked(Yarrow_CTX* y, int pool)
{
EXCEP_DECL;
HASH_CTX* fast_pool = &y->pool[YARROW_FAST_POOL];
EXCEP_RET;
}
+int krb5int_yarrow_reseed(Yarrow_CTX* y, int pool)
+{
+ int r;
+ LOCK();
+ r = yarrow_reseed_locked(y, pool);
+ UNLOCK();
+ return r;
+}
int krb5int_yarrow_stretch(const byte* m, size_t size, byte* out, size_t out_size)
{
#endif
CATCH:
- if ( locked ) { TRY( UNLOCK() ); }
krb5int_yarrow_cipher_final(&y->cipher);
mem_zero( y, sizeof(Yarrow_CTX) );
+ if ( locked ) { TRY( UNLOCK() ); }
EXCEP_RET;
}