mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-27 04:04:24 +01:00
Merge remote-tracking branch 'public/pr/1763' into mbedtls-2.7-proposed
This commit is contained in:
commit
e2a6f01f3f
@ -16,6 +16,8 @@ Bugfix
|
||||
Fixes #2069.
|
||||
* Fix memory leak and freeing without initialization in the example
|
||||
program programs/x509/cert_write. Fixes #1422.
|
||||
* Ignore iv in mbedtls_cipher_set_iv() when the cipher mode is MBEDTLS_MODE_ECB
|
||||
Fix for #1091 raised by ezdevelop
|
||||
|
||||
Changes
|
||||
* Add tests for session resumption in DTLS.
|
||||
|
@ -211,9 +211,13 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx,
|
||||
const unsigned char *iv, size_t iv_len )
|
||||
{
|
||||
size_t actual_iv_size;
|
||||
|
||||
if( NULL == ctx || NULL == ctx->cipher_info || NULL == iv )
|
||||
if( NULL == ctx || NULL == ctx->cipher_info )
|
||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||
else if( NULL == iv && iv_len != 0 )
|
||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||
|
||||
if( NULL == iv && iv_len == 0 )
|
||||
ctx->iv_size = 0;
|
||||
|
||||
/* avoid buffer overflow in ctx->iv */
|
||||
if( iv_len > MBEDTLS_MAX_IV_LENGTH )
|
||||
@ -229,9 +233,11 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx,
|
||||
if( actual_iv_size > iv_len )
|
||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||
}
|
||||
|
||||
memcpy( ctx->iv, iv, actual_iv_size );
|
||||
ctx->iv_size = actual_iv_size;
|
||||
if ( actual_iv_size != 0 )
|
||||
{
|
||||
memcpy( ctx->iv, iv, actual_iv_size );
|
||||
ctx->iv_size = actual_iv_size;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ static const mbedtls_cipher_info_t aes_128_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
128,
|
||||
"AES-128-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aes_info
|
||||
@ -215,7 +215,7 @@ static const mbedtls_cipher_info_t aes_192_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
192,
|
||||
"AES-192-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aes_info
|
||||
@ -226,7 +226,7 @@ static const mbedtls_cipher_info_t aes_256_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
256,
|
||||
"AES-256-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aes_info
|
||||
|
@ -1122,6 +1122,190 @@ AES-256-ECB Decrypt NIST KAT #12
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_ecb:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"9b80eefb7ebe2d2b16247aa0efc72f5d":"e0000000000000000000000000000000":0
|
||||
|
||||
AES-128-ECB crypt Encrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"":"f34481ec3cc627bacd5dc3fb08f273e6":"0336763e966d92595a567cc9ce537f5e":0
|
||||
|
||||
AES-128-ECB crypt Encrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"f0000000000000000000000000000000":"":"00000000000000000000000000000000":"970014d634e2b7650777e8e84d03ccd8":0
|
||||
|
||||
AES-128-ECB crypt Encrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"":"ffffffffffffffc00000000000000000":"3a4d354f02bb5a5e47d39666867f246a":0
|
||||
|
||||
AES-128-ECB crypt Decrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"":"db4f1aa530967d6732ce4715eb0ee24b":"ff000000000000000000000000000000":0
|
||||
|
||||
AES-128-ECB crypt Decrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"b69418a85332240dc82492353956ae0c":"":"a303d940ded8f0baff6f75414cac5243":"00000000000000000000000000000000":0
|
||||
|
||||
AES-128-ECB crypt Decrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"ffffffffffffffff8000000000000000":"":"32cd652842926aea4aa6137bb2be2b5e":"00000000000000000000000000000000":0
|
||||
|
||||
AES-192-ECB crypt Encrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"":"fffffffffffffffffffff80000000000":"156f07767a85a4312321f63968338a01":0
|
||||
|
||||
AES-192-ECB crypt Encrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"":"51719783d3185a535bd75adc65071ce1":"4f354592ff7c8847d2d0870ca9481b7c":0
|
||||
|
||||
AES-192-ECB crypt Encrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3":"":"00000000000000000000000000000000":"dd619e1cf204446112e0af2b9afa8f8c":0
|
||||
|
||||
AES-192-ECB crypt Encrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"fffffffffffffffffffffffffff800000000000000000000":"":"00000000000000000000000000000000":"8dd274bd0f1b58ae345d9e7233f9b8f3":0
|
||||
|
||||
AES-192-ECB crypt Decrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"fffffffffffffffffffffffffffffffff000000000000000":"":"bb2852c891c5947d2ed44032c421b85f":"00000000000000000000000000000000":0
|
||||
|
||||
AES-192-ECB crypt Decrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79":"":"cfe4d74002696ccf7d87b14a2f9cafc9":"00000000000000000000000000000000":0
|
||||
|
||||
AES-192-ECB crypt Decrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"":"275cfc0413d8ccb70513c3859b1d0f72":"1b077a6af4b7f98229de786d7516b639":0
|
||||
|
||||
AES-192-ECB crypt Decrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"":"b2099795e88cc158fd75ea133d7e7fbe":"ffffffffffffffffffffc00000000000":0
|
||||
|
||||
AES-256-ECB crypt Encrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c":"":"00000000000000000000000000000000":"352065272169abf9856843927d0674fd":0
|
||||
|
||||
AES-256-ECB crypt Encrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"0b24af36193ce4665f2825d7b4749c98":"a9ff75bd7cf6613d3731c77c3b6d0c04":0
|
||||
|
||||
AES-256-ECB crypt Encrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"ffffff80000000000000000000000000":"36aff0ef7bf3280772cf4cac80a0d2b2":0
|
||||
|
||||
AES-256-ECB crypt Encrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"ffffffffffffffffffffffffffffffffffff8000000000000000000000000000":"":"00000000000000000000000000000000":"45d089c36d5c5a4efc689e3b0de10dd5":0
|
||||
|
||||
AES-256-ECB crypt Decrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"fffffffffffffffffffffffffffffffffffffffffffffff00000000000000000":"":"edf61ae362e882ddc0167474a7a77f3a":"00000000000000000000000000000000":0
|
||||
|
||||
AES-256-ECB crypt Decrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9":"":"a3944b95ca0b52043584ef02151926a8":"00000000000000000000000000000000":0
|
||||
|
||||
AES-256-ECB crypt Decrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"623a52fcea5d443e48d9181ab32c7421":"761c1fe41a18acf20d241650611d90f1":0
|
||||
|
||||
AES-256-ECB crypt Decrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"ddc6bf790c15760d8d9aeb6f9a75fd4e":"80000000000000000000000000000000":0
|
||||
|
||||
AES-128-CBC crypt Encrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"3ad78e726c1ec02b7ebfe92b23d9ec34":0
|
||||
|
||||
AES-128-CBC crypt Encrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_ENCRYPT:"ffffffffffffffffffffffffffffe000":"00000000000000000000000000000000":"00000000000000000000000000000000":"323994cfb9da285a5d9642e1759b224a":0
|
||||
|
||||
AES-128-CBC crypt Encrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_ENCRYPT:"10a58869d74be5a374cf867cfb473859":"00000000000000000000000000000000":"00000000000000000000000000000000":"6d251e6944b051e04eaa6fb4dbf78465":0
|
||||
|
||||
AES-128-CBC crypt Encrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"f34481ec3cc627bacd5dc3fb08f273e6":"0336763e966d92595a567cc9ce537f5e":0
|
||||
|
||||
AES-128-CBC crypt Decrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"3ad78e726c1ec02b7ebfe92b23d9ec34":"80000000000000000000000000000000":0
|
||||
|
||||
AES-128-CBC crypt Decrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_DECRYPT:"ffffc000000000000000000000000000":"00000000000000000000000000000000":"df556a33438db87bc41b1752c55e5e49":"00000000000000000000000000000000":0
|
||||
|
||||
AES-128-CBC crypt Decrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_DECRYPT:"10a58869d74be5a374cf867cfb473859":"00000000000000000000000000000000":"6d251e6944b051e04eaa6fb4dbf78465":"00000000000000000000000000000000":0
|
||||
|
||||
AES-128-CBC crypt Decrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"0336763e966d92595a567cc9ce537f5e":"f34481ec3cc627bacd5dc3fb08f273e6":0
|
||||
|
||||
AES-192-CBC crypt Encrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_CBC:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"6cd02513e8d4dc986b4afe087a60bd0c":0
|
||||
|
||||
AES-192-CBC crypt Encrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_CBC:MBEDTLS_ENCRYPT:"ff0000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"833f71258d53036b02952c76c744f5a1":0
|
||||
|
||||
AES-192-CBC crypt Encrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_CBC:MBEDTLS_ENCRYPT:"e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd":"00000000000000000000000000000000":"00000000000000000000000000000000":"0956259c9cd5cfd0181cca53380cde06":0
|
||||
|
||||
AES-192-CBC crypt Encrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_CBC:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"1b077a6af4b7f98229de786d7516b639":"275cfc0413d8ccb70513c3859b1d0f72":0
|
||||
|
||||
AES-192-CBC crypt Decrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_CBC:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"6cd02513e8d4dc986b4afe087a60bd0c":"80000000000000000000000000000000":0
|
||||
|
||||
AES-192-CBC crypt Decrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_CBC:MBEDTLS_DECRYPT:"ffe000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"7ababc4b3f516c9aafb35f4140b548f9":"00000000000000000000000000000000":0
|
||||
|
||||
AES-192-CBC crypt Decrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_CBC:MBEDTLS_DECRYPT:"e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd":"00000000000000000000000000000000":"0956259c9cd5cfd0181cca53380cde06":"00000000000000000000000000000000":0
|
||||
|
||||
AES-192-CBC crypt Decrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_192_CBC:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"275cfc0413d8ccb70513c3859b1d0f72":"1b077a6af4b7f98229de786d7516b639":0
|
||||
|
||||
AES-256-CBC crypt Encrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"ddc6bf790c15760d8d9aeb6f9a75fd4e":0
|
||||
|
||||
AES-256-CBC crypt Encrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_ENCRYPT:"ff00000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"ec52a212f80a09df6317021bc2a9819e":0
|
||||
|
||||
AES-256-CBC crypt Encrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_ENCRYPT:"c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558":"00000000000000000000000000000000":"00000000000000000000000000000000":"46f2fb342d6f0ab477476fc501242c5f":0
|
||||
|
||||
AES-256-CBC crypt Encrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"014730f80ac625fe84f026c60bfd547d":"5c9d844ed46f9885085e5d6a4f94c7d7":0
|
||||
|
||||
AES-256-CBC crypt Decrypt NIST KAT #1
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ddc6bf790c15760d8d9aeb6f9a75fd4e":"80000000000000000000000000000000":0
|
||||
|
||||
AES-256-CBC crypt Decrypt NIST KAT #2
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_DECRYPT:"ffe0000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"d1ccb9b1337002cbac42c520b5d67722":"00000000000000000000000000000000":0
|
||||
|
||||
AES-256-CBC crypt Decrypt NIST KAT #3
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_DECRYPT:"c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558":"00000000000000000000000000000000":"46f2fb342d6f0ab477476fc501242c5f":"00000000000000000000000000000000":0
|
||||
|
||||
AES-256-CBC crypt Decrypt NIST KAT #4
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||
test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"5c9d844ed46f9885085e5d6a4f94c7d7":"014730f80ac625fe84f026c60bfd547d":0
|
||||
|
||||
Cipher Corner Case behaviours
|
||||
depends_on:MBEDTLS_AES_C
|
||||
cipher_special_behaviours:
|
||||
|
@ -98,16 +98,19 @@ void cipher_special_behaviours( )
|
||||
mbedtls_cipher_context_t ctx;
|
||||
unsigned char input[32];
|
||||
unsigned char output[32];
|
||||
#if defined (MBEDTLS_CIPHER_MODE_CBC)
|
||||
unsigned char iv[32];
|
||||
#endif
|
||||
size_t olen = 0;
|
||||
|
||||
mbedtls_cipher_init( &ctx );
|
||||
memset( input, 0, sizeof( input ) );
|
||||
memset( output, 0, sizeof( output ) );
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
memset( iv, 0, sizeof( iv ) );
|
||||
|
||||
/* Check and get info structures */
|
||||
cipher_info = mbedtls_cipher_info_from_type( MBEDTLS_CIPHER_AES_128_ECB );
|
||||
cipher_info = mbedtls_cipher_info_from_type( MBEDTLS_CIPHER_AES_128_CBC );
|
||||
TEST_ASSERT( NULL != cipher_info );
|
||||
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx, cipher_info ) );
|
||||
@ -120,6 +123,14 @@ void cipher_special_behaviours( )
|
||||
TEST_ASSERT( mbedtls_cipher_set_iv( &ctx, iv, 0 )
|
||||
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||
|
||||
mbedtls_cipher_free( &ctx );
|
||||
mbedtls_cipher_init( &ctx );
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
cipher_info = mbedtls_cipher_info_from_type( MBEDTLS_CIPHER_AES_128_ECB );
|
||||
TEST_ASSERT( NULL != cipher_info );
|
||||
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx, cipher_info ) );
|
||||
|
||||
/* Update ECB with partial block */
|
||||
TEST_ASSERT( mbedtls_cipher_update( &ctx, input, 1, output, &olen )
|
||||
== MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED );
|
||||
@ -690,6 +701,55 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_WITH_PADDING */
|
||||
void test_vec_crypt( int cipher_id, int operation, char *hex_key,
|
||||
char *hex_iv, char *hex_input, char *hex_result,
|
||||
int finish_result )
|
||||
{
|
||||
unsigned char key[50];
|
||||
unsigned char input[16];
|
||||
unsigned char result[16];
|
||||
unsigned char iv[16];
|
||||
size_t key_len, iv_len, inputlen, resultlen;
|
||||
mbedtls_cipher_context_t ctx;
|
||||
unsigned char output[32];
|
||||
size_t outlen;
|
||||
|
||||
mbedtls_cipher_init( &ctx );
|
||||
|
||||
memset( key, 0x00, sizeof( key ) );
|
||||
memset( input, 0x00, sizeof( input ) );
|
||||
memset( result, 0x00, sizeof( result ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( iv, 0x00, sizeof( iv ) );
|
||||
|
||||
/* Prepare context */
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx,
|
||||
mbedtls_cipher_info_from_type( cipher_id ) ) );
|
||||
|
||||
key_len = unhexify( key, hex_key );
|
||||
inputlen = unhexify( input, hex_input );
|
||||
resultlen = unhexify( result, hex_result );
|
||||
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, operation ) );
|
||||
if( MBEDTLS_MODE_CBC == ctx.cipher_info->mode )
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx, MBEDTLS_PADDING_NONE ) );
|
||||
|
||||
iv_len = unhexify( iv, hex_iv );
|
||||
|
||||
TEST_ASSERT( finish_result == mbedtls_cipher_crypt( &ctx, iv_len ? iv : NULL,
|
||||
iv_len, input, inputlen,
|
||||
output, &outlen ) );
|
||||
TEST_ASSERT( resultlen == outlen );
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result, outlen ) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_WITH_PADDING */
|
||||
void set_padding( int cipher_id, int pad_mode, int ret )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user