mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +03:00
Adapt programs / test suites to _init() and _free()
This commit is contained in:
@@ -93,6 +93,8 @@ int main( int argc, char *argv[] )
|
||||
off_t filesize, offset;
|
||||
#endif
|
||||
|
||||
aes_init( &aes_ctx );
|
||||
|
||||
/*
|
||||
* Parse the command-line arguments.
|
||||
*/
|
||||
@@ -357,7 +359,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
|
||||
memset( key, 0, sizeof( key ) );
|
||||
aes_setkey_dec( &aes_ctx, digest, 256 );
|
||||
aes_setkey_dec( &aes_ctx, digest, 256 );
|
||||
sha256_hmac_starts( &sha_ctx, digest, 32, 0 );
|
||||
|
||||
/*
|
||||
@@ -426,7 +428,7 @@ exit:
|
||||
memset( buffer, 0, sizeof( buffer ) );
|
||||
memset( digest, 0, sizeof( digest ) );
|
||||
|
||||
memset( &aes_ctx, 0, sizeof( aes_context ) );
|
||||
aes_free( &aes_ctx );
|
||||
memset( &sha_ctx, 0, sizeof( sha256_context ) );
|
||||
|
||||
return( ret );
|
||||
|
@@ -84,6 +84,8 @@ int main( int argc, char *argv[] )
|
||||
memset( &rsa, 0, sizeof( rsa ) );
|
||||
memset( &dhm, 0, sizeof( dhm ) );
|
||||
|
||||
aes_init( &aes );
|
||||
|
||||
/*
|
||||
* 1. Setup the RNG
|
||||
*/
|
||||
@@ -279,6 +281,7 @@ exit:
|
||||
if( server_fd != -1 )
|
||||
net_close( server_fd );
|
||||
|
||||
aes_free( &aes );
|
||||
rsa_free( &rsa );
|
||||
dhm_free( &dhm );
|
||||
entropy_free( &entropy );
|
||||
|
@@ -84,6 +84,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
memset( &rsa, 0, sizeof( rsa ) );
|
||||
memset( &dhm, 0, sizeof( dhm ) );
|
||||
aes_init( &aes );
|
||||
|
||||
/*
|
||||
* 1. Setup the RNG
|
||||
@@ -280,6 +281,7 @@ exit:
|
||||
if( client_fd != -1 )
|
||||
net_close( client_fd );
|
||||
|
||||
aes_free( &aes );
|
||||
rsa_free( &rsa );
|
||||
dhm_free( &dhm );
|
||||
entropy_free( &entropy );
|
||||
|
@@ -273,8 +273,10 @@ int main( int argc, char *argv[] )
|
||||
if( todo.arc4 )
|
||||
{
|
||||
arc4_context arc4;
|
||||
arc4_init( &arc4 );
|
||||
arc4_setup( &arc4, tmp, 32 );
|
||||
TIME_AND_TSC( "ARC4", arc4_crypt( &arc4, BUFSIZE, buf, buf ) );
|
||||
arc4_free( &arc4 );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -282,17 +284,21 @@ int main( int argc, char *argv[] )
|
||||
if( todo.des3 )
|
||||
{
|
||||
des3_context des3;
|
||||
des3_init( &des3 );
|
||||
des3_set3key_enc( &des3, tmp );
|
||||
TIME_AND_TSC( "3DES",
|
||||
des3_crypt_cbc( &des3, DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
|
||||
des3_free( &des3 );
|
||||
}
|
||||
|
||||
if( todo.des )
|
||||
{
|
||||
des_context des;
|
||||
des_init( &des );
|
||||
des_setkey_enc( &des, tmp );
|
||||
TIME_AND_TSC( "DES",
|
||||
des_crypt_cbc( &des, DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
|
||||
des_free( &des );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -301,6 +307,7 @@ int main( int argc, char *argv[] )
|
||||
if( todo.aes_cbc )
|
||||
{
|
||||
aes_context aes;
|
||||
aes_init( &aes );
|
||||
for( keysize = 128; keysize <= 256; keysize += 64 )
|
||||
{
|
||||
snprintf( title, sizeof( title ), "AES-CBC-%d", keysize );
|
||||
@@ -312,6 +319,7 @@ int main( int argc, char *argv[] )
|
||||
TIME_AND_TSC( title,
|
||||
aes_crypt_cbc( &aes, AES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
|
||||
}
|
||||
aes_free( &aes );
|
||||
}
|
||||
#endif
|
||||
#if defined(POLARSSL_GCM_C)
|
||||
@@ -360,6 +368,7 @@ int main( int argc, char *argv[] )
|
||||
if( todo.camellia )
|
||||
{
|
||||
camellia_context camellia;
|
||||
camellia_init( &camellia );
|
||||
for( keysize = 128; keysize <= 256; keysize += 64 )
|
||||
{
|
||||
snprintf( title, sizeof( title ), "CAMELLIA-CBC-%d", keysize );
|
||||
@@ -372,6 +381,7 @@ int main( int argc, char *argv[] )
|
||||
camellia_crypt_cbc( &camellia, CAMELLIA_ENCRYPT,
|
||||
BUFSIZE, tmp, buf, buf ) );
|
||||
}
|
||||
camellia_free( &camellia );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -379,6 +389,8 @@ int main( int argc, char *argv[] )
|
||||
if( todo.blowfish )
|
||||
{
|
||||
blowfish_context blowfish;
|
||||
blowfish_init( &blowfish );
|
||||
|
||||
for( keysize = 128; keysize <= 256; keysize += 64 )
|
||||
{
|
||||
snprintf( title, sizeof( title ), "BLOWFISH-CBC-%d", keysize );
|
||||
@@ -391,6 +403,8 @@ int main( int argc, char *argv[] )
|
||||
blowfish_crypt_cbc( &blowfish, BLOWFISH_ENCRYPT, BUFSIZE,
|
||||
tmp, buf, buf ) );
|
||||
}
|
||||
|
||||
blowfish_free( &blowfish );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user