diff --git a/host/xtest/xtest_4000.c b/host/xtest/xtest_4000.c index 52a7e576c..e0328bb29 100644 --- a/host/xtest/xtest_4000.c +++ b/host/xtest/xtest_4000.c @@ -2000,6 +2000,50 @@ static const uint8_t ciph_data_aes_cts_vect6_ctx[] = { 0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8, }; +/* + * Test case for https://github.com/OP-TEE/optee_os/issues/1203 + * 80 bytes of data, processed in two steps (32 + 48). + */ + +#define ciph_data_aes_cts_issue1203_key ciph_data_aes_cts_vect1_key + +static const uint8_t ciph_data_aes_cts_issue1203_iv[] = { + 0x5b, 0x11, 0x7b, 0xf9, 0x83, 0x6a, 0x01, 0x27, + 0x1d, 0x2a, 0xae, 0x0a, 0xd3, 0x27, 0x35, 0x81, +}; + +static const uint8_t ciph_data_aes_cts_issue1203_ptx[] = { + 0x33, 0x2a, 0xf4, 0x8c, 0x18, 0xa1, 0x30, 0x7c, + 0xa7, 0x52, 0x76, 0xca, 0xa6, 0x68, 0xad, 0xf6, + 0x1e, 0xba, 0xc9, 0x66, 0x66, 0x52, 0x1a, 0xe7, + 0x3e, 0xbc, 0xba, 0x60, 0x95, 0x71, 0x04, 0x5e, + 0xb4, 0xb7, 0x10, 0xd7, 0x93, 0x6d, 0x5f, 0x9a, + 0xb8, 0xbb, 0x6b, 0xb0, 0x6d, 0x47, 0x93, 0x41, + 0x29, 0x21, 0xf2, 0x84, 0xf5, 0xb2, 0xf2, 0x6d, + 0xbe, 0xe5, 0x8a, 0x2b, 0x58, 0x8d, 0x1b, 0x5e, + 0x41, 0x04, 0xba, 0x9e, 0x92, 0xe9, 0x52, 0xb6, + 0x8b, 0x1e, 0x36, 0x72, 0x91, 0xe4, 0x56, 0x66, +}; + +/* + * Ciphertext was generated by an online tool for AES CBC. + * Since the input size is a multiple of the block size, and the ciphertext + * format is CS3, the output is the same as plain AES CBC with the last + * two blocks swapped. + */ +static const uint8_t ciph_data_aes_cts_issue1203_ctx[] = { + 0x6c, 0xfe, 0xef, 0x6a, 0x1c, 0x8f, 0xd3, 0xc3, + 0x66, 0xc4, 0xd9, 0x0e, 0xbe, 0x24, 0x17, 0x3f, + 0xcd, 0x19, 0xc9, 0xd2, 0x10, 0x3f, 0xcf, 0xdc, + 0xe9, 0x05, 0xab, 0xd5, 0x1a, 0x31, 0x41, 0x77, + 0x3b, 0xd7, 0x6a, 0x26, 0xae, 0x0d, 0xc9, 0x47, + 0x77, 0xd4, 0xa7, 0xd5, 0x73, 0x88, 0x9e, 0xde, + 0x72, 0x66, 0xe0, 0xe2, 0x3d, 0x62, 0x91, 0x22, + 0xae, 0x11, 0x01, 0x97, 0x22, 0x6a, 0x45, 0xa9, + 0xba, 0x56, 0xd2, 0xbc, 0x55, 0x2d, 0x99, 0x4d, + 0x3d, 0x22, 0x27, 0x9a, 0xac, 0x66, 0x2f, 0xf5, +}; + static const uint8_t ciph_data_des_ecb_nopad_out1[] = { 0x46, 0x2B, 0x91, 0xA8, 0x55, 0xE6, 0x7E, 0x75, /* F+..U.~u */ 0x5E, 0x53, 0xF4, 0x8F, 0x29, 0x41, 0x4E, 0xEF, /* ^S..)AN. */ @@ -2161,6 +2205,7 @@ static const struct xtest_ciph_case ciph_cases[] = { XTEST_CIPH_CASE_AES_CTS(vect5, 7), XTEST_CIPH_CASE_AES_CTS(vect6, 17), XTEST_CIPH_CASE_AES_CTS(vect6, 0x20), + XTEST_CIPH_CASE_AES_CTS(issue1203, 32), /* DES */ XTEST_CIPH_CASE_NO_IV(TEE_ALG_DES_ECB_NOPAD, TEE_TYPE_DES,