mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-01 20:25:28 +01:00
Add cipher_set_padding() (no effect yet)
Fix pattern in tests/.gitignore along the way.
This commit is contained in:
parent
0f2f0bfc87
commit
d5fdcaf9e5
7 changed files with 111 additions and 1 deletions
2
tests/.gitignore
vendored
2
tests/.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
test_suite*
|
||||
/test_suite*
|
||||
data_files/mpi_write
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ add_test_suite(cipher cipher.blowfish)
|
|||
add_test_suite(cipher cipher.camellia)
|
||||
add_test_suite(cipher cipher.des)
|
||||
add_test_suite(cipher cipher.null)
|
||||
add_test_suite(cipher cipher.padding)
|
||||
add_test_suite(ctr_drbg)
|
||||
add_test_suite(debug)
|
||||
add_test_suite(des)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ APPS = test_suite_aes.ecb test_suite_aes.cbc \
|
|||
test_suite_cipher.blowfish \
|
||||
test_suite_cipher.camellia \
|
||||
test_suite_cipher.des test_suite_cipher.null \
|
||||
test_suite_cipher.padding \
|
||||
test_suite_ctr_drbg test_suite_debug \
|
||||
test_suite_des test_suite_dhm \
|
||||
test_suite_ecdh test_suite_ecdsa \
|
||||
|
|
@ -89,6 +90,10 @@ test_suite_cipher.null.c : suites/test_suite_cipher.function suites/test_suite_c
|
|||
echo " Generate $@"
|
||||
scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.null
|
||||
|
||||
test_suite_cipher.padding.c : suites/test_suite_cipher.function suites/test_suite_cipher.padding.data scripts/generate_code.pl suites/helpers.function
|
||||
echo " Generate $@"
|
||||
scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.padding
|
||||
|
||||
test_suite_gcm.decrypt_128.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_128.data scripts/generate_code.pl suites/helpers.function
|
||||
echo " Generate $@"
|
||||
scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_128
|
||||
|
|
@ -169,6 +174,10 @@ test_suite_cipher.null: test_suite_cipher.null.c ../library/libpolarssl.a
|
|||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
||||
test_suite_cipher.padding: test_suite_cipher.padding.c ../library/libpolarssl.a
|
||||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
||||
test_suite_ctr_drbg: test_suite_ctr_drbg.c ../library/libpolarssl.a
|
||||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
|
|
|||
|
|
@ -252,6 +252,19 @@ enc_dec_buf_multipart:cipher_id:key_len:first_length:second_length:
|
|||
TEST_ASSERT( 0 == cipher_free_ctx( &ctx_enc ) );
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
set_padding:cipher_id:pad_mode:ret:
|
||||
const cipher_info_t *cipher_info;
|
||||
cipher_context_t ctx;
|
||||
|
||||
cipher_info = cipher_info_from_type( {cipher_id} );
|
||||
TEST_ASSERT( NULL != cipher_info );
|
||||
TEST_ASSERT( 0 == cipher_init_ctx( &ctx, cipher_info ) );
|
||||
|
||||
TEST_ASSERT( {ret} == cipher_set_padding_mode( &ctx, {pad_mode} ) );
|
||||
|
||||
TEST_ASSERT( 0 == cipher_free_ctx( &ctx ) );
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
cipher_selftest:
|
||||
|
|
|
|||
59
tests/suites/test_suite_cipher.padding.data
Normal file
59
tests/suites/test_suite_cipher.padding.data
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
Set padding with AES-CBC
|
||||
depends_on:POLARSSL_AES_C
|
||||
set_padding:POLARSSL_CIPHER_AES_128_CBC:POLARSSL_PADDING_PKCS7:0
|
||||
|
||||
Set padding with AES-CFB
|
||||
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CFB
|
||||
set_padding:POLARSSL_CIPHER_AES_128_CFB128:POLARSSL_PADDING_PKCS7:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set padding with AES-CTR
|
||||
depends_on:POLARSSL_AES_C:POLARSSL_CIPHER_MODE_CTR
|
||||
set_padding:POLARSSL_CIPHER_AES_128_CTR:POLARSSL_PADDING_PKCS7:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set padding with CAMELLIA-CBC
|
||||
depends_on:POLARSSL_CAMELLIA_C
|
||||
set_padding:POLARSSL_CIPHER_CAMELLIA_128_CBC:POLARSSL_PADDING_PKCS7:0
|
||||
|
||||
Set padding with CAMELLIA-CFB
|
||||
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CFB
|
||||
set_padding:POLARSSL_CIPHER_CAMELLIA_128_CFB128:POLARSSL_PADDING_PKCS7:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set padding with CAMELLIA-CTR
|
||||
depends_on:POLARSSL_CAMELLIA_C:POLARSSL_CIPHER_MODE_CTR
|
||||
set_padding:POLARSSL_CIPHER_CAMELLIA_128_CTR:POLARSSL_PADDING_PKCS7:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set padding with DES-CBC
|
||||
depends_on:POLARSSL_DES_C
|
||||
set_padding:POLARSSL_CIPHER_DES_CBC:POLARSSL_PADDING_PKCS7:0
|
||||
|
||||
Set padding with BLOWFISH-CBC
|
||||
depends_on:POLARSSL_BLOWFISH_C
|
||||
set_padding:POLARSSL_CIPHER_BLOWFISH_CBC:POLARSSL_PADDING_PKCS7:0
|
||||
|
||||
Set padding with BLOWFISH-CFB
|
||||
depends_on:POLARSSL_BLOWFISH_C:POLARSSL_CIPHER_MODE_CFB
|
||||
set_padding:POLARSSL_CIPHER_BLOWFISH_CFB64:POLARSSL_PADDING_PKCS7:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set padding with BLOWFISH-CTR
|
||||
depends_on:POLARSSL_BLOWFISH_C:POLARSSL_CIPHER_MODE_CTR
|
||||
set_padding:POLARSSL_CIPHER_BLOWFISH_CTR:POLARSSL_PADDING_PKCS7:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set padding with NULL
|
||||
depends_on:POLARSSL_CIPHER_NULL_CIPHER
|
||||
set_padding:POLARSSL_CIPHER_NULL:POLARSSL_PADDING_PKCS7:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set non-existent padding with AES-CBC
|
||||
depends_on:POLARSSL_AES_C
|
||||
set_padding:POLARSSL_CIPHER_AES_128_CBC:-1:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set non-existent padding with CAMELLIA-CBC
|
||||
depends_on:POLARSSL_CAMELLIA_C
|
||||
set_padding:POLARSSL_CIPHER_CAMELLIA_128_CBC:-1:POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
|
||||
Set non-existent padding with DES-CBC
|
||||
depends_on:POLARSSL_DES_C
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue