mirror of
https://github.com/openssl/openssl.git
synced 2025-01-30 14:01:55 +08:00
test: add sm4 xts test cases
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19619)
This commit is contained in:
parent
2788b56f0c
commit
6cdf83eaab
@ -557,6 +557,7 @@ typedef struct cipher_data_st {
|
||||
int tag_late;
|
||||
unsigned char *mac_key;
|
||||
size_t mac_key_len;
|
||||
const char *xts_standard;
|
||||
} CIPHER_DATA;
|
||||
|
||||
static int cipher_test_init(EVP_TEST *t, const char *alg)
|
||||
@ -698,6 +699,10 @@ static int cipher_test_parse(EVP_TEST *t, const char *keyword,
|
||||
cdat->cts_mode = value;
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(keyword, "XTSStandard") == 0) {
|
||||
cdat->xts_standard = value;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -940,7 +945,18 @@ static int cipher_test_enc(EVP_TEST *t, int enc,
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (expected->xts_standard != NULL) {
|
||||
OSSL_PARAM params[2];
|
||||
|
||||
params[0] =
|
||||
OSSL_PARAM_construct_utf8_string(OSSL_CIPHER_PARAM_XTS_STANDARD,
|
||||
(char *)expected->xts_standard, 0);
|
||||
params[1] = OSSL_PARAM_construct_end();
|
||||
if (!EVP_CIPHER_CTX_set_params(ctx, params)) {
|
||||
t->err = "SET_XTS_STANDARD_ERROR";
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
EVP_CIPHER_CTX_set_padding(ctx, 0);
|
||||
t->err = "CIPHERUPDATE_ERROR";
|
||||
tmplen = 0;
|
||||
|
@ -56,3 +56,27 @@ AAD = feedfacedeadbeeffeedfacedeadbeefabaddad2
|
||||
Tag = 16842d4fa186f56ab33256971fa110f4
|
||||
Plaintext = aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbccccccccccccccccddddddddddddddddeeeeeeeeeeeeeeeeffffffffffffffffeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaa
|
||||
Ciphertext = 48af93501fa62adbcd414cce6034d895dda1bf8f132f042098661572e7483094fd12e518ce062c98acee28d95df4416bed31a2f04476c18bb40c84a74b97dc5b
|
||||
|
||||
Title = SM4 XTS test vectors from GB/T 17964-2021
|
||||
|
||||
Cipher = SM4-XTS
|
||||
Key = 2B7E151628AED2A6ABF7158809CF4F3C000102030405060708090A0B0C0D0E0F
|
||||
IV = F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
|
||||
Plaintext = 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17
|
||||
Ciphertext = E9538251C71D7B80BBE4483FEF497BD12C5C581BD6242FC51E08964FB4F60FDB0BA42F63499279213D318D2C11F6886E903BE7F93A1B3479
|
||||
|
||||
Cipher = SM4-XTS
|
||||
Key = 2B7E151628AED2A6ABF7158809CF4F3C000102030405060708090A0B0C0D0E0F
|
||||
IV = F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
|
||||
Plaintext = 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17
|
||||
Ciphertext = E9538251C71D7B80BBE4483FEF497BD12C5C581BD6242FC51E08964FB4F60FDB0BA42F63499279213D318D2C11F6886E903BE7F93A1B3479
|
||||
XTSStandard = GB
|
||||
|
||||
Title = SM4 XTS test vectors, while the XTS mode is standardized in IEEE Std 1619-2007
|
||||
|
||||
Cipher = SM4-XTS
|
||||
Key = 2B7E151628AED2A6ABF7158809CF4F3C000102030405060708090A0B0C0D0E0F
|
||||
IV = F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
|
||||
Plaintext = 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17
|
||||
Ciphertext = E9538251C71D7B80BBE4483FEF497BD1B3DB1A3E60408C575D63FF7DB39F83260869F9E2585FEC9F0B863BF8FD784B8627D16C0DB6D2CFC7
|
||||
XTSStandard = IEEE
|
||||
|
Loading…
Reference in New Issue
Block a user