1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

- Addedd writing and updating of seedfiles as functions to CTR_DRBG

This commit is contained in:
Paul Bakker
2011-12-05 13:23:51 +00:00
parent 1c70d409ad
commit fc754a9178
4 changed files with 105 additions and 1 deletions

View File

@ -64,6 +64,26 @@ int main( int argc, char *argv[] )
ctr_drbg_init( &ctr_drbg, entropy_func, &entropy, (unsigned char *) "RANDOM_GEN", 10 );
ctr_drbg_set_prediction_resistance( &ctr_drbg, CTR_DRBG_PR_OFF );
#if defined(POLARSSL_FS_IO)
ret = ctr_drbg_update_seed_file( &ctr_drbg, "seedfile" );
if( ret == 1 )
{
printf("Failed to open seedfile. Generating one.\n");
ret = ctr_drbg_write_seed_file( &ctr_drbg, "seedfile" );
if( ret != 0 )
{
printf("failed in ctr_drbg_write_seed_file: %d\n", ret );
goto cleanup;
}
}
else if( ret != 0 )
{
printf("failed in ctr_drbg_update_seed_file: %d\n", ret );
goto cleanup;
}
#endif
for( i = 0, k = 768; i < k; i++ )
{
ret = ctr_drbg_random( &ctr_drbg, buf, sizeof( buf ) );
@ -83,6 +103,7 @@ int main( int argc, char *argv[] )
ret = 0;
cleanup:
printf("\n");
fclose( f );

View File

@ -83,6 +83,8 @@ int main( int argc, char *argv[] )
if( t == time( NULL ) )
t--;
printf(" \n ");
fclose( f );
return( 0 );
}