X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=test%2Ftest%2Ftest_cryptodev.c;h=83b8ee7f3e3f9c0ede60872bbbffeaf985b38973;hb=51e202f0596f3cc2061bd2c69bd1f7bd5f04d4be;hp=745f2611aca2267dc005897eeda6b0ebdc538033;hpb=b3bbd9e5f265937164ed8c9c61d12f7543a745ea;p=dpdk.git diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index 745f2611ac..83b8ee7f3e 100644 --- a/test/test/test_cryptodev.c +++ b/test/test/test_cryptodev.c @@ -58,7 +58,7 @@ #include "test_cryptodev_snow3g_test_vectors.h" #include "test_cryptodev_snow3g_hash_test_vectors.h" #include "test_cryptodev_zuc_test_vectors.h" -#include "test_cryptodev_gcm_test_vectors.h" +#include "test_cryptodev_aead_test_vectors.h" #include "test_cryptodev_hmac_test_vectors.h" static int gbl_driver_id; @@ -404,7 +404,7 @@ testsuite_setup(void) "session mempool allocation failed"); TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, - &ts_params->conf, ts_params->session_mpool), + &ts_params->conf), "Failed to configure cryptodev %u with %u qps", dev_id, ts_params->conf.nb_queue_pairs); @@ -413,7 +413,8 @@ testsuite_setup(void) for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) { TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( dev_id, qp_id, &ts_params->qp_conf, - rte_cryptodev_socket_id(dev_id)), + rte_cryptodev_socket_id(dev_id), + ts_params->session_mpool), "Failed to setup queue pair %u on cryptodev %u", qp_id, dev_id); } @@ -458,7 +459,7 @@ ut_setup(void) ts_params->conf.socket_id = SOCKET_ID_ANY; TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], - &ts_params->conf, ts_params->session_mpool), + &ts_params->conf), "Failed to configure cryptodev %u", ts_params->valid_devs[0]); @@ -466,7 +467,8 @@ ut_setup(void) TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &ts_params->qp_conf, - rte_cryptodev_socket_id(ts_params->valid_devs[0])), + rte_cryptodev_socket_id(ts_params->valid_devs[0]), + ts_params->session_mpool), "Failed to setup queue pair %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); } @@ -542,23 +544,20 @@ test_device_configure_invalid_dev_id(void) /* Stop the device in case it's started so it can be configured */ rte_cryptodev_stop(ts_params->valid_devs[dev_id]); - TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf, - ts_params->session_mpool), + TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf), "Failed test for rte_cryptodev_configure: " "invalid dev_num %u", dev_id); /* invalid dev_id values */ dev_id = num_devs; - TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf, - ts_params->session_mpool), + TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf), "Failed test for rte_cryptodev_configure: " "invalid dev_num %u", dev_id); dev_id = 0xff; - TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf, - ts_params->session_mpool), + TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf), "Failed test for rte_cryptodev_configure:" "invalid dev_num %u", dev_id); @@ -578,7 +577,7 @@ test_device_configure_invalid_queue_pair_ids(void) ts_params->conf.nb_queue_pairs = 1; TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], - &ts_params->conf, ts_params->session_mpool), + &ts_params->conf), "Failed to configure cryptodev: dev_id %u, qp_id %u", ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs); @@ -587,7 +586,7 @@ test_device_configure_invalid_queue_pair_ids(void) ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE; TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], - &ts_params->conf, ts_params->session_mpool), + &ts_params->conf), "Failed to configure cryptodev: dev_id %u, qp_id %u", ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs); @@ -597,7 +596,7 @@ test_device_configure_invalid_queue_pair_ids(void) ts_params->conf.nb_queue_pairs = 0; TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0], - &ts_params->conf, ts_params->session_mpool), + &ts_params->conf), "Failed test for rte_cryptodev_configure, dev_id %u," " invalid qps: %u", ts_params->valid_devs[0], @@ -608,7 +607,7 @@ test_device_configure_invalid_queue_pair_ids(void) ts_params->conf.nb_queue_pairs = UINT16_MAX; TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0], - &ts_params->conf, ts_params->session_mpool), + &ts_params->conf), "Failed test for rte_cryptodev_configure, dev_id %u," " invalid qps: %u", ts_params->valid_devs[0], @@ -619,7 +618,7 @@ test_device_configure_invalid_queue_pair_ids(void) ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1; TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0], - &ts_params->conf, ts_params->session_mpool), + &ts_params->conf), "Failed test for rte_cryptodev_configure, dev_id %u," " invalid qps: %u", ts_params->valid_devs[0], @@ -649,7 +648,7 @@ test_queue_pair_descriptor_setup(void) rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], - &ts_params->conf, ts_params->session_mpool), + &ts_params->conf), "Failed to configure cryptodev %u", ts_params->valid_devs[0]); @@ -663,7 +662,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, rte_cryptodev_socket_id( - ts_params->valid_devs[0])), + ts_params->valid_devs[0]), + ts_params->session_mpool), "Failed test for " "rte_cryptodev_queue_pair_setup: num_inflights " "%u on qp %u on cryptodev %u", @@ -677,7 +677,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, rte_cryptodev_socket_id( - ts_params->valid_devs[0])), + ts_params->valid_devs[0]), + ts_params->session_mpool), "Failed test for" " rte_cryptodev_queue_pair_setup: num_inflights" " %u on qp %u on cryptodev %u", @@ -691,7 +692,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, rte_cryptodev_socket_id( - ts_params->valid_devs[0])), + ts_params->valid_devs[0]), + ts_params->session_mpool), "Failed test for " "rte_cryptodev_queue_pair_setup: num_inflights" " %u on qp %u on cryptodev %u", @@ -706,7 +708,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, rte_cryptodev_socket_id( - ts_params->valid_devs[0])), + ts_params->valid_devs[0]), + ts_params->session_mpool), "Unexpectedly passed test for " "rte_cryptodev_queue_pair_setup:" "num_inflights %u on qp %u on cryptodev %u", @@ -721,7 +724,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, rte_cryptodev_socket_id( - ts_params->valid_devs[0])), + ts_params->valid_devs[0]), + ts_params->session_mpool), "Unexpectedly passed test for " "rte_cryptodev_queue_pair_setup:" "num_inflights %u on qp %u on cryptodev %u", @@ -735,7 +739,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, rte_cryptodev_socket_id( - ts_params->valid_devs[0])), + ts_params->valid_devs[0]), + ts_params->session_mpool), "Failed test for" " rte_cryptodev_queue_pair_setup:" "num_inflights %u on qp %u on cryptodev %u", @@ -750,7 +755,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, rte_cryptodev_socket_id( - ts_params->valid_devs[0])), + ts_params->valid_devs[0]), + ts_params->session_mpool), "Unexpectedly passed test for " "rte_cryptodev_queue_pair_setup:" "num_inflights %u on qp %u on cryptodev %u", @@ -766,7 +772,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, - rte_cryptodev_socket_id(ts_params->valid_devs[0])), + rte_cryptodev_socket_id(ts_params->valid_devs[0]), + ts_params->session_mpool), "Failed test for rte_cryptodev_queue_pair_setup:" "invalid qp %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); @@ -776,7 +783,8 @@ test_queue_pair_descriptor_setup(void) TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, - rte_cryptodev_socket_id(ts_params->valid_devs[0])), + rte_cryptodev_socket_id(ts_params->valid_devs[0]), + ts_params->session_mpool), "Failed test for rte_cryptodev_queue_pair_setup:" "invalid qp %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); @@ -1585,6 +1593,24 @@ test_authonly_mb_all(void) return TEST_SUCCESS; } +static int +test_authonly_qat_all(void) +{ + struct crypto_testsuite_params *ts_params = &testsuite_params; + int status; + + status = test_blockcipher_all_tests(ts_params->mbuf_pool, + ts_params->op_mpool, + ts_params->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), + BLKCIPHER_AUTHONLY_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} static int test_AES_chain_mb_all(void) { @@ -1790,7 +1816,7 @@ test_authonly_dpaa2_sec_all(void) ts_params->session_mpool, ts_params->valid_devs[0], rte_cryptodev_driver_id_get( - RTE_STR(RTE_CRYPTODEV_DPAA2_SEC_PMD)), + RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)), BLKCIPHER_AUTHONLY_TYPE); TEST_ASSERT_EQUAL(status, 0, "Test failed"); @@ -2327,9 +2353,9 @@ create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag, rte_memcpy(iv_ptr, auth_iv, auth_iv_len); sym_op->cipher.data.length = cipher_len; - sym_op->cipher.data.offset = cipher_offset + auth_offset; + sym_op->cipher.data.offset = cipher_offset; sym_op->auth.data.length = auth_len; - sym_op->auth.data.offset = auth_offset + cipher_offset; + sym_op->auth.data.offset = auth_offset; return 0; } @@ -2383,10 +2409,10 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len, rte_memcpy(iv_ptr, auth_iv, auth_iv_len); sym_op->cipher.data.length = cipher_len; - sym_op->cipher.data.offset = auth_offset + cipher_offset; + sym_op->cipher.data.offset = cipher_offset; sym_op->auth.data.length = auth_len; - sym_op->auth.data.offset = auth_offset + cipher_offset; + sym_op->auth.data.offset = auth_offset; return 0; } @@ -2525,7 +2551,7 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata) /* Create KASUMI session */ retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], tdata->key.data, tdata->key.len, - tdata->auth_iv.len, tdata->digest.len, + 0, tdata->digest.len, RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_KASUMI_F9); if (retval < 0) @@ -2547,9 +2573,9 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len, - tdata->auth_iv.data, tdata->auth_iv.len, + NULL, 0, plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, - tdata->validAuthLenInBits.len, + tdata->plaintext.len, 0); if (retval < 0) return retval; @@ -2585,7 +2611,7 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata) /* Create KASUMI session */ retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], tdata->key.data, tdata->key.len, - tdata->auth_iv.len, tdata->digest.len, + 0, tdata->digest.len, RTE_CRYPTO_AUTH_OP_VERIFY, RTE_CRYPTO_AUTH_KASUMI_F9); if (retval < 0) @@ -2607,10 +2633,10 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_hash_operation(tdata->digest.data, tdata->digest.len, - tdata->auth_iv.data, tdata->auth_iv.len, + NULL, 0, plaintext_pad_len, RTE_CRYPTO_AUTH_OP_VERIFY, - tdata->validAuthLenInBits.len, + tdata->plaintext.len, 0); if (retval < 0) return retval; @@ -2808,9 +2834,9 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, - tdata->cipher_iv.len, - tdata->plaintext.len, - 0); + tdata->cipher_iv.len, + RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), + tdata->validCipherOffsetInBits.len); if (retval < 0) return retval; @@ -2822,14 +2848,16 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata) if (ut_params->obuf) ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); else - ciphertext = plaintext; + ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3); TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + const uint8_t *reference_ciphertext = tdata->ciphertext.data + + (tdata->validCipherOffsetInBits.len >> 3); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, - tdata->ciphertext.data, + reference_ciphertext, tdata->validCipherLenInBits.len, "KASUMI Ciphertext data not as expected"); return 0; @@ -2881,9 +2909,9 @@ test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, - tdata->cipher_iv.len, - tdata->plaintext.len, - 0); + tdata->cipher_iv.len, + RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), + tdata->validCipherOffsetInBits.len); if (retval < 0) return retval; @@ -2897,19 +2925,22 @@ test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata) ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, plaintext_len, buffer); else - ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, + ciphertext = rte_pktmbuf_read(ut_params->ibuf, + tdata->validCipherOffsetInBits.len >> 3, plaintext_len, buffer); /* Validate obuf */ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); - /* Validate obuf */ - TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( - ciphertext, - tdata->ciphertext.data, - tdata->validCipherLenInBits.len, - "KASUMI Ciphertext data not as expected"); - return 0; + const uint8_t *reference_ciphertext = tdata->ciphertext.data + + (tdata->validCipherOffsetInBits.len >> 3); + /* Validate obuf */ + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( + ciphertext, + reference_ciphertext, + tdata->validCipherLenInBits.len, + "KASUMI Ciphertext data not as expected"); + return 0; } static int @@ -2952,9 +2983,9 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, - tdata->cipher_iv.len, - tdata->plaintext.len, - 0); + tdata->cipher_iv.len, + RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), + tdata->validCipherOffsetInBits.len); if (retval < 0) return retval; @@ -2966,14 +2997,16 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata) if (ut_params->obuf) ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); else - ciphertext = plaintext; + ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3); TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); + const uint8_t *reference_ciphertext = tdata->ciphertext.data + + (tdata->validCipherOffsetInBits.len >> 3); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, - tdata->ciphertext.data, + reference_ciphertext, tdata->validCipherLenInBits.len, "KASUMI Ciphertext data not as expected"); return 0; @@ -3026,9 +3059,9 @@ test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, - tdata->cipher_iv.len, - tdata->plaintext.len, - 0); + tdata->cipher_iv.len, + RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), + tdata->validCipherOffsetInBits.len); if (retval < 0) return retval; @@ -3041,13 +3074,16 @@ test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata) ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, plaintext_pad_len, buffer); else - ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, + ciphertext = rte_pktmbuf_read(ut_params->ibuf, + tdata->validCipherOffsetInBits.len >> 3, plaintext_pad_len, buffer); + const uint8_t *reference_ciphertext = tdata->ciphertext.data + + (tdata->validCipherOffsetInBits.len >> 3); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, - tdata->ciphertext.data, + reference_ciphertext, tdata->validCipherLenInBits.len, "KASUMI Ciphertext data not as expected"); return 0; @@ -3094,9 +3130,9 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, - tdata->cipher_iv.len, - tdata->ciphertext.len, - 0); + tdata->cipher_iv.len, + RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), + tdata->validCipherOffsetInBits.len); if (retval < 0) return retval; @@ -3108,14 +3144,16 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata) if (ut_params->obuf) plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); else - plaintext = ciphertext; + plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3); TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); + const uint8_t *reference_plaintext = tdata->plaintext.data + + (tdata->validCipherOffsetInBits.len >> 3); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( plaintext, - tdata->plaintext.data, + reference_plaintext, tdata->validCipherLenInBits.len, "KASUMI Plaintext data not as expected"); return 0; @@ -3161,7 +3199,7 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata) retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, tdata->cipher_iv.len, tdata->ciphertext.len, - 0); + tdata->validCipherOffsetInBits.len); if (retval < 0) return retval; @@ -3173,14 +3211,16 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata) if (ut_params->obuf) plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); else - plaintext = ciphertext; + plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3); TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); + const uint8_t *reference_plaintext = tdata->plaintext.data + + (tdata->validCipherOffsetInBits.len >> 3); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( plaintext, - tdata->plaintext.data, + reference_plaintext, tdata->validCipherLenInBits.len, "KASUMI Plaintext data not as expected"); return 0; @@ -3921,7 +3961,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->auth_iv.len, tdata->digest.len, + 0, tdata->digest.len, tdata->cipher_iv.len); if (retval < 0) return retval; @@ -3944,10 +3984,10 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len, tdata->cipher_iv.data, tdata->cipher_iv.len, - tdata->auth_iv.data, tdata->auth_iv.len, + NULL, 0, plaintext_pad_len, tdata->validCipherLenInBits.len, - 0, + tdata->validCipherOffsetInBits.len, tdata->validAuthLenInBits.len, 0 ); @@ -3958,19 +3998,23 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata) ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); - ut_params->obuf = ut_params->op->sym->m_src; - if (ut_params->obuf) - ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); + if (ut_params->op->sym->m_dst) + ut_params->obuf = ut_params->op->sym->m_dst; else - ciphertext = plaintext; + ut_params->obuf = ut_params->op->sym->m_src; + + ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *, + tdata->validCipherOffsetInBits.len >> 3); + const uint8_t *reference_ciphertext = tdata->ciphertext.data + + (tdata->validCipherOffsetInBits.len >> 3); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, - tdata->ciphertext.data, + reference_ciphertext, tdata->validCipherLenInBits.len, "KASUMI Ciphertext data not as expected"); - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) + ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *) + plaintext_pad_len; /* Validate obuf */ @@ -4002,7 +4046,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->auth_iv.len, tdata->digest.len, + 0, tdata->digest.len, tdata->cipher_iv.len); if (retval < 0) return retval; @@ -4025,12 +4069,11 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data, - tdata->digest.len, tdata->auth_iv.data, - tdata->auth_iv.len, + tdata->digest.len, NULL, 0, plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, tdata->cipher_iv.data, tdata->cipher_iv.len, - tdata->validCipherLenInBits.len, - 0, + RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), + tdata->validCipherOffsetInBits.len, tdata->validAuthLenInBits.len, 0 ); @@ -4040,19 +4083,24 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata) ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); - ut_params->obuf = ut_params->op->sym->m_src; - if (ut_params->obuf) - ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); + + if (ut_params->op->sym->m_dst) + ut_params->obuf = ut_params->op->sym->m_dst; else - ciphertext = plaintext; + ut_params->obuf = ut_params->op->sym->m_src; + + ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *, + tdata->validCipherOffsetInBits.len >> 3); ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) + plaintext_pad_len; + const uint8_t *reference_ciphertext = tdata->ciphertext.data + + (tdata->validCipherOffsetInBits.len >> 3); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, - tdata->ciphertext.data, + reference_ciphertext, tdata->validCipherLenInBits.len, "KASUMI Ciphertext data not as expected"); @@ -4623,6 +4671,25 @@ test_DES_cipheronly_qat_all(void) return TEST_SUCCESS; } +static int +test_DES_cipheronly_openssl_all(void) +{ + struct crypto_testsuite_params *ts_params = &testsuite_params; + int status; + + status = test_blockcipher_all_tests(ts_params->mbuf_pool, + ts_params->op_mpool, + ts_params->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)), + BLKCIPHER_DES_CIPHERONLY_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + static int test_DES_docsis_openssl_all(void) { @@ -4642,6 +4709,44 @@ test_DES_docsis_openssl_all(void) return TEST_SUCCESS; } +static int +test_DES_cipheronly_mb_all(void) +{ + struct crypto_testsuite_params *ts_params = &testsuite_params; + int status; + + status = test_blockcipher_all_tests(ts_params->mbuf_pool, + ts_params->op_mpool, + ts_params->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), + BLKCIPHER_DES_CIPHERONLY_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + +static int +test_DES_docsis_mb_all(void) +{ + struct crypto_testsuite_params *ts_params = &testsuite_params; + int status; + + status = test_blockcipher_all_tests(ts_params->mbuf_pool, + ts_params->op_mpool, + ts_params->session_mpool, + ts_params->valid_devs[0], + rte_cryptodev_driver_id_get( + RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), + BLKCIPHER_DES_DOCSIS_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + static int test_3DES_chain_dpaa2_sec_all(void) { @@ -4737,10 +4842,11 @@ test_3DES_cipheronly_openssl_all(void) return TEST_SUCCESS; } -/* ***** AES-GCM Tests ***** */ +/* ***** AEAD algorithm Tests ***** */ static int -create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op, +create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, + enum rte_crypto_aead_operation op, const uint8_t *key, const uint8_t key_len, const uint16_t aad_len, const uint8_t auth_len, uint8_t iv_len) @@ -4755,14 +4861,14 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op, /* Setup AEAD Parameters */ ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD; ut_params->aead_xform.next = NULL; - ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM; + ut_params->aead_xform.aead.algo = algo; ut_params->aead_xform.aead.op = op; ut_params->aead_xform.aead.key.data = aead_key; ut_params->aead_xform.aead.key.length = key_len; ut_params->aead_xform.aead.iv.offset = IV_OFFSET; ut_params->aead_xform.aead.iv.length = iv_len; ut_params->aead_xform.aead.digest_length = auth_len; - ut_params->aead_xform.aead.add_auth_data_length = aad_len; + ut_params->aead_xform.aead.aad_length = aad_len; TEST_HEXDUMP(stdout, "key:", key, key_len); @@ -4779,7 +4885,8 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op, } static int -create_gcm_xforms(struct rte_crypto_op *op, +create_aead_xform(struct rte_crypto_op *op, + enum rte_crypto_aead_algorithm algo, enum rte_crypto_aead_operation aead_op, uint8_t *key, const uint8_t key_len, const uint8_t aad_len, const uint8_t auth_len, @@ -4793,14 +4900,14 @@ create_gcm_xforms(struct rte_crypto_op *op, /* Setup AEAD Parameters */ sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD; sym_op->xform->next = NULL; - sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM; + sym_op->xform->aead.algo = algo; sym_op->xform->aead.op = aead_op; sym_op->xform->aead.key.data = key; sym_op->xform->aead.key.length = key_len; sym_op->xform->aead.iv.offset = IV_OFFSET; sym_op->xform->aead.iv.length = iv_len; sym_op->xform->aead.digest_length = auth_len; - sym_op->xform->aead.add_auth_data_length = aad_len; + sym_op->xform->aead.aad_length = aad_len; TEST_HEXDUMP(stdout, "key:", key, key_len); @@ -4808,8 +4915,8 @@ create_gcm_xforms(struct rte_crypto_op *op, } static int -create_gcm_operation(enum rte_crypto_aead_operation op, - const struct gcm_test_data *tdata) +create_aead_operation(enum rte_crypto_aead_operation op, + const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -4928,7 +5035,7 @@ create_gcm_operation(enum rte_crypto_aead_operation op, } static int -test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) +test_authenticated_encryption(const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -4938,8 +5045,9 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) uint16_t plaintext_pad_len; uint32_t i; - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -4950,7 +5058,7 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) if (tdata->aad.len > MBUF_SIZE) { ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); /* Populate full size of add data */ - for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32) + for (i = 32; i < MAX_AAD_LENGTH; i += 32) memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32); } else ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); @@ -4959,8 +5067,8 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); if (retval < 0) return retval; @@ -4997,13 +5105,13 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) ciphertext, tdata->ciphertext.data, tdata->ciphertext.len, - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); TEST_ASSERT_BUFFERS_ARE_EQUAL( auth_tag, tdata->auth_tag.data, tdata->auth_tag.len, - "GCM Generated auth tag not as expected"); + "Generated auth tag not as expected"); return 0; @@ -5012,143 +5120,143 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) static int test_AES_GCM_authenticated_encryption_test_case_1(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_1); + return test_authenticated_encryption(&gcm_test_case_1); } static int test_AES_GCM_authenticated_encryption_test_case_2(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_2); + return test_authenticated_encryption(&gcm_test_case_2); } static int test_AES_GCM_authenticated_encryption_test_case_3(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_3); + return test_authenticated_encryption(&gcm_test_case_3); } static int test_AES_GCM_authenticated_encryption_test_case_4(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_4); + return test_authenticated_encryption(&gcm_test_case_4); } static int test_AES_GCM_authenticated_encryption_test_case_5(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_5); + return test_authenticated_encryption(&gcm_test_case_5); } static int test_AES_GCM_authenticated_encryption_test_case_6(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_6); + return test_authenticated_encryption(&gcm_test_case_6); } static int test_AES_GCM_authenticated_encryption_test_case_7(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_7); + return test_authenticated_encryption(&gcm_test_case_7); } static int test_AES_GCM_auth_encryption_test_case_192_1(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_1); + return test_authenticated_encryption(&gcm_test_case_192_1); } static int test_AES_GCM_auth_encryption_test_case_192_2(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_2); + return test_authenticated_encryption(&gcm_test_case_192_2); } static int test_AES_GCM_auth_encryption_test_case_192_3(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_3); + return test_authenticated_encryption(&gcm_test_case_192_3); } static int test_AES_GCM_auth_encryption_test_case_192_4(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_4); + return test_authenticated_encryption(&gcm_test_case_192_4); } static int test_AES_GCM_auth_encryption_test_case_192_5(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_5); + return test_authenticated_encryption(&gcm_test_case_192_5); } static int test_AES_GCM_auth_encryption_test_case_192_6(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_6); + return test_authenticated_encryption(&gcm_test_case_192_6); } static int test_AES_GCM_auth_encryption_test_case_192_7(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_7); + return test_authenticated_encryption(&gcm_test_case_192_7); } static int test_AES_GCM_auth_encryption_test_case_256_1(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1); + return test_authenticated_encryption(&gcm_test_case_256_1); } static int test_AES_GCM_auth_encryption_test_case_256_2(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2); + return test_authenticated_encryption(&gcm_test_case_256_2); } static int test_AES_GCM_auth_encryption_test_case_256_3(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3); + return test_authenticated_encryption(&gcm_test_case_256_3); } static int test_AES_GCM_auth_encryption_test_case_256_4(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4); + return test_authenticated_encryption(&gcm_test_case_256_4); } static int test_AES_GCM_auth_encryption_test_case_256_5(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5); + return test_authenticated_encryption(&gcm_test_case_256_5); } static int test_AES_GCM_auth_encryption_test_case_256_6(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6); + return test_authenticated_encryption(&gcm_test_case_256_6); } static int test_AES_GCM_auth_encryption_test_case_256_7(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7); + return test_authenticated_encryption(&gcm_test_case_256_7); } static int test_AES_GCM_auth_encryption_test_case_aad_1(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1); + return test_authenticated_encryption(&gcm_test_case_aad_1); } static int test_AES_GCM_auth_encryption_test_case_aad_2(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2); + return test_authenticated_encryption(&gcm_test_case_aad_2); } static int -test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) +test_authenticated_decryption(const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5157,8 +5265,9 @@ test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) uint8_t *plaintext; uint32_t i; - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_DECRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5170,7 +5279,7 @@ test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) if (tdata->aad.len > MBUF_SIZE) { ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); /* Populate full size of add data */ - for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32) + for (i = 32; i < MAX_AAD_LENGTH; i += 32) memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32); } else ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); @@ -5178,8 +5287,8 @@ test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); if (retval < 0) return retval; @@ -5209,154 +5318,154 @@ test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) plaintext, tdata->plaintext.data, tdata->plaintext.len, - "GCM plaintext data not as expected"); + "Plaintext data not as expected"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, - "GCM authentication failed"); + "Authentication failed"); return 0; } static int test_AES_GCM_authenticated_decryption_test_case_1(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_1); + return test_authenticated_decryption(&gcm_test_case_1); } static int test_AES_GCM_authenticated_decryption_test_case_2(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_2); + return test_authenticated_decryption(&gcm_test_case_2); } static int test_AES_GCM_authenticated_decryption_test_case_3(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_3); + return test_authenticated_decryption(&gcm_test_case_3); } static int test_AES_GCM_authenticated_decryption_test_case_4(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_4); + return test_authenticated_decryption(&gcm_test_case_4); } static int test_AES_GCM_authenticated_decryption_test_case_5(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_5); + return test_authenticated_decryption(&gcm_test_case_5); } static int test_AES_GCM_authenticated_decryption_test_case_6(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_6); + return test_authenticated_decryption(&gcm_test_case_6); } static int test_AES_GCM_authenticated_decryption_test_case_7(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_7); + return test_authenticated_decryption(&gcm_test_case_7); } static int test_AES_GCM_auth_decryption_test_case_192_1(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_1); + return test_authenticated_decryption(&gcm_test_case_192_1); } static int test_AES_GCM_auth_decryption_test_case_192_2(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_2); + return test_authenticated_decryption(&gcm_test_case_192_2); } static int test_AES_GCM_auth_decryption_test_case_192_3(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_3); + return test_authenticated_decryption(&gcm_test_case_192_3); } static int test_AES_GCM_auth_decryption_test_case_192_4(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_4); + return test_authenticated_decryption(&gcm_test_case_192_4); } static int test_AES_GCM_auth_decryption_test_case_192_5(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_5); + return test_authenticated_decryption(&gcm_test_case_192_5); } static int test_AES_GCM_auth_decryption_test_case_192_6(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_6); + return test_authenticated_decryption(&gcm_test_case_192_6); } static int test_AES_GCM_auth_decryption_test_case_192_7(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_7); + return test_authenticated_decryption(&gcm_test_case_192_7); } static int test_AES_GCM_auth_decryption_test_case_256_1(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1); + return test_authenticated_decryption(&gcm_test_case_256_1); } static int test_AES_GCM_auth_decryption_test_case_256_2(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2); + return test_authenticated_decryption(&gcm_test_case_256_2); } static int test_AES_GCM_auth_decryption_test_case_256_3(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3); + return test_authenticated_decryption(&gcm_test_case_256_3); } static int test_AES_GCM_auth_decryption_test_case_256_4(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4); + return test_authenticated_decryption(&gcm_test_case_256_4); } static int test_AES_GCM_auth_decryption_test_case_256_5(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5); + return test_authenticated_decryption(&gcm_test_case_256_5); } static int test_AES_GCM_auth_decryption_test_case_256_6(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6); + return test_authenticated_decryption(&gcm_test_case_256_6); } static int test_AES_GCM_auth_decryption_test_case_256_7(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7); + return test_authenticated_decryption(&gcm_test_case_256_7); } static int test_AES_GCM_auth_decryption_test_case_aad_1(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1); + return test_authenticated_decryption(&gcm_test_case_aad_1); } static int test_AES_GCM_auth_decryption_test_case_aad_2(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2); + return test_authenticated_decryption(&gcm_test_case_aad_2); } static int -test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) +test_authenticated_encryption_oop(const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5365,8 +5474,9 @@ test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) uint8_t *ciphertext, *auth_tag; uint16_t plaintext_pad_len; - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5383,8 +5493,8 @@ test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->obuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); if (retval < 0) return retval; @@ -5414,13 +5524,13 @@ test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) ciphertext, tdata->ciphertext.data, tdata->ciphertext.len, - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); TEST_ASSERT_BUFFERS_ARE_EQUAL( auth_tag, tdata->auth_tag.data, tdata->auth_tag.len, - "GCM Generated auth tag not as expected"); + "Generated auth tag not as expected"); return 0; @@ -5429,11 +5539,11 @@ test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) static int test_AES_GCM_authenticated_encryption_oop_test_case_1(void) { - return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5); + return test_authenticated_encryption_oop(&gcm_test_case_5); } static int -test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata) +test_authenticated_decryption_oop(const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5441,8 +5551,9 @@ test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata) int retval; uint8_t *plaintext; - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_DECRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5459,8 +5570,8 @@ test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata) memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->obuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); if (retval < 0) return retval; @@ -5486,23 +5597,23 @@ test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata) plaintext, tdata->plaintext.data, tdata->plaintext.len, - "GCM plaintext data not as expected"); + "Plaintext data not as expected"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, - "GCM authentication failed"); + "Authentication failed"); return 0; } static int test_AES_GCM_authenticated_decryption_oop_test_case_1(void) { - return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5); + return test_authenticated_decryption_oop(&gcm_test_case_5); } static int -test_AES_GCM_authenticated_encryption_sessionless( - const struct gcm_test_data *tdata) +test_authenticated_encryption_sessionless( + const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5518,14 +5629,15 @@ test_AES_GCM_authenticated_encryption_sessionless( memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); if (retval < 0) return retval; - /* Create GCM xforms */ + /* Create GCM xform */ memcpy(key, tdata->key.data, tdata->key.len); - retval = create_gcm_xforms(ut_params->op, + retval = create_aead_xform(ut_params->op, + tdata->algo, RTE_CRYPTO_AEAD_OP_ENCRYPT, key, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5562,13 +5674,13 @@ test_AES_GCM_authenticated_encryption_sessionless( ciphertext, tdata->ciphertext.data, tdata->ciphertext.len, - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); TEST_ASSERT_BUFFERS_ARE_EQUAL( auth_tag, tdata->auth_tag.data, tdata->auth_tag.len, - "GCM Generated auth tag not as expected"); + "Generated auth tag not as expected"); return 0; @@ -5577,13 +5689,13 @@ test_AES_GCM_authenticated_encryption_sessionless( static int test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void) { - return test_AES_GCM_authenticated_encryption_sessionless( + return test_authenticated_encryption_sessionless( &gcm_test_case_5); } static int -test_AES_GCM_authenticated_decryption_sessionless( - const struct gcm_test_data *tdata) +test_authenticated_decryption_sessionless( + const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5598,14 +5710,15 @@ test_AES_GCM_authenticated_decryption_sessionless( memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); if (retval < 0) return retval; - /* Create GCM xforms */ + /* Create AEAD xform */ memcpy(key, tdata->key.data, tdata->key.len); - retval = create_gcm_xforms(ut_params->op, + retval = create_aead_xform(ut_params->op, + tdata->algo, RTE_CRYPTO_AEAD_OP_DECRYPT, key, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5638,18 +5751,18 @@ test_AES_GCM_authenticated_decryption_sessionless( plaintext, tdata->plaintext.data, tdata->plaintext.len, - "GCM plaintext data not as expected"); + "Plaintext data not as expected"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, - "GCM authentication failed"); + "Authentication failed"); return 0; } static int test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void) { - return test_AES_GCM_authenticated_decryption_sessionless( + return test_authenticated_decryption_sessionless( &gcm_test_case_5); } @@ -6367,7 +6480,7 @@ test_null_invalid_operation(void) ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, &ut_params->cipher_xform, ts_params->session_mpool); - TEST_ASSERT(ret == -1, + TEST_ASSERT(ret < 0, "Session creation succeeded unexpectedly"); @@ -6385,7 +6498,7 @@ test_null_invalid_operation(void) ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, &ut_params->auth_xform, ts_params->session_mpool); - TEST_ASSERT(ret == -1, + TEST_ASSERT(ret < 0, "Session creation succeeded unexpectedly"); return TEST_SUCCESS; @@ -7358,8 +7471,8 @@ test_authenticated_decryption_fail_when_corruption( } static int -create_gcm_operation_SGL(enum rte_crypto_aead_operation op, - const struct gcm_test_data *tdata, +create_aead_operation_SGL(enum rte_crypto_aead_operation op, + const struct aead_test_data *tdata, void *digest_mem, uint64_t digest_phys) { struct crypto_testsuite_params *ts_params = &testsuite_params; @@ -7420,7 +7533,7 @@ create_gcm_operation_SGL(enum rte_crypto_aead_operation op, #define SGL_MAX_NO 16 static int -test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, +test_authenticated_encryption_SGL(const struct aead_test_data *tdata, const int oop, uint32_t fragsz, uint32_t fragsz_oop) { struct crypto_testsuite_params *ts_params = &testsuite_params; @@ -7465,8 +7578,9 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, buf_oop = ut_params->obuf; } - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -7595,8 +7709,8 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, tdata->plaintext.len); } - /* Create GCM opertaion */ - retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT, + /* Create AEAD operation */ + retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata, digest_mem, digest_phys); if (retval < 0) @@ -7630,7 +7744,7 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, ciphertext, tdata->ciphertext.data, fragsz, - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); buf = ut_params->op->sym->m_src->next; if (oop) @@ -7647,7 +7761,7 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, ciphertext, tdata->ciphertext.data + off, to_trn_tbl[ecx], - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); off += to_trn_tbl[ecx++]; buf = buf->next; @@ -7658,7 +7772,7 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, auth_tag, tdata->auth_tag.data, tdata->auth_tag.len, - "GCM Generated auth tag not as expected"); + "Generated auth tag not as expected"); return 0; } @@ -7669,21 +7783,21 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, static int test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void) { - return test_AES_GCM_authenticated_encryption_SGL( + return test_authenticated_encryption_SGL( &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400); } static int test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void) { - return test_AES_GCM_authenticated_encryption_SGL( + return test_authenticated_encryption_SGL( &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000); } static int test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void) { - return test_AES_GCM_authenticated_encryption_SGL( + return test_authenticated_encryption_SGL( &gcm_test_case_8, OUT_OF_PLACE, 400, gcm_test_case_8.plaintext.len); } @@ -7692,7 +7806,7 @@ static int test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void) { - return test_AES_GCM_authenticated_encryption_SGL( + return test_authenticated_encryption_SGL( &gcm_test_case_SGL_1, IN_PLACE, 1500, 0); } @@ -7986,6 +8100,7 @@ static struct unit_test_suite cryptodev_qat_testsuite = { test_AES_docsis_qat_all), TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_qat_all), + TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all), TEST_CASE_ST(ut_setup, ut_teardown, test_stats), /** AES GCM Authenticated Encryption */ @@ -8179,10 +8294,31 @@ static struct unit_test_suite cryptodev_qat_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_null_auth_cipher_operation), + /** KASUMI tests */ + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_generate_test_case_1), + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_generate_test_case_2), + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_generate_test_case_3), + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_generate_test_case_4), + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_generate_test_case_5), TEST_CASE_ST(ut_setup, ut_teardown, test_kasumi_hash_generate_test_case_6), - /** KASUMI tests */ + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_verify_test_case_1), + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_verify_test_case_2), + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_verify_test_case_3), + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_verify_test_case_4), + TEST_CASE_ST(ut_setup, ut_teardown, + test_kasumi_hash_verify_test_case_5), + TEST_CASE_ST(ut_setup, ut_teardown, test_kasumi_encryption_test_case_1), TEST_CASE_ST(ut_setup, ut_teardown, @@ -8219,6 +8355,10 @@ static struct unit_test_suite cryptodev_aesni_mb_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all), TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all), TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_DES_cipheronly_mb_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_DES_docsis_mb_all), TEST_CASES_END() /**< NULL terminate unit test array */ } @@ -8240,6 +8380,8 @@ static struct unit_test_suite cryptodev_openssl_testsuite = { test_3DES_chain_openssl_all), TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_openssl_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_DES_cipheronly_openssl_all), TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_openssl_all), TEST_CASE_ST(ut_setup, ut_teardown, @@ -8908,8 +9050,8 @@ test_cryptodev_openssl(void) RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)); if (gbl_driver_id == -1) { - RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if " - "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled " + RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if " + "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled " "in config file to run this testsuite.\n"); return TEST_FAILED; }