From ec0f0c3b5973841e50e1b5ec8054f2c805452ac2 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 28 Apr 2005 21:37:18 +0000 Subject: [PATCH] * yarrow.c: Delete old macintosh support. (yarrow_input_maybe_locking): Do the optional locking, and verify that the mutex is locked, before doing anything else. (yarrow_reseed_locked): Verify that the global mutex is locked before doing anything else. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17204 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/yarrow/ChangeLog | 8 ++++++++ src/lib/crypto/yarrow/yarrow.c | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/lib/crypto/yarrow/ChangeLog b/src/lib/crypto/yarrow/ChangeLog index cf08dc9ed..6e9d02804 100644 --- a/src/lib/crypto/yarrow/ChangeLog +++ b/src/lib/crypto/yarrow/ChangeLog @@ -1,3 +1,11 @@ +2005-04-28 Ken Raeburn + + * yarrow.c: Delete old macintosh support. + (yarrow_input_maybe_locking): Do the optional locking, and verify + that the mutex is locked, before doing anything else. + (yarrow_reseed_locked): Verify that the global mutex is locked + before doing anything else. + 2005-01-13 Ken Raeburn * yarrow.c (yarrow_reseed_locked): Renamed from diff --git a/src/lib/crypto/yarrow/yarrow.c b/src/lib/crypto/yarrow/yarrow.c index 29c10f79e..b52057daa 100644 --- a/src/lib/crypto/yarrow/yarrow.c +++ b/src/lib/crypto/yarrow/yarrow.c @@ -26,11 +26,7 @@ #include "port-sockets.h" #else # include -# if defined(macintosh) -# include -# else -# include -# endif +# include #endif #if !defined(YARROW_NO_MATHLIB) #include @@ -262,23 +258,24 @@ int yarrow_input_maybe_locking( Yarrow_CTX* y, unsigned source_id, Source* source; size_t new_entropy; size_t estimate; + + if (do_lock) { + TRY( LOCK() ); + locked = 1; + } + k5_assert_locked(&krb5int_yarrow_lock); if (!y) { THROW( YARROW_BAD_ARG ); } if (source_id >= y->num_sources) { THROW( YARROW_BAD_SOURCE ); } source = &y->source[source_id]; - + if(source->pool != YARROW_FAST_POOL && source->pool != YARROW_SLOW_POOL) { THROW( YARROW_BAD_SOURCE ); } - if (do_lock) { - TRY( LOCK() ); - locked = 1; - } - /* hash in the sample */ HASH_Update(&y->pool[source->pool], (const void*)sample, size); @@ -672,8 +669,8 @@ static int Yarrow_Save_State( Yarrow_CTX *y ) static int yarrow_reseed_locked(Yarrow_CTX* y, int pool) { EXCEP_DECL; - HASH_CTX* fast_pool = &y->pool[YARROW_FAST_POOL]; - HASH_CTX* slow_pool = &y->pool[YARROW_SLOW_POOL]; + HASH_CTX* fast_pool; + HASH_CTX* slow_pool; byte digest[HASH_DIGEST_SIZE]; HASH_CTX hash; byte v_0[HASH_DIGEST_SIZE]; @@ -681,7 +678,10 @@ static int yarrow_reseed_locked(Yarrow_CTX* y, int pool) krb5_ui_4 big_endian_int32; COUNTER i; + k5_assert_locked(&krb5int_yarrow_lock); if (!y) { THROW( YARROW_BAD_ARG ); } + fast_pool = &y->pool[YARROW_FAST_POOL]; + slow_pool = &y->pool[YARROW_SLOW_POOL]; if( pool != YARROW_FAST_POOL && pool != YARROW_SLOW_POOL ) { THROW( YARROW_BAD_ARG ); -- 2.26.2