Add _init() and _free() for cipher modules
diff --git a/library/pkcs12.c b/library/pkcs12.c
index b025450..027f84a 100644
--- a/library/pkcs12.c
+++ b/library/pkcs12.c
@@ -147,6 +147,8 @@
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 @@
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 */
}