mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 02:55:41 +01:00
Add tests for get_padding() (PKCS#7)
This commit is contained in:
parent
725680ffd2
commit
a640849b55
@ -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:
|
||||
{
|
||||
|
@ -57,3 +57,27 @@ set_padding:POLARSSL_CIPHER_DES_CBC:-1:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
Set non-existent padding with BLOWFISH-CBC
|
||||
depends_on:POLARSSL_BLOWFISH_C
|
||||
set_padding:POLARSSL_CIPHER_BLOWFISH_CBC:-1:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Check PKCS padding #1 (correct)
|
||||
check_padding:POLARSSL_PADDING_PKCS7:"DABBAD0004040404":0:4
|
||||
|
||||
Check PKCS padding #2 (correct)
|
||||
check_padding:POLARSSL_PADDING_PKCS7:"DABBAD0001":0:4
|
||||
|
||||
Check PKCS padding #3 (correct)
|
||||
check_padding:POLARSSL_PADDING_PKCS7:"DABBAD000101":0:5
|
||||
|
||||
Check PKCS padding #4 (correct)
|
||||
check_padding:POLARSSL_PADDING_PKCS7:"030303":0:0
|
||||
|
||||
Check PKCS padding #5 (null padding)
|
||||
check_padding:POLARSSL_PADDING_PKCS7:"DABBAD0000":POLARSSL_ERR_CIPHER_INVALID_PADDING:0
|
||||
|
||||
Check PKCS padding #6 (too few padding bytes)
|
||||
check_padding:POLARSSL_PADDING_PKCS7:"DABBAD0002":POLARSSL_ERR_CIPHER_INVALID_PADDING:0
|
||||
|
||||
Check PKCS padding #7 (non-uniform padding bytes)
|
||||
check_padding:POLARSSL_PADDING_PKCS7:"DABBAD00030203":POLARSSL_ERR_CIPHER_INVALID_PADDING:0
|
||||
|
||||
Check PKCS padding #8 (overlong)
|
||||
check_padding:POLARSSL_PADDING_PKCS7:"040404":POLARSSL_ERR_CIPHER_INVALID_PADDING:0
|
||||
|
Loading…
Reference in New Issue
Block a user