Split cipher_update_ad() out or cipher_reset()

This commit is contained in:
Manuel Pégourié-Gonnard 2013-09-03 13:54:12 +02:00
parent a235b5b5bd
commit 2adc40c346
6 changed files with 59 additions and 15 deletions

View file

@ -61,8 +61,11 @@ void enc_dec_buf( int cipher_id, char *cipher_string, int key_len,
TEST_ASSERT( 0 == cipher_set_iv( &ctx_dec, iv, 16 ) );
TEST_ASSERT( 0 == cipher_set_iv( &ctx_enc, iv, 16 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_dec, ad, 13 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_enc, ad, 13 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_dec ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_enc ) );
TEST_ASSERT( 0 == cipher_update_ad( &ctx_dec, ad, 13 ) );
TEST_ASSERT( 0 == cipher_update_ad( &ctx_enc, ad, 13 ) );
/* encode length number of bytes from inbuf */
TEST_ASSERT( 0 == cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
@ -137,7 +140,8 @@ void enc_fail( int cipher_id, int pad_mode, int key_len,
TEST_ASSERT( 0 == cipher_setkey( &ctx, key, key_len, POLARSSL_ENCRYPT ) );
TEST_ASSERT( 0 == cipher_set_padding_mode( &ctx, pad_mode ) );
TEST_ASSERT( 0 == cipher_set_iv( &ctx, iv, 16 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx, NULL, 0 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx ) );
TEST_ASSERT( 0 == cipher_update_ad( &ctx, NULL, 0 ) );
/* encode length number of bytes from inbuf */
TEST_ASSERT( 0 == cipher_update( &ctx, inbuf, length, encbuf, &outlen ) );
@ -180,7 +184,9 @@ void dec_empty_buf()
TEST_ASSERT( 0 == cipher_set_iv( &ctx_dec, iv, 16 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_dec, NULL, 0 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_dec ) );
TEST_ASSERT( 0 == cipher_update_ad( &ctx_dec, NULL, 0 ) );
/* decode 0-byte string */
TEST_ASSERT( 0 == cipher_update( &ctx_dec, encbuf, 0, decbuf, &outlen ) );
@ -237,8 +243,11 @@ void enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_val,
TEST_ASSERT( 0 == cipher_set_iv( &ctx_dec, iv, 16 ) );
TEST_ASSERT( 0 == cipher_set_iv( &ctx_enc, iv, 16 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_dec, NULL, 0 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_enc, NULL, 0 ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_dec ) );
TEST_ASSERT( 0 == cipher_reset( &ctx_enc ) );
TEST_ASSERT( 0 == cipher_update_ad( &ctx_dec, NULL, 0 ) );
TEST_ASSERT( 0 == cipher_update_ad( &ctx_enc, NULL, 0 ) );
/* encode length number of bytes from inbuf */
TEST_ASSERT( 0 == cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );