add support of sm4 xts test. Signed-off-by: Hanxiao Li --- app/test/test_cryptodev_blockcipher.c | 3 +- app/test/test_cryptodev_sm4_test_vectors.h | 58 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 87a321fac3..8e13cdfc7a 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -1175,7 +1175,8 @@ sm4_cipheronly_setup(void) RTE_CRYPTO_CIPHER_SM4_ECB, RTE_CRYPTO_CIPHER_SM4_CTR, RTE_CRYPTO_CIPHER_SM4_OFB, - RTE_CRYPTO_CIPHER_SM4_CFB + RTE_CRYPTO_CIPHER_SM4_CFB, + RTE_CRYPTO_CIPHER_SM4_XTS }; rte_cryptodev_info_get(dev_id, &dev_info); diff --git a/app/test/test_cryptodev_sm4_test_vectors.h b/app/test/test_cryptodev_sm4_test_vectors.h index 582b333296..ad38a31723 100644 --- a/app/test/test_cryptodev_sm4_test_vectors.h +++ b/app/test/test_cryptodev_sm4_test_vectors.h @@ -119,6 +119,25 @@ static const uint8_t ciphertext_sm4_ctr[] = { 0x27, 0xF4, 0x99, 0x03, 0xDA, 0x1C, 0x52, 0x04 }; +static const uint8_t ciphertext_sm4_xts[] = { + 0xEB, 0x4E, 0x0F, 0x8B, 0x44, 0x75, 0x9A, 0xE4, + 0xCD, 0xAF, 0x1F, 0x69, 0xCA, 0x90, 0x62, 0x58, + 0x91, 0x7A, 0xA8, 0x14, 0x5D, 0xF3, 0x4E, 0xBC, + 0xFC, 0xA6, 0xFE, 0x36, 0x48, 0x8D, 0x4D, 0x55, + 0x10, 0x00, 0xF0, 0xA5, 0xB2, 0x6D, 0xAB, 0x61, + 0x54, 0x14, 0x8C, 0x9A, 0xFA, 0x8B, 0xDA, 0xA2, + 0x00, 0x12, 0xFE, 0xDF, 0x4A, 0x26, 0x61, 0xE8, + 0x6E, 0x67, 0x8F, 0xE1, 0xBA, 0xAC, 0x27, 0x72, + 0xD8, 0xA1, 0x84, 0xF4, 0xD2, 0x3C, 0xFA, 0xB5, + 0x59, 0xE2, 0x0E, 0xC0, 0x7B, 0xCF, 0x25, 0x78, + 0x1C, 0x02, 0xDE, 0xB7, 0x17, 0xF8, 0x9E, 0x22, + 0x8B, 0x79, 0xF8, 0xA2, 0xFC, 0x12, 0xF9, 0x4A, + 0x5E, 0x48, 0x82, 0xBF, 0x87, 0x57, 0x5E, 0xDC, + 0xF3, 0xA7, 0x47, 0x96, 0x56, 0x00, 0xDD, 0x04, + 0x0E, 0x0E, 0x1B, 0x9E, 0x6B, 0x5C, 0xD0, 0xA6, + 0xB5, 0x7B, 0x9E, 0xB5, 0x5A, 0x19, 0xD9, 0x52, +}; + static const struct blockcipher_test_data sm4_test_data_cbc = { .crypto_algo = RTE_CRYPTO_CIPHER_SM4_CBC, @@ -247,6 +266,35 @@ sm4_test_data_cfb = { }, }; +static const struct blockcipher_test_data +sm4_test_data_xts = { + .crypto_algo = RTE_CRYPTO_CIPHER_SM4_XTS, + .cipher_key = { + .data = { + 0x59, 0x32, 0x43, 0x97, 0x5c, 0xce, 0x7c, 0x8a, + 0x32, 0xac, 0x6b, 0x3c, 0xaf, 0x8a, 0x19, 0xc5, + 0x90, 0xb4, 0x46, 0x18, 0xc8, 0xbf, 0x7a, 0x18, + 0x23, 0x26, 0xc3, 0xb2, 0xb0, 0xa9, 0x93, 0x1c + }, + .len = 32 + }, + .iv = { + .data = { + 0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F, + 0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6 + }, + .len = 16 + }, + .plaintext = { + .data = plaintext_sm4, + .len = 128 + }, + .ciphertext = { + .data = ciphertext_sm4_xts, + .len = 128 + }, +}; + static const struct blockcipher_test_case sm4_cipheronly_test_cases[] = { { .test_descr = "SM4-CBC Encryption", @@ -298,6 +346,16 @@ static const struct blockcipher_test_case sm4_cipheronly_test_cases[] = { .test_data = &sm4_test_data_cfb, .op_mask = BLOCKCIPHER_TEST_OP_DECRYPT, }, + { + .test_descr = "SM4-XTS Encryption", + .test_data = &sm4_test_data_xts, + .op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT, + }, + { + .test_descr = "SM4-XTS Decryption", + .test_data = &sm4_test_data_xts, + .op_mask = BLOCKCIPHER_TEST_OP_DECRYPT, + }, }; static const uint8_t plaintext_sm4_common[] = { -- 2.27.0