mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
- Addedd writing and updating of seedfiles as functions to CTR_DRBG
This commit is contained in:
parent
1c70d409ad
commit
fc754a9178
4 changed files with 105 additions and 1 deletions
|
|
@ -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 );
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ int main( int argc, char *argv[] )
|
|||
if( t == time( NULL ) )
|
||||
t--;
|
||||
|
||||
printf(" \n ");
|
||||
|
||||
fclose( f );
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue