diff --git a/ChangeLog b/ChangeLog index 06987cc783..56b65b49ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ Changes * Added const correctness for main code base * X509 signature algorithm determination is now in a function to allow easy future expansion + * Changed symmetric cipher functions to + identical interface (returning int result values) Bug fixes * Fixed bug resulting in failure to send the last diff --git a/include/polarssl/aes.h b/include/polarssl/aes.h index 11abc90545..61ad457322 100644 --- a/include/polarssl/aes.h +++ b/include/polarssl/aes.h @@ -27,6 +27,7 @@ #define AES_DECRYPT 0 #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH -0x0800 +#define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH -0x0810 /** * \brief AES context structure @@ -72,8 +73,10 @@ int aes_setkey_dec( aes_context *ctx, const unsigned char *key, int keysize ); * \param mode AES_ENCRYPT or AES_DECRYPT * \param input 16-byte input block * \param output 16-byte output block + * + * \return 0 */ -void aes_crypt_ecb( aes_context *ctx, +int aes_crypt_ecb( aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ); @@ -89,8 +92,10 @@ void aes_crypt_ecb( aes_context *ctx, * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data + * + * \return 0 if successful, or POLARSSL_ERR_AES_INVALID_INPUT_LENGTH */ -void aes_crypt_cbc( aes_context *ctx, +int aes_crypt_cbc( aes_context *ctx, int mode, int length, unsigned char iv[16], @@ -107,8 +112,10 @@ void aes_crypt_cbc( aes_context *ctx, * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data + * + * \return 0 */ -void aes_crypt_cfb128( aes_context *ctx, +int aes_crypt_cfb128( aes_context *ctx, int mode, int length, int *iv_off, diff --git a/include/polarssl/arc4.h b/include/polarssl/arc4.h index 20f142a567..76e7e0a3c4 100644 --- a/include/polarssl/arc4.h +++ b/include/polarssl/arc4.h @@ -53,8 +53,10 @@ void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen ); * \param ctx ARC4 context * \param buf buffer to be processed * \param buflen amount of data in buf + * + * \return 0 */ -void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); +int arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); /* * \brief Checkup routine diff --git a/include/polarssl/camellia.h b/include/polarssl/camellia.h index d03495a9d6..e9ded1518c 100644 --- a/include/polarssl/camellia.h +++ b/include/polarssl/camellia.h @@ -32,6 +32,7 @@ typedef UINT32 uint32_t; #define CAMELLIA_DECRYPT 0 #define POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0a00 +#define POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0a10 /** * \brief CAMELLIA context structure @@ -76,8 +77,10 @@ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, int ke * \param mode CAMELLIA_ENCRYPT or CAMELLIA_DECRYPT * \param input 16-byte input block * \param output 16-byte output block + * + * \return 0 */ -void camellia_crypt_ecb( camellia_context *ctx, +int camellia_crypt_ecb( camellia_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ); @@ -93,8 +96,10 @@ void camellia_crypt_ecb( camellia_context *ctx, * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data + * + * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH */ -void camellia_crypt_cbc( camellia_context *ctx, +int camellia_crypt_cbc( camellia_context *ctx, int mode, int length, unsigned char iv[16], @@ -111,8 +116,10 @@ void camellia_crypt_cbc( camellia_context *ctx, * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data + * + * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH */ -void camellia_crypt_cfb128( camellia_context *ctx, +int camellia_crypt_cfb128( camellia_context *ctx, int mode, int length, int *iv_off, diff --git a/include/polarssl/des.h b/include/polarssl/des.h index 1a09ad191b..a655a15d2a 100644 --- a/include/polarssl/des.h +++ b/include/polarssl/des.h @@ -26,6 +26,8 @@ #define DES_ENCRYPT 1 #define DES_DECRYPT 0 +#define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH -0x0C00 + /** * \brief DES context structure */ @@ -104,8 +106,10 @@ void des3_set3key_dec( des3_context *ctx, const unsigned char key[24] ); * \param ctx DES context * \param input 64-bit input block * \param output 64-bit output block + * + * \return 0 */ -void des_crypt_ecb( des_context *ctx, +int des_crypt_ecb( des_context *ctx, const unsigned char input[8], unsigned char output[8] ); @@ -119,7 +123,7 @@ void des_crypt_ecb( des_context *ctx, * \param input buffer holding the input data * \param output buffer holding the output data */ -void des_crypt_cbc( des_context *ctx, +int des_crypt_cbc( des_context *ctx, int mode, int length, unsigned char iv[8], @@ -132,8 +136,10 @@ void des_crypt_cbc( des_context *ctx, * \param ctx 3DES context * \param input 64-bit input block * \param output 64-bit output block + * + * \return 0 */ -void des3_crypt_ecb( des3_context *ctx, +int des3_crypt_ecb( des3_context *ctx, const unsigned char input[8], unsigned char output[8] ); @@ -146,8 +152,10 @@ void des3_crypt_ecb( des3_context *ctx, * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data + * + * \return 0 if successful, or POLARSSL_ERR_DES_INVALID_INPUT_LENGTH */ -void des3_crypt_cbc( des3_context *ctx, +int des3_crypt_cbc( des3_context *ctx, int mode, int length, unsigned char iv[8], diff --git a/include/polarssl/padlock.h b/include/polarssl/padlock.h index cde76aee2b..cccc55d997 100644 --- a/include/polarssl/padlock.h +++ b/include/polarssl/padlock.h @@ -38,6 +38,8 @@ #define PADLOCK_ALIGN16(x) (unsigned long *) (16 + ((long) x & ~15)) +#define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED -0x08E0 + #ifdef __cplusplus extern "C" { #endif diff --git a/include/polarssl/xtea.h b/include/polarssl/xtea.h index 9d3dadd8ff..12a945592c 100644 --- a/include/polarssl/xtea.h +++ b/include/polarssl/xtea.h @@ -60,8 +60,10 @@ void xtea_setup( xtea_context *ctx, unsigned char key[16] ); * \param mode XTEA_ENCRYPT or XTEA_DECRYPT * \param input 8-byte input block * \param output 8-byte output block + * + * \return 0 */ -void xtea_crypt_ecb( xtea_context *ctx, +int xtea_crypt_ecb( xtea_context *ctx, int mode, unsigned char input[8], unsigned char output[8] ); diff --git a/library/aes.c b/library/aes.c index 373b2a05f2..bf7b337b6c 100644 --- a/library/aes.c +++ b/library/aes.c @@ -647,7 +647,7 @@ int aes_setkey_dec( aes_context *ctx, const unsigned char *key, int keysize ) /* * AES-ECB block encryption/decryption */ -void aes_crypt_ecb( aes_context *ctx, +int aes_crypt_ecb( aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ) @@ -659,7 +659,11 @@ void aes_crypt_ecb( aes_context *ctx, if( padlock_supports( PADLOCK_ACE ) ) { if( padlock_xcryptecb( ctx, mode, input, output ) == 0 ) - return; + return( 0 ); + + // If padlock data misaligned, we just fall back to + // unaccelerated mode + // } #endif @@ -743,12 +747,14 @@ void aes_crypt_ecb( aes_context *ctx, PUT_ULONG_LE( X1, output, 4 ); PUT_ULONG_LE( X2, output, 8 ); PUT_ULONG_LE( X3, output, 12 ); + + return( 0 ); } /* * AES-CBC buffer encryption/decryption */ -void aes_crypt_cbc( aes_context *ctx, +int aes_crypt_cbc( aes_context *ctx, int mode, int length, unsigned char iv[16], @@ -758,11 +764,18 @@ void aes_crypt_cbc( aes_context *ctx, int i; unsigned char temp[16]; + if( length % 16 ) + return( POLARSSL_ERR_AES_INVALID_INPUT_LENGTH ); + #if defined(POLARSSL_PADLOCK_C) && defined(POLARSSL_HAVE_X86) if( padlock_supports( PADLOCK_ACE ) ) { if( padlock_xcryptcbc( ctx, mode, length, iv, input, output ) == 0 ) - return; + return( 0 ); + + // If padlock data misaligned, we just fall back to + // unaccelerated mode + // } #endif @@ -798,12 +811,14 @@ void aes_crypt_cbc( aes_context *ctx, length -= 16; } } + + return( 0 ); } /* * AES-CFB128 buffer encryption/decryption */ -void aes_crypt_cfb128( aes_context *ctx, +int aes_crypt_cfb128( aes_context *ctx, int mode, int length, int *iv_off, @@ -841,6 +856,8 @@ void aes_crypt_cfb128( aes_context *ctx, } *iv_off = n; + + return( 0 ); } #if defined(POLARSSL_SELF_TEST) diff --git a/library/arc4.c b/library/arc4.c index fb4542f698..5e70311d77 100644 --- a/library/arc4.c +++ b/library/arc4.c @@ -63,7 +63,7 @@ void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen ) /* * ARC4 cipher function */ -void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ) +int arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ) { int i, x, y, a, b; unsigned char *m; @@ -86,6 +86,8 @@ void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ) ctx->x = x; ctx->y = y; + + return( 0 ); } #if defined(POLARSSL_SELF_TEST) diff --git a/library/camellia.c b/library/camellia.c index 7c499cd532..7656084673 100644 --- a/library/camellia.c +++ b/library/camellia.c @@ -458,7 +458,7 @@ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, int ke /* * Camellia-ECB block encryption/decryption */ -void camellia_crypt_ecb( camellia_context *ctx, +int camellia_crypt_ecb( camellia_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ) @@ -513,12 +513,14 @@ void camellia_crypt_ecb( camellia_context *ctx, PUT_ULONG_BE( X[3], output, 4 ); PUT_ULONG_BE( X[0], output, 8 ); PUT_ULONG_BE( X[1], output, 12 ); + + return( 0 ); } /* * Camellia-CBC buffer encryption/decryption */ -void camellia_crypt_cbc( camellia_context *ctx, +int camellia_crypt_cbc( camellia_context *ctx, int mode, int length, unsigned char iv[16], @@ -528,6 +530,9 @@ void camellia_crypt_cbc( camellia_context *ctx, int i; unsigned char temp[16]; + if( length % 16 ) + return( POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH ); + if( mode == CAMELLIA_DECRYPT ) { while( length > 0 ) @@ -560,12 +565,14 @@ void camellia_crypt_cbc( camellia_context *ctx, length -= 16; } } + + return( 0 ); } /* * Camellia-CFB128 buffer encryption/decryption */ -void camellia_crypt_cfb128( camellia_context *ctx, +int camellia_crypt_cfb128( camellia_context *ctx, int mode, int length, int *iv_off, @@ -603,6 +610,8 @@ void camellia_crypt_cfb128( camellia_context *ctx, } *iv_off = n; + + return( 0 ); } #if defined(POLARSSL_SELF_TEST) diff --git a/library/des.c b/library/des.c index 79ebd3836f..d2f7662b02 100644 --- a/library/des.c +++ b/library/des.c @@ -476,7 +476,7 @@ void des3_set3key_dec( des3_context *ctx, const unsigned char key[24] ) /* * DES-ECB block encryption/decryption */ -void des_crypt_ecb( des_context *ctx, +int des_crypt_ecb( des_context *ctx, const unsigned char input[8], unsigned char output[8] ) { @@ -500,12 +500,14 @@ void des_crypt_ecb( des_context *ctx, PUT_ULONG_BE( Y, output, 0 ); PUT_ULONG_BE( X, output, 4 ); + + return( 0 ); } /* * DES-CBC buffer encryption/decryption */ -void des_crypt_cbc( des_context *ctx, +int des_crypt_cbc( des_context *ctx, int mode, int length, unsigned char iv[8], @@ -515,6 +517,9 @@ void des_crypt_cbc( des_context *ctx, int i; unsigned char temp[8]; + if( length % 8 ) + return( POLARSSL_ERR_DES_INVALID_INPUT_LENGTH ); + if( mode == DES_ENCRYPT ) { while( length > 0 ) @@ -547,12 +552,14 @@ void des_crypt_cbc( des_context *ctx, length -= 8; } } + + return( 0 ); } /* * 3DES-ECB block encryption/decryption */ -void des3_crypt_ecb( des3_context *ctx, +int des3_crypt_ecb( des3_context *ctx, const unsigned char input[8], unsigned char output[8] ) { @@ -588,12 +595,14 @@ void des3_crypt_ecb( des3_context *ctx, PUT_ULONG_BE( Y, output, 0 ); PUT_ULONG_BE( X, output, 4 ); + + return( 0 ); } /* * 3DES-CBC buffer encryption/decryption */ -void des3_crypt_cbc( des3_context *ctx, +int des3_crypt_cbc( des3_context *ctx, int mode, int length, unsigned char iv[8], @@ -603,6 +612,9 @@ void des3_crypt_cbc( des3_context *ctx, int i; unsigned char temp[8]; + if( length % 8 ) + return( POLARSSL_ERR_DES_INVALID_INPUT_LENGTH ); + if( mode == DES_ENCRYPT ) { while( length > 0 ) @@ -635,6 +647,8 @@ void des3_crypt_cbc( des3_context *ctx, length -= 8; } } + + return( 0 ); } #if defined(POLARSSL_SELF_TEST) diff --git a/library/padlock.c b/library/padlock.c index 9d62d0a1d1..4c30ddd9d0 100644 --- a/library/padlock.c +++ b/library/padlock.c @@ -126,7 +126,7 @@ int padlock_xcryptcbc( aes_context *ctx, if( ( (long) input & 15 ) != 0 || ( (long) output & 15 ) != 0 ) - return( 1 ); + return( POLARSSL_ERR_PADLOCK_DATA_MISALIGNED ); rk = ctx->rk; iw = PADLOCK_ALIGN16( buf ); diff --git a/library/xtea.c b/library/xtea.c index 5e479d226b..f7df1442b4 100644 --- a/library/xtea.c +++ b/library/xtea.c @@ -68,7 +68,7 @@ void xtea_setup( xtea_context *ctx, unsigned char key[16] ) /* * XTEA encrypt function */ -void xtea_crypt_ecb( xtea_context *ctx, int mode, unsigned char input[8], +int xtea_crypt_ecb( xtea_context *ctx, int mode, unsigned char input[8], unsigned char output[8]) { uint32_t *k, v0, v1, i; @@ -103,6 +103,8 @@ void xtea_crypt_ecb( xtea_context *ctx, int mode, unsigned char input[8], PUT_ULONG_BE( v0, output, 0 ); PUT_ULONG_BE( v1, output, 4 ); + + return( 0 ); } #if defined(POLARSSL_SELF_TEST) diff --git a/tests/suites/test_suite_aes.data b/tests/suites/test_suite_aes.data index 3fc476a493..8a0de606a4 100644 --- a/tests/suites/test_suite_aes.data +++ b/tests/suites/test_suite_aes.data @@ -230,220 +230,220 @@ AES-256-ECB Decrypt NIST KAT #12 aes_decrypt_ecb:"0000000000000000000000000000000000000000000000000000000000000000":"9b80eefb7ebe2d2b16247aa0efc72f5d":"e0000000000000000000000000000000":0 AES-128-CBC Encrypt NIST KAT #1 -aes_encrypt_cbc:"fffffffffffff8000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"8b527a6aebdaec9eaef8eda2cb7783e5" +aes_encrypt_cbc:"fffffffffffff8000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"8b527a6aebdaec9eaef8eda2cb7783e5":0 AES-128-CBC Encrypt NIST KAT #2 -aes_encrypt_cbc:"fffffffffffffc000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"43fdaf53ebbc9880c228617d6a9b548b" +aes_encrypt_cbc:"fffffffffffffc000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"43fdaf53ebbc9880c228617d6a9b548b":0 AES-128-CBC Encrypt NIST KAT #3 -aes_encrypt_cbc:"fffffffffffffe000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"53786104b9744b98f052c46f1c850d0b" +aes_encrypt_cbc:"fffffffffffffe000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"53786104b9744b98f052c46f1c850d0b":0 AES-128-CBC Encrypt NIST KAT #4 -aes_encrypt_cbc:"e37b1c6aa2846f6fdb413f238b089f23":"00000000000000000000000000000000":"00000000000000000000000000000000":"43c9f7e62f5d288bb27aa40ef8fe1ea8" +aes_encrypt_cbc:"e37b1c6aa2846f6fdb413f238b089f23":"00000000000000000000000000000000":"00000000000000000000000000000000":"43c9f7e62f5d288bb27aa40ef8fe1ea8":0 AES-128-CBC Encrypt NIST KAT #5 -aes_encrypt_cbc:"6c002b682483e0cabcc731c253be5674":"00000000000000000000000000000000":"00000000000000000000000000000000":"3580d19cff44f1014a7c966a69059de5" +aes_encrypt_cbc:"6c002b682483e0cabcc731c253be5674":"00000000000000000000000000000000":"00000000000000000000000000000000":"3580d19cff44f1014a7c966a69059de5":0 AES-128-CBC Encrypt NIST KAT #6 -aes_encrypt_cbc:"143ae8ed6555aba96110ab58893a8ae1":"00000000000000000000000000000000":"00000000000000000000000000000000":"806da864dd29d48deafbe764f8202aef" +aes_encrypt_cbc:"143ae8ed6555aba96110ab58893a8ae1":"00000000000000000000000000000000":"00000000000000000000000000000000":"806da864dd29d48deafbe764f8202aef":0 AES-128-CBC Encrypt NIST KAT #7 -aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"6a118a874519e64e9963798a503f1d35":"dc43be40be0e53712f7e2bf5ca707209" +aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"6a118a874519e64e9963798a503f1d35":"dc43be40be0e53712f7e2bf5ca707209":0 AES-128-CBC Encrypt NIST KAT #8 -aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"cb9fceec81286ca3e989bd979b0cb284":"92beedab1895a94faa69b632e5cc47ce" +aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"cb9fceec81286ca3e989bd979b0cb284":"92beedab1895a94faa69b632e5cc47ce":0 AES-128-CBC Encrypt NIST KAT #9 -aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"b26aeb1874e47ca8358ff22378f09144":"459264f4798f6a78bacb89c15ed3d601" +aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"b26aeb1874e47ca8358ff22378f09144":"459264f4798f6a78bacb89c15ed3d601":0 AES-128-CBC Encrypt NIST KAT #10 -aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffffffffffc000000000":"90684a2ac55fe1ec2b8ebd5622520b73" +aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffffffffffc000000000":"90684a2ac55fe1ec2b8ebd5622520b73":0 AES-128-CBC Encrypt NIST KAT #11 -aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffffffffffe000000000":"7472f9a7988607ca79707795991035e6" +aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffffffffffe000000000":"7472f9a7988607ca79707795991035e6":0 AES-128-CBC Encrypt NIST KAT #12 -aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"fffffffffffffffffffffff000000000":"56aff089878bf3352f8df172a3ae47d8" +aes_encrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"fffffffffffffffffffffff000000000":"56aff089878bf3352f8df172a3ae47d8":0 AES-128-CBC Decrypt NIST KAT #1 -aes_decrypt_cbc:"ffffffffe00000000000000000000000":"00000000000000000000000000000000":"23f710842b9bb9c32f26648c786807ca":"00000000000000000000000000000000" +aes_decrypt_cbc:"ffffffffe00000000000000000000000":"00000000000000000000000000000000":"23f710842b9bb9c32f26648c786807ca":"00000000000000000000000000000000":0 AES-128-CBC Decrypt NIST KAT #2 -aes_decrypt_cbc:"fffffffff00000000000000000000000":"00000000000000000000000000000000":"44a98bf11e163f632c47ec6a49683a89":"00000000000000000000000000000000" +aes_decrypt_cbc:"fffffffff00000000000000000000000":"00000000000000000000000000000000":"44a98bf11e163f632c47ec6a49683a89":"00000000000000000000000000000000":0 AES-128-CBC Decrypt NIST KAT #3 -aes_decrypt_cbc:"fffffffff80000000000000000000000":"00000000000000000000000000000000":"0f18aff94274696d9b61848bd50ac5e5":"00000000000000000000000000000000" +aes_decrypt_cbc:"fffffffff80000000000000000000000":"00000000000000000000000000000000":"0f18aff94274696d9b61848bd50ac5e5":"00000000000000000000000000000000":0 AES-128-CBC Decrypt NIST KAT #4 -aes_decrypt_cbc:"e234cdca2606b81f29408d5f6da21206":"00000000000000000000000000000000":"fff60a4740086b3b9c56195b98d91a7b":"00000000000000000000000000000000" +aes_decrypt_cbc:"e234cdca2606b81f29408d5f6da21206":"00000000000000000000000000000000":"fff60a4740086b3b9c56195b98d91a7b":"00000000000000000000000000000000":0 AES-128-CBC Decrypt NIST KAT #5 -aes_decrypt_cbc:"13237c49074a3da078dc1d828bb78c6f":"00000000000000000000000000000000":"8146a08e2357f0caa30ca8c94d1a0544":"00000000000000000000000000000000" +aes_decrypt_cbc:"13237c49074a3da078dc1d828bb78c6f":"00000000000000000000000000000000":"8146a08e2357f0caa30ca8c94d1a0544":"00000000000000000000000000000000":0 AES-128-CBC Decrypt NIST KAT #6 -aes_decrypt_cbc:"3071a2a48fe6cbd04f1a129098e308f8":"00000000000000000000000000000000":"4b98e06d356deb07ebb824e5713f7be3":"00000000000000000000000000000000" +aes_decrypt_cbc:"3071a2a48fe6cbd04f1a129098e308f8":"00000000000000000000000000000000":"4b98e06d356deb07ebb824e5713f7be3":"00000000000000000000000000000000":0 AES-128-CBC Decrypt NIST KAT #7 -aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"0336763e966d92595a567cc9ce537f5e":"f34481ec3cc627bacd5dc3fb08f273e6" +aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"0336763e966d92595a567cc9ce537f5e":"f34481ec3cc627bacd5dc3fb08f273e6":0 AES-128-CBC Decrypt NIST KAT #8 -aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"a9a1631bf4996954ebc093957b234589":"9798c4640bad75c7c3227db910174e72" +aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"a9a1631bf4996954ebc093957b234589":"9798c4640bad75c7c3227db910174e72":0 AES-128-CBC Decrypt NIST KAT #9 -aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"ff4f8391a6a40ca5b25d23bedd44a597":"96ab5c2ff612d9dfaae8c31f30c42168" +aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"ff4f8391a6a40ca5b25d23bedd44a597":"96ab5c2ff612d9dfaae8c31f30c42168":0 AES-128-CBC Decrypt NIST KAT #10 -aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"f9b0fda0c4a898f5b9e6f661c4ce4d07":"fffffffffffffffffffffffffffffff0" +aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"f9b0fda0c4a898f5b9e6f661c4ce4d07":"fffffffffffffffffffffffffffffff0":0 AES-128-CBC Decrypt NIST KAT #11 -aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"8ade895913685c67c5269f8aae42983e":"fffffffffffffffffffffffffffffff8" +aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"8ade895913685c67c5269f8aae42983e":"fffffffffffffffffffffffffffffff8":0 AES-128-CBC Decrypt NIST KAT #12 -aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"39bde67d5c8ed8a8b1c37eb8fa9f5ac0":"fffffffffffffffffffffffffffffffc" +aes_decrypt_cbc:"00000000000000000000000000000000":"00000000000000000000000000000000":"39bde67d5c8ed8a8b1c37eb8fa9f5ac0":"fffffffffffffffffffffffffffffffc":0 AES-192-CBC Encrypt NIST KAT #1 -aes_encrypt_cbc:"fffffffffffffffffffffffffffffffffffffffffffffe00":"00000000000000000000000000000000":"00000000000000000000000000000000":"ddb505e6cc1384cbaec1df90b80beb20" +aes_encrypt_cbc:"fffffffffffffffffffffffffffffffffffffffffffffe00":"00000000000000000000000000000000":"00000000000000000000000000000000":"ddb505e6cc1384cbaec1df90b80beb20":0 AES-192-CBC Encrypt NIST KAT #2 -aes_encrypt_cbc:"ffffffffffffffffffffffffffffffffffffffffffffff00":"00000000000000000000000000000000":"00000000000000000000000000000000":"5674a3bed27bf4bd3622f9f5fe208306" +aes_encrypt_cbc:"ffffffffffffffffffffffffffffffffffffffffffffff00":"00000000000000000000000000000000":"00000000000000000000000000000000":"5674a3bed27bf4bd3622f9f5fe208306":0 AES-192-CBC Encrypt NIST KAT #3 -aes_encrypt_cbc:"ffffffffffffffffffffffffffffffffffffffffffffff80":"00000000000000000000000000000000":"00000000000000000000000000000000":"b687f26a89cfbfbb8e5eeac54055315e" +aes_encrypt_cbc:"ffffffffffffffffffffffffffffffffffffffffffffff80":"00000000000000000000000000000000":"00000000000000000000000000000000":"b687f26a89cfbfbb8e5eeac54055315e":0 AES-192-CBC Encrypt NIST KAT #4 -aes_encrypt_cbc:"25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce":"00000000000000000000000000000000":"00000000000000000000000000000000":"3608c344868e94555d23a120f8a5502d" +aes_encrypt_cbc:"25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce":"00000000000000000000000000000000":"00000000000000000000000000000000":"3608c344868e94555d23a120f8a5502d":0 AES-192-CBC Encrypt NIST KAT #5 -aes_encrypt_cbc:"e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53":"00000000000000000000000000000000":"00000000000000000000000000000000":"77da2021935b840b7f5dcc39132da9e5" +aes_encrypt_cbc:"e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53":"00000000000000000000000000000000":"00000000000000000000000000000000":"77da2021935b840b7f5dcc39132da9e5":0 AES-192-CBC Encrypt NIST KAT #6 -aes_encrypt_cbc:"3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980":"00000000000000000000000000000000":"00000000000000000000000000000000":"3b7c24f825e3bf9873c9f14d39a0e6f4" +aes_encrypt_cbc:"3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980":"00000000000000000000000000000000":"00000000000000000000000000000000":"3b7c24f825e3bf9873c9f14d39a0e6f4":0 AES-192-CBC Encrypt NIST KAT #7 -aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"51719783d3185a535bd75adc65071ce1":"4f354592ff7c8847d2d0870ca9481b7c" +aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"51719783d3185a535bd75adc65071ce1":"4f354592ff7c8847d2d0870ca9481b7c":0 AES-192-CBC Encrypt NIST KAT #8 -aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"26aa49dcfe7629a8901a69a9914e6dfd":"d5e08bf9a182e857cf40b3a36ee248cc" +aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"26aa49dcfe7629a8901a69a9914e6dfd":"d5e08bf9a182e857cf40b3a36ee248cc":0 AES-192-CBC Encrypt NIST KAT #9 -aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"941a4773058224e1ef66d10e0a6ee782":"067cd9d3749207791841562507fa9626" +aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"941a4773058224e1ef66d10e0a6ee782":"067cd9d3749207791841562507fa9626":0 AES-192-CBC Encrypt NIST KAT #10 -aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffc00000000000000000000000000000":"030d7e5b64f380a7e4ea5387b5cd7f49" +aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffc00000000000000000000000000000":"030d7e5b64f380a7e4ea5387b5cd7f49":0 AES-192-CBC Encrypt NIST KAT #11 -aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffe00000000000000000000000000000":"0dc9a2610037009b698f11bb7e86c83e" +aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffe00000000000000000000000000000":"0dc9a2610037009b698f11bb7e86c83e":0 AES-192-CBC Encrypt NIST KAT #12 -aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"fff00000000000000000000000000000":"0046612c766d1840c226364f1fa7ed72" +aes_encrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"fff00000000000000000000000000000":"0046612c766d1840c226364f1fa7ed72":0 AES-192-CBC Decrypt NIST KAT #1 -aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"902d88d13eae52089abd6143cfe394e9":"ffffffffe00000000000000000000000" +aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"902d88d13eae52089abd6143cfe394e9":"ffffffffe00000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #2 -aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"d49bceb3b823fedd602c305345734bd2":"fffffffff00000000000000000000000" +aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"d49bceb3b823fedd602c305345734bd2":"fffffffff00000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #3 -aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"707b1dbb0ffa40ef7d95def421233fae":"fffffffff80000000000000000000000" +aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"707b1dbb0ffa40ef7d95def421233fae":"fffffffff80000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #4 -aes_decrypt_cbc:"fffffffffffffffffffc0000000000000000000000000000":"00000000000000000000000000000000":"8dfd999be5d0cfa35732c0ddc88ff5a5":"00000000000000000000000000000000" +aes_decrypt_cbc:"fffffffffffffffffffc0000000000000000000000000000":"00000000000000000000000000000000":"8dfd999be5d0cfa35732c0ddc88ff5a5":"00000000000000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #5 -aes_decrypt_cbc:"fffffffffffffffffffe0000000000000000000000000000":"00000000000000000000000000000000":"02647c76a300c3173b841487eb2bae9f":"00000000000000000000000000000000" +aes_decrypt_cbc:"fffffffffffffffffffe0000000000000000000000000000":"00000000000000000000000000000000":"02647c76a300c3173b841487eb2bae9f":"00000000000000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #6 -aes_decrypt_cbc:"ffffffffffffffffffff0000000000000000000000000000":"00000000000000000000000000000000":"172df8b02f04b53adab028b4e01acd87":"00000000000000000000000000000000" +aes_decrypt_cbc:"ffffffffffffffffffff0000000000000000000000000000":"00000000000000000000000000000000":"172df8b02f04b53adab028b4e01acd87":"00000000000000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #7 -aes_decrypt_cbc:"b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35":"00000000000000000000000000000000":"3cf5e1d21a17956d1dffad6a7c41c659":"00000000000000000000000000000000" +aes_decrypt_cbc:"b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35":"00000000000000000000000000000000":"3cf5e1d21a17956d1dffad6a7c41c659":"00000000000000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #8 -aes_decrypt_cbc:"45899367c3132849763073c435a9288a766c8b9ec2308516":"00000000000000000000000000000000":"69fd12e8505f8ded2fdcb197a121b362":"00000000000000000000000000000000" +aes_decrypt_cbc:"45899367c3132849763073c435a9288a766c8b9ec2308516":"00000000000000000000000000000000":"69fd12e8505f8ded2fdcb197a121b362":"00000000000000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #9 -aes_decrypt_cbc:"ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e":"00000000000000000000000000000000":"8aa584e2cc4d17417a97cb9a28ba29c8":"00000000000000000000000000000000" +aes_decrypt_cbc:"ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e":"00000000000000000000000000000000":"8aa584e2cc4d17417a97cb9a28ba29c8":"00000000000000000000000000000000":0 AES-192-CBC Decrypt NIST KAT #10 -aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"c9b8135ff1b5adc413dfd053b21bd96d":"9c2d8842e5f48f57648205d39a239af1" +aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"c9b8135ff1b5adc413dfd053b21bd96d":"9c2d8842e5f48f57648205d39a239af1":0 AES-192-CBC Decrypt NIST KAT #11 -aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"4a3650c3371ce2eb35e389a171427440":"bff52510095f518ecca60af4205444bb" +aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"4a3650c3371ce2eb35e389a171427440":"bff52510095f518ecca60af4205444bb":0 AES-192-CBC Decrypt NIST KAT #12 -aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"4f354592ff7c8847d2d0870ca9481b7c":"51719783d3185a535bd75adc65071ce1" +aes_decrypt_cbc:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"4f354592ff7c8847d2d0870ca9481b7c":"51719783d3185a535bd75adc65071ce1":0 AES-256-CBC Encrypt NIST KAT #1 -aes_encrypt_cbc:"8000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"e35a6dcb19b201a01ebcfa8aa22b5759" +aes_encrypt_cbc:"8000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"e35a6dcb19b201a01ebcfa8aa22b5759":0 AES-256-CBC Encrypt NIST KAT #2 -aes_encrypt_cbc:"c000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"b29169cdcf2d83e838125a12ee6aa400" +aes_encrypt_cbc:"c000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"b29169cdcf2d83e838125a12ee6aa400":0 AES-256-CBC Encrypt NIST KAT #3 -aes_encrypt_cbc:"e000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"d8f3a72fc3cdf74dfaf6c3e6b97b2fa6" +aes_encrypt_cbc:"e000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"d8f3a72fc3cdf74dfaf6c3e6b97b2fa6":0 AES-256-CBC Encrypt NIST KAT #4 -aes_encrypt_cbc:"dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf":"00000000000000000000000000000000":"00000000000000000000000000000000":"fc6aec906323480005c58e7e1ab004ad" +aes_encrypt_cbc:"dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf":"00000000000000000000000000000000":"00000000000000000000000000000000":"fc6aec906323480005c58e7e1ab004ad":0 AES-256-CBC Encrypt NIST KAT #5 -aes_encrypt_cbc:"f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9":"00000000000000000000000000000000":"00000000000000000000000000000000":"a3944b95ca0b52043584ef02151926a8" +aes_encrypt_cbc:"f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9":"00000000000000000000000000000000":"00000000000000000000000000000000":"a3944b95ca0b52043584ef02151926a8":0 AES-256-CBC Encrypt NIST KAT #6 -aes_encrypt_cbc:"797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e":"00000000000000000000000000000000":"00000000000000000000000000000000":"a74289fe73a4c123ca189ea1e1b49ad5" +aes_encrypt_cbc:"797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e":"00000000000000000000000000000000":"00000000000000000000000000000000":"a74289fe73a4c123ca189ea1e1b49ad5":0 AES-256-CBC Encrypt NIST KAT #7 -aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"761c1fe41a18acf20d241650611d90f1":"623a52fcea5d443e48d9181ab32c7421" +aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"761c1fe41a18acf20d241650611d90f1":"623a52fcea5d443e48d9181ab32c7421":0 AES-256-CBC Encrypt NIST KAT #8 -aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"8a560769d605868ad80d819bdba03771":"38f2c7ae10612415d27ca190d27da8b4" +aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"8a560769d605868ad80d819bdba03771":"38f2c7ae10612415d27ca190d27da8b4":0 AES-256-CBC Encrypt NIST KAT #9 -aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"91fbef2d15a97816060bee1feaa49afe":"1bc704f1bce135ceb810341b216d7abe" +aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"91fbef2d15a97816060bee1feaa49afe":"1bc704f1bce135ceb810341b216d7abe":0 AES-256-CBC Encrypt NIST KAT #10 -aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffff800000000000000000":"0d9ac756eb297695eed4d382eb126d26" +aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffff800000000000000000":"0d9ac756eb297695eed4d382eb126d26":0 AES-256-CBC Encrypt NIST KAT #11 -aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffc00000000000000000":"56ede9dda3f6f141bff1757fa689c3e1" +aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffc00000000000000000":"56ede9dda3f6f141bff1757fa689c3e1":0 AES-256-CBC Encrypt NIST KAT #12 -aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffe00000000000000000":"768f520efe0f23e61d3ec8ad9ce91774" +aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffe00000000000000000":"768f520efe0f23e61d3ec8ad9ce91774":0 AES-256-CBC Decrypt NIST KAT #1 -aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"49af6b372135acef10132e548f217b17":"ff000000000000000000000000000000" +aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"49af6b372135acef10132e548f217b17":"ff000000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #2 -aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"8bcd40f94ebb63b9f7909676e667f1e7":"ff800000000000000000000000000000" +aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"8bcd40f94ebb63b9f7909676e667f1e7":"ff800000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #3 -aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"fe1cffb83f45dcfb38b29be438dbd3ab":"ffc00000000000000000000000000000" +aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"fe1cffb83f45dcfb38b29be438dbd3ab":"ffc00000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #4 -aes_decrypt_cbc:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00":"00000000000000000000000000000000":"cca7c3086f5f9511b31233da7cab9160":"00000000000000000000000000000000" +aes_decrypt_cbc:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00":"00000000000000000000000000000000":"cca7c3086f5f9511b31233da7cab9160":"00000000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #5 -aes_decrypt_cbc:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00":"00000000000000000000000000000000":"5b40ff4ec9be536ba23035fa4f06064c":"00000000000000000000000000000000" +aes_decrypt_cbc:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00":"00000000000000000000000000000000":"5b40ff4ec9be536ba23035fa4f06064c":"00000000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #6 -aes_decrypt_cbc:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00":"00000000000000000000000000000000":"60eb5af8416b257149372194e8b88749":"00000000000000000000000000000000" +aes_decrypt_cbc:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00":"00000000000000000000000000000000":"60eb5af8416b257149372194e8b88749":"00000000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #7 -aes_decrypt_cbc:"90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1":"00000000000000000000000000000000":"798c7c005dee432b2c8ea5dfa381ecc3":"00000000000000000000000000000000" +aes_decrypt_cbc:"90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1":"00000000000000000000000000000000":"798c7c005dee432b2c8ea5dfa381ecc3":"00000000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #8 -aes_decrypt_cbc:"b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07":"00000000000000000000000000000000":"637c31dc2591a07636f646b72daabbe7":"00000000000000000000000000000000" +aes_decrypt_cbc:"b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07":"00000000000000000000000000000000":"637c31dc2591a07636f646b72daabbe7":"00000000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #9 -aes_decrypt_cbc:"fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e":"00000000000000000000000000000000":"179a49c712154bbffbe6e7a84a18e220":"00000000000000000000000000000000" +aes_decrypt_cbc:"fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e":"00000000000000000000000000000000":"179a49c712154bbffbe6e7a84a18e220":"00000000000000000000000000000000":0 AES-256-CBC Decrypt NIST KAT #10 -aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"5c9d844ed46f9885085e5d6a4f94c7d7":"014730f80ac625fe84f026c60bfd547d" +aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"5c9d844ed46f9885085e5d6a4f94c7d7":"014730f80ac625fe84f026c60bfd547d":0 AES-256-CBC Decrypt NIST KAT #11 -aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"a9ff75bd7cf6613d3731c77c3b6d0c04":"0b24af36193ce4665f2825d7b4749c98" +aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"a9ff75bd7cf6613d3731c77c3b6d0c04":"0b24af36193ce4665f2825d7b4749c98":0 AES-256-CBC Decrypt NIST KAT #12 -aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"623a52fcea5d443e48d9181ab32c7421":"761c1fe41a18acf20d241650611d90f1" +aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"623a52fcea5d443e48d9181ab32c7421":"761c1fe41a18acf20d241650611d90f1":0 AES-128-CFB128 Encrypt NIST KAT #1 aes_encrypt_cfb128:"f0000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"970014d634e2b7650777e8e84d03ccd8" @@ -667,5 +667,11 @@ aes_encrypt_ecb:"000000000000000000000000000000":"f34481ec3cc627bacd5dc3fb08f273 AES-ECB Decrypt (Invalid keylength) aes_decrypt_ecb:"000000000000000000000000000000":"f34481ec3cc627bacd5dc3fb08f273e6":"0336763e966d92595a567cc9ce537f5e":POLARSSL_ERR_AES_INVALID_KEY_LENGTH +AES-256-CBC Encrypt (Invalid input length) +aes_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffe000000000000000":"":POLARSSL_ERR_AES_INVALID_INPUT_LENGTH + +AES-256-CBC Decrypt (Invalid input length) +aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"623a52fcea5d443e48d9181ab32c74":"":POLARSSL_ERR_AES_INVALID_INPUT_LENGTH + AES Selftest aes_selftest: diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function index 15bb9badd7..1b7049a100 100644 --- a/tests/suites/test_suite_aes.function +++ b/tests/suites/test_suite_aes.function @@ -23,7 +23,7 @@ aes_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string:setkey_result TEST_ASSERT( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == {setkey_result} ); if( {setkey_result} == 0 ) { - aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ); + TEST_ASSERT( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); hexify( dst_str, output, 16 ); TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -52,7 +52,7 @@ aes_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string:setkey_result TEST_ASSERT( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == {setkey_result} ); if( {setkey_result} == 0 ) { - aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ); + TEST_ASSERT( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); hexify( dst_str, output, 16 ); TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -61,7 +61,7 @@ aes_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string:setkey_result END_CASE BEGIN_CASE -aes_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string +aes_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result { unsigned char key_str[100]; unsigned char iv_str[100]; @@ -69,7 +69,7 @@ aes_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string unsigned char dst_str[100]; unsigned char output[100]; aes_context ctx; - int key_len; + int key_len, data_len; memset(key_str, 0x00, 100); memset(iv_str, 0x00, 100); @@ -79,18 +79,21 @@ aes_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string key_len = unhexify( key_str, {hex_key_string} ); unhexify( iv_str, {hex_iv_string} ); - unhexify( src_str, {hex_src_string} ); + data_len = unhexify( src_str, {hex_src_string} ); aes_setkey_enc( &ctx, key_str, key_len * 8 ); - aes_crypt_cbc( &ctx, AES_ENCRYPT, 16, iv_str, src_str, output ); - hexify( dst_str, output, 16 ); + TEST_ASSERT( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == {cbc_result} ); + if( {cbc_result} == 0 ) + { + hexify( dst_str, output, data_len ); - TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + } } END_CASE BEGIN_CASE -aes_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string +aes_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result { unsigned char key_str[100]; unsigned char iv_str[100]; @@ -98,7 +101,7 @@ aes_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string unsigned char dst_str[100]; unsigned char output[100]; aes_context ctx; - int key_len; + int key_len, data_len; memset(key_str, 0x00, 100); memset(iv_str, 0x00, 100); @@ -108,13 +111,16 @@ aes_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string key_len = unhexify( key_str, {hex_key_string} ); unhexify( iv_str, {hex_iv_string} ); - unhexify( src_str, {hex_src_string} ); + data_len = unhexify( src_str, {hex_src_string} ); aes_setkey_dec( &ctx, key_str, key_len * 8 ); - aes_crypt_cbc( &ctx, AES_DECRYPT, 16, iv_str, src_str, output ); - hexify( dst_str, output, 16 ); + TEST_ASSERT( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == {cbc_result} ); + if( {cbc_result} == 0) + { + hexify( dst_str, output, data_len ); - TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + } } END_CASE @@ -141,7 +147,7 @@ aes_encrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string unhexify( src_str, {hex_src_string} ); aes_setkey_enc( &ctx, key_str, key_len * 8 ); - aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ); + TEST_ASSERT( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); hexify( dst_str, output, 16 ); TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -171,7 +177,7 @@ aes_decrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string unhexify( src_str, {hex_src_string} ); aes_setkey_enc( &ctx, key_str, key_len * 8 ); - aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ); + TEST_ASSERT( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); hexify( dst_str, output, 16 ); TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); diff --git a/tests/suites/test_suite_arc4.function b/tests/suites/test_suite_arc4.function index 6c71cb2320..a7a5333403 100644 --- a/tests/suites/test_suite_arc4.function +++ b/tests/suites/test_suite_arc4.function @@ -19,7 +19,7 @@ arc4_crypt:hex_src_string:hex_key_string:hex_dst_string key_len = unhexify( key_str, {hex_key_string} ); arc4_setup(&ctx, key_str, key_len); - arc4_crypt(&ctx, src_str, src_len); + TEST_ASSERT( arc4_crypt(&ctx, src_str, src_len) == 0 ); hexify( dst_str, src_str, src_len ); TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); diff --git a/tests/suites/test_suite_camellia.data b/tests/suites/test_suite_camellia.data index 3f870b8daa..d1c446b9a3 100644 --- a/tests/suites/test_suite_camellia.data +++ b/tests/suites/test_suite_camellia.data @@ -53,40 +53,40 @@ Camellia-256-ECB Encrypt Perl EVP #4 camellia_encrypt_ecb:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"F69F2445DF4F9B17AD2B417BE66C3710":"7960109FB6DC42947FCFE59EA3C5EB6B":0 Camellia-128-CBC Encrypt Perl EVP #1 -camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"1607CF494B36BBF00DAEB0B503C831AB" +camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"1607CF494B36BBF00DAEB0B503C831AB":0 Camellia-128-CBC Encrypt Perl EVP #2 -camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"1607CF494B36BBF00DAEB0B503C831AB":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"A2F2CF671629EF7840C5A5DFB5074887" +camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"1607CF494B36BBF00DAEB0B503C831AB":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"A2F2CF671629EF7840C5A5DFB5074887":0 Camellia-128-CBC Encrypt Perl EVP #3 -camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"A2F2CF671629EF7840C5A5DFB5074887":"30C81C46A35CE411E5FBC1191A0A52EF":"0F06165008CF8B8B5A63586362543E54" +camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"A2F2CF671629EF7840C5A5DFB5074887":"30C81C46A35CE411E5FBC1191A0A52EF":"0F06165008CF8B8B5A63586362543E54":0 Camellia-128-CBC Encrypt Perl EVP #4 -camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"36A84CDAFD5F9A85ADA0F0A993D6D577":"F69F2445DF4F9B17AD2B417BE66C3710":"74C64268CDB8B8FAF5B34E8AF3732980" +camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"36A84CDAFD5F9A85ADA0F0A993D6D577":"F69F2445DF4F9B17AD2B417BE66C3710":"74C64268CDB8B8FAF5B34E8AF3732980":0 Camellia-192-CBC Encrypt Perl EVP #1 -camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"2A4830AB5AC4A1A2405955FD2195CF93" +camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"2A4830AB5AC4A1A2405955FD2195CF93":0 Camellia-192-CBC Encrypt Perl EVP #2 -camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"2A4830AB5AC4A1A2405955FD2195CF93":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"5D5A869BD14CE54264F892A6DD2EC3D5" +camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"2A4830AB5AC4A1A2405955FD2195CF93":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"5D5A869BD14CE54264F892A6DD2EC3D5":0 Camellia-192-CBC Encrypt Perl EVP #3 -camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"5D5A869BD14CE54264F892A6DD2EC3D5":"30C81C46A35CE411E5FBC1191A0A52EF":"37D359C3349836D884E310ADDF68C449" +camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"5D5A869BD14CE54264F892A6DD2EC3D5":"30C81C46A35CE411E5FBC1191A0A52EF":"37D359C3349836D884E310ADDF68C449":0 Camellia-192-CBC Encrypt Perl EVP #4 -camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"37D359C3349836D884E310ADDF68C449":"F69F2445DF4F9B17AD2B417BE66C3710":"01FAAA930B4AB9916E9668E1428C6B08" +camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"37D359C3349836D884E310ADDF68C449":"F69F2445DF4F9B17AD2B417BE66C3710":"01FAAA930B4AB9916E9668E1428C6B08":0 Camellia-256-CBC Encrypt Perl EVP #1 -camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"E6CFA35FC02B134A4D2C0B6737AC3EDA" +camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"E6CFA35FC02B134A4D2C0B6737AC3EDA":0 Camellia-256-CBC Encrypt Perl EVP #2 -camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"E6CFA35FC02B134A4D2C0B6737AC3EDA":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"36CBEB73BD504B4070B1B7DE2B21EB50" +camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"E6CFA35FC02B134A4D2C0B6737AC3EDA":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"36CBEB73BD504B4070B1B7DE2B21EB50":0 Camellia-256-CBC Encrypt Perl EVP #3 -camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"36CBEB73BD504B4070B1B7DE2B21EB50":"30C81C46A35CE411E5FBC1191A0A52EF":"E31A6055297D96CA3330CDF1B1860A83" +camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"36CBEB73BD504B4070B1B7DE2B21EB50":"30C81C46A35CE411E5FBC1191A0A52EF":"E31A6055297D96CA3330CDF1B1860A83":0 Camellia-256-CBC Encrypt Perl EVP #4 -camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"E31A6055297D96CA3330CDF1B1860A83":"F69F2445DF4F9B17AD2B417BE66C3710":"5D563F6D1CCCF236051C0C5C1C58F28F" +camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"E31A6055297D96CA3330CDF1B1860A83":"F69F2445DF4F9B17AD2B417BE66C3710":"5D563F6D1CCCF236051C0C5C1C58F28F":0 Camellia-128-CFB128 Encrypt Perl EVP #1 camellia_encrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"14F7646187817EB586599146B82BD719" @@ -166,5 +166,11 @@ camellia_encrypt_ecb:"0123456789abcdeffedcba98765432":"0123456789abcdeffedcba987 Camellia-ECB Decrypt (Invalid key length) camellia_decrypt_ecb:"0123456789abcdeffedcba98765432":"0123456789abcdeffedcba9876543210":"67673138549669730857065648eabe43":POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH +Camellia-256-CBC Encrypt (Invalid input length) +camellia_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffe000000000000000":"":POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH + +Camellia-256-CBC Decrypt (Invalid input length) +camellia_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"623a52fcea5d443e48d9181ab32c74":"":POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH + Camellia Selftest camellia_selftest: diff --git a/tests/suites/test_suite_camellia.function b/tests/suites/test_suite_camellia.function index 408fb6c8bd..fb45453c2f 100644 --- a/tests/suites/test_suite_camellia.function +++ b/tests/suites/test_suite_camellia.function @@ -23,7 +23,7 @@ camellia_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string:setkey_result TEST_ASSERT( camellia_setkey_enc( &ctx, key_str, key_len * 8 ) == {setkey_result} ); if( {setkey_result} == 0 ) { - camellia_crypt_ecb( &ctx, CAMELLIA_ENCRYPT, src_str, output ); + TEST_ASSERT( camellia_crypt_ecb( &ctx, CAMELLIA_ENCRYPT, src_str, output ) == 0 ); hexify( dst_str, output, 16 ); TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -52,7 +52,7 @@ camellia_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string:setkey_result TEST_ASSERT( camellia_setkey_dec( &ctx, key_str, key_len * 8 ) == {setkey_result} ); if( {setkey_result} == 0 ) { - camellia_crypt_ecb( &ctx, CAMELLIA_DECRYPT, src_str, output ); + TEST_ASSERT( camellia_crypt_ecb( &ctx, CAMELLIA_DECRYPT, src_str, output ) == 0 ); hexify( dst_str, output, 16 ); TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -61,7 +61,7 @@ camellia_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string:setkey_result END_CASE BEGIN_CASE -camellia_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string +camellia_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result { unsigned char key_str[100]; unsigned char iv_str[100]; @@ -69,7 +69,7 @@ camellia_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string unsigned char dst_str[100]; unsigned char output[100]; camellia_context ctx; - int key_len; + int key_len, data_len; memset(key_str, 0x00, 100); memset(iv_str, 0x00, 100); @@ -79,18 +79,21 @@ camellia_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string key_len = unhexify( key_str, {hex_key_string} ); unhexify( iv_str, {hex_iv_string} ); - unhexify( src_str, {hex_src_string} ); + data_len = unhexify( src_str, {hex_src_string} ); camellia_setkey_enc( &ctx, key_str, key_len * 8 ); - camellia_crypt_cbc( &ctx, CAMELLIA_ENCRYPT, 16, iv_str, src_str, output ); - hexify( dst_str, output, 16 ); + TEST_ASSERT( camellia_crypt_cbc( &ctx, CAMELLIA_ENCRYPT, data_len, iv_str, src_str, output) == {cbc_result} ); + if( {cbc_result} == 0 ) + { + hexify( dst_str, output, data_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + } } END_CASE BEGIN_CASE -camellia_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string +camellia_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result { unsigned char key_str[100]; unsigned char iv_str[100]; @@ -98,7 +101,7 @@ camellia_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string unsigned char dst_str[100]; unsigned char output[100]; camellia_context ctx; - int key_len; + int key_len, data_len; memset(key_str, 0x00, 100); memset(iv_str, 0x00, 100); @@ -108,13 +111,16 @@ camellia_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string key_len = unhexify( key_str, {hex_key_string} ); unhexify( iv_str, {hex_iv_string} ); - unhexify( src_str, {hex_src_string} ); + data_len = unhexify( src_str, {hex_src_string} ); camellia_setkey_dec( &ctx, key_str, key_len * 8 ); - camellia_crypt_cbc( &ctx, CAMELLIA_DECRYPT, 16, iv_str, src_str, output ); - hexify( dst_str, output, 16 ); + TEST_ASSERT( camellia_crypt_cbc( &ctx, CAMELLIA_DECRYPT, data_len, iv_str, src_str, output ) == {cbc_result} ); + if( {cbc_result} == 0 ) + { + hexify( dst_str, output, data_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + } } END_CASE @@ -141,7 +147,7 @@ camellia_encrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_stri unhexify( src_str, {hex_src_string} ); camellia_setkey_enc( &ctx, key_str, key_len * 8 ); - camellia_crypt_cfb128( &ctx, CAMELLIA_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ); + TEST_ASSERT( camellia_crypt_cfb128( &ctx, CAMELLIA_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); hexify( dst_str, output, 16 ); TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -171,7 +177,7 @@ camellia_decrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_stri unhexify( src_str, {hex_src_string} ); camellia_setkey_enc( &ctx, key_str, key_len * 8 ); - camellia_crypt_cfb128( &ctx, CAMELLIA_DECRYPT, 16, &iv_offset, iv_str, src_str, output ); + TEST_ASSERT( camellia_crypt_cfb128( &ctx, CAMELLIA_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); hexify( dst_str, output, 16 ); TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); diff --git a/tests/suites/test_suite_des.data b/tests/suites/test_suite_des.data index 85315ea230..a317bae49f 100644 --- a/tests/suites/test_suite_des.data +++ b/tests/suites/test_suite_des.data @@ -203,10 +203,10 @@ DES Decrypt OpenSSL Test Vector #34 des_decrypt_ecb:"FEDCBA9876543210":"2A2BB008DF97C2F2":"FFFFFFFFFFFFFFFF" DES-CBC Encrypt OpenSSL Test Vector #1 -des_encrypt_cbc:"0123456789abcdef":"fedcba9876543210":"37363534333231204E6F77206973207468652074696D6520":"ccd173ffab2039f4acd8aefddfd8a1eb468e91157888ba68" +des_encrypt_cbc:"0123456789abcdef":"fedcba9876543210":"37363534333231204E6F77206973207468652074696D6520":"ccd173ffab2039f4acd8aefddfd8a1eb468e91157888ba68":0 DES-CBC Decrypt OpenSSL Test Vector #1 -des_decrypt_cbc:"0123456789abcdef":"fedcba9876543210":"ccd173ffab2039f4acd8aefddfd8a1eb468e91157888ba68":"37363534333231204E6F77206973207468652074696D6520" +des_decrypt_cbc:"0123456789abcdef":"fedcba9876543210":"ccd173ffab2039f4acd8aefddfd8a1eb468e91157888ba68":"37363534333231204E6F77206973207468652074696D6520":0 3DES-ECB 2Key Encrypt OpenSSL Test Vector #1 des3_encrypt_ecb:2:"0000000000000000FFFFFFFFFFFFFFFF":"0000000000000000":"9295B59BB384736E" @@ -221,10 +221,16 @@ des3_decrypt_ecb:2:"0000000000000000FFFFFFFFFFFFFFFF":"9295B59BB384736E":"000000 des3_decrypt_ecb:2:"FFFFFFFFFFFFFFFF3000000000000000":"199E9D6DF39AA816":"FFFFFFFFFFFFFFFF" 3DES-CBC 3Key Encrypt OpenSSL Test Vector #1 -des3_encrypt_cbc:3:"0123456789abcdeff1e0d3c2b5a49786fedcba9876543210":"fedcba9876543210":"37363534333231204E6F77206973207468652074696D6520":"3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D4" +des3_encrypt_cbc:3:"0123456789abcdeff1e0d3c2b5a49786fedcba9876543210":"fedcba9876543210":"37363534333231204E6F77206973207468652074696D6520":"3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D4":0 3DES-CBC 3Key Decrypt OpenSSL Test Vector #1 -des3_decrypt_cbc:3:"0123456789abcdeff1e0d3c2b5a49786fedcba9876543210":"fedcba9876543210":"3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D4":"37363534333231204E6F77206973207468652074696D6520" +des3_decrypt_cbc:3:"0123456789abcdeff1e0d3c2b5a49786fedcba9876543210":"fedcba9876543210":"3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D4":"37363534333231204E6F77206973207468652074696D6520":0 + +DES-CBC Encrypt (Invalid input length) +des_encrypt_cbc:"0123456789abcdef":"fedcba9876543210":"37363534333231204E6F77206973207468652074696D65":"":POLARSSL_ERR_DES_INVALID_INPUT_LENGTH + +3DES-CBC 3Key Encrypt (Invalid input length) +des3_encrypt_cbc:3:"0123456789abcdeff1e0d3c2b5a49786fedcba9876543210":"fedcba9876543210":"37363534333231204E6F77206973207468652074696D65":"":POLARSSL_ERR_DES_INVALID_INPUT_LENGTH DES Selftest des_selftest: diff --git a/tests/suites/test_suite_des.function b/tests/suites/test_suite_des.function index 839fa97ea5..59458b86e8 100644 --- a/tests/suites/test_suite_des.function +++ b/tests/suites/test_suite_des.function @@ -20,7 +20,7 @@ des_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string unhexify( src_str, {hex_src_string} ); des_setkey_enc( &ctx, key_str ); - des_crypt_ecb( &ctx, src_str, output ); + TEST_ASSERT( des_crypt_ecb( &ctx, src_str, output ) == 0 ); hexify( dst_str, output, 8 ); TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -45,7 +45,7 @@ des_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string unhexify( src_str, {hex_src_string} ); des_setkey_dec( &ctx, key_str ); - des_crypt_ecb( &ctx, src_str, output ); + TEST_ASSERT( des_crypt_ecb( &ctx, src_str, output ) == 0 ); hexify( dst_str, output, 8 ); TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -53,7 +53,7 @@ des_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string END_CASE BEGIN_CASE -des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string +des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result { unsigned char key_str[100]; unsigned char iv_str[100]; @@ -74,15 +74,18 @@ des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string src_len = unhexify( src_str, {hex_src_string} ); des_setkey_enc( &ctx, key_str ); - des_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output ); - hexify( dst_str, output, src_len ); + TEST_ASSERT( des_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output ) == {cbc_result} ); + if( {cbc_result} == 0 ) + { + hexify( dst_str, output, src_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + } } END_CASE BEGIN_CASE -des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string +des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result { unsigned char key_str[100]; unsigned char iv_str[100]; @@ -103,10 +106,13 @@ des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string src_len = unhexify( src_str, {hex_src_string} ); des_setkey_dec( &ctx, key_str ); - des_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output ); - hexify( dst_str, output, src_len ); + TEST_ASSERT( des_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output ) == {cbc_result} ); + if( {cbc_result} == 0 ) + { + hexify( dst_str, output, src_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + } } END_CASE @@ -134,7 +140,7 @@ des3_encrypt_ecb:key_count:hex_key_string:hex_src_string:hex_dst_string else TEST_ASSERT( 0 ); - des3_crypt_ecb( &ctx, src_str, output ); + TEST_ASSERT( des3_crypt_ecb( &ctx, src_str, output ) == 0 ); hexify( dst_str, output, 8 ); TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -165,7 +171,7 @@ des3_decrypt_ecb:key_count:hex_key_string:hex_src_string:hex_dst_string else TEST_ASSERT( 0 ); - des3_crypt_ecb( &ctx, src_str, output ); + TEST_ASSERT( des3_crypt_ecb( &ctx, src_str, output ) == 0 ); hexify( dst_str, output, 8 ); TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -173,7 +179,7 @@ des3_decrypt_ecb:key_count:hex_key_string:hex_src_string:hex_dst_string END_CASE BEGIN_CASE -des3_encrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string +des3_encrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result { unsigned char key_str[100]; unsigned char iv_str[100]; @@ -200,15 +206,18 @@ des3_encrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_s else TEST_ASSERT( 0 ); - des3_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output ); - hexify( dst_str, output, src_len ); + TEST_ASSERT( des3_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output ) == {cbc_result} ); + if( {cbc_result} == 0 ) + { + hexify( dst_str, output, src_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + } } END_CASE BEGIN_CASE -des3_decrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string +des3_decrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result { unsigned char key_str[100]; unsigned char iv_str[100]; @@ -235,10 +244,13 @@ des3_decrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_s else TEST_ASSERT( 0 ); - des3_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output ); - hexify( dst_str, output, src_len ); + TEST_ASSERT( des3_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output ) == {cbc_result} ) + if( {cbc_result} == 0 ) + { + hexify( dst_str, output, src_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 ); + } } END_CASE diff --git a/tests/suites/test_suite_xtea.function b/tests/suites/test_suite_xtea.function index e75d0a707f..8b133bda82 100644 --- a/tests/suites/test_suite_xtea.function +++ b/tests/suites/test_suite_xtea.function @@ -20,7 +20,7 @@ xtea_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string unhexify( src_str, {hex_src_string} ); xtea_setup( &ctx, key_str ); - xtea_crypt_ecb( &ctx, XTEA_ENCRYPT, src_str, output ); + TEST_ASSERT( xtea_crypt_ecb( &ctx, XTEA_ENCRYPT, src_str, output ) == 0 ); hexify( dst_str, output, 8 ); TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); @@ -45,7 +45,7 @@ xtea_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string unhexify( src_str, {hex_src_string} ); xtea_setup( &ctx, key_str ); - xtea_crypt_ecb( &ctx, XTEA_DECRYPT, src_str, output ); + TEST_ASSERT( xtea_crypt_ecb( &ctx, XTEA_DECRYPT, src_str, output ) == 0 ); hexify( dst_str, output, 8 ); TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );