@@ -119,6 +119,25 @@ static const uint8_t ciphertext_sm4_ctr[] = {
119119 0x27 , 0xF4 , 0x99 , 0x03 , 0xDA , 0x1C , 0x52 , 0x04
120120};
121121
122+ static const uint8_t ciphertext_sm4_xts [] = {
123+ 0xEB , 0x4E , 0x0F , 0x8B , 0x44 , 0x75 , 0x9A , 0xE4 ,
124+ 0xCD , 0xAF , 0x1F , 0x69 , 0xCA , 0x90 , 0x62 , 0x58 ,
125+ 0x91 , 0x7A , 0xA8 , 0x14 , 0x5D , 0xF3 , 0x4E , 0xBC ,
126+ 0xFC , 0xA6 , 0xFE , 0x36 , 0x48 , 0x8D , 0x4D , 0x55 ,
127+ 0x10 , 0x00 , 0xF0 , 0xA5 , 0xB2 , 0x6D , 0xAB , 0x61 ,
128+ 0x54 , 0x14 , 0x8C , 0x9A , 0xFA , 0x8B , 0xDA , 0xA2 ,
129+ 0x00 , 0x12 , 0xFE , 0xDF , 0x4A , 0x26 , 0x61 , 0xE8 ,
130+ 0x6E , 0x67 , 0x8F , 0xE1 , 0xBA , 0xAC , 0x27 , 0x72 ,
131+ 0xD8 , 0xA1 , 0x84 , 0xF4 , 0xD2 , 0x3C , 0xFA , 0xB5 ,
132+ 0x59 , 0xE2 , 0x0E , 0xC0 , 0x7B , 0xCF , 0x25 , 0x78 ,
133+ 0x1C , 0x02 , 0xDE , 0xB7 , 0x17 , 0xF8 , 0x9E , 0x22 ,
134+ 0x8B , 0x79 , 0xF8 , 0xA2 , 0xFC , 0x12 , 0xF9 , 0x4A ,
135+ 0x5E , 0x48 , 0x82 , 0xBF , 0x87 , 0x57 , 0x5E , 0xDC ,
136+ 0xF3 , 0xA7 , 0x47 , 0x96 , 0x56 , 0x00 , 0xDD , 0x04 ,
137+ 0x0E , 0x0E , 0x1B , 0x9E , 0x6B , 0x5C , 0xD0 , 0xA6 ,
138+ 0xB5 , 0x7B , 0x9E , 0xB5 , 0x5A , 0x19 , 0xD9 , 0x52 ,
139+ };
140+
122141static const struct blockcipher_test_data
123142sm4_test_data_cbc = {
124143 .crypto_algo = RTE_CRYPTO_CIPHER_SM4_CBC ,
@@ -247,6 +266,35 @@ sm4_test_data_cfb = {
247266 },
248267};
249268
269+ static const struct blockcipher_test_data
270+ sm4_test_data_xts = {
271+ .crypto_algo = RTE_CRYPTO_CIPHER_SM4_XTS ,
272+ .cipher_key = {
273+ .data = {
274+ 0x59 , 0x32 , 0x43 , 0x97 , 0x5c , 0xce , 0x7c , 0x8a ,
275+ 0x32 , 0xac , 0x6b , 0x3c , 0xaf , 0x8a , 0x19 , 0xc5 ,
276+ 0x90 , 0xb4 , 0x46 , 0x18 , 0xc8 , 0xbf , 0x7a , 0x18 ,
277+ 0x23 , 0x26 , 0xc3 , 0xb2 , 0xb0 , 0xa9 , 0x93 , 0x1c
278+ },
279+ .len = 32
280+ },
281+ .iv = {
282+ .data = {
283+ 0xC7 , 0x2B , 0x65 , 0x91 , 0xA0 , 0xD7 , 0xDE , 0x8F ,
284+ 0x6B , 0x40 , 0x72 , 0x33 , 0xAD , 0x35 , 0x81 , 0xD6
285+ },
286+ .len = 16
287+ },
288+ .plaintext = {
289+ .data = plaintext_sm4 ,
290+ .len = 128
291+ },
292+ .ciphertext = {
293+ .data = ciphertext_sm4_xts ,
294+ .len = 128
295+ },
296+ };
297+
250298static const struct blockcipher_test_case sm4_cipheronly_test_cases [] = {
251299 {
252300 .test_descr = "SM4-CBC Encryption" ,
@@ -298,6 +346,16 @@ static const struct blockcipher_test_case sm4_cipheronly_test_cases[] = {
298346 .test_data = & sm4_test_data_cfb ,
299347 .op_mask = BLOCKCIPHER_TEST_OP_DECRYPT ,
300348 },
349+ {
350+ .test_descr = "SM4-XTS Encryption" ,
351+ .test_data = & sm4_test_data_xts ,
352+ .op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT ,
353+ },
354+ {
355+ .test_descr = "SM4-XTS Decryption" ,
356+ .test_data = & sm4_test_data_xts ,
357+ .op_mask = BLOCKCIPHER_TEST_OP_DECRYPT ,
358+ },
301359};
302360
303361static const uint8_t plaintext_sm4_common [] = {
0 commit comments