From 679f9e90adb52628c71ff25f3b3031064d903d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 26 Jul 2013 12:46:02 +0200 Subject: [PATCH] Add one-and-zeros (ISO/IEC 7816-4) padding --- include/polarssl/cipher.h | 1 + library/cipher.c | 43 ++++++++++++++ tests/suites/test_suite_cipher.aes.data | 60 ++++++++++++++++++++ tests/suites/test_suite_cipher.blowfish.data | 60 ++++++++++++++++++++ tests/suites/test_suite_cipher.camellia.data | 60 ++++++++++++++++++++ tests/suites/test_suite_cipher.des.data | 60 ++++++++++++++++++++ tests/suites/test_suite_cipher.padding.data | 21 +++++++ 7 files changed, 305 insertions(+) diff --git a/include/polarssl/cipher.h b/include/polarssl/cipher.h index aa0c42a65..d4231ff2b 100644 --- a/include/polarssl/cipher.h +++ b/include/polarssl/cipher.h @@ -106,6 +106,7 @@ typedef enum { typedef enum { POLARSSL_PADDING_PKCS7 = 0, /**< PKCS7 padding (default) */ + POLARSSL_PADDING_ONE_AND_ZEROS, /**< ISO/IEC 7816-4 padding */ } cipher_padding_t; typedef enum { diff --git a/library/cipher.c b/library/cipher.c index f7f3d1a32..9a750db08 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -526,6 +526,9 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ile return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; } +/* + * PKCS7 (and PKCS5) padding: fill with ll bytes, with ll = padding_len + */ static void add_pkcs_padding( unsigned char *output, size_t output_len, size_t data_len ) { @@ -558,6 +561,39 @@ static int get_pkcs_padding( unsigned char *input, size_t input_len, return 0; } +/* + * One and zeros padding: fill with 80 00 ... 00 + */ +static void add_one_and_zeros_padding( unsigned char *output, + size_t output_len, size_t data_len ) +{ + size_t padding_len = output_len - data_len; + unsigned char i = 0; + + output[data_len] = 0x80; + for( i = 1; i < padding_len; i++ ) + output[data_len + i] = 0x00; +} + +static int get_one_and_zeros_padding( unsigned char *input, size_t input_len, + size_t *data_len ) +{ + unsigned char *p = input + input_len - 1; + + if( NULL == input || NULL == data_len ) + return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; + + while( *p == 0x00 && p > input ) + --p; + + if( *p != 0x80 ) + return POLARSSL_ERR_CIPHER_INVALID_PADDING; + + *data_len = p - input; + + return 0; +} + int cipher_finish( cipher_context_t *ctx, unsigned char *output, size_t *olen) { int ret = 0; @@ -623,6 +659,13 @@ int cipher_set_padding_mode( cipher_context_t *ctx, cipher_padding_t mode ) return 0; } + if( POLARSSL_PADDING_ONE_AND_ZEROS == mode ) + { + ctx->add_padding = add_one_and_zeros_padding; + ctx->get_padding = get_one_and_zeros_padding; + return 0; + } + return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; } diff --git a/tests/suites/test_suite_cipher.aes.data b/tests/suites/test_suite_cipher.aes.data index 4d8ed92b9..5b9ac1bca 100644 --- a/tests/suites/test_suite_cipher.aes.data +++ b/tests/suites/test_suite_cipher.aes.data @@ -65,6 +65,66 @@ AES Encrypt and decrypt 49 bytes depends_on:POLARSSL_AES_C enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:49:-1 +AES Encrypt and decrypt 0 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:0:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 1 byte with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:1:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 2 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:2:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 7 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:7:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 8 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:8:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 9 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:9:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 15 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:15:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 16 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:16:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 17 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:17:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 31 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:31:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 32 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:32:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 33 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:33:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 47 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:47:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 48 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:48:POLARSSL_PADDING_ONE_AND_ZEROS + +AES Encrypt and decrypt 49 bytes with one and zeros padding +depends_on:POLARSSL_AES_C +enc_dec_buf:POLARSSL_CIPHER_AES_128_CBC:AES-128-CBC:128:49:POLARSSL_PADDING_ONE_AND_ZEROS + AES Encrypt and decrypt 0 bytes in multiple parts depends_on:POLARSSL_AES_C enc_dec_buf_multipart:POLARSSL_CIPHER_AES_128_CBC:128:0:0: diff --git a/tests/suites/test_suite_cipher.blowfish.data b/tests/suites/test_suite_cipher.blowfish.data index 68092e256..b8f615dbb 100644 --- a/tests/suites/test_suite_cipher.blowfish.data +++ b/tests/suites/test_suite_cipher.blowfish.data @@ -65,6 +65,66 @@ BLOWFISH Encrypt and decrypt 49 bytes depends_on:POLARSSL_BLOWFISH_C enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:49:-1 +BLOWFISH Encrypt and decrypt 0 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:0:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 1 byte with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:1:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 2 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:2:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 7 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:7:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 8 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:8:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 9 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:9:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 15 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:15:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 16 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:16:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 17 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:17:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 31 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:31:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 32 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:32:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 32 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:33:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 47 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:47:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 48 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:48:POLARSSL_PADDING_ONE_AND_ZEROS + +BLOWFISH Encrypt and decrypt 49 bytes with one and zeros padding +depends_on:POLARSSL_BLOWFISH_C +enc_dec_buf:POLARSSL_CIPHER_BLOWFISH_CBC:BLOWFISH-CBC:128:49:POLARSSL_PADDING_ONE_AND_ZEROS + BLOWFISH Encrypt and decrypt 0 bytes in multiple parts depends_on:POLARSSL_BLOWFISH_C enc_dec_buf_multipart:POLARSSL_CIPHER_BLOWFISH_CBC:128:0:0: diff --git a/tests/suites/test_suite_cipher.camellia.data b/tests/suites/test_suite_cipher.camellia.data index 38f78c035..fd469ee5e 100644 --- a/tests/suites/test_suite_cipher.camellia.data +++ b/tests/suites/test_suite_cipher.camellia.data @@ -65,6 +65,66 @@ CAMELLIA Encrypt and decrypt 49 bytes depends_on:POLARSSL_CAMELLIA_C enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:49:-1 +CAMELLIA Encrypt and decrypt 0 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:0:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 1 byte with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:1:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 2 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:2:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 7 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:7:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 8 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:8:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 9 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:9:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 15 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:15:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 16 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:16:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 17 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:17:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 31 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:31:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 32 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:32:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 32 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:33:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 47 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:47:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 48 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:48:POLARSSL_PADDING_ONE_AND_ZEROS + +CAMELLIA Encrypt and decrypt 49 bytes with one and zeros padding +depends_on:POLARSSL_CAMELLIA_C +enc_dec_buf:POLARSSL_CIPHER_CAMELLIA_128_CBC:CAMELLIA-128-CBC:128:49:POLARSSL_PADDING_ONE_AND_ZEROS + CAMELLIA Encrypt and decrypt 0 bytes in multiple parts depends_on:POLARSSL_CAMELLIA_C enc_dec_buf_multipart:POLARSSL_CIPHER_CAMELLIA_128_CBC:128:0:0: diff --git a/tests/suites/test_suite_cipher.des.data b/tests/suites/test_suite_cipher.des.data index 9620898cb..7fc83d542 100644 --- a/tests/suites/test_suite_cipher.des.data +++ b/tests/suites/test_suite_cipher.des.data @@ -65,6 +65,66 @@ DES Encrypt and decrypt 49 bytes depends_on:POLARSSL_DES_C enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:49:-1 +DES Encrypt and decrypt 0 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:0:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 1 byte with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:1:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 2 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:2:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 7 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:7:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 8 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:8:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 9 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:9:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 15 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:15:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 16 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:16:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 17 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:17:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 31 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:31:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 32 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:32:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 32 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:33:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 47 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:47:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 48 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:48:POLARSSL_PADDING_ONE_AND_ZEROS + +DES Encrypt and decrypt 49 bytes with one and zeros padding +depends_on:POLARSSL_DES_C +enc_dec_buf:POLARSSL_CIPHER_DES_CBC:DES-CBC:56:49:POLARSSL_PADDING_ONE_AND_ZEROS + DES Encrypt and decrypt 0 bytes in multiple parts depends_on:POLARSSL_DES_C enc_dec_buf_multipart:POLARSSL_CIPHER_DES_CBC:56:0:0: diff --git a/tests/suites/test_suite_cipher.padding.data b/tests/suites/test_suite_cipher.padding.data index 1c9fc0d82..6548d568d 100644 --- a/tests/suites/test_suite_cipher.padding.data +++ b/tests/suites/test_suite_cipher.padding.data @@ -81,3 +81,24 @@ check_padding:POLARSSL_PADDING_PKCS7:"DABBAD00030203":POLARSSL_ERR_CIPHER_INVALI Check PKCS padding #8 (overlong) check_padding:POLARSSL_PADDING_PKCS7:"040404":POLARSSL_ERR_CIPHER_INVALID_PADDING:0 + +Check one and zeros padding #1 (correct) +check_padding:POLARSSL_PADDING_ONE_AND_ZEROS:"DABBAD0080":0:4 + +Check one and zeros padding #2 (correct) +check_padding:POLARSSL_PADDING_ONE_AND_ZEROS:"DABBAD008000":0:4 + +Check one and zeros padding #3 (correct) +check_padding:POLARSSL_PADDING_ONE_AND_ZEROS:"DABBAD00800000":0:4 + +Check one and zeros padding #4 (correct) +check_padding:POLARSSL_PADDING_ONE_AND_ZEROS:"DABBAD00808000":0:5 + +Check one and zeros padding #5 (correct) +check_padding:POLARSSL_PADDING_ONE_AND_ZEROS:"800000":0:0 + +Check one and zeros padding #6 (missing one) +check_padding:POLARSSL_PADDING_ONE_AND_ZEROS:"DABBAD0000":POLARSSL_ERR_CIPHER_INVALID_PADDING:4 + +Check one and zeros padding #7 (overlong) +check_padding:POLARSSL_PADDING_ONE_AND_ZEROS:"0000000000":POLARSSL_ERR_CIPHER_INVALID_PADDING:4