cryptodev: do not use AAD in wireless algorithms

For wireless algorithms (SNOW3G, KASUMI, ZUC),
the IV for the authentication algorithms (F9, UIA2 and EIA3)
was taken from the AAD parameter, as there was no IV parameter
in the authentication structure.

Now that IV is available for all algorithms, there is need
to keep doing this, so AAD is not used for these algorithms
anymore.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Declan Doherty <declan.doherty@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
This commit is contained in:
Pablo de Lara 2017-07-02 06:41:16 +01:00
parent acf8616901
commit 681f540da5
22 changed files with 332 additions and 420 deletions

View File

@ -488,12 +488,6 @@ cperf_test_vector_get_dummy(struct cperf_options *options)
t_vec->auth_key.data = NULL; t_vec->auth_key.data = NULL;
aad_alloc = 1; aad_alloc = 1;
break; break;
case RTE_CRYPTO_AUTH_SNOW3G_UIA2:
case RTE_CRYPTO_AUTH_KASUMI_F9:
case RTE_CRYPTO_AUTH_ZUC_EIA3:
t_vec->auth_key.data = auth_key;
aad_alloc = 1;
break;
case RTE_CRYPTO_AUTH_AES_GMAC: case RTE_CRYPTO_AUTH_AES_GMAC:
/* auth key should be the same as cipher key */ /* auth key should be the same as cipher key */
t_vec->auth_key.data = cipher_key; t_vec->auth_key.data = cipher_key;

View File

@ -117,7 +117,7 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_KASUMI_F8) if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_KASUMI_F8)
return -EINVAL; return -EINVAL;
sess->iv_offset = cipher_xform->cipher.iv.offset; sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;
if (cipher_xform->cipher.iv.length != KASUMI_IV_LENGTH) { if (cipher_xform->cipher.iv.length != KASUMI_IV_LENGTH) {
KASUMI_LOG_ERR("Wrong IV length"); KASUMI_LOG_ERR("Wrong IV length");
return -EINVAL; return -EINVAL;
@ -133,6 +133,13 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_KASUMI_F9) if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_KASUMI_F9)
return -EINVAL; return -EINVAL;
sess->auth_op = auth_xform->auth.op; sess->auth_op = auth_xform->auth.op;
sess->auth_iv_offset = auth_xform->auth.iv.offset;
if (auth_xform->auth.iv.length != KASUMI_IV_LENGTH) {
KASUMI_LOG_ERR("Wrong IV length");
return -EINVAL;
}
/* Initialize key */ /* Initialize key */
sso_kasumi_init_f9_key_sched(auth_xform->auth.key.data, sso_kasumi_init_f9_key_sched(auth_xform->auth.key.data,
&sess->pKeySched_hash); &sess->pKeySched_hash);
@ -194,7 +201,7 @@ process_kasumi_cipher_op(struct rte_crypto_op **ops,
rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
(ops[i]->sym->cipher.data.offset >> 3); (ops[i]->sym->cipher.data.offset >> 3);
iv_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *, iv_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->iv_offset); session->cipher_iv_offset);
iv[i] = *((uint64_t *)(iv_ptr)); iv[i] = *((uint64_t *)(iv_ptr));
num_bytes[i] = ops[i]->sym->cipher.data.length >> 3; num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
@ -227,7 +234,7 @@ process_kasumi_cipher_op_bit(struct rte_crypto_op *op,
} }
dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *); dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
session->iv_offset); session->cipher_iv_offset);
iv = *((uint64_t *)(iv_ptr)); iv = *((uint64_t *)(iv_ptr));
length_in_bits = op->sym->cipher.data.length; length_in_bits = op->sym->cipher.data.length;
@ -246,6 +253,7 @@ process_kasumi_hash_op(struct rte_crypto_op **ops,
unsigned i; unsigned i;
uint8_t processed_ops = 0; uint8_t processed_ops = 0;
uint8_t *src, *dst; uint8_t *src, *dst;
uint8_t *iv_ptr;
uint32_t length_in_bits; uint32_t length_in_bits;
uint32_t num_bytes; uint32_t num_bytes;
uint32_t shift_bits; uint32_t shift_bits;
@ -253,12 +261,6 @@ process_kasumi_hash_op(struct rte_crypto_op **ops,
uint8_t direction; uint8_t direction;
for (i = 0; i < num_ops; i++) { for (i = 0; i < num_ops; i++) {
if (unlikely(ops[i]->sym->auth.aad.length != KASUMI_IV_LENGTH)) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
KASUMI_LOG_ERR("aad");
break;
}
if (unlikely(ops[i]->sym->auth.digest.length != KASUMI_DIGEST_LENGTH)) { if (unlikely(ops[i]->sym->auth.digest.length != KASUMI_DIGEST_LENGTH)) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
KASUMI_LOG_ERR("digest"); KASUMI_LOG_ERR("digest");
@ -276,8 +278,9 @@ process_kasumi_hash_op(struct rte_crypto_op **ops,
src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
(ops[i]->sym->auth.data.offset >> 3); (ops[i]->sym->auth.data.offset >> 3);
/* IV from AAD */ iv_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
iv = *((uint64_t *)(ops[i]->sym->auth.aad.data)); session->auth_iv_offset);
iv = *((uint64_t *)(iv_ptr));
/* Direction from next bit after end of message */ /* Direction from next bit after end of message */
num_bytes = (length_in_bits >> 3) + 1; num_bytes = (length_in_bits >> 3) + 1;
shift_bits = (BYTE_LEN - 1 - length_in_bits) % BYTE_LEN; shift_bits = (BYTE_LEN - 1 - length_in_bits) % BYTE_LEN;

View File

@ -56,12 +56,12 @@ static const struct rte_cryptodev_capabilities kasumi_pmd_capabilities[] = {
.max = 4, .max = 4,
.increment = 0 .increment = 0
}, },
.aad_size = { .iv_size = {
.min = 8, .min = 8,
.max = 8, .max = 8,
.increment = 0 .increment = 0
}, },
.iv_size = { 0 } .aad_size = { 0 }
}, } }, }
}, } }, }
}, },

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2016 Intel Corporation. All rights reserved. * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -92,7 +92,8 @@ struct kasumi_session {
sso_kasumi_key_sched_t pKeySched_hash; sso_kasumi_key_sched_t pKeySched_hash;
enum kasumi_operation op; enum kasumi_operation op;
enum rte_crypto_auth_operation auth_op; enum rte_crypto_auth_operation auth_op;
uint16_t iv_offset; uint16_t cipher_iv_offset;
uint16_t auth_iv_offset;
} __rte_cache_aligned; } __rte_cache_aligned;

View File

@ -17,7 +17,7 @@
* qat-linux@intel.com * qat-linux@intel.com
* *
* BSD LICENSE * BSD LICENSE
* Copyright(c) 2015-2016 Intel Corporation. * Copyright(c) 2015-2017 Intel Corporation.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@ -130,7 +130,11 @@ struct qat_session {
struct { struct {
uint16_t offset; uint16_t offset;
uint16_t length; uint16_t length;
} iv; } cipher_iv;
struct {
uint16_t offset;
uint16_t length;
} auth_iv;
rte_spinlock_t lock; /* protects this struct */ rte_spinlock_t lock; /* protects this struct */
}; };

View File

@ -17,7 +17,7 @@
* qat-linux@intel.com * qat-linux@intel.com
* *
* BSD LICENSE * BSD LICENSE
* Copyright(c) 2015-2016 Intel Corporation. * Copyright(c) 2015-2017 Intel Corporation.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@ -837,8 +837,7 @@ int qat_alg_aead_session_create_content_desc_auth(struct qat_session *cdesc,
0, ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ); 0, ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ);
cdesc->cd_cur_ptr += sizeof(struct icp_qat_hw_cipher_config) + cdesc->cd_cur_ptr += sizeof(struct icp_qat_hw_cipher_config) +
authkeylen + ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ; authkeylen + ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ;
auth_param->hash_state_sz = auth_param->hash_state_sz = ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ >> 3;
RTE_ALIGN_CEIL(add_auth_data_length, 16) >> 3;
break; break;
case ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3: case ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3:
hash->auth_config.config = hash->auth_config.config =
@ -854,8 +853,7 @@ int qat_alg_aead_session_create_content_desc_auth(struct qat_session *cdesc,
memcpy(cdesc->cd_cur_ptr + state1_size, authkey, authkeylen); memcpy(cdesc->cd_cur_ptr + state1_size, authkey, authkeylen);
cdesc->cd_cur_ptr += state1_size + state2_size cdesc->cd_cur_ptr += state1_size + state2_size
+ ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ; + ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ;
auth_param->hash_state_sz = auth_param->hash_state_sz = ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ >> 3;
RTE_ALIGN_CEIL(add_auth_data_length, 16) >> 3;
break; break;
case ICP_QAT_HW_AUTH_ALGO_MD5: case ICP_QAT_HW_AUTH_ALGO_MD5:

View File

@ -298,8 +298,8 @@ qat_crypto_sym_configure_session_cipher(struct rte_cryptodev *dev,
/* Get cipher xform from crypto xform chain */ /* Get cipher xform from crypto xform chain */
cipher_xform = qat_get_cipher_xform(xform); cipher_xform = qat_get_cipher_xform(xform);
session->iv.offset = cipher_xform->iv.offset; session->cipher_iv.offset = cipher_xform->iv.offset;
session->iv.length = cipher_xform->iv.length; session->cipher_iv.length = cipher_xform->iv.length;
switch (cipher_xform->algo) { switch (cipher_xform->algo) {
case RTE_CRYPTO_CIPHER_AES_CBC: case RTE_CRYPTO_CIPHER_AES_CBC:
@ -584,6 +584,9 @@ qat_crypto_sym_configure_session_auth(struct rte_cryptodev *dev,
} }
cipher_xform = qat_get_cipher_xform(xform); cipher_xform = qat_get_cipher_xform(xform);
session->auth_iv.offset = auth_xform->iv.offset;
session->auth_iv.length = auth_xform->iv.length;
if ((session->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_GALOIS_128) || if ((session->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_GALOIS_128) ||
(session->qat_hash_alg == (session->qat_hash_alg ==
ICP_QAT_HW_AUTH_ALGO_GALOIS_64)) { ICP_QAT_HW_AUTH_ALGO_GALOIS_64)) {
@ -646,7 +649,7 @@ qat_bpicipher_preprocess(struct qat_session *ctx,
else else
/* runt block, i.e. less than one full block */ /* runt block, i.e. less than one full block */
iv = rte_crypto_op_ctod_offset(op, uint8_t *, iv = rte_crypto_op_ctod_offset(op, uint8_t *,
ctx->iv.offset); ctx->cipher_iv.offset);
#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX #ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX
rte_hexdump(stdout, "BPI: src before pre-process:", last_block, rte_hexdump(stdout, "BPI: src before pre-process:", last_block,
@ -702,7 +705,7 @@ qat_bpicipher_postprocess(struct qat_session *ctx,
else else
/* runt block, i.e. less than one full block */ /* runt block, i.e. less than one full block */
iv = rte_crypto_op_ctod_offset(op, uint8_t *, iv = rte_crypto_op_ctod_offset(op, uint8_t *,
ctx->iv.offset); ctx->cipher_iv.offset);
#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_RX #ifdef RTE_LIBRTE_PMD_QAT_DEBUG_RX
rte_hexdump(stdout, "BPI: src before post-process:", last_block, rte_hexdump(stdout, "BPI: src before post-process:", last_block,
@ -903,8 +906,7 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
uint32_t min_ofs = 0; uint32_t min_ofs = 0;
uint64_t src_buf_start = 0, dst_buf_start = 0; uint64_t src_buf_start = 0, dst_buf_start = 0;
uint8_t do_sgl = 0; uint8_t do_sgl = 0;
uint8_t *iv_ptr; uint8_t *cipher_iv_ptr = NULL;
#ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX #ifdef RTE_LIBRTE_PMD_QAT_DEBUG_TX
if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) { if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) {
@ -977,21 +979,21 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
cipher_ofs = op->sym->cipher.data.offset; cipher_ofs = op->sym->cipher.data.offset;
} }
iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, cipher_iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
ctx->iv.offset); ctx->cipher_iv.offset);
/* copy IV into request if it fits */ /* copy IV into request if it fits */
if (ctx->iv.length <= if (ctx->cipher_iv.length <=
sizeof(cipher_param->u.cipher_IV_array)) { sizeof(cipher_param->u.cipher_IV_array)) {
rte_memcpy(cipher_param->u.cipher_IV_array, rte_memcpy(cipher_param->u.cipher_IV_array,
iv_ptr, cipher_iv_ptr,
ctx->iv.length); ctx->cipher_iv.length);
} else { } else {
ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET( ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET(
qat_req->comn_hdr.serv_specif_flags, qat_req->comn_hdr.serv_specif_flags,
ICP_QAT_FW_CIPH_IV_64BIT_PTR); ICP_QAT_FW_CIPH_IV_64BIT_PTR);
cipher_param->u.s.cipher_IV_ptr = cipher_param->u.s.cipher_IV_ptr =
rte_crypto_op_ctophys_offset(op, rte_crypto_op_ctophys_offset(op,
ctx->iv.offset); ctx->cipher_iv.offset);
} }
min_ofs = cipher_ofs; min_ofs = cipher_ofs;
} }
@ -1022,7 +1024,10 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
auth_len = auth_len + auth_ofs + 1; auth_len = auth_len + auth_ofs + 1;
auth_ofs = 0; auth_ofs = 0;
} }
} } else
auth_param->u1.aad_adr =
rte_crypto_op_ctophys_offset(op,
ctx->auth_iv.offset);
} else if (ctx->qat_hash_alg == } else if (ctx->qat_hash_alg ==
ICP_QAT_HW_AUTH_ALGO_GALOIS_128 || ICP_QAT_HW_AUTH_ALGO_GALOIS_128 ||
@ -1030,16 +1035,17 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
ICP_QAT_HW_AUTH_ALGO_GALOIS_64) { ICP_QAT_HW_AUTH_ALGO_GALOIS_64) {
auth_ofs = op->sym->cipher.data.offset; auth_ofs = op->sym->cipher.data.offset;
auth_len = op->sym->cipher.data.length; auth_len = op->sym->cipher.data.length;
auth_param->u1.aad_adr = op->sym->auth.aad.phys_addr;
} else { } else {
auth_ofs = op->sym->auth.data.offset; auth_ofs = op->sym->auth.data.offset;
auth_len = op->sym->auth.data.length; auth_len = op->sym->auth.data.length;
} }
min_ofs = auth_ofs; min_ofs = auth_ofs;
auth_param->auth_res_addr = op->sym->auth.digest.phys_addr; auth_param->auth_res_addr = op->sym->auth.digest.phys_addr;
auth_param->u1.aad_adr = op->sym->auth.aad.phys_addr;
} }
if (op->sym->m_src->next || (op->sym->m_dst && op->sym->m_dst->next)) if (op->sym->m_src->next || (op->sym->m_dst && op->sym->m_dst->next))
@ -1147,7 +1153,7 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
if (ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_GALOIS_128 || if (ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_GALOIS_128 ||
ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_GALOIS_64) { ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_GALOIS_64) {
if (ctx->iv.length == 12) { if (ctx->cipher_iv.length == 12) {
/* /*
* For GCM a 12 byte IV is allowed, * For GCM a 12 byte IV is allowed,
* but we need to inform the f/w * but we need to inform the f/w
@ -1182,10 +1188,17 @@ qat_write_hw_desc_entry(struct rte_crypto_op *op, uint8_t *out_msg,
rte_pktmbuf_mtod(op->sym->m_src, uint8_t*), rte_pktmbuf_mtod(op->sym->m_src, uint8_t*),
rte_pktmbuf_data_len(op->sym->m_src)); rte_pktmbuf_data_len(op->sym->m_src));
if (do_cipher) if (do_cipher)
rte_hexdump(stdout, "iv:", iv_ptr, rte_hexdump(stdout, "cipher iv:", cipher_iv_ptr,
ctx->iv.length); ctx->cipher_iv.length);
if (do_auth) { if (do_auth) {
if (ctx->auth_iv.length) {
uint8_t *auth_iv_ptr = rte_crypto_op_ctod_offset(op,
uint8_t *,
ctx->auth_iv.offset);
rte_hexdump(stdout, "auth iv:", auth_iv_ptr,
ctx->auth_iv.length);
}
rte_hexdump(stdout, "digest:", op->sym->auth.digest.data, rte_hexdump(stdout, "digest:", op->sym->auth.digest.data,
op->sym->auth.digest.length); op->sym->auth.digest.length);
rte_hexdump(stdout, "aad:", op->sym->auth.aad.data, rte_hexdump(stdout, "aad:", op->sym->auth.aad.data,

View File

@ -258,12 +258,12 @@
.max = 4, \ .max = 4, \
.increment = 0 \ .increment = 0 \
}, \ }, \
.aad_size = { \ .iv_size = { \
.min = 16, \ .min = 16, \
.max = 16, \ .max = 16, \
.increment = 0 \ .increment = 0 \
}, \ }, \
.iv_size = { 0 } \ .aad_size = { 0 } \
}, } \ }, } \
}, } \ }, } \
}, \ }, \
@ -446,12 +446,12 @@
.max = 4, \ .max = 4, \
.increment = 0 \ .increment = 0 \
}, \ }, \
.aad_size = { \ .iv_size = { \
.min = 8, \ .min = 8, \
.max = 8, \ .max = 8, \
.increment = 0 \ .increment = 0 \
}, \ }, \
.iv_size = { 0 } \ .aad_size = { 0 } \
}, } \ }, } \
}, } \ }, } \
}, \ }, \
@ -574,12 +574,12 @@
.max = 4, \ .max = 4, \
.increment = 0 \ .increment = 0 \
}, \ }, \
.aad_size = { \ .iv_size = { \
.min = 16, \ .min = 16, \
.max = 16, \ .max = 16, \
.increment = 0 \ .increment = 0 \
}, \ }, \
.iv_size = { 0 } \ .aad_size = { 0 } \
}, } \ }, } \
}, } \ }, } \
} }

View File

@ -121,7 +121,7 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
SNOW3G_LOG_ERR("Wrong IV length"); SNOW3G_LOG_ERR("Wrong IV length");
return -EINVAL; return -EINVAL;
} }
sess->iv_offset = cipher_xform->cipher.iv.offset; sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;
/* Initialize key */ /* Initialize key */
sso_snow3g_init_key_sched(cipher_xform->cipher.key.data, sso_snow3g_init_key_sched(cipher_xform->cipher.key.data,
@ -133,6 +133,13 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_SNOW3G_UIA2) if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_SNOW3G_UIA2)
return -EINVAL; return -EINVAL;
sess->auth_op = auth_xform->auth.op; sess->auth_op = auth_xform->auth.op;
if (auth_xform->auth.iv.length != SNOW3G_IV_LENGTH) {
SNOW3G_LOG_ERR("Wrong IV length");
return -EINVAL;
}
sess->auth_iv_offset = auth_xform->auth.iv.offset;
/* Initialize key */ /* Initialize key */
sso_snow3g_init_key_sched(auth_xform->auth.key.data, sso_snow3g_init_key_sched(auth_xform->auth.key.data,
&sess->pKeySched_hash); &sess->pKeySched_hash);
@ -193,7 +200,7 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
(ops[i]->sym->cipher.data.offset >> 3); (ops[i]->sym->cipher.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *, iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->iv_offset); session->cipher_iv_offset);
num_bytes[i] = ops[i]->sym->cipher.data.length >> 3; num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
processed_ops++; processed_ops++;
@ -223,7 +230,7 @@ process_snow3g_cipher_op_bit(struct rte_crypto_op *op,
} }
dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *); dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
iv = rte_crypto_op_ctod_offset(op, uint8_t *, iv = rte_crypto_op_ctod_offset(op, uint8_t *,
session->iv_offset); session->cipher_iv_offset);
length_in_bits = op->sym->cipher.data.length; length_in_bits = op->sym->cipher.data.length;
sso_snow3g_f8_1_buffer_bit(&session->pKeySched_cipher, iv, sso_snow3g_f8_1_buffer_bit(&session->pKeySched_cipher, iv,
@ -242,14 +249,9 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
uint8_t processed_ops = 0; uint8_t processed_ops = 0;
uint8_t *src, *dst; uint8_t *src, *dst;
uint32_t length_in_bits; uint32_t length_in_bits;
uint8_t *iv;
for (i = 0; i < num_ops; i++) { for (i = 0; i < num_ops; i++) {
if (unlikely(ops[i]->sym->auth.aad.length != SNOW3G_IV_LENGTH)) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
SNOW3G_LOG_ERR("aad");
break;
}
if (unlikely(ops[i]->sym->auth.digest.length != SNOW3G_DIGEST_LENGTH)) { if (unlikely(ops[i]->sym->auth.digest.length != SNOW3G_DIGEST_LENGTH)) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
SNOW3G_LOG_ERR("digest"); SNOW3G_LOG_ERR("digest");
@ -267,13 +269,15 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
(ops[i]->sym->auth.data.offset >> 3); (ops[i]->sym->auth.data.offset >> 3);
iv = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->auth_iv_offset);
if (session->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) { if (session->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) {
dst = (uint8_t *)rte_pktmbuf_append(ops[i]->sym->m_src, dst = (uint8_t *)rte_pktmbuf_append(ops[i]->sym->m_src,
ops[i]->sym->auth.digest.length); ops[i]->sym->auth.digest.length);
sso_snow3g_f9_1_buffer(&session->pKeySched_hash, sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
ops[i]->sym->auth.aad.data, src, iv, src,
length_in_bits, dst); length_in_bits, dst);
/* Verify digest. */ /* Verify digest. */
if (memcmp(dst, ops[i]->sym->auth.digest.data, if (memcmp(dst, ops[i]->sym->auth.digest.data,
@ -287,7 +291,7 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
dst = ops[i]->sym->auth.digest.data; dst = ops[i]->sym->auth.digest.data;
sso_snow3g_f9_1_buffer(&session->pKeySched_hash, sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
ops[i]->sym->auth.aad.data, src, iv, src,
length_in_bits, dst); length_in_bits, dst);
} }
processed_ops++; processed_ops++;

View File

@ -56,12 +56,12 @@ static const struct rte_cryptodev_capabilities snow3g_pmd_capabilities[] = {
.max = 4, .max = 4,
.increment = 0 .increment = 0
}, },
.aad_size = { .iv_size = {
.min = 16, .min = 16,
.max = 16, .max = 16,
.increment = 0 .increment = 0
}, },
.iv_size = { 0 }, .aad_size = { 0 }
}, } }, }
}, } }, }
}, },

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2016 Intel Corporation. All rights reserved. * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -91,7 +91,8 @@ struct snow3g_session {
enum rte_crypto_auth_operation auth_op; enum rte_crypto_auth_operation auth_op;
sso_snow3g_key_schedule_t pKeySched_cipher; sso_snow3g_key_schedule_t pKeySched_cipher;
sso_snow3g_key_schedule_t pKeySched_hash; sso_snow3g_key_schedule_t pKeySched_hash;
uint16_t iv_offset; uint16_t cipher_iv_offset;
uint16_t auth_iv_offset;
} __rte_cache_aligned; } __rte_cache_aligned;

View File

@ -120,7 +120,7 @@ zuc_set_session_parameters(struct zuc_session *sess,
ZUC_LOG_ERR("Wrong IV length"); ZUC_LOG_ERR("Wrong IV length");
return -EINVAL; return -EINVAL;
} }
sess->iv_offset = cipher_xform->cipher.iv.offset; sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;
/* Copy the key */ /* Copy the key */
memcpy(sess->pKey_cipher, cipher_xform->cipher.key.data, memcpy(sess->pKey_cipher, cipher_xform->cipher.key.data,
@ -132,6 +132,13 @@ zuc_set_session_parameters(struct zuc_session *sess,
if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_ZUC_EIA3) if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_ZUC_EIA3)
return -EINVAL; return -EINVAL;
sess->auth_op = auth_xform->auth.op; sess->auth_op = auth_xform->auth.op;
if (auth_xform->auth.iv.length != ZUC_IV_KEY_LENGTH) {
ZUC_LOG_ERR("Wrong IV length");
return -EINVAL;
}
sess->auth_iv_offset = auth_xform->auth.iv.offset;
/* Copy the key */ /* Copy the key */
memcpy(sess->pKey_hash, auth_xform->auth.key.data, memcpy(sess->pKey_hash, auth_xform->auth.key.data,
ZUC_IV_KEY_LENGTH); ZUC_IV_KEY_LENGTH);
@ -214,7 +221,7 @@ process_zuc_cipher_op(struct rte_crypto_op **ops,
rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
(ops[i]->sym->cipher.data.offset >> 3); (ops[i]->sym->cipher.data.offset >> 3);
iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *, iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->iv_offset); session->cipher_iv_offset);
num_bytes[i] = ops[i]->sym->cipher.data.length >> 3; num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
cipher_keys[i] = session->pKey_cipher; cipher_keys[i] = session->pKey_cipher;
@ -239,14 +246,9 @@ process_zuc_hash_op(struct rte_crypto_op **ops,
uint8_t *src; uint8_t *src;
uint32_t *dst; uint32_t *dst;
uint32_t length_in_bits; uint32_t length_in_bits;
uint8_t *iv;
for (i = 0; i < num_ops; i++) { for (i = 0; i < num_ops; i++) {
if (unlikely(ops[i]->sym->auth.aad.length != ZUC_IV_KEY_LENGTH)) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
ZUC_LOG_ERR("aad");
break;
}
if (unlikely(ops[i]->sym->auth.digest.length != ZUC_DIGEST_LENGTH)) { if (unlikely(ops[i]->sym->auth.digest.length != ZUC_DIGEST_LENGTH)) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
ZUC_LOG_ERR("digest"); ZUC_LOG_ERR("digest");
@ -264,13 +266,15 @@ process_zuc_hash_op(struct rte_crypto_op **ops,
src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
(ops[i]->sym->auth.data.offset >> 3); (ops[i]->sym->auth.data.offset >> 3);
iv = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
session->auth_iv_offset);
if (session->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) { if (session->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) {
dst = (uint32_t *)rte_pktmbuf_append(ops[i]->sym->m_src, dst = (uint32_t *)rte_pktmbuf_append(ops[i]->sym->m_src,
ops[i]->sym->auth.digest.length); ops[i]->sym->auth.digest.length);
sso_zuc_eia3_1_buffer(session->pKey_hash, sso_zuc_eia3_1_buffer(session->pKey_hash,
ops[i]->sym->auth.aad.data, src, iv, src,
length_in_bits, dst); length_in_bits, dst);
/* Verify digest. */ /* Verify digest. */
if (memcmp(dst, ops[i]->sym->auth.digest.data, if (memcmp(dst, ops[i]->sym->auth.digest.data,
@ -284,7 +288,7 @@ process_zuc_hash_op(struct rte_crypto_op **ops,
dst = (uint32_t *)ops[i]->sym->auth.digest.data; dst = (uint32_t *)ops[i]->sym->auth.digest.data;
sso_zuc_eia3_1_buffer(session->pKey_hash, sso_zuc_eia3_1_buffer(session->pKey_hash,
ops[i]->sym->auth.aad.data, src, iv, src,
length_in_bits, dst); length_in_bits, dst);
} }
processed_ops++; processed_ops++;

View File

@ -56,12 +56,12 @@ static const struct rte_cryptodev_capabilities zuc_pmd_capabilities[] = {
.max = 4, .max = 4,
.increment = 0 .increment = 0
}, },
.aad_size = { .iv_size = {
.min = 16, .min = 16,
.max = 16, .max = 16,
.increment = 0 .increment = 0
}, },
.iv_size = { 0 } .aad_size = { 0 }
}, } }, }
}, } }, }
}, },

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2016 Intel Corporation. All rights reserved. * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -92,7 +92,8 @@ struct zuc_session {
enum rte_crypto_auth_operation auth_op; enum rte_crypto_auth_operation auth_op;
uint8_t pKey_cipher[ZUC_IV_KEY_LENGTH]; uint8_t pKey_cipher[ZUC_IV_KEY_LENGTH];
uint8_t pKey_hash[ZUC_IV_KEY_LENGTH]; uint8_t pKey_hash[ZUC_IV_KEY_LENGTH];
uint16_t iv_offset; uint16_t cipher_iv_offset;
uint16_t auth_iv_offset;
} __rte_cache_aligned; } __rte_cache_aligned;

View File

@ -373,9 +373,6 @@ struct rte_crypto_auth_xform {
* This field must be specified when the hash algorithm is one of the * This field must be specified when the hash algorithm is one of the
* following: * following:
* *
* - For SNOW 3G (@ref RTE_CRYPTO_AUTH_SNOW3G_UIA2), this is the
* length of the IV (which should be 16).
*
* - For GCM (@ref RTE_CRYPTO_AUTH_AES_GCM). In this case, this is * - For GCM (@ref RTE_CRYPTO_AUTH_AES_GCM). In this case, this is
* the length of the Additional Authenticated Data (called A, in NIST * the length of the Additional Authenticated Data (called A, in NIST
* SP800-38D). * SP800-38D).
@ -617,9 +614,7 @@ struct rte_crypto_sym_op {
uint8_t *data; uint8_t *data;
/**< Pointer to Additional Authenticated Data (AAD) /**< Pointer to Additional Authenticated Data (AAD)
* needed for authenticated cipher mechanisms (CCM and * needed for authenticated cipher mechanisms (CCM and
* GCM), and to the IV for SNOW 3G authentication * GCM).
* (@ref RTE_CRYPTO_AUTH_SNOW3G_UIA2). For other
* authentication mechanisms this pointer is ignored.
* *
* The length of the data pointed to by this field is * The length of the data pointed to by this field is
* set up for the session in the @ref * set up for the session in the @ref

View File

@ -1775,7 +1775,7 @@ test_AES_chain_armv8_all(void)
static int static int
create_wireless_algo_hash_session(uint8_t dev_id, create_wireless_algo_hash_session(uint8_t dev_id,
const uint8_t *key, const uint8_t key_len, const uint8_t *key, const uint8_t key_len,
const uint8_t aad_len, const uint8_t auth_len, const uint8_t iv_len, const uint8_t auth_len,
enum rte_crypto_auth_operation op, enum rte_crypto_auth_operation op,
enum rte_crypto_auth_algorithm algo) enum rte_crypto_auth_algorithm algo)
{ {
@ -1796,7 +1796,8 @@ create_wireless_algo_hash_session(uint8_t dev_id,
ut_params->auth_xform.auth.key.length = key_len; ut_params->auth_xform.auth.key.length = key_len;
ut_params->auth_xform.auth.key.data = hash_key; ut_params->auth_xform.auth.key.data = hash_key;
ut_params->auth_xform.auth.digest_length = auth_len; ut_params->auth_xform.auth.digest_length = auth_len;
ut_params->auth_xform.auth.add_auth_data_length = aad_len; ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
ut_params->auth_xform.auth.iv.length = iv_len;
ut_params->sess = rte_cryptodev_sym_session_create(dev_id, ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
&ut_params->auth_xform); &ut_params->auth_xform);
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
@ -1904,9 +1905,9 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
enum rte_crypto_auth_operation auth_op, enum rte_crypto_auth_operation auth_op,
enum rte_crypto_auth_algorithm auth_algo, enum rte_crypto_auth_algorithm auth_algo,
enum rte_crypto_cipher_algorithm cipher_algo, enum rte_crypto_cipher_algorithm cipher_algo,
const uint8_t *key, const uint8_t key_len, const uint8_t *key, uint8_t key_len,
const uint8_t aad_len, const uint8_t auth_len, uint8_t auth_iv_len, uint8_t auth_len,
uint8_t iv_len) uint8_t cipher_iv_len)
{ {
uint8_t cipher_auth_key[key_len]; uint8_t cipher_auth_key[key_len];
@ -1925,7 +1926,9 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
/* Hash key = cipher key */ /* Hash key = cipher key */
ut_params->auth_xform.auth.key.data = cipher_auth_key; ut_params->auth_xform.auth.key.data = cipher_auth_key;
ut_params->auth_xform.auth.digest_length = auth_len; ut_params->auth_xform.auth.digest_length = auth_len;
ut_params->auth_xform.auth.add_auth_data_length = aad_len; /* Auth IV will be after cipher IV */
ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
ut_params->auth_xform.auth.iv.length = auth_iv_len;
/* Setup Cipher Parameters */ /* Setup Cipher Parameters */
ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@ -1936,7 +1939,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id,
ut_params->cipher_xform.cipher.key.data = cipher_auth_key; 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.length = key_len;
ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
ut_params->cipher_xform.cipher.iv.length = iv_len; ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
TEST_HEXDUMP(stdout, "key:", key, key_len); TEST_HEXDUMP(stdout, "key:", key, key_len);
@ -1961,9 +1964,9 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
struct crypto_unittest_params *ut_params = &unittest_params; struct crypto_unittest_params *ut_params = &unittest_params;
const uint8_t *key = tdata->key.data; const uint8_t *key = tdata->key.data;
const uint8_t aad_len = tdata->aad.len;
const uint8_t auth_len = tdata->digest.len; const uint8_t auth_len = tdata->digest.len;
uint8_t iv_len = tdata->iv.len; uint8_t cipher_iv_len = tdata->cipher_iv.len;
uint8_t auth_iv_len = tdata->auth_iv.len;
memcpy(cipher_auth_key, key, key_len); memcpy(cipher_auth_key, key, key_len);
@ -1977,7 +1980,9 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
/* Hash key = cipher key */ /* Hash key = cipher key */
ut_params->auth_xform.auth.key.data = cipher_auth_key; ut_params->auth_xform.auth.key.data = cipher_auth_key;
ut_params->auth_xform.auth.digest_length = auth_len; ut_params->auth_xform.auth.digest_length = auth_len;
ut_params->auth_xform.auth.add_auth_data_length = aad_len; /* Auth IV will be after cipher IV */
ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
ut_params->auth_xform.auth.iv.length = auth_iv_len;
/* Setup Cipher Parameters */ /* Setup Cipher Parameters */
ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@ -1988,7 +1993,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id,
ut_params->cipher_xform.cipher.key.data = cipher_auth_key; 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.length = key_len;
ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
ut_params->cipher_xform.cipher.iv.length = iv_len; ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
TEST_HEXDUMP(stdout, "key:", key, key_len); TEST_HEXDUMP(stdout, "key:", key, key_len);
@ -2018,8 +2023,8 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
enum rte_crypto_auth_algorithm auth_algo, enum rte_crypto_auth_algorithm auth_algo,
enum rte_crypto_cipher_algorithm cipher_algo, enum rte_crypto_cipher_algorithm cipher_algo,
const uint8_t *key, const uint8_t key_len, const uint8_t *key, const uint8_t key_len,
const uint8_t aad_len, const uint8_t auth_len, uint8_t auth_iv_len, uint8_t auth_len,
uint8_t iv_len) uint8_t cipher_iv_len)
{ {
uint8_t auth_cipher_key[key_len]; uint8_t auth_cipher_key[key_len];
@ -2035,7 +2040,9 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
ut_params->auth_xform.auth.key.length = key_len; 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.data = auth_cipher_key;
ut_params->auth_xform.auth.digest_length = auth_len; ut_params->auth_xform.auth.digest_length = auth_len;
ut_params->auth_xform.auth.add_auth_data_length = aad_len; /* Auth IV will be after cipher IV */
ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
ut_params->auth_xform.auth.iv.length = auth_iv_len;
/* Setup Cipher Parameters */ /* Setup Cipher Parameters */
ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@ -2045,7 +2052,7 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
ut_params->cipher_xform.cipher.key.data = auth_cipher_key; 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.length = key_len;
ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
ut_params->cipher_xform.cipher.iv.length = iv_len; ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
TEST_HEXDUMP(stdout, "key:", key, key_len); TEST_HEXDUMP(stdout, "key:", key, key_len);
@ -2060,19 +2067,16 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id,
static int static int
create_wireless_algo_hash_operation(const uint8_t *auth_tag, create_wireless_algo_hash_operation(const uint8_t *auth_tag,
const unsigned auth_tag_len, unsigned int auth_tag_len,
const uint8_t *aad, const unsigned aad_len, const uint8_t *iv, unsigned int iv_len,
unsigned data_pad_len, unsigned int data_pad_len,
enum rte_crypto_auth_operation op, enum rte_crypto_auth_operation op,
enum rte_crypto_auth_algorithm algo, unsigned int auth_len, unsigned int auth_offset)
const unsigned auth_len, const unsigned auth_offset)
{ {
struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params; struct crypto_unittest_params *ut_params = &unittest_params;
unsigned aad_buffer_len;
/* Generate Crypto op data structure */ /* Generate Crypto op data structure */
ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
RTE_CRYPTO_OP_TYPE_SYMMETRIC); RTE_CRYPTO_OP_TYPE_SYMMETRIC);
@ -2087,32 +2091,9 @@ create_wireless_algo_hash_operation(const uint8_t *auth_tag,
/* set crypto operation source mbuf */ /* set crypto operation source mbuf */
sym_op->m_src = ut_params->ibuf; sym_op->m_src = ut_params->ibuf;
/* aad */ /* iv */
/* rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
* Always allocate the aad up to the block size. iv, iv_len);
* The cryptodev API calls out -
* - the array must be big enough to hold the AAD, plus any
* space to round this up to the nearest multiple of the
* block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
*/
if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
else
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
ut_params->ibuf, aad_buffer_len);
TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
"no room to prepend aad");
sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
ut_params->ibuf);
sym_op->auth.aad.length = aad_len;
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
/* digest */ /* digest */
sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
ut_params->ibuf, auth_tag_len); ut_params->ibuf, auth_tag_len);
@ -2121,7 +2102,7 @@ create_wireless_algo_hash_operation(const uint8_t *auth_tag,
"no room to append auth tag"); "no room to append auth tag");
ut_params->digest = sym_op->auth.digest.data; ut_params->digest = sym_op->auth.digest.data;
sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset( sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
ut_params->ibuf, data_pad_len + aad_len); ut_params->ibuf, data_pad_len);
sym_op->auth.digest.length = auth_tag_len; sym_op->auth.digest.length = auth_tag_len;
if (op == RTE_CRYPTO_AUTH_OP_GENERATE) if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
memset(sym_op->auth.digest.data, 0, auth_tag_len); memset(sym_op->auth.digest.data, 0, auth_tag_len);
@ -2140,27 +2121,22 @@ create_wireless_algo_hash_operation(const uint8_t *auth_tag,
static int static int
create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata, create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
enum rte_crypto_auth_operation op, enum rte_crypto_auth_operation op)
enum rte_crypto_auth_algorithm auth_algo)
{ {
struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params; struct crypto_unittest_params *ut_params = &unittest_params;
const uint8_t *auth_tag = tdata->digest.data; const uint8_t *auth_tag = tdata->digest.data;
const unsigned int auth_tag_len = tdata->digest.len; const unsigned int auth_tag_len = tdata->digest.len;
const uint8_t *aad = tdata->aad.data;
const uint8_t aad_len = tdata->aad.len;
unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len); unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
const uint8_t *iv = tdata->iv.data; const uint8_t *cipher_iv = tdata->cipher_iv.data;
const uint8_t iv_len = tdata->iv.len; const uint8_t cipher_iv_len = tdata->cipher_iv.len;
const uint8_t *auth_iv = tdata->auth_iv.data;
const uint8_t auth_iv_len = tdata->auth_iv.len;
const unsigned int cipher_len = tdata->validCipherLenInBits.len; const unsigned int cipher_len = tdata->validCipherLenInBits.len;
const unsigned int cipher_offset = 0;
const unsigned int auth_len = tdata->validAuthLenInBits.len; const unsigned int auth_len = tdata->validAuthLenInBits.len;
const unsigned int auth_offset = tdata->aad.len << 3;
unsigned int aad_buffer_len;
/* Generate Crypto op data structure */ /* Generate Crypto op data structure */
ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
@ -2194,37 +2170,17 @@ create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
sym_op->auth.digest.data, sym_op->auth.digest.data,
sym_op->auth.digest.length); sym_op->auth.digest.length);
/* aad */ /* Copy cipher and auth IVs at the end of the crypto operation */
/* uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
* Always allocate the aad up to the block size. IV_OFFSET);
* The cryptodev API calls out - rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
* - the array must be big enough to hold the AAD, plus any iv_ptr += cipher_iv_len;
* space to round this up to the nearest multiple of the rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
* block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
*/
if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
else
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
sym_op->auth.aad.data =
(uint8_t *)rte_pktmbuf_prepend(
ut_params->ibuf, aad_buffer_len);
TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
"no room to prepend aad");
sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
ut_params->ibuf);
sym_op->auth.aad.length = aad_len;
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
/* iv */
rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
iv, iv_len);
sym_op->cipher.data.length = cipher_len; sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = cipher_offset + auth_offset; sym_op->cipher.data.offset = 0;
sym_op->auth.data.length = auth_len; sym_op->auth.data.length = auth_len;
sym_op->auth.data.offset = auth_offset + cipher_offset; sym_op->auth.data.offset = 0;
return 0; return 0;
} }
@ -2234,26 +2190,22 @@ create_zuc_cipher_hash_generate_operation(
const struct wireless_test_data *tdata) const struct wireless_test_data *tdata)
{ {
return create_wireless_cipher_hash_operation(tdata, return create_wireless_cipher_hash_operation(tdata,
RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_OP_GENERATE);
RTE_CRYPTO_AUTH_ZUC_EIA3);
} }
static int static int
create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag, create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
const unsigned auth_tag_len, const unsigned auth_tag_len,
const uint8_t *aad, const uint8_t aad_len, const uint8_t *auth_iv, uint8_t auth_iv_len,
unsigned data_pad_len, unsigned data_pad_len,
enum rte_crypto_auth_operation op, enum rte_crypto_auth_operation op,
enum rte_crypto_auth_algorithm auth_algo, const uint8_t *cipher_iv, uint8_t cipher_iv_len,
const uint8_t *iv, const uint8_t iv_len,
const unsigned cipher_len, const unsigned cipher_offset, const unsigned cipher_len, const unsigned cipher_offset,
const unsigned auth_len, const unsigned auth_offset) const unsigned auth_len, const unsigned auth_offset)
{ {
struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params; struct crypto_unittest_params *ut_params = &unittest_params;
unsigned aad_buffer_len;
/* Generate Crypto op data structure */ /* Generate Crypto op data structure */
ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
RTE_CRYPTO_OP_TYPE_SYMMETRIC); RTE_CRYPTO_OP_TYPE_SYMMETRIC);
@ -2286,33 +2238,13 @@ create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
sym_op->auth.digest.data, sym_op->auth.digest.data,
sym_op->auth.digest.length); sym_op->auth.digest.length);
/* aad */ /* Copy cipher and auth IVs at the end of the crypto operation */
/* uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
* Always allocate the aad up to the block size. IV_OFFSET);
* The cryptodev API calls out - rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
* - the array must be big enough to hold the AAD, plus any iv_ptr += cipher_iv_len;
* space to round this up to the nearest multiple of the rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
* block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
*/
if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
else
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
sym_op->auth.aad.data =
(uint8_t *)rte_pktmbuf_prepend(
ut_params->ibuf, aad_buffer_len);
TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
"no room to prepend aad");
sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
ut_params->ibuf);
sym_op->auth.aad.length = aad_len;
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
/* iv */
rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
iv, iv_len);
sym_op->cipher.data.length = cipher_len; sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = cipher_offset + auth_offset; sym_op->cipher.data.offset = cipher_offset + auth_offset;
sym_op->auth.data.length = auth_len; sym_op->auth.data.length = auth_len;
@ -2322,19 +2254,16 @@ create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
} }
static int static int
create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len, create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
const uint8_t *iv, const uint8_t iv_len, const uint8_t *cipher_iv, uint8_t cipher_iv_len,
const uint8_t *aad, const uint8_t aad_len, const uint8_t *auth_iv, uint8_t auth_iv_len,
unsigned data_pad_len, unsigned int data_pad_len,
const unsigned cipher_len, const unsigned cipher_offset, unsigned int cipher_len, unsigned int cipher_offset,
const unsigned auth_len, const unsigned auth_offset, unsigned int auth_len, unsigned int auth_offset)
enum rte_crypto_auth_algorithm auth_algo)
{ {
struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params; struct crypto_unittest_params *ut_params = &unittest_params;
unsigned aad_buffer_len = 0;
/* Generate Crypto op data structure */ /* Generate Crypto op data structure */
ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
RTE_CRYPTO_OP_TYPE_SYMMETRIC); RTE_CRYPTO_OP_TYPE_SYMMETRIC);
@ -2366,33 +2295,13 @@ create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
sym_op->auth.digest.data, sym_op->auth.digest.data,
sym_op->auth.digest.length); sym_op->auth.digest.length);
/* aad */ /* Copy cipher and auth IVs at the end of the crypto operation */
/* uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
* Always allocate the aad up to the block size. IV_OFFSET);
* The cryptodev API calls out - rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
* - the array must be big enough to hold the AAD, plus any iv_ptr += cipher_iv_len;
* space to round this up to the nearest multiple of the rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
* block size (8 bytes for KASUMI 16 bytes).
*/
if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
else
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
ut_params->ibuf, aad_buffer_len);
TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
"no room to prepend aad");
sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
ut_params->ibuf);
sym_op->auth.aad.length = aad_len;
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
/* iv */
rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
iv, iv_len);
sym_op->cipher.data.length = cipher_len; sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = auth_offset + cipher_offset; sym_op->cipher.data.offset = auth_offset + cipher_offset;
@ -2416,7 +2325,7 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
/* Create SNOW 3G session */ /* Create SNOW 3G session */
retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_OP_GENERATE,
RTE_CRYPTO_AUTH_SNOW3G_UIA2); RTE_CRYPTO_AUTH_SNOW3G_UIA2);
if (retval < 0) if (retval < 0)
@ -2438,11 +2347,10 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len, retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
tdata->aad.data, tdata->aad.len, tdata->auth_iv.data, tdata->auth_iv.len,
plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
RTE_CRYPTO_AUTH_SNOW3G_UIA2,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3)); 0);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -2451,7 +2359,7 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len; + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL( TEST_ASSERT_BUFFERS_ARE_EQUAL(
@ -2477,7 +2385,7 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
/* Create SNOW 3G session */ /* Create SNOW 3G session */
retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
RTE_CRYPTO_AUTH_OP_VERIFY, RTE_CRYPTO_AUTH_OP_VERIFY,
RTE_CRYPTO_AUTH_SNOW3G_UIA2); RTE_CRYPTO_AUTH_SNOW3G_UIA2);
if (retval < 0) if (retval < 0)
@ -2499,12 +2407,11 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_hash_operation(tdata->digest.data, retval = create_wireless_algo_hash_operation(tdata->digest.data,
tdata->digest.len, tdata->digest.len,
tdata->aad.data, tdata->aad.len, tdata->auth_iv.data, tdata->auth_iv.len,
plaintext_pad_len, plaintext_pad_len,
RTE_CRYPTO_AUTH_OP_VERIFY, RTE_CRYPTO_AUTH_OP_VERIFY,
RTE_CRYPTO_AUTH_SNOW3G_UIA2,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3)); 0);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -2513,7 +2420,7 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len; + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@ -2538,7 +2445,7 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
/* Create KASUMI session */ /* Create KASUMI session */
retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_OP_GENERATE,
RTE_CRYPTO_AUTH_KASUMI_F9); RTE_CRYPTO_AUTH_KASUMI_F9);
if (retval < 0) if (retval < 0)
@ -2560,11 +2467,10 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len, retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
tdata->aad.data, tdata->aad.len, tdata->auth_iv.data, tdata->auth_iv.len,
plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
RTE_CRYPTO_AUTH_KASUMI_F9,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3)); 0);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -2573,7 +2479,7 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8); + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL( TEST_ASSERT_BUFFERS_ARE_EQUAL(
@ -2599,7 +2505,7 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
/* Create KASUMI session */ /* Create KASUMI session */
retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
RTE_CRYPTO_AUTH_OP_VERIFY, RTE_CRYPTO_AUTH_OP_VERIFY,
RTE_CRYPTO_AUTH_KASUMI_F9); RTE_CRYPTO_AUTH_KASUMI_F9);
if (retval < 0) if (retval < 0)
@ -2621,12 +2527,11 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_hash_operation(tdata->digest.data, retval = create_wireless_algo_hash_operation(tdata->digest.data,
tdata->digest.len, tdata->digest.len,
tdata->aad.data, tdata->aad.len, tdata->auth_iv.data, tdata->auth_iv.len,
plaintext_pad_len, plaintext_pad_len,
RTE_CRYPTO_AUTH_OP_VERIFY, RTE_CRYPTO_AUTH_OP_VERIFY,
RTE_CRYPTO_AUTH_KASUMI_F9,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3)); 0);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -2635,7 +2540,7 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len; + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@ -2801,7 +2706,7 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_KASUMI_F8, RTE_CRYPTO_CIPHER_KASUMI_F8,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -2822,7 +2727,8 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata)
TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len, retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
tdata->cipher_iv.len,
tdata->plaintext.len, tdata->plaintext.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -2877,7 +2783,7 @@ test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_KASUMI_F8, RTE_CRYPTO_CIPHER_KASUMI_F8,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -2894,8 +2800,8 @@ test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data); pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_cipher_operation(tdata->iv.data, retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->plaintext.len, tdata->plaintext.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -2942,7 +2848,7 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_KASUMI_F8, RTE_CRYPTO_CIPHER_KASUMI_F8,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -2965,8 +2871,8 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data, retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->plaintext.len, tdata->plaintext.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3020,7 +2926,7 @@ test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_KASUMI_F8, RTE_CRYPTO_CIPHER_KASUMI_F8,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3039,8 +2945,8 @@ test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data); pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data, retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->plaintext.len, tdata->plaintext.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3084,7 +2990,7 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_CIPHER_OP_DECRYPT,
RTE_CRYPTO_CIPHER_KASUMI_F8, RTE_CRYPTO_CIPHER_KASUMI_F8,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3107,8 +3013,8 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data, retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->ciphertext.len, tdata->ciphertext.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3151,7 +3057,7 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_CIPHER_OP_DECRYPT,
RTE_CRYPTO_CIPHER_KASUMI_F8, RTE_CRYPTO_CIPHER_KASUMI_F8,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3172,8 +3078,8 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)
TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_cipher_operation(tdata->iv.data, retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->ciphertext.len, tdata->ciphertext.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3216,7 +3122,7 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_SNOW3G_UEA2, RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3237,7 +3143,8 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len, retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
tdata->cipher_iv.len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3281,7 +3188,7 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_SNOW3G_UEA2, RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3309,8 +3216,8 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data, retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3363,7 +3270,7 @@ test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_SNOW3G_UEA2, RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3385,8 +3292,8 @@ test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data); pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data, retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3453,7 +3360,7 @@ test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_SNOW3G_UEA2, RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3488,8 +3395,8 @@ test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len); rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
#endif #endif
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data, retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
extra_offset); extra_offset);
if (retval < 0) if (retval < 0)
@ -3544,7 +3451,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_CIPHER_OP_DECRYPT,
RTE_CRYPTO_CIPHER_SNOW3G_UEA2, RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3565,7 +3472,8 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len, retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
tdata->cipher_iv.len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3606,7 +3514,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_CIPHER_OP_DECRYPT,
RTE_CRYPTO_CIPHER_SNOW3G_UEA2, RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3637,8 +3545,8 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data, retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
tdata->iv.len, tdata->cipher_iv.len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -3725,8 +3633,7 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata)
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
if (ut_params->obuf) if (ut_params->obuf)
ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
+ tdata->aad.len;
else else
ciphertext = plaintext; ciphertext = plaintext;
@ -3739,7 +3646,7 @@ test_zuc_cipher_auth(const struct wireless_test_data *tdata)
"ZUC Ciphertext data not as expected"); "ZUC Ciphertext data not as expected");
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len; + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL( TEST_ASSERT_BUFFERS_ARE_EQUAL(
@ -3769,8 +3676,8 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
RTE_CRYPTO_AUTH_SNOW3G_UIA2, RTE_CRYPTO_AUTH_SNOW3G_UIA2,
RTE_CRYPTO_CIPHER_SNOW3G_UEA2, RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
@ -3791,15 +3698,14 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data, retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
tdata->digest.len, tdata->aad.data, tdata->digest.len, tdata->auth_iv.data,
tdata->aad.len, /*tdata->plaintext.len,*/ tdata->auth_iv.len,
plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
RTE_CRYPTO_AUTH_SNOW3G_UIA2, tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->iv.data, tdata->iv.len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0, 0,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3) 0
); );
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3809,8 +3715,7 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
if (ut_params->obuf) if (ut_params->obuf)
ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
+ tdata->aad.len;
else else
ciphertext = plaintext; ciphertext = plaintext;
@ -3823,7 +3728,7 @@ test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
"SNOW 3G Ciphertext data not as expected"); "SNOW 3G Ciphertext data not as expected");
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len; + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL( TEST_ASSERT_BUFFERS_ARE_EQUAL(
@ -3852,8 +3757,8 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
RTE_CRYPTO_AUTH_SNOW3G_UIA2, RTE_CRYPTO_AUTH_SNOW3G_UIA2,
RTE_CRYPTO_CIPHER_SNOW3G_UEA2, RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3876,15 +3781,13 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
/* Create SNOW 3G operation */ /* Create SNOW 3G operation */
retval = create_wireless_algo_auth_cipher_operation( retval = create_wireless_algo_auth_cipher_operation(
tdata->digest.len, tdata->digest.len,
tdata->iv.data, tdata->iv.len, tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->aad.data, tdata->aad.len, tdata->auth_iv.data, tdata->auth_iv.len,
plaintext_pad_len, plaintext_pad_len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0, 0,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3), 0);
RTE_CRYPTO_AUTH_SNOW3G_UIA2
);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -3894,13 +3797,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
if (ut_params->obuf) if (ut_params->obuf)
ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
+ tdata->aad.len;
else else
ciphertext = plaintext; ciphertext = plaintext;
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len; + plaintext_pad_len;
TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
/* Validate obuf */ /* Validate obuf */
@ -3939,8 +3841,8 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
RTE_CRYPTO_AUTH_KASUMI_F9, RTE_CRYPTO_AUTH_KASUMI_F9,
RTE_CRYPTO_CIPHER_KASUMI_F8, RTE_CRYPTO_CIPHER_KASUMI_F8,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
@ -3961,14 +3863,13 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len, retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
tdata->iv.data, tdata->iv.len, tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->aad.data, tdata->aad.len, tdata->auth_iv.data, tdata->auth_iv.len,
plaintext_pad_len, plaintext_pad_len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0, 0,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3), 0
RTE_CRYPTO_AUTH_KASUMI_F9
); );
if (retval < 0) if (retval < 0)
@ -3979,8 +3880,7 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
if (ut_params->obuf) if (ut_params->obuf)
ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
+ tdata->aad.len;
else else
ciphertext = plaintext; ciphertext = plaintext;
@ -3991,7 +3891,7 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
"KASUMI Ciphertext data not as expected"); "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->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len; + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL( TEST_ASSERT_BUFFERS_ARE_EQUAL(
@ -4022,8 +3922,8 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
RTE_CRYPTO_AUTH_KASUMI_F9, RTE_CRYPTO_AUTH_KASUMI_F9,
RTE_CRYPTO_CIPHER_KASUMI_F8, RTE_CRYPTO_CIPHER_KASUMI_F8,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -4045,15 +3945,14 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
/* Create KASUMI operation */ /* Create KASUMI operation */
retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data, retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
tdata->digest.len, tdata->aad.data, tdata->digest.len, tdata->auth_iv.data,
tdata->aad.len, tdata->auth_iv.len,
plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
RTE_CRYPTO_AUTH_KASUMI_F9, tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->iv.data, tdata->iv.len,
tdata->validCipherLenInBits.len, tdata->validCipherLenInBits.len,
0, 0,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3) 0
); );
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -4063,13 +3962,12 @@ test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
if (ut_params->obuf) if (ut_params->obuf)
ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
+ tdata->aad.len;
else else
ciphertext = plaintext; ciphertext = plaintext;
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len; + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
@ -4113,7 +4011,7 @@ test_zuc_encryption(const struct wireless_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_ZUC_EEA3, RTE_CRYPTO_CIPHER_ZUC_EEA3,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -4134,7 +4032,8 @@ test_zuc_encryption(const struct wireless_test_data *tdata)
TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
/* Create ZUC operation */ /* Create ZUC operation */
retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len, retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
tdata->cipher_iv.len,
tdata->plaintext.len, tdata->plaintext.len,
0); 0);
if (retval < 0) if (retval < 0)
@ -4209,7 +4108,7 @@ test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
RTE_CRYPTO_CIPHER_ZUC_EEA3, RTE_CRYPTO_CIPHER_ZUC_EEA3,
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->iv.len); tdata->cipher_iv.len);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -4218,8 +4117,8 @@ test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data); pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
/* Create ZUC operation */ /* Create ZUC operation */
retval = create_wireless_algo_cipher_operation(tdata->iv.data, retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
tdata->iv.len, tdata->plaintext.len, tdata->cipher_iv.len, tdata->plaintext.len,
0); 0);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -4273,7 +4172,7 @@ test_zuc_authentication(const struct wireless_test_data *tdata)
/* Create ZUC session */ /* Create ZUC session */
retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
tdata->key.data, tdata->key.len, tdata->key.data, tdata->key.len,
tdata->aad.len, tdata->digest.len, tdata->auth_iv.len, tdata->digest.len,
RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_OP_GENERATE,
RTE_CRYPTO_AUTH_ZUC_EIA3); RTE_CRYPTO_AUTH_ZUC_EIA3);
if (retval < 0) if (retval < 0)
@ -4295,11 +4194,10 @@ test_zuc_authentication(const struct wireless_test_data *tdata)
/* Create ZUC operation */ /* Create ZUC operation */
retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len, retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
tdata->aad.data, tdata->aad.len, tdata->auth_iv.data, tdata->auth_iv.len,
plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
RTE_CRYPTO_AUTH_ZUC_EIA3,
tdata->validAuthLenInBits.len, tdata->validAuthLenInBits.len,
(tdata->aad.len << 3)); 0);
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -4308,7 +4206,7 @@ test_zuc_authentication(const struct wireless_test_data *tdata)
ut_params->obuf = ut_params->op->sym->m_src; ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8); + plaintext_pad_len;
/* Validate obuf */ /* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL( TEST_ASSERT_BUFFERS_ARE_EQUAL(

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2016 Intel Corporation. All rights reserved. * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -43,7 +43,7 @@ struct kasumi_hash_test_data {
struct { struct {
uint8_t data[8]; uint8_t data[8];
unsigned len; unsigned len;
} aad; } auth_iv;
/* Includes message and DIRECTION (1 bit), plus 1 0*, /* Includes message and DIRECTION (1 bit), plus 1 0*,
* with enough 0s, so total length is multiple of 64 bits */ * with enough 0s, so total length is multiple of 64 bits */
@ -71,7 +71,7 @@ struct kasumi_hash_test_data kasumi_hash_test_case_1 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49, 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
}, },
@ -102,7 +102,7 @@ struct kasumi_hash_test_data kasumi_hash_test_case_2 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2, 0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2,
}, },
@ -134,7 +134,7 @@ struct kasumi_hash_test_data kasumi_hash_test_case_3 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A, 0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A,
}, },
@ -168,7 +168,7 @@ struct kasumi_hash_test_data kasumi_hash_test_case_4 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD 0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD
}, },
@ -203,7 +203,7 @@ struct kasumi_hash_test_data kasumi_hash_test_case_5 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37,
}, },
@ -247,7 +247,7 @@ struct kasumi_hash_test_data kasumi_hash_test_case_6 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x36, 0xAF, 0x61, 0x44, 0x4F, 0x30, 0x2A, 0xD2 0x36, 0xAF, 0x61, 0x44, 0x4F, 0x30, 0x2A, 0xD2
}, },
@ -288,7 +288,7 @@ struct kasumi_hash_test_data kasumi_hash_test_case_7 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49, 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
}, },

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2016 Intel Corporation. All rights reserved. * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -42,13 +42,13 @@ struct kasumi_test_data {
struct { struct {
uint8_t data[64] __rte_aligned(16); uint8_t data[64] __rte_aligned(16);
unsigned len; unsigned len;
} iv; } cipher_iv;
/* Includes: COUNT (4 bytes) and FRESH (4 bytes) */ /* Includes: COUNT (4 bytes) and FRESH (4 bytes) */
struct { struct {
uint8_t data[8]; uint8_t data[8];
unsigned len; unsigned len;
} aad; } auth_iv;
struct { struct {
uint8_t data[1024]; /* Data may include direction bit */ uint8_t data[1024]; /* Data may include direction bit */
@ -88,7 +88,7 @@ struct kasumi_test_data kasumi_test_case_1 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00 0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00
}, },
@ -143,7 +143,7 @@ struct kasumi_test_data kasumi_test_case_2 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00 0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00
}, },
@ -188,13 +188,13 @@ struct kasumi_test_data kasumi_test_case_3 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00
}, },
.len = 8 .len = 8
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49
}, },
@ -237,7 +237,7 @@ struct kasumi_test_data kasumi_test_case_4 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00, 0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00,
}, },
@ -274,7 +274,7 @@ struct kasumi_test_data kasumi_test_case_5 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00 0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00
}, },
@ -331,13 +331,13 @@ struct kasumi_test_data kasumi_test_case_6 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00
}, },
.len = 8 .len = 8
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49
}, },

View File

@ -2704,10 +2704,12 @@ test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
auth_xform.auth.algo = auth_algo; auth_xform.auth.algo = auth_algo;
auth_xform.auth.add_auth_data_length = SNOW3G_CIPHER_IV_LENGTH;
auth_xform.auth.key.data = snow3g_hash_key; auth_xform.auth.key.data = snow3g_hash_key;
auth_xform.auth.key.length = get_auth_key_max_length(auth_algo); auth_xform.auth.key.length = get_auth_key_max_length(auth_algo);
auth_xform.auth.digest_length = get_auth_digest_length(auth_algo); auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
/* Auth IV will be after cipher IV */
auth_xform.auth.iv.offset = IV_OFFSET + SNOW3G_CIPHER_IV_LENGTH;
auth_xform.auth.iv.length = SNOW3G_CIPHER_IV_LENGTH;
switch (chain) { switch (chain) {
case CIPHER_HASH: case CIPHER_HASH:
@ -2969,10 +2971,6 @@ test_perf_set_crypto_op_snow3g(struct rte_crypto_op *op, struct rte_mbuf *m,
op->sym->auth.digest.phys_addr = op->sym->auth.digest.phys_addr =
rte_pktmbuf_mtophys_offset(m, data_len); rte_pktmbuf_mtophys_offset(m, data_len);
op->sym->auth.digest.length = digest_len; op->sym->auth.digest.length = digest_len;
op->sym->auth.aad.data = iv_ptr;
op->sym->auth.aad.phys_addr = rte_crypto_op_ctophys_offset(op,
IV_OFFSET);
op->sym->auth.aad.length = SNOW3G_CIPHER_IV_LENGTH;
/* Data lengths/offsets Parameters */ /* Data lengths/offsets Parameters */
op->sym->auth.data.offset = 0; op->sym->auth.data.offset = 0;
@ -3017,11 +3015,16 @@ test_perf_set_crypto_op_snow3g_hash(struct rte_crypto_op *op,
unsigned data_len, unsigned data_len,
unsigned digest_len) unsigned digest_len)
{ {
uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op,
uint8_t *, IV_OFFSET);
if (rte_crypto_op_attach_sym_session(op, sess) != 0) { if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
rte_crypto_op_free(op); rte_crypto_op_free(op);
return NULL; return NULL;
} }
rte_memcpy(iv_ptr, snow3g_iv, SNOW3G_CIPHER_IV_LENGTH);
/* Authentication Parameters */ /* Authentication Parameters */
op->sym->auth.digest.data = op->sym->auth.digest.data =
@ -3031,13 +3034,6 @@ test_perf_set_crypto_op_snow3g_hash(struct rte_crypto_op *op,
rte_pktmbuf_mtophys_offset(m, data_len + rte_pktmbuf_mtophys_offset(m, data_len +
SNOW3G_CIPHER_IV_LENGTH); SNOW3G_CIPHER_IV_LENGTH);
op->sym->auth.digest.length = digest_len; op->sym->auth.digest.length = digest_len;
op->sym->auth.aad.data = rte_crypto_op_ctod_offset(op,
uint8_t *, IV_OFFSET);
op->sym->auth.aad.phys_addr = rte_crypto_op_ctophys_offset(op,
IV_OFFSET);
op->sym->auth.aad.length = SNOW3G_CIPHER_IV_LENGTH;
rte_memcpy(op->sym->auth.aad.data, snow3g_iv,
SNOW3G_CIPHER_IV_LENGTH);
/* Data lengths/offsets Parameters */ /* Data lengths/offsets Parameters */
op->sym->auth.data.offset = 0; op->sym->auth.data.offset = 0;

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2016 Intel Corporation. All rights reserved. * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -42,7 +42,7 @@ struct snow3g_hash_test_data {
struct { struct {
uint8_t data[64]; uint8_t data[64];
unsigned len; unsigned len;
} aad; } auth_iv;
struct { struct {
uint8_t data[2056]; uint8_t data[2056];
@ -67,7 +67,7 @@ struct snow3g_hash_test_data snow3g_hash_test_case_1 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD, 0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD,
0x94, 0x79, 0x3E, 0x41, 0x03, 0x97, 0x68, 0xFD 0x94, 0x79, 0x3E, 0x41, 0x03, 0x97, 0x68, 0xFD
@ -102,7 +102,7 @@ struct snow3g_hash_test_data snow3g_hash_test_case_2 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37,
0xA9, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0xF7, 0x37 0xA9, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0xF7, 0x37
@ -147,7 +147,7 @@ struct snow3g_hash_test_data snow3g_hash_test_case_3 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37,
0xA9, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0xF7, 0x37 0xA9, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0xF7, 0x37
@ -433,7 +433,7 @@ struct snow3g_hash_test_data snow3g_hash_test_case_4 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49, 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49, 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
@ -465,7 +465,7 @@ struct snow3g_hash_test_data snow3g_hash_test_case_5 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2, 0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2,
0xBE, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0x58, 0xE2 0xBE, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0x58, 0xE2
@ -498,7 +498,7 @@ struct snow3g_hash_test_data snow3g_hash_test_case_6 = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A, 0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A,
0xB6, 0xAF, 0x61, 0x44, 0x98, 0x38, 0x70, 0x3A 0xB6, 0xAF, 0x61, 0x44, 0x98, 0x38, 0x70, 0x3A

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2015 Intel Corporation. All rights reserved. * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -42,7 +42,7 @@ struct snow3g_test_data {
struct { struct {
uint8_t data[64] __rte_aligned(16); uint8_t data[64] __rte_aligned(16);
unsigned len; unsigned len;
} iv; } cipher_iv;
struct { struct {
uint8_t data[1024]; uint8_t data[1024];
@ -69,7 +69,7 @@ struct snow3g_test_data {
struct { struct {
uint8_t data[64]; uint8_t data[64];
unsigned len; unsigned len;
} aad; } auth_iv;
struct { struct {
uint8_t data[64]; uint8_t data[64];
@ -84,7 +84,7 @@ struct snow3g_test_data snow3g_test_case_1 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00, 0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00,
0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00 0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00
@ -133,7 +133,7 @@ struct snow3g_test_data snow3g_test_case_1 = {
.validCipherLenInBits = { .validCipherLenInBits = {
.len = 800 .len = 800
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00, 0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00,
0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00 0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00
@ -150,7 +150,7 @@ struct snow3g_test_data snow3g_test_case_2 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00, 0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00,
0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00 0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00
@ -189,7 +189,7 @@ struct snow3g_test_data snow3g_test_case_2 = {
.validCipherLenInBits = { .validCipherLenInBits = {
.len = 512 .len = 512
}, },
.aad = { .auth_iv = {
.data = { .data = {
0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00, 0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00,
0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00 0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00
@ -206,7 +206,7 @@ struct snow3g_test_data snow3g_test_case_3 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00, 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00,
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00
@ -233,7 +233,7 @@ struct snow3g_test_data snow3g_test_case_3 = {
.validCipherLenInBits = { .validCipherLenInBits = {
.len = 120 .len = 120
}, },
.aad = { .auth_iv = {
.data = { .data = {
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00, 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00,
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00
@ -257,7 +257,7 @@ struct snow3g_test_data snow3g_test_case_4 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00, 0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00,
0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00 0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00
@ -298,7 +298,7 @@ struct snow3g_test_data snow3g_test_case_5 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00, 0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00,
0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00 0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00
@ -357,14 +357,14 @@ struct snow3g_test_data snow3g_test_case_6 = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD, 0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD,
0x94, 0x79, 0x3E, 0x41, 0x03, 0x97, 0x68, 0xFD 0x94, 0x79, 0x3E, 0x41, 0x03, 0x97, 0x68, 0xFD
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD, 0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD,
0x94, 0x79, 0x3E, 0x41, 0x03, 0x97, 0x68, 0xFD 0x94, 0x79, 0x3E, 0x41, 0x03, 0x97, 0x68, 0xFD

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2016 Intel Corporation. All rights reserved. * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -42,7 +42,7 @@ struct wireless_test_data {
struct { struct {
uint8_t data[64] __rte_aligned(16); uint8_t data[64] __rte_aligned(16);
unsigned len; unsigned len;
} iv; } cipher_iv;
struct { struct {
uint8_t data[2048]; uint8_t data[2048];
@ -69,7 +69,7 @@ struct wireless_test_data {
struct { struct {
uint8_t data[64]; uint8_t data[64];
unsigned len; unsigned len;
} aad; } auth_iv;
struct { struct {
uint8_t data[64]; uint8_t data[64];
@ -84,7 +84,7 @@ static struct wireless_test_data zuc_test_case_cipher_193b = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00, 0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00,
0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00 0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00
@ -125,7 +125,7 @@ static struct wireless_test_data zuc_test_case_cipher_800b = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x00, 0x05, 0x68, 0x23, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x05, 0x68, 0x23, 0xC4, 0x00, 0x00, 0x00,
0x00, 0x05, 0x68, 0x23, 0xC4, 0x00, 0x00, 0x00 0x00, 0x05, 0x68, 0x23, 0xC4, 0x00, 0x00, 0x00
@ -184,7 +184,7 @@ static struct wireless_test_data zuc_test_case_cipher_1570b = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x76, 0x45, 0x2E, 0xC1, 0x14, 0x00, 0x00, 0x00, 0x76, 0x45, 0x2E, 0xC1, 0x14, 0x00, 0x00, 0x00,
0x76, 0x45, 0x2E, 0xC1, 0x14, 0x00, 0x00, 0x00 0x76, 0x45, 0x2E, 0xC1, 0x14, 0x00, 0x00, 0x00
@ -267,7 +267,7 @@ static struct wireless_test_data zuc_test_case_cipher_2798b = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0xE4, 0x85, 0x0F, 0xE1, 0x84, 0x00, 0x00, 0x00, 0xE4, 0x85, 0x0F, 0xE1, 0x84, 0x00, 0x00, 0x00,
0xE4, 0x85, 0x0F, 0xE1, 0x84, 0x00, 0x00, 0x00 0xE4, 0x85, 0x0F, 0xE1, 0x84, 0x00, 0x00, 0x00
@ -388,7 +388,7 @@ static struct wireless_test_data zuc_test_case_cipher_4019b = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x27, 0x38, 0xCD, 0xAA, 0xD0, 0x00, 0x00, 0x00, 0x27, 0x38, 0xCD, 0xAA, 0xD0, 0x00, 0x00, 0x00,
0x27, 0x38, 0xCD, 0xAA, 0xD0, 0x00, 0x00, 0x00 0x27, 0x38, 0xCD, 0xAA, 0xD0, 0x00, 0x00, 0x00
@ -547,7 +547,7 @@ static struct wireless_test_data zuc_test_case_cipher_200b_auth_200b = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00, 0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00,
0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00 0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00
@ -578,7 +578,7 @@ static struct wireless_test_data zuc_test_case_cipher_200b_auth_200b = {
.validCipherLenInBits = { .validCipherLenInBits = {
.len = 200 .len = 200
}, },
.aad = { .auth_iv = {
.data = { .data = {
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00, 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00,
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00
@ -602,7 +602,7 @@ static struct wireless_test_data zuc_test_case_cipher_800b_auth_120b = {
}, },
.len = 16 .len = 16
}, },
.iv = { .cipher_iv = {
.data = { .data = {
0x00, 0x05, 0x68, 0x23, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x05, 0x68, 0x23, 0xC4, 0x00, 0x00, 0x00,
0x00, 0x05, 0x68, 0x23, 0xC4, 0x00, 0x00, 0x00 0x00, 0x05, 0x68, 0x23, 0xC4, 0x00, 0x00, 0x00
@ -651,7 +651,7 @@ static struct wireless_test_data zuc_test_case_cipher_800b_auth_120b = {
.validCipherLenInBits = { .validCipherLenInBits = {
.len = 800 .len = 800
}, },
.aad = { .auth_iv = {
.data = { .data = {
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00, 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00,
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00
@ -675,7 +675,7 @@ struct wireless_test_data zuc_test_case_auth_1b = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@ -703,7 +703,7 @@ struct wireless_test_data zuc_test_case_auth_90b = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x56, 0x1E, 0xB2, 0xDD, 0xA0, 0x00, 0x00, 0x00, 0x56, 0x1E, 0xB2, 0xDD, 0xA0, 0x00, 0x00, 0x00,
0x56, 0x1E, 0xB2, 0xDD, 0xA0, 0x00, 0x00, 0x00 0x56, 0x1E, 0xB2, 0xDD, 0xA0, 0x00, 0x00, 0x00
@ -734,7 +734,7 @@ struct wireless_test_data zuc_test_case_auth_577b = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0xA9, 0x40, 0x59, 0xDA, 0x50, 0x00, 0x00, 0x00, 0xA9, 0x40, 0x59, 0xDA, 0x50, 0x00, 0x00, 0x00,
0x29, 0x40, 0x59, 0xDA, 0x50, 0x00, 0x80, 0x00 0x29, 0x40, 0x59, 0xDA, 0x50, 0x00, 0x80, 0x00
@ -773,7 +773,7 @@ struct wireless_test_data zuc_test_case_auth_2079b = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x05, 0x09, 0x78, 0x50, 0x80, 0x00, 0x00, 0x00, 0x05, 0x09, 0x78, 0x50, 0x80, 0x00, 0x00, 0x00,
0x85, 0x09, 0x78, 0x50, 0x80, 0x00, 0x80, 0x00 0x85, 0x09, 0x78, 0x50, 0x80, 0x00, 0x80, 0x00
@ -835,7 +835,7 @@ struct wireless_test_data zuc_test_auth_5670b = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x56, 0x1E, 0xB2, 0xDD, 0xE0, 0x00, 0x00, 0x00, 0x56, 0x1E, 0xB2, 0xDD, 0xE0, 0x00, 0x00, 0x00,
0x56, 0x1E, 0xB2, 0xDD, 0xE0, 0x00, 0x00, 0x00 0x56, 0x1E, 0xB2, 0xDD, 0xE0, 0x00, 0x00, 0x00
@ -950,7 +950,7 @@ static struct wireless_test_data zuc_test_case_auth_128b = {
.data = { 0x0 }, .data = { 0x0 },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { 0x0 }, .data = { 0x0 },
.len = 16 .len = 16
}, },
@ -975,7 +975,7 @@ static struct wireless_test_data zuc_test_case_auth_2080b = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0x05, 0x09, 0x78, 0x50, 0x80, 0x00, 0x00, 0x00, 0x05, 0x09, 0x78, 0x50, 0x80, 0x00, 0x00, 0x00,
0x85, 0x09, 0x78, 0x50, 0x80, 0x00, 0x80, 0x00 0x85, 0x09, 0x78, 0x50, 0x80, 0x00, 0x80, 0x00
@ -1037,7 +1037,7 @@ static struct wireless_test_data zuc_test_case_auth_584b = {
}, },
.len = 16 .len = 16
}, },
.aad = { .auth_iv = {
.data = { .data = {
0xa9, 0x40, 0x59, 0xda, 0x50, 0x0, 0x0, 0x0, 0xa9, 0x40, 0x59, 0xda, 0x50, 0x0, 0x0, 0x0,
0x29, 0x40, 0x59, 0xda, 0x50, 0x0, 0x80, 0x0 0x29, 0x40, 0x59, 0xda, 0x50, 0x0, 0x80, 0x0