#include "ccp_pci.h"
#include "ccp_pmd_private.h"
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
#include <openssl/conf.h>
#include <openssl/err.h>
#include <openssl/hmac.h>
-#endif
/* SHA initial context values */
static uint32_t ccp_sha1_init[SHA_COMMON_DIGEST_SIZE / sizeof(uint32_t)] = {
else
sess->auth.op = CCP_AUTH_OP_VERIFY;
switch (auth_xform->algo) {
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
case RTE_CRYPTO_AUTH_MD5_HMAC:
- sess->auth.algo = CCP_AUTH_ALGO_MD5_HMAC;
- sess->auth.offset = (CCP_SB_BYTES << 1) - MD5_DIGEST_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- sess->auth.block_size = MD5_BLOCK_SIZE;
- memset(sess->auth.key, 0, sess->auth.block_size);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
+ if (sess->auth_opt) {
+ sess->auth.algo = CCP_AUTH_ALGO_MD5_HMAC;
+ sess->auth.offset = ((CCP_SB_BYTES << 1) -
+ MD5_DIGEST_SIZE);
+ sess->auth.key_length = auth_xform->key.length;
+ sess->auth.block_size = MD5_BLOCK_SIZE;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ } else
+ return -1; /* HMAC MD5 not supported on CCP */
break;
-#endif
case RTE_CRYPTO_AUTH_SHA1:
sess->auth.engine = CCP_ENGINE_SHA;
sess->auth.algo = CCP_AUTH_ALGO_SHA1;
sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE;
break;
case RTE_CRYPTO_AUTH_SHA1_HMAC:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- if (auth_xform->key.length > SHA1_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA1_HMAC;
- sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE;
- sess->auth.block_size = SHA1_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
-#else
- if (auth_xform->key.length > SHA1_BLOCK_SIZE)
- return -1;
- sess->auth.engine = CCP_ENGINE_SHA;
- sess->auth.algo = CCP_AUTH_ALGO_SHA1_HMAC;
- sess->auth.ut.sha_type = CCP_SHA_TYPE_1;
- sess->auth.ctx_len = CCP_SB_BYTES;
- sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE;
- sess->auth.block_size = SHA1_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- memset(sess->auth.pre_compute, 0, sess->auth.ctx_len << 1);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
- if (generate_partial_hash(sess))
- return -1;
-#endif
+ if (sess->auth_opt) {
+ if (auth_xform->key.length > SHA1_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA1_HMAC;
+ sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE;
+ sess->auth.block_size = SHA1_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ } else {
+ if (auth_xform->key.length > SHA1_BLOCK_SIZE)
+ return -1;
+ sess->auth.engine = CCP_ENGINE_SHA;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA1_HMAC;
+ sess->auth.ut.sha_type = CCP_SHA_TYPE_1;
+ sess->auth.ctx_len = CCP_SB_BYTES;
+ sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE;
+ sess->auth.block_size = SHA1_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ memset(sess->auth.pre_compute, 0,
+ sess->auth.ctx_len << 1);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ if (generate_partial_hash(sess))
+ return -1;
+ }
break;
case RTE_CRYPTO_AUTH_SHA224:
sess->auth.algo = CCP_AUTH_ALGO_SHA224;
sess->auth.offset = CCP_SB_BYTES - SHA224_DIGEST_SIZE;
break;
case RTE_CRYPTO_AUTH_SHA224_HMAC:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- if (auth_xform->key.length > SHA224_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA224_HMAC;
- sess->auth.offset = CCP_SB_BYTES - SHA224_DIGEST_SIZE;
- sess->auth.block_size = SHA224_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
-#else
- if (auth_xform->key.length > SHA224_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA224_HMAC;
- sess->auth.engine = CCP_ENGINE_SHA;
- sess->auth.ut.sha_type = CCP_SHA_TYPE_224;
- sess->auth.ctx_len = CCP_SB_BYTES;
- sess->auth.offset = CCP_SB_BYTES - SHA224_DIGEST_SIZE;
- sess->auth.block_size = SHA224_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- memset(sess->auth.pre_compute, 0, sess->auth.ctx_len << 1);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
- if (generate_partial_hash(sess))
- return -1;
-#endif
+ if (sess->auth_opt) {
+ if (auth_xform->key.length > SHA224_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA224_HMAC;
+ sess->auth.offset = CCP_SB_BYTES - SHA224_DIGEST_SIZE;
+ sess->auth.block_size = SHA224_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ } else {
+ if (auth_xform->key.length > SHA224_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA224_HMAC;
+ sess->auth.engine = CCP_ENGINE_SHA;
+ sess->auth.ut.sha_type = CCP_SHA_TYPE_224;
+ sess->auth.ctx_len = CCP_SB_BYTES;
+ sess->auth.offset = CCP_SB_BYTES - SHA224_DIGEST_SIZE;
+ sess->auth.block_size = SHA224_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ memset(sess->auth.pre_compute, 0,
+ sess->auth.ctx_len << 1);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ if (generate_partial_hash(sess))
+ return -1;
+ }
break;
case RTE_CRYPTO_AUTH_SHA3_224:
sess->auth.algo = CCP_AUTH_ALGO_SHA3_224;
sess->auth.offset = CCP_SB_BYTES - SHA256_DIGEST_SIZE;
break;
case RTE_CRYPTO_AUTH_SHA256_HMAC:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- if (auth_xform->key.length > SHA256_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA256_HMAC;
- sess->auth.offset = CCP_SB_BYTES - SHA256_DIGEST_SIZE;
- sess->auth.block_size = SHA256_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
-#else
- if (auth_xform->key.length > SHA256_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA256_HMAC;
- sess->auth.engine = CCP_ENGINE_SHA;
- sess->auth.ut.sha_type = CCP_SHA_TYPE_256;
- sess->auth.ctx_len = CCP_SB_BYTES;
- sess->auth.offset = CCP_SB_BYTES - SHA256_DIGEST_SIZE;
- sess->auth.block_size = SHA256_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- memset(sess->auth.pre_compute, 0, sess->auth.ctx_len << 1);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
- if (generate_partial_hash(sess))
- return -1;
-#endif
+ if (sess->auth_opt) {
+ if (auth_xform->key.length > SHA256_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA256_HMAC;
+ sess->auth.offset = CCP_SB_BYTES - SHA256_DIGEST_SIZE;
+ sess->auth.block_size = SHA256_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ } else {
+ if (auth_xform->key.length > SHA256_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA256_HMAC;
+ sess->auth.engine = CCP_ENGINE_SHA;
+ sess->auth.ut.sha_type = CCP_SHA_TYPE_256;
+ sess->auth.ctx_len = CCP_SB_BYTES;
+ sess->auth.offset = CCP_SB_BYTES - SHA256_DIGEST_SIZE;
+ sess->auth.block_size = SHA256_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ memset(sess->auth.pre_compute, 0,
+ sess->auth.ctx_len << 1);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ if (generate_partial_hash(sess))
+ return -1;
+ }
break;
case RTE_CRYPTO_AUTH_SHA3_256:
sess->auth.algo = CCP_AUTH_ALGO_SHA3_256;
sess->auth.offset = (CCP_SB_BYTES << 1) - SHA384_DIGEST_SIZE;
break;
case RTE_CRYPTO_AUTH_SHA384_HMAC:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- if (auth_xform->key.length > SHA384_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA384_HMAC;
- sess->auth.offset = (CCP_SB_BYTES << 1) - SHA384_DIGEST_SIZE;
- sess->auth.block_size = SHA384_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
-#else
- if (auth_xform->key.length > SHA384_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA384_HMAC;
- sess->auth.engine = CCP_ENGINE_SHA;
- sess->auth.ut.sha_type = CCP_SHA_TYPE_384;
- sess->auth.ctx_len = CCP_SB_BYTES << 1;
- sess->auth.offset = (CCP_SB_BYTES << 1) - SHA384_DIGEST_SIZE;
- sess->auth.block_size = SHA384_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- memset(sess->auth.pre_compute, 0, sess->auth.ctx_len << 1);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
- if (generate_partial_hash(sess))
- return -1;
-#endif
+ if (sess->auth_opt) {
+ if (auth_xform->key.length > SHA384_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA384_HMAC;
+ sess->auth.offset = ((CCP_SB_BYTES << 1) -
+ SHA384_DIGEST_SIZE);
+ sess->auth.block_size = SHA384_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ } else {
+ if (auth_xform->key.length > SHA384_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA384_HMAC;
+ sess->auth.engine = CCP_ENGINE_SHA;
+ sess->auth.ut.sha_type = CCP_SHA_TYPE_384;
+ sess->auth.ctx_len = CCP_SB_BYTES << 1;
+ sess->auth.offset = ((CCP_SB_BYTES << 1) -
+ SHA384_DIGEST_SIZE);
+ sess->auth.block_size = SHA384_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ memset(sess->auth.pre_compute, 0,
+ sess->auth.ctx_len << 1);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ if (generate_partial_hash(sess))
+ return -1;
+ }
break;
case RTE_CRYPTO_AUTH_SHA3_384:
sess->auth.algo = CCP_AUTH_ALGO_SHA3_384;
sess->auth.offset = (CCP_SB_BYTES << 1) - SHA512_DIGEST_SIZE;
break;
case RTE_CRYPTO_AUTH_SHA512_HMAC:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- if (auth_xform->key.length > SHA512_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA512_HMAC;
- sess->auth.offset = (CCP_SB_BYTES << 1) - SHA512_DIGEST_SIZE;
- sess->auth.block_size = SHA512_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
-#else
- if (auth_xform->key.length > SHA512_BLOCK_SIZE)
- return -1;
- sess->auth.algo = CCP_AUTH_ALGO_SHA512_HMAC;
- sess->auth.engine = CCP_ENGINE_SHA;
- sess->auth.ut.sha_type = CCP_SHA_TYPE_512;
- sess->auth.ctx_len = CCP_SB_BYTES << 1;
- sess->auth.offset = (CCP_SB_BYTES << 1) - SHA512_DIGEST_SIZE;
- sess->auth.block_size = SHA512_BLOCK_SIZE;
- sess->auth.key_length = auth_xform->key.length;
- memset(sess->auth.key, 0, sess->auth.block_size);
- memset(sess->auth.pre_compute, 0, sess->auth.ctx_len << 1);
- rte_memcpy(sess->auth.key, auth_xform->key.data,
- auth_xform->key.length);
- if (generate_partial_hash(sess))
- return -1;
-#endif
+ if (sess->auth_opt) {
+ if (auth_xform->key.length > SHA512_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA512_HMAC;
+ sess->auth.offset = ((CCP_SB_BYTES << 1) -
+ SHA512_DIGEST_SIZE);
+ sess->auth.block_size = SHA512_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ } else {
+ if (auth_xform->key.length > SHA512_BLOCK_SIZE)
+ return -1;
+ sess->auth.algo = CCP_AUTH_ALGO_SHA512_HMAC;
+ sess->auth.engine = CCP_ENGINE_SHA;
+ sess->auth.ut.sha_type = CCP_SHA_TYPE_512;
+ sess->auth.ctx_len = CCP_SB_BYTES << 1;
+ sess->auth.offset = ((CCP_SB_BYTES << 1) -
+ SHA512_DIGEST_SIZE);
+ sess->auth.block_size = SHA512_BLOCK_SIZE;
+ sess->auth.key_length = auth_xform->key.length;
+ memset(sess->auth.key, 0, sess->auth.block_size);
+ memset(sess->auth.pre_compute, 0,
+ sess->auth.ctx_len << 1);
+ rte_memcpy(sess->auth.key, auth_xform->key.data,
+ auth_xform->key.length);
+ if (generate_partial_hash(sess))
+ return -1;
+ }
break;
case RTE_CRYPTO_AUTH_SHA3_512:
sess->auth.algo = CCP_AUTH_ALGO_SHA3_512;
int
ccp_set_session_parameters(struct ccp_session *sess,
- const struct rte_crypto_sym_xform *xform)
+ const struct rte_crypto_sym_xform *xform,
+ struct ccp_private *internals)
{
const struct rte_crypto_sym_xform *cipher_xform = NULL;
const struct rte_crypto_sym_xform *auth_xform = NULL;
const struct rte_crypto_sym_xform *aead_xform = NULL;
int ret = 0;
+ sess->auth_opt = internals->auth_opt;
sess->cmd_id = ccp_get_cmd_id(xform);
switch (sess->cmd_id) {
count = 3;
/**< op + lsb passthrough cpy to/from*/
break;
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
case CCP_AUTH_ALGO_MD5_HMAC:
break;
-#endif
case CCP_AUTH_ALGO_SHA1_HMAC:
case CCP_AUTH_ALGO_SHA224_HMAC:
case CCP_AUTH_ALGO_SHA256_HMAC:
-#ifndef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- count = 6;
-#endif
+ if (session->auth_opt == 0)
+ count = 6;
break;
case CCP_AUTH_ALGO_SHA384_HMAC:
case CCP_AUTH_ALGO_SHA512_HMAC:
-#ifndef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- count = 7;
-#endif
/**
* 1. Load PHash1 = H(k ^ ipad); to LSB
* 2. generate IHash = H(hash on meassage with PHash1
* as init value);
* 6. Retrieve HMAC output from LSB to host memory
*/
+ if (session->auth_opt == 0)
+ count = 7;
break;
case CCP_AUTH_ALGO_SHA3_224:
case CCP_AUTH_ALGO_SHA3_256:
return count;
}
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
static uint8_t
algo_select(int sessalgo,
const EVP_MD **algo)
EVP_PKEY_free(pkey);
return 0;
}
-#endif
static void
ccp_perform_passthru(struct ccp_passthru *pst,
void *append_ptr;
uint8_t *addr;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
addr = session->auth.pre_compute;
void *append_ptr;
uint64_t auth_msg_bits;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
uint32_t tail;
phys_addr_t src_addr, dest_addr, ctx_paddr, dest_addr_t;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
uint32_t tail;
phys_addr_t src_addr, dest_addr, ctx_paddr;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
phys_addr_t src_addr, dest_addr, key_addr;
int length, non_align_len;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
key_addr = rte_mem_virt2phy(session->auth.key_ccp);
phys_addr_t src_addr, dest_addr, key_addr;
uint8_t *iv;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
function.raw = 0;
uint8_t *iv;
phys_addr_t src_addr, dest_addr, key_addr;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
phys_addr_t digest_dest_addr;
int length, non_align_len;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
iv = rte_crypto_op_ctod_offset(op, uint8_t *, session->iv.offset);
int result = 0;
struct ccp_session *session;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
int result = 0;
struct ccp_session *session;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
result = ccp_perform_sha(op, cmd_q);
b_info->desccnt += 3;
break;
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
case CCP_AUTH_ALGO_MD5_HMAC:
+ if (session->auth_opt == 0)
+ result = -1;
break;
-#endif
case CCP_AUTH_ALGO_SHA1_HMAC:
case CCP_AUTH_ALGO_SHA224_HMAC:
case CCP_AUTH_ALGO_SHA256_HMAC:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- break;
-#endif
- result = ccp_perform_hmac(op, cmd_q);
- b_info->desccnt += 6;
+ if (session->auth_opt == 0) {
+ result = ccp_perform_hmac(op, cmd_q);
+ b_info->desccnt += 6;
+ }
break;
case CCP_AUTH_ALGO_SHA384_HMAC:
case CCP_AUTH_ALGO_SHA512_HMAC:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- break;
-#endif
- result = ccp_perform_hmac(op, cmd_q);
- b_info->desccnt += 7;
+ if (session->auth_opt == 0) {
+ result = ccp_perform_hmac(op, cmd_q);
+ b_info->desccnt += 7;
+ }
break;
case CCP_AUTH_ALGO_SHA3_224:
case CCP_AUTH_ALGO_SHA3_256:
int result = 0;
struct ccp_session *session;
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
int i, result = 0;
struct ccp_batch_info *b_info;
struct ccp_session *session;
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
EVP_MD_CTX *auth_ctx = NULL;
-#endif
if (rte_mempool_get(qp->batch_mp, (void **)&b_info)) {
CCP_LOG_ERR("batch info allocation failed");
return 0;
}
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
+
auth_ctx = EVP_MD_CTX_create();
if (unlikely(!auth_ctx)) {
CCP_LOG_ERR("Unable to create auth ctx");
return 0;
}
b_info->auth_ctr = 0;
-#endif
+
/* populate batch info necessary for dequeue */
b_info->op_idx = 0;
b_info->lsb_buf_idx = 0;
b_info->head_offset = (uint32_t)(cmd_q->qbase_phys_addr + cmd_q->qidx *
Q_DESC_SIZE);
for (i = 0; i < nb_ops; i++) {
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op[i]->sym->session,
ccp_cryptodev_driver_id);
switch (session->cmd_id) {
result = ccp_crypto_cipher(op[i], cmd_q, b_info);
break;
case CCP_CMD_AUTH:
- result = ccp_crypto_auth(op[i], cmd_q, b_info);
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- b_info->auth_ctr++;
- result = cpu_crypto_auth(qp, op[i],
- session, auth_ctx);
-#endif
+ if (session->auth_opt) {
+ b_info->auth_ctr++;
+ result = cpu_crypto_auth(qp, op[i],
+ session, auth_ctx);
+ } else
+ result = ccp_crypto_auth(op[i], cmd_q, b_info);
break;
case CCP_CMD_CIPHER_HASH:
result = ccp_crypto_cipher(op[i], cmd_q, b_info);
result = ccp_crypto_auth(op[i], cmd_q, b_info);
break;
case CCP_CMD_HASH_CIPHER:
- result = ccp_crypto_auth(op[i], cmd_q, b_info);
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- result = cpu_crypto_auth(qp, op[i],
- session, auth_ctx);
- if (op[i]->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
- continue;
-#endif
+ if (session->auth_opt) {
+ result = cpu_crypto_auth(qp, op[i],
+ session, auth_ctx);
+ if (op[i]->status !=
+ RTE_CRYPTO_OP_STATUS_SUCCESS)
+ continue;
+ } else
+ result = ccp_crypto_auth(op[i], cmd_q, b_info);
+
if (result)
break;
result = ccp_crypto_cipher(op[i], cmd_q, b_info);
rte_ring_enqueue(qp->processed_pkts, (void *)b_info);
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
EVP_MD_CTX_destroy(auth_ctx);
-#endif
return i;
}
int offset, digest_offset;
uint8_t digest_le[64];
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op->sym->session,
ccp_cryptodev_driver_id);
}
static int
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
ccp_prepare_ops(struct ccp_qp *qp,
-#else
-ccp_prepare_ops(struct ccp_qp *qp __rte_unused,
-#endif
struct rte_crypto_op **op_d,
struct ccp_batch_info *b_info,
uint16_t nb_ops)
int i, min_ops;
struct ccp_session *session;
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
EVP_MD_CTX *auth_ctx = NULL;
auth_ctx = EVP_MD_CTX_create();
CCP_LOG_ERR("Unable to create auth ctx");
return 0;
}
-#endif
min_ops = RTE_MIN(nb_ops, b_info->opcnt);
for (i = 0; i < min_ops; i++) {
op_d[i] = b_info->op[b_info->op_idx++];
- session = (struct ccp_session *)get_session_private_data(
+ session = (struct ccp_session *)get_sym_session_private_data(
op_d[i]->sym->session,
ccp_cryptodev_driver_id);
switch (session->cmd_id) {
op_d[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
break;
case CCP_CMD_AUTH:
-#ifndef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- ccp_auth_dq_prepare(op_d[i]);
-#endif
+ if (session->auth_opt == 0)
+ ccp_auth_dq_prepare(op_d[i]);
break;
case CCP_CMD_CIPHER_HASH:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- cpu_crypto_auth(qp, op_d[i],
- session, auth_ctx);
-#else
- ccp_auth_dq_prepare(op_d[i]);
-#endif
+ if (session->auth_opt)
+ cpu_crypto_auth(qp, op_d[i],
+ session, auth_ctx);
+ else
+ ccp_auth_dq_prepare(op_d[i]);
break;
case CCP_CMD_HASH_CIPHER:
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
- op_d[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
-#else
- ccp_auth_dq_prepare(op_d[i]);
-#endif
+ if (session->auth_opt)
+ op_d[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+ else
+ ccp_auth_dq_prepare(op_d[i]);
break;
case CCP_CMD_COMBINED:
ccp_auth_dq_prepare(op_d[i]);
}
}
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
EVP_MD_CTX_destroy(auth_ctx);
-#endif
b_info->opcnt -= min_ops;
return min_ops;
}
} else if (rte_ring_dequeue(qp->processed_pkts,
(void **)&b_info))
return 0;
-#ifdef RTE_LIBRTE_PMD_CCP_CPU_AUTH
+
if (b_info->auth_ctr == b_info->opcnt)
goto success;
-#endif
cur_head_offset = CCP_READ_REG(b_info->cmd_q->reg_base,
CMD_Q_HEAD_LO_BASE);