summaryrefslogtreecommitdiffstats
path: root/test/test/test_cryptodev_blockcipher.c
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@gmail.com>2017-08-16 18:42:05 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2017-08-16 18:46:04 +0100
commitf239aed5e674965691846e8ce3f187dd47523689 (patch)
treea153a3125c6e183c73871a8ecaa4b285fed5fbd5 /test/test/test_cryptodev_blockcipher.c
parentbf7567fd2a5b0b28ab724046143c24561d38d015 (diff)
New upstream version 17.08
Change-Id: I288b50990f52646089d6b1f3aaa6ba2f091a51d7 Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'test/test/test_cryptodev_blockcipher.c')
-rw-r--r--test/test/test_cryptodev_blockcipher.c130
1 files changed, 66 insertions, 64 deletions
diff --git a/test/test/test_cryptodev_blockcipher.c b/test/test/test_cryptodev_blockcipher.c
index 603c7765..6089af4e 100644
--- a/test/test/test_cryptodev_blockcipher.c
+++ b/test/test/test_cryptodev_blockcipher.c
@@ -35,6 +35,7 @@
#include <rte_mbuf.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
+#include <rte_pause.h>
#include <rte_crypto.h>
#include <rte_cryptodev.h>
@@ -46,14 +47,14 @@
#include "test_cryptodev_aes_test_vectors.h"
#include "test_cryptodev_des_test_vectors.h"
#include "test_cryptodev_hash_test_vectors.h"
-#include "test_cryptodev.h"
static int
test_blockcipher_one_case(const struct blockcipher_test_case *t,
struct rte_mempool *mbuf_pool,
struct rte_mempool *op_mpool,
+ struct rte_mempool *sess_mpool,
uint8_t dev_id,
- enum rte_cryptodev_type cryptodev_type,
+ int driver_id,
char *test_msg)
{
struct rte_mbuf *ibuf = NULL;
@@ -64,8 +65,8 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
struct rte_crypto_sym_xform *init_xform = NULL;
struct rte_crypto_sym_op *sym_op = NULL;
struct rte_crypto_op *op = NULL;
- struct rte_cryptodev_sym_session *sess = NULL;
struct rte_cryptodev_info dev_info;
+ struct rte_cryptodev_sym_session *sess = NULL;
int status = TEST_SUCCESS;
const struct blockcipher_test_data *tdata = t->test_data;
@@ -79,6 +80,19 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
uint8_t tmp_src_buf[MBUF_SIZE];
uint8_t tmp_dst_buf[MBUF_SIZE];
+ int openssl_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
+ int scheduler_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
+ int armv8_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
+ int aesni_mb_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
+ int qat_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
+ int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
+
int nb_segs = 1;
if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
@@ -99,17 +113,15 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
memcpy(auth_key, tdata->auth_key.data,
tdata->auth_key.len);
- switch (cryptodev_type) {
- case RTE_CRYPTODEV_QAT_SYM_PMD:
- case RTE_CRYPTODEV_OPENSSL_PMD:
- case RTE_CRYPTODEV_ARMV8_PMD: /* Fall through */
+ if (driver_id == dpaa2_sec_pmd ||
+ driver_id == qat_pmd ||
+ driver_id == openssl_pmd ||
+ driver_id == armv8_pmd) { /* Fall through */
digest_len = tdata->digest.len;
- break;
- case RTE_CRYPTODEV_AESNI_MB_PMD:
- case RTE_CRYPTODEV_SCHEDULER_PMD:
+ } else if (driver_id == aesni_mb_pmd ||
+ driver_id == scheduler_pmd) {
digest_len = tdata->digest.truncated_len;
- break;
- default:
+ } else {
snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
"line %u FAILED: %s",
__LINE__, "Unsupported PMD type");
@@ -118,8 +130,6 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
}
/* preparing data */
- if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
- buf_len += tdata->iv.len;
if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
buf_len += digest_len;
@@ -145,10 +155,6 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
tdata->ciphertext.data);
- if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
- rte_memcpy(rte_pktmbuf_prepend(ibuf, tdata->iv.len),
- tdata->iv.data, tdata->iv.len);
- }
buf_p = rte_pktmbuf_append(ibuf, digest_len);
if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
rte_memcpy(buf_p, tdata->digest.data, digest_len);
@@ -293,25 +299,19 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
RTE_CRYPTO_CIPHER_OP_DECRYPT;
cipher_xform->cipher.key.data = cipher_key;
cipher_xform->cipher.key.length = tdata->cipher_key.len;
+ cipher_xform->cipher.iv.offset = IV_OFFSET;
+ cipher_xform->cipher.iv.length = tdata->iv.len;
- sym_op->cipher.data.offset = tdata->iv.len;
+ sym_op->cipher.data.offset = 0;
sym_op->cipher.data.length = tdata->ciphertext.len;
- sym_op->cipher.iv.data = rte_pktmbuf_mtod(sym_op->m_src,
- uint8_t *);
- sym_op->cipher.iv.length = tdata->iv.len;
- sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(
- sym_op->m_src);
+ rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
+ tdata->iv.data,
+ tdata->iv.len);
}
if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
- uint32_t auth_data_offset = 0;
uint32_t digest_offset = tdata->ciphertext.len;
- if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
- digest_offset += tdata->iv.len;
- auth_data_offset += tdata->iv.len;
- }
-
auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
auth_xform->auth.algo = tdata->auth_algo;
auth_xform->auth.key.length = tdata->auth_key.len;
@@ -334,15 +334,16 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
digest_offset);
}
- sym_op->auth.data.offset = auth_data_offset;
+ sym_op->auth.data.offset = 0;
sym_op->auth.data.length = tdata->ciphertext.len;
- sym_op->auth.digest.length = digest_len;
}
/* create session for sessioned op */
if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
- sess = rte_cryptodev_sym_session_create(dev_id,
- init_xform);
+ sess = rte_cryptodev_sym_session_create(sess_mpool);
+
+ rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
+ sess_mpool);
if (!sess) {
snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
"FAILED: %s", __LINE__,
@@ -421,7 +422,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
compare_len = tdata->plaintext.len;
}
- if (memcmp(rte_pktmbuf_read(iobuf, tdata->iv.len, compare_len,
+ if (memcmp(rte_pktmbuf_read(iobuf, 0, compare_len,
buffer), compare_ref, compare_len)) {
snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
"FAILED: %s", __LINE__,
@@ -432,13 +433,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
}
if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
- uint8_t *auth_res;
-
- if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
- auth_res = pktmbuf_mtod_offset(iobuf,
- tdata->iv.len + tdata->ciphertext.len);
- else
- auth_res = pktmbuf_mtod_offset(iobuf,
+ uint8_t *auth_res = pktmbuf_mtod_offset(iobuf,
tdata->ciphertext.len);
if (memcmp(auth_res, tdata->digest.data, digest_len)) {
@@ -492,7 +487,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
sym_op->auth.data.offset;
changed_len = sym_op->auth.data.length;
if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
- changed_len += sym_op->auth.digest.length;
+ changed_len += digest_len;
} else {
/* cipher-only */
head_unchanged_len = rte_pktmbuf_headroom(mbuf) +
@@ -534,7 +529,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
}
if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
- changed_len += sym_op->auth.digest.length;
+ changed_len += digest_len;
if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) {
/* white-box test: PMDs use some of the
@@ -568,8 +563,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
error_exit:
if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
- if (sess)
- rte_cryptodev_sym_session_free(dev_id, sess);
+ if (sess) {
+ rte_cryptodev_sym_session_clear(dev_id, sess);
+ rte_cryptodev_sym_session_free(sess);
+ }
if (cipher_xform)
rte_free(cipher_xform);
if (auth_xform)
@@ -591,8 +588,9 @@ error_exit:
int
test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
struct rte_mempool *op_mpool,
+ struct rte_mempool *sess_mpool,
uint8_t dev_id,
- enum rte_cryptodev_type cryptodev_type,
+ int driver_id,
enum blockcipher_test_type test_type)
{
int status, overall_status = TEST_SUCCESS;
@@ -602,6 +600,19 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
uint32_t target_pmd_mask = 0;
const struct blockcipher_test_case *tcs = NULL;
+ int openssl_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
+ int dpaa2_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
+ int scheduler_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
+ int armv8_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
+ int aesni_mb_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
+ int qat_pmd = rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
+
switch (test_type) {
case BLKCIPHER_AES_CHAIN_TYPE:
n_test_cases = sizeof(aes_chain_test_cases) /
@@ -647,29 +658,20 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
break;
}
- switch (cryptodev_type) {
- case RTE_CRYPTODEV_AESNI_MB_PMD:
+ if (driver_id == aesni_mb_pmd)
target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB;
- break;
- case RTE_CRYPTODEV_QAT_SYM_PMD:
+ else if (driver_id == qat_pmd)
target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT;
- break;
- case RTE_CRYPTODEV_OPENSSL_PMD:
+ else if (driver_id == openssl_pmd)
target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL;
- break;
- case RTE_CRYPTODEV_ARMV8_PMD:
+ else if (driver_id == armv8_pmd)
target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8;
- break;
- case RTE_CRYPTODEV_SCHEDULER_PMD:
+ else if (driver_id == scheduler_pmd)
target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER;
- break;
- case RTE_CRYPTODEV_DPAA2_SEC_PMD:
+ else if (driver_id == dpaa2_pmd)
target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC;
- break;
- default:
+ else
TEST_ASSERT(0, "Unrecognized cryptodev type");
- break;
- }
for (i = 0; i < n_test_cases; i++) {
const struct blockcipher_test_case *tc = &tcs[i];
@@ -678,7 +680,7 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
continue;
status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
- dev_id, cryptodev_type, test_msg);
+ sess_mpool, dev_id, driver_id, test_msg);
printf(" %u) TestCase %s %s\n", test_index ++,
tc->test_descr, test_msg);