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

Add _init() and _free() for cipher modules

This commit is contained in:
Paul Bakker
2014-06-18 11:12:03 +02:00
parent 0464dd9357
commit c7ea99af4f
17 changed files with 375 additions and 61 deletions

View File

@ -147,6 +147,8 @@ int pkcs12_pbe_sha1_rc4_128( asn1_buf *pbe_params, int mode,
arc4_context ctx;
((void) mode);
arc4_init( &ctx );
if( ( ret = pkcs12_pbe_derive_key_iv( pbe_params, POLARSSL_MD_SHA1,
pwd, pwdlen,
key, 16, NULL, 0 ) ) != 0 )
@ -156,9 +158,13 @@ int pkcs12_pbe_sha1_rc4_128( asn1_buf *pbe_params, int mode,
arc4_setup( &ctx, key, 16 );
if( ( ret = arc4_crypt( &ctx, len, data, output ) ) != 0 )
return( ret );
goto exit;
return( 0 );
exit:
polarssl_zeroize( key, sizeof( key ) );
arc4_free( &ctx );
return( ret );
#endif /* POLARSSL_ARC4_C */
}