/* calculate limits after initialization */
-static void Yarrow_Init_Limits(Yarrow_CTX* y)
+static void krb5int_yarrow_init_Limits(Yarrow_CTX* y)
{
double tmp1, tmp2, limit;
/* max number of gates between reseeds -> exceed this, do forced reseed */
* pids */
if ( y->pid != getpid() )
{
- TRY( Yarrow_Init( y, y->entropyfile ) );
+ TRY( krb5int_yarrow_init( y, y->entropyfile ) );
}
CATCH:
}
YARROW_DLL
-int Yarrow_Init(Yarrow_CTX* y, const char *filename)
+int krb5int_yarrow_init(Yarrow_CTX* y, const char *filename)
{
EXCEP_DECL;
int locked = 0;
y->fast_thresh = YARROW_FAST_INIT_THRESH;
y->slow_k_of_n_thresh = YARROW_K_OF_N_INIT_THRESH;
- Yarrow_Init_Limits(y);
+ krb5int_yarrow_init_Limits(y);
#if defined( YARROW_SAVE_STATE )
if ( y->entropyfile != NULL )
}
YARROW_DLL
-int Yarrow_Input( Yarrow_CTX* y, unsigned source_id,
+int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id,
const void* sample,
size_t size, size_t entropy_bits )
{
{
if (source->entropy[YARROW_FAST_POOL] >= y->fast_thresh)
{
- ret = Yarrow_Reseed(y, YARROW_FAST_POOL);
+ ret = krb5int_yarrow_reseed(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 = Yarrow_Reseed(y, YARROW_SLOW_POOL);
+ ret = krb5int_yarrow_reseed(y, YARROW_SLOW_POOL);
if ( ret != YARROW_OK && ret != YARROW_NOT_SEEDED )
{
THROW( ret );
}
YARROW_DLL
-int Yarrow_New_Source(Yarrow_CTX* y, unsigned* source_id)
+int krb5int_yarrow_new_source(Yarrow_CTX* y, unsigned* source_id)
{
EXCEP_DECL;
int locked = 0;
EXCEP_RET;
}
-int Yarrow_Register_Source_Estimator(Yarrow_CTX* y, unsigned source_id,
+int krb5int_yarrow_register_source_estimator(Yarrow_CTX* y, unsigned source_id,
estimator_fn* fptr)
{
EXCEP_DECL;
EXCEP_RET;
}
-static int Yarrow_Output_Block( Yarrow_CTX* y, void* out )
+static int krb5int_yarrow_output_Block( Yarrow_CTX* y, void* out )
{
EXCEP_DECL;
if (y->out_count >= y->Pg)
{
y->out_count = 0;
- TRY( Yarrow_Gate( y ) );
+ TRY( krb5int_yarrow_gate( y ) );
/* require new seed after reaching gates_limit */
TRACE( printf( "OUTPUT LIMIT REACHED," ); );
- TRY( Yarrow_Reseed( y, YARROW_SLOW_POOL ) );
+ TRY( krb5int_yarrow_reseed( y, YARROW_SLOW_POOL ) );
}
}
}
YARROW_DLL
-int Yarrow_Status( Yarrow_CTX* y, int *num_sources, unsigned *source_id,
+int krb5int_yarrow_status( Yarrow_CTX* y, int *num_sources, unsigned *source_id,
size_t *entropy_bits, size_t *entropy_max )
{
EXCEP_DECL;
}
YARROW_DLL
-int Yarrow_Output( Yarrow_CTX* y, void* out, size_t size )
+int krb5int_yarrow_output( Yarrow_CTX* y, void* out, size_t size )
{
EXCEP_DECL;
int locked = 0;
left >= CIPHER_BLOCK_SIZE;
left -= CIPHER_BLOCK_SIZE, outp += CIPHER_BLOCK_SIZE)
{
- TRY( Yarrow_Output_Block(y, outp) );
+ TRY( krb5int_yarrow_output_Block(y, outp) );
}
if (left > 0)
{
- TRY( Yarrow_Output_Block(y, y->out) );
+ TRY( krb5int_yarrow_output_Block(y, y->out) );
mem_copy(outp, y->out, left);
y->out_left = CIPHER_BLOCK_SIZE - left;
}
EXCEP_RET;
}
-int Yarrow_Gate(Yarrow_CTX* y)
+int krb5int_yarrow_gate(Yarrow_CTX* y)
{
EXCEP_DECL;
byte new_K[CIPHER_KEY_SIZE];
/* K <- Next k bits of PRNG output */
- TRY( Yarrow_Output(y, new_K, CIPHER_KEY_SIZE) );
+ TRY( krb5int_yarrow_output(y, new_K, CIPHER_KEY_SIZE) );
mem_copy(y->K, new_K, CIPHER_KEY_SIZE);
/* need to resetup the key schedule as the key has changed */
Yarrow_Make_Seeded( y );
- TRY( Yarrow_Reseed(y, YARROW_FAST_POOL) );
+ TRY( krb5int_yarrow_reseed(y, YARROW_FAST_POOL) );
}
CATCH:
mem_zero(state.seed, sizeof(state.seed));
if ( y->entropyfile && y->seeded )
{
TRACE( printf( "SAVE STATE[" ); );
- TRY( Yarrow_Output( y, state.seed, sizeof(state.seed) ) );
+ TRY( krb5int_yarrow_output( y, state.seed, sizeof(state.seed) ) );
TRY( STATE_Save(y->entropyfile, &state) );
}
y->saved = 1;
#endif
-int Yarrow_Reseed(Yarrow_CTX* y, int pool)
+int krb5int_yarrow_reseed(Yarrow_CTX* y, int pool)
{
EXCEP_DECL;
HASH_CTX* fast_pool = &y->pool[YARROW_FAST_POOL];
#endif
/* K <- h'(t) */
- TRY( Yarrow_Stretch(v_i, HASH_DIGEST_SIZE, y->K, CIPHER_KEY_SIZE) );
+ TRY( krb5int_yarrow_stretch(v_i, HASH_DIGEST_SIZE, y->K, CIPHER_KEY_SIZE) );
/* need to resetup the key schedule as the key has changed */
EXCEP_RET;
}
-int Yarrow_Stretch(const byte* m, size_t size, byte* out, size_t out_size)
+int krb5int_yarrow_stretch(const byte* m, size_t size, byte* out, size_t out_size)
{
EXCEP_DECL;
const byte* s_i;
}
YARROW_DLL
-int Yarrow_Final(Yarrow_CTX* y)
+int krb5int_yarrow_final(Yarrow_CTX* y)
{
EXCEP_DECL;
int locked = 0;
}
YARROW_DLL
-const char* Yarrow_Str_Error( int err )
+const char* krb5int_yarrow_str_error( int err )
{
err = 1-err;
if ( err < 0 || err >= sizeof( yarrow_str_error ) / sizeof( char* ) )
YARROW_DLL
-int Yarrow_Init( Yarrow_CTX* y, const char *filename );
+int krb5int_yarrow_init( Yarrow_CTX* y, const char *filename );
YARROW_DLL
-int Yarrow_Input( Yarrow_CTX* y, unsigned source_id,
+int krb5int_yarrow_input( Yarrow_CTX* y, unsigned source_id,
const void* sample,
size_t size, size_t entropy_bits );
YARROW_DLL
-int Yarrow_Status( Yarrow_CTX* y, int *num_sources, unsigned *source_id,
+int krb5int_yarrow_status( Yarrow_CTX* y, int *num_sources, unsigned *source_id,
size_t *entropy_bits, size_t *entropy_max );
YARROW_DLL
-int Yarrow_Output( Yarrow_CTX* y, void* out, size_t size );
+int krb5int_yarrow_output( Yarrow_CTX* y, void* out, size_t size );
YARROW_DLL
-int Yarrow_New_Source( Yarrow_CTX* y, unsigned* source_id );
+int krb5int_yarrow_new_source( Yarrow_CTX* y, unsigned* source_id );
YARROW_DLL
-int Yarrow_Register_Source_Estimator( Yarrow_CTX* y, unsigned source_id,
+int krb5int_yarrow_register_source_estimator( Yarrow_CTX* y, unsigned source_id,
estimator_fn* fptr );
YARROW_DLL
-int Yarrow_Stretch( const byte* m, size_t size, byte* out, size_t out_size );
+int krb5int_yarrow_stretch( const byte* m, size_t size, byte* out, size_t out_size );
YARROW_DLL
-int Yarrow_Reseed( Yarrow_CTX* y, int pool );
+int krb5int_yarrow_reseed( Yarrow_CTX* y, int pool );
YARROW_DLL
-int Yarrow_Gate( Yarrow_CTX* y );
+int krb5int_yarrow_gate( Yarrow_CTX* y );
YARROW_DLL
-int Yarrow_Final( Yarrow_CTX* y );
+int krb5int_yarrow_final( Yarrow_CTX* y );
YARROW_DLL
-const char* Yarrow_Str_Error( int );
+const char* krb5int_yarrow_str_error( int );
# define mem_zero(p, n) memset((p), 0, (n))
int yarrow_verbose = 0;
#define VERBOSE( x ) if ( yarrow_verbose ) { x }
-int Instrumented_Yarrow_Input( Yarrow_CTX* y, int sid, void* sample,
+int Instrumented_krb5int_yarrow_input( Yarrow_CTX* y, int sid, void* sample,
size_t size, int entropy )
{
int ret;
- VERBOSE( printf( "Yarrow_Input( #%d, %d bits, %s ) = [", sid, entropy,
+ VERBOSE( printf( "krb5int_yarrow_input( #%d, %d bits, %s ) = [", sid, entropy,
y->source[sid].pool ==
YARROW_SLOW_POOL ? "slow" : "fast" ); );
- ret = Yarrow_Input( y, sid, sample, size, entropy );
+ ret = krb5int_yarrow_input( y, sid, sample, size, entropy );
- VERBOSE( printf( "%s]\n", Yarrow_Str_Error( ret ) ); );
+ VERBOSE( printf( "%s]\n", krb5int_yarrow_str_error( ret ) ); );
VERBOSE( print_yarrow_status( y ); );
return (ret);
}
printf( "doing test %d ... ", t ); fflush( stdout );
ret = test_func[ t-1 ]();
VERBOSE( printf( "\ndone test %d ", t ); );
- printf( "[%s]\n", Yarrow_Str_Error( ret ) ); fflush( stdout );
+ printf( "[%s]\n", krb5int_yarrow_str_error( ret ) ); fflush( stdout );
THROW( ret );
CATCH:
THROW( YARROW_NOT_IMPL );
#endif
- VERBOSE( printf( "\nYarrow_Stretch\n\n" ); );
+ VERBOSE( printf( "\nkrb5int_yarrow_stretch\n\n" ); );
THROW( YARROW_NOT_IMPL );
CATCH:
VERBOSE( printf( "\nGeneral workout test\n\n" ); )
- VERBOSE( printf( "Yarrow_Init() = [" ); );
- ret = Yarrow_Init( &yarrow, YARROW_SEED_FILE );
- VERBOSE( printf( "%s]\n", Yarrow_Str_Error( ret ) ); );
+ VERBOSE( printf( "krb5int_yarrow_init() = [" ); );
+ ret = krb5int_yarrow_init( &yarrow, YARROW_SEED_FILE );
+ VERBOSE( printf( "%s]\n", krb5int_yarrow_str_error( ret ) ); );
if ( ret != YARROW_OK && ret != YARROW_NOT_SEEDED ) { THROW( ret ); }
initialized = 1;
dump_yarrow_state( stdout, &yarrow );
#endif
- ret = Yarrow_New_Source( &yarrow, &user );
- VERBOSE( printf( "Yarrow_New_Source() = [%s]\n",
- Yarrow_Str_Error( ret ) ); );
+ ret = krb5int_yarrow_new_source( &yarrow, &user );
+ VERBOSE( printf( "krb5int_yarrow_new_source() = [%s]\n",
+ krb5int_yarrow_str_error( ret ) ); );
if ( ret != YARROW_OK ) { THROW( ret ); }
VERBOSE( printf( "Yarrow_Poll( #%d ) = [", user ); );
ret = Yarrow_Poll( &yarrow, user );
- VERBOSE( printf( "%s]\n", Yarrow_Str_Error( ret ) ); );
+ VERBOSE( printf( "%s]\n", krb5int_yarrow_str_error( ret ) ); );
- ret = Yarrow_New_Source( &yarrow, &mouse );
- VERBOSE( printf( "Yarrow_New_Source() = [%s]\n",
- Yarrow_Str_Error( ret ) ); );
+ ret = krb5int_yarrow_new_source( &yarrow, &mouse );
+ VERBOSE( printf( "krb5int_yarrow_new_source() = [%s]\n",
+ krb5int_yarrow_str_error( ret ) ); );
if ( ret != YARROW_OK ) { THROW( ret ); }
- ret = Yarrow_New_Source( &yarrow, &keyboard );
- VERBOSE( printf( "Yarrow_New_Source() = [%s]\n",
- Yarrow_Str_Error( ret ) ); );
+ ret = krb5int_yarrow_new_source( &yarrow, &keyboard );
+ VERBOSE( printf( "krb5int_yarrow_new_source() = [%s]\n",
+ krb5int_yarrow_str_error( ret ) ); );
if ( ret != YARROW_OK ) { THROW( ret ); }
/* prematurely try to draw output, to check failure when no
* seed file, or state saving turned off
*/
- VERBOSE( printf( "Yarrow_Output( %d ) = [", sizeof( random ) ); );
- ret = Yarrow_Output( &yarrow, random, sizeof( random ) );
- VERBOSE( printf( "%s]\n", Yarrow_Str_Error( ret ) ); );
+ VERBOSE( printf( "krb5int_yarrow_output( %d ) = [", sizeof( random ) ); );
+ ret = krb5int_yarrow_output( &yarrow, random, sizeof( random ) );
+ VERBOSE( printf( "%s]\n", krb5int_yarrow_str_error( ret ) ); );
/* do it twice so that we some slow samples
* (first sample goes to fast pool, and then samples alternate)
for ( i = 0; i < 2; i++ )
{
- TRY( Instrumented_Yarrow_Input( &yarrow, mouse, mouse_sample,
+ TRY( Instrumented_krb5int_yarrow_input( &yarrow, mouse, mouse_sample,
sizeof( mouse_sample ), 2 ) );
- TRY( Instrumented_Yarrow_Input( &yarrow, keyboard, keyboard_sample,
+ TRY( Instrumented_krb5int_yarrow_input( &yarrow, keyboard, keyboard_sample,
sizeof( keyboard_sample ), 2 ) );
- TRY( Instrumented_Yarrow_Input( &yarrow, user, user_sample,
+ TRY( Instrumented_krb5int_yarrow_input( &yarrow, user, user_sample,
sizeof( user_sample ), 2 ) );
}
for ( i = 0; i < 7; i++ )
{
- TRY( Instrumented_Yarrow_Input( &yarrow, user, user_sample,
+ TRY( Instrumented_krb5int_yarrow_input( &yarrow, user, user_sample,
sizeof( user_sample ),
sizeof( user_sample ) * 3 ) );
}
for ( i = 0; i < 40; i++ )
{
- TRY( Instrumented_Yarrow_Input( &yarrow, mouse, mouse_sample,
+ TRY( Instrumented_krb5int_yarrow_input( &yarrow, mouse, mouse_sample,
sizeof( mouse_sample ),
sizeof( mouse_sample )*2 ) );
}
for ( i = 0; i < 30; i++ )
{
- VERBOSE( printf( "Yarrow_Output( %d ) = [", sizeof( junk ) ); );
- ret = Yarrow_Output( &yarrow, junk, sizeof( junk ) );
- VERBOSE( printf( "%s]\n", Yarrow_Str_Error( ret ) ); );
+ VERBOSE( printf( "krb5int_yarrow_output( %d ) = [", sizeof( junk ) ); );
+ ret = krb5int_yarrow_output( &yarrow, junk, sizeof( junk ) );
+ VERBOSE( printf( "%s]\n", krb5int_yarrow_str_error( ret ) ); );
if ( ret != YARROW_OK ) { THROW( ret ); }
}
if ( i % 16 == 0 )
{
- TRY( Instrumented_Yarrow_Input( &yarrow, mouse, junk,
+ TRY( Instrumented_krb5int_yarrow_input( &yarrow, mouse, junk,
sizeof( junk ),
sizeof( junk ) * 3 ) );
}
else
{
- TRY( Instrumented_Yarrow_Input( &yarrow, user, junk,
+ TRY( Instrumented_krb5int_yarrow_input( &yarrow, user, junk,
sizeof( junk ),
sizeof( junk ) * 3 ) );
}
VERBOSE( printf( "\nPrint some random output\n\n" ); );
- VERBOSE( printf( "Yarrow_Output( %d ) = [", sizeof( random ) ); );
- ret = Yarrow_Output( &yarrow, random, sizeof( random ) );
- VERBOSE( printf( "%s]\n", Yarrow_Str_Error( ret ) ); );
+ VERBOSE( printf( "krb5int_yarrow_output( %d ) = [", sizeof( random ) ); );
+ ret = krb5int_yarrow_output( &yarrow, random, sizeof( random ) );
+ VERBOSE( printf( "%s]\n", krb5int_yarrow_str_error( ret ) ); );
if ( ret != YARROW_OK )
{
THROW( ret );
CATCH:
if ( initialized )
{
- VERBOSE( printf( "Yarrow_Final() = [" ); );
- ret = Yarrow_Final( &yarrow );
- VERBOSE( printf( "%s]\n", Yarrow_Str_Error( ret ) ); );
+ VERBOSE( printf( "krb5int_yarrow_final() = [" ); );
+ ret = krb5int_yarrow_final( &yarrow );
+ VERBOSE( printf( "%s]\n", krb5int_yarrow_str_error( ret ) ); );
THROW( ret );
}
EXCEP_RET;