test/crypto: use separate keys for auth and cipher
PATCH 1/2 test/crypto: use separate keys for auth and cipher
The mixed test cases can have keys with different key lengths. The routine which prepares the session parameters uses same key length for both cipher & auth keys. Instead allow the caller to use same keys as required.
--- app/test/test_cryptodev.c | 48 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-)
app/test/test_cryptodev.c +28 -20
@@ -2554,27 +2554,23 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,enum rte_crypto_auth_operation auth_op, enum rte_crypto_auth_algorithm auth_algo, enum rte_crypto_cipher_algorithm cipher_algo, - const uint8_t *key, uint8_t key_len, + const uint8_t *a_key, uint8_t a_key_len, + const uint8_t *c_key, uint8_t c_key_len, uint8_t auth_iv_len, uint8_t auth_len, uint8_t cipher_iv_len) { - uint8_t cipher_auth_key[key_len]; - struct crypto_testsuite_params *ts_params = &testsuite_params;struct crypto_unittest_params *ut_params = &unittest_params; -memcpy (cipher_auth_key, key, key_len); -/* Setup Authentication Parameters */ ut_params->auth_xform.type =RTE_CRYPTO_SYM_XFORM_AUTH ; ut_params->auth_xform.next =NULL ; ut_params->auth_xform.auth.op = auth_op; ut_params->auth_xform.auth.algo = auth_algo; - ut_params->auth_xform.auth.key.length = key_len; -/* Hash key = cipher key */ - ut_params->auth_xform.auth.key.data = cipher_auth_key; + ut_params->auth_xform.auth.key.length = a_key_len; + ut_params->auth_xform.auth.key.data = a_key; ut_params->auth_xform.auth.digest_length = auth_len;/* Auth IV will be after cipher IV */ ut_params->auth_xform.auth.iv.offset =IV_OFFSET + cipher_iv_len;
@@ -2586,12 +2582,13 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id, ut_params->cipher_xform.cipher.algo = cipher_algo; ut_params->cipher_xform.cipher.op = cipher_op; - ut_params->cipher_xform.cipher.key.data = cipher_auth_key; - ut_params->cipher_xform.cipher.key.length = key_len; + ut_params->cipher_xform.cipher.key.data = c_key; + ut_params->cipher_xform.cipher.key.length = c_key_len; ut_params->cipher_xform.cipher.iv.offset =IV_OFFSET ; ut_params->cipher_xform.cipher.iv.length = cipher_iv_len; -debug_hexdump (stdout,"key:" , key, key_len); +debug_hexdump (stdout,"Auth key:" , a_key, c_key_len); +debug_hexdump (stdout,"Cipher key:" , c_key, c_key_len);/* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
@@ -2677,23 +2674,21 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,enum rte_crypto_auth_operation auth_op, enum rte_crypto_auth_algorithm auth_algo, enum rte_crypto_cipher_algorithm cipher_algo, - const uint8_t *key, const uint8_t key_len, + const uint8_t *a_key, const uint8_t a_key_len, + const uint8_t *c_key, const uint8_t c_key_len, uint8_t auth_iv_len, uint8_t auth_len, uint8_t cipher_iv_len) { - uint8_t auth_cipher_key[key_len]; struct crypto_testsuite_params *ts_params = &testsuite_params;struct crypto_unittest_params *ut_params = &unittest_params; -memcpy (auth_cipher_key, key, key_len); -/* Setup Authentication Parameters */ ut_params->auth_xform.type =RTE_CRYPTO_SYM_XFORM_AUTH ; ut_params->auth_xform.auth.op = auth_op; ut_params->auth_xform.next = &ut_params->cipher_xform; ut_params->auth_xform.auth.algo = auth_algo; - ut_params->auth_xform.auth.key.length = key_len; - ut_params->auth_xform.auth.key.data = auth_cipher_key; + ut_params->auth_xform.auth.key.length = a_key_len; + ut_params->auth_xform.auth.key.data = a_key; ut_params->auth_xform.auth.digest_length = auth_len;/* Auth IV will be after cipher IV */ ut_params->auth_xform.auth.iv.offset =IV_OFFSET + cipher_iv_len;
@@ -2704,12 +2699,13 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id, ut_params->cipher_xform.next =NULL ; ut_params->cipher_xform.cipher.algo = cipher_algo; ut_params->cipher_xform.cipher.op = cipher_op; - ut_params->cipher_xform.cipher.key.data = auth_cipher_key; - ut_params->cipher_xform.cipher.key.length = key_len; + ut_params->cipher_xform.cipher.key.data = c_key; + ut_params->cipher_xform.cipher.key.length = c_key_len; ut_params->cipher_xform.cipher.iv.offset =IV_OFFSET ; ut_params->cipher_xform.cipher.iv.length = cipher_iv_len; -debug_hexdump (stdout,"key:" , key, key_len); +debug_hexdump (stdout,"Auth key:" , a_key, a_key_len); +debug_hexdump (stdout,"Cipher key:" , c_key, c_key_len);/* Create Crypto session*/ if (cipher_op ==RTE_CRYPTO_CIPHER_OP_DECRYPT ) {
@@ -4908,6 +4904,7 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)RTE_CRYPTO_AUTH_SNOW3G_UIA2 ,RTE_CRYPTO_CIPHER_SNOW3G_UEA2 , tdata->key.data, tdata->key.len, + tdata->key.data, tdata->key.len, tdata->auth_iv.len, tdata->digest.len, tdata->cipher_iv.len);if (retval !=0 )
@@ -5037,6 +5034,7 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,RTE_CRYPTO_AUTH_SNOW3G_UIA2 ,RTE_CRYPTO_CIPHER_SNOW3G_UEA2 , tdata->key.data, tdata->key.len, + tdata->key.data, tdata->key.len, tdata->auth_iv.len, tdata->digest.len, tdata->cipher_iv.len);if (retval !=0 )
@@ -5242,6 +5240,7 @@ test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,RTE_CRYPTO_AUTH_SNOW3G_UIA2 ,RTE_CRYPTO_CIPHER_SNOW3G_UEA2 , tdata->key.data, tdata->key.len, + tdata->key.data, tdata->key.len, tdata->auth_iv.len, tdata->digest.len, tdata->cipher_iv.len);
@@ -5443,6 +5442,7 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,RTE_CRYPTO_AUTH_KASUMI_F9 ,RTE_CRYPTO_CIPHER_KASUMI_F8 , tdata->key.data, tdata->key.len, + tdata->key.data, tdata->key.len,0 , tdata->digest.len, tdata->cipher_iv.len);
@@ -5647,6 +5647,7 @@ test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,RTE_CRYPTO_AUTH_KASUMI_F9 ,RTE_CRYPTO_CIPHER_KASUMI_F8 , tdata->key.data, tdata->key.len, + tdata->key.data, tdata->key.len,0 , tdata->digest.len, tdata->cipher_iv.len);
@@ -5828,6 +5829,7 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)RTE_CRYPTO_AUTH_KASUMI_F9 ,RTE_CRYPTO_CIPHER_KASUMI_F8 , tdata->key.data, tdata->key.len, + tdata->key.data, tdata->key.len,0 , tdata->digest.len, tdata->cipher_iv.len);if (retval !=0 )
@@ -6382,6 +6384,7 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,RTE_CRYPTO_AUTH_ZUC_EIA3 ,RTE_CRYPTO_CIPHER_ZUC_EEA3 , tdata->key.data, tdata->key.len, + tdata->key.data, tdata->key.len, tdata->auth_iv.len, tdata->digest.len, tdata->cipher_iv.len);
@@ -6585,6 +6588,7 @@ test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,RTE_CRYPTO_AUTH_ZUC_EIA3 ,RTE_CRYPTO_CIPHER_ZUC_EEA3 , tdata->key.data, tdata->key.len, + tdata->key.data, tdata->key.len, tdata->auth_iv.len, tdata->digest.len, tdata->cipher_iv.len);
@@ -7858,6 +7862,7 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata, tdata->auth_algo, tdata->cipher_algo, tdata->auth_key.data, tdata->auth_key.len, + tdata->cipher_key.data, tdata->cipher_key.len, tdata->auth_iv.len, tdata->digest_enc.len, tdata->cipher_iv.len); else
@@ -7868,6 +7873,7 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata, tdata->auth_algo, tdata->cipher_algo, tdata->auth_key.data, tdata->auth_key.len, + tdata->cipher_key.data, tdata->cipher_key.len, tdata->auth_iv.len, tdata->digest_enc.len, tdata->cipher_iv.len);if (retval !=0 )
@@ -8071,6 +8077,7 @@ test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata, tdata->auth_algo, tdata->cipher_algo, tdata->auth_key.data, tdata->auth_key.len, + tdata->cipher_key.data, tdata->cipher_key.len, tdata->auth_iv.len, tdata->digest_enc.len, tdata->cipher_iv.len); else
@@ -8081,6 +8088,7 @@ test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata, tdata->auth_algo, tdata->cipher_algo, tdata->auth_key.data, tdata->auth_key.len, + tdata->cipher_key.data, tdata->cipher_key.len, tdata->auth_iv.len, tdata->digest_enc.len, tdata->cipher_iv.len);if (retval !=0 )
Signature · 1 line
2.25.1
PATCH 2/2 test/crypto: specify correct parameters with null algos
Keys are not required for NULL algorithms. Same way IV, digest lengths should also be set to 0. The values are invalid and any PMD which validates such parameters would return "-ENOTSUP" for such cases which would result in false skipping of tests.
--- app/test/test_cryptodev_aes_test_vectors.h | 114 ++++++------------- app/test/test_cryptodev_hash_test_vectors.h | 19 +--- app/test/test_cryptodev_mixed_test_vectors.h | 92 +++++---------- 3 files changed, 71 insertions(+), 154 deletions(-)
app/test/test_cryptodev_aes_test_vectors.h +36 -78
@@ -894,19 +894,13 @@ static const struct blockcipher_test_data aes_test_data_21 = {/* NULL cipher NULL auth 8-byte multiple test vector */ static const struct blockcipher_test_data null_test_data_chain_x8_multiple = { .crypto_algo =RTE_CRYPTO_CIPHER_NULL , - .cipher_key = {/* arbitrary data - shouldn't be used */ - .data = { -0x2B ,0x7E ,0x15 ,0x16 ,0x28 ,0xAE ,0xD2 ,0xA6 , -0xAB ,0xF7 ,0x15 ,0x88 ,0x09 ,0xCF ,0x4F ,0x3C - }, - .len =16 + .cipher_key = { + .data = {0x0 }, + .len =0 }, - .iv = {/* arbitrary data - shouldn't be used */ - .data = { -0xF0 ,0xF1 ,0xF2 ,0xF3 ,0xF4 ,0xF5 ,0xF6 ,0xF7 , -0xF8 ,0xF9 ,0xFA ,0xFB ,0xFC ,0xFD ,0xFE ,0xFF - }, - .len =16 + .iv = { + .data = {0x0 }, + .len =0 }, .plaintext = { .data = plaintext_aes_common,
@@ -917,41 +911,27 @@ static const struct blockcipher_test_data null_test_data_chain_x8_multiple = { .len = 512 }, .auth_algo = RTE_CRYPTO_AUTH_NULL, - .auth_key = { /* arbitrary data - shouldn't be used */ - .data = { - 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, - 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, - 0xDE, 0xF4, 0xDE, 0xAD - }, - .len = 20 + .auth_key = { + .data = { 0x0 }, + .len =0 }, .digest = { - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }, - .len = 20, - .truncated_len = 12 + .data = { 0x0 }, + .len = 0, + .truncated_len = 0 } };/* NULL cipher NULL auth 4-byte multiple test vector */ static const struct blockcipher_test_data null_test_data_chain_x4_multiple = { .crypto_algo =RTE_CRYPTO_CIPHER_NULL , - .cipher_key = { /* arbitrary data - shouldn't be used */ - .data = { - 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, - 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C - }, - .len = 16 + .cipher_key = { + .data = {0x0 }, + .len =0 }, - .iv = { /* arbitrary data - shouldn't be used */ - .data = { - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF - }, - .len = 16 + .iv = { + .data = {0x0 }, + .len =0 }, .plaintext = { .data = plaintext_aes128ctr,
@@ -962,41 +942,27 @@ static const struct blockcipher_test_data null_test_data_chain_x4_multiple = { .len = 20 }, .auth_algo = RTE_CRYPTO_AUTH_NULL, - .auth_key = { /* arbitrary data - shouldn't be used */ - .data = { - 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, - 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, - 0xDE, 0xF4, 0xDE, 0xAD - }, - .len = 20 + .auth_key = { + .data = { 0x0 }, + .len =0 }, .digest = { - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }, - .len = 20, - .truncated_len = 12 + .data = { 0x0 }, + .len = 0, + .truncated_len = 0 } };/* NULL cipher NULL auth 1-byte multiple test vector */ static const struct blockcipher_test_data null_test_data_chain_x1_multiple = { .crypto_algo =RTE_CRYPTO_CIPHER_NULL , - .cipher_key = { /* arbitrary data - shouldn't be used */ - .data = { - 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, - 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C - }, - .len = 16 + .cipher_key = { + .data = {0x0 }, + .len =0 }, - .iv = { /* arbitrary data - shouldn't be used */ - .data = { - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF - }, - .len = 16 + .iv = { + .data = {0x0 }, + .len =0 }, .plaintext = { .data = plaintext_aes128ctr,
@@ -1007,22 +973,14 @@ static const struct blockcipher_test_data null_test_data_chain_x1_multiple = { .len = 21 }, .auth_algo = RTE_CRYPTO_AUTH_NULL, - .auth_key = { /* arbitrary data - shouldn't be used */ - .data = { - 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, - 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, - 0xDE, 0xF4, 0xDE, 0xAD - }, - .len = 20 + .auth_key = { + .data = { 0x0 }, + .len =0 }, .digest = { - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }, - .len = 20, - .truncated_len = 12 + .data = { 0x0 }, + .len = 0, + .truncated_len = 0 } };
app/test/test_cryptodev_hash_test_vectors.h +6 -13
@@ -640,21 +640,14 @@ null_auth_test_vector = { .data = plaintext_hash, .len = 512 }, - .auth_key = { /* arbitrary data - shouldn't be used */ - .data = { - 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, - 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C - }, - .len = 16 + .auth_key = { + .data = { 0x0 }, + .len =0 }, .digest = { - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }, - .len = 20, - .truncated_len = 12 + .data = { 0x0 }, + .len = 0, + .truncated_len = 0 } };
app/test/test_cryptodev_mixed_test_vectors.h +29 -63
153 lines not on this page · raw message
Signature · 1 line
2.25.1
RE: [PATCH 2/2] test/crypto: specify correct parameters with null algos
Quoted 8 lines
Subject: [PATCH 2/2] test/crypto: specify correct parameters with null algos
Keys are not required for NULL algorithms. Same way IV, digest lengths should also be set to 0. The values are invalid and any PMD which validates such parameters would return "
-ENOTSUP" for such cases which would result in false skipping of tests.Signed-off-by Anoob Joseph <[email protected]>
RE: [PATCH 2/2] test/crypto: specify correct parameters with null algos
In reply to Anoob JosephHi Anoob,
Quoted 15 lines
-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 12 May 2023 06:34
To: Akhil Goyal <[email protected]>; Fan Zhang <[email protected]>; Power, Ciara <[email protected]>
Cc: Hemant Agrawal <[email protected]>; Jerin Jacob <[email protected]>; Tejasree Kondoj <[email protected]>; [email protected]
Subject: [PATCH 2/2] test/crypto: specify correct parameters with null algosKeys are not required for NULL algorithms. Same way IV, digest lengths should also be set to 0. The values are invalid and any PMD which validates such parameters would return "
-ENOTSUP" for such cases which would result in false skipping of tests.
Quoted 6 lines
Signed-off-by Anoob Joseph <[email protected]>--- app/test/test_cryptodev_aes_test_vectors.h | 114 ++++++------------- app/test/test_cryptodev_hash_test_vectors.h | 19 +--- app/test/test_cryptodev_mixed_test_vectors.h | 92 +++++---------- 3 files changed, 71 insertions(+), 154 deletions(-)
<snip>
+1 for this change, not sure why data was added in these vectors. In saying that, it seems to fail for QAT autotest.... Passing for AESNI_MB PMD though.
Will need to debug a little more for QAT failure, not sure why this is happening yet.
Thanks,
Ciara
Quoted 8 lines
Subject: [PATCH 1/2] test/crypto: use separate keys for auth and cipher
The mixed test cases can have keys with different key lengths. The routine which prepares the session parameters uses same key length for both cipher & auth keys. Instead allow the caller to use same keys as required.
Signed-off-by Anoob Joseph <[email protected]>
Quoted 20 lines
-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Friday 12 May 2023 06:34
To: Akhil Goyal <[email protected]>; Fan Zhang <[email protected]>; Power, Ciara <[email protected]>
Cc: Hemant Agrawal <[email protected]>; Jerin Jacob <[email protected]>; Tejasree Kondoj <[email protected]>; [email protected]
Subject: [PATCH 1/2] test/crypto: use separate keys for auth and cipherThe mixed test cases can have keys with different key lengths. The routine which prepares the session parameters uses same key length for both cipher & auth keys. Instead allow the caller to use same keys as required.
Signed-off-by Anoob Joseph <[email protected]>--- app/test/test_cryptodev.c | 48 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-)
<snip>
Quoted 6 lines
Quoted 6 lines
Subject: [PATCH 1/2] test/crypto: use separate keys for auth and cipher
The mixed test cases can have keys with different key lengths. The routine which prepares the session parameters uses same key length for both cipher & auth keys. Instead allow the caller to use same keys as required.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Anoob Joseph <[email protected]>--- app/test/test_cryptodev.c | 48 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-)Acked-by Ciara Power <[email protected]>
Patchset applied to dpdk-next-crypto
Thanks.