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

Add tests for get_padding() (PKCS#7)

This commit is contained in:
Manuel Pégourié-Gonnard
2013-07-26 10:55:02 +02:00
committed by Paul Bakker
parent 725680ffd2
commit a640849b55
2 changed files with 45 additions and 0 deletions

View File

@ -218,6 +218,27 @@ set_padding:cipher_id:pad_mode:ret:
TEST_ASSERT( 0 == cipher_free_ctx( &ctx ) );
END_CASE
BEGIN_CASE
check_padding:pad_mode:input:ret:dlen:
cipher_info_t cipher_info;
cipher_context_t ctx;
unsigned char input[16];
size_t ilen, dlen;
/* build a fake context just for getting access to get_padding */
memset( &ctx, 0, sizeof( ctx ) );
cipher_info.mode = POLARSSL_MODE_CBC;
ctx.cipher_info = &cipher_info;
TEST_ASSERT( 0 == cipher_set_padding_mode( &ctx, {pad_mode} ) );
ilen = unhexify( input, {input} );
TEST_ASSERT( {ret} == ctx.get_padding( input, ilen, &dlen ) );
if( 0 == {ret} )
TEST_ASSERT( dlen == {dlen} );
END_CASE
BEGIN_CASE
cipher_selftest:
{