Crypto completion event is now sole responsibility of the
implementation when API is operating asynchrnously. Synchronous
mode can now return results directly without involving completion
event at all.
Signed-off-by: Robbie King <robk...@cisco.com>
---
example/ipsec/odp_ipsec.c | 81 ++++++++++-------
platform/linux-generic/include/api/odp_crypto.h | 91 +++++++++----------
.../linux-generic/include/odp_crypto_internal.h | 6 +-
platform/linux-generic/odp_crypto.c | 95 +++++++++-----------
test/validation/crypto/odp_crypto_test_async_inp.c | 100 +++++----------------
test/validation/crypto/odp_crypto_test_sync_inp.c | 13 ++-
6 files changed, 164 insertions(+), 222 deletions(-)
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 7a0fbef..036f6b2 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -674,7 +674,8 @@ pkt_disposition_e do_route_fwd_db(odp_packet_t pkt,
pkt_ctx_t *ctx)
static
pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt,
pkt_ctx_t *ctx,
- bool *skip)
+ bool *skip,
+ odp_crypto_op_result_t *result)
{
uint8_t *buf = odp_packet_data(pkt);
odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
@@ -704,6 +705,7 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt,
/* Initialize parameters block */
memset(¶ms, 0, sizeof(params));
+ params.ctx = ctx;
params.session = entry->state.session;
params.pkt = pkt;
params.out_pkt = entry->in_place ? pkt : ODP_PACKET_INVALID;
@@ -740,7 +742,7 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt,
*skip = FALSE;
if (odp_crypto_operation(¶ms,
&posted,
- odp_packet_to_buffer(pkt))) {
+ result)) {
abort();
}
return (posted) ? PKT_POSTED : PKT_CONTINUE;
@@ -756,22 +758,20 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t pkt,
*/
static
pkt_disposition_e do_ipsec_in_finish(odp_packet_t pkt,
- pkt_ctx_t *ctx)
+ pkt_ctx_t *ctx,
+ odp_crypto_op_result_t *result)
{
- odp_buffer_t event;
- odp_crypto_compl_status_t cipher_rc;
- odp_crypto_compl_status_t auth_rc;
odph_ipv4hdr_t *ip;
int hdr_len = ctx->ipsec.hdr_len;
int trl_len = 0;
/* Check crypto result */
- event = odp_packet_to_buffer(pkt);
- odp_crypto_get_operation_compl_status(event, &auth_rc, &cipher_rc);
- if (!is_crypto_compl_status_ok(&cipher_rc))
- return PKT_DROP;
- if (!is_crypto_compl_status_ok(&auth_rc))
- return PKT_DROP;
+ if (!result->ok) {
+ if (!is_crypto_compl_status_ok(&result->cipher_status))
+ return PKT_DROP;
+ if (!is_crypto_compl_status_ok(&result->auth_status))
+ return PKT_DROP;
+ }
ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
/*
@@ -865,6 +865,7 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt,
/* Initialize parameters block */
memset(¶ms, 0, sizeof(params));
params.session = entry->state.session;
+ params.ctx = ctx;
params.pkt = pkt;
params.out_pkt = entry->in_place ? pkt : ODP_PACKET_INVALID;
@@ -952,7 +953,8 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t pkt,
*/
static
pkt_disposition_e do_ipsec_out_seq(odp_packet_t pkt,
- pkt_ctx_t *ctx)
+ pkt_ctx_t *ctx,
+ odp_crypto_op_result_t *result)
{
uint8_t *buf = odp_packet_data(pkt);
bool posted = 0;
@@ -974,7 +976,7 @@ pkt_disposition_e do_ipsec_out_seq(odp_packet_t pkt,
/* Issue crypto request */
if (odp_crypto_operation(&ctx->ipsec.params,
&posted,
- odp_packet_to_buffer(pkt))) {
+ result)) {
abort();
}
return (posted) ? PKT_POSTED : PKT_CONTINUE;
@@ -990,20 +992,18 @@ pkt_disposition_e do_ipsec_out_seq(odp_packet_t pkt,
*/
static
pkt_disposition_e do_ipsec_out_finish(odp_packet_t pkt,
- pkt_ctx_t *ctx)
+ pkt_ctx_t *ctx,
+ odp_crypto_op_result_t *result)
{
- odp_buffer_t event;
- odp_crypto_compl_status_t cipher_rc;
- odp_crypto_compl_status_t auth_rc;
odph_ipv4hdr_t *ip;
/* Check crypto result */
- event = odp_packet_to_buffer(pkt);
- odp_crypto_get_operation_compl_status(event, &auth_rc, &cipher_rc);
- if (!is_crypto_compl_status_ok(&cipher_rc))
- return PKT_DROP;
- if (!is_crypto_compl_status_ok(&auth_rc))
- return PKT_DROP;
+ if (!result->ok) {
+ if (!is_crypto_compl_status_ok(&result->cipher_status))
+ return PKT_DROP;
+ if (!is_crypto_compl_status_ok(&result->auth_status))
+ return PKT_DROP;
+ }
ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
/* Finalize the IPv4 header */
@@ -1051,17 +1051,27 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
pkt_disposition_e rc;
pkt_ctx_t *ctx;
odp_queue_t dispatchq;
+ odp_crypto_op_result_t result;
/* Use schedule to get buf from any input queue */
buf = SCHEDULE(&dispatchq, ODP_SCHED_WAIT);
- pkt = odp_packet_from_buffer(buf);
/* Determine new work versus completion or sequence number */
- if ((completionq != dispatchq) && (seqnumq != dispatchq)) {
+ if (seqnumq == dispatchq) {
+ pkt = odp_packet_from_buffer(buf);
+ ctx = get_pkt_ctx_from_pkt(pkt);
+ } else if (completionq == dispatchq) {
+ odp_crypto_compl_event_t compl_event;
+
+ compl_event = odp_crypto_compl_event_from_buffer(buf);
+ odp_crypto_get_compl_event_result(compl_event, &result);
+ odp_crypto_release_compl_event(compl_event);
+ pkt = result.pkt;
+ ctx = result.ctx;
+ } else {
+ pkt = odp_packet_from_buffer(buf);
ctx = alloc_pkt_ctx(pkt);
ctx->state = PKT_STATE_INPUT_VERIFY;
- } else {
- ctx = get_pkt_ctx_from_pkt(pkt);
}
/*
@@ -1088,7 +1098,10 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
case PKT_STATE_IPSEC_IN_CLASSIFY:
- rc = do_ipsec_in_classify(pkt, ctx, &skip);
+ rc = do_ipsec_in_classify(pkt,
+ ctx,
+ &skip,
+ &result);
ctx->state = (skip) ?
PKT_STATE_ROUTE_LOOKUP :
PKT_STATE_IPSEC_IN_FINISH;
@@ -1096,7 +1109,7 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
case PKT_STATE_IPSEC_IN_FINISH:
- rc = do_ipsec_in_finish(pkt, ctx);
+ rc = do_ipsec_in_finish(pkt, ctx, &result);
ctx->state = PKT_STATE_ROUTE_LOOKUP;
break;
@@ -1108,7 +1121,9 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
case PKT_STATE_IPSEC_OUT_CLASSIFY:
- rc = do_ipsec_out_classify(pkt, ctx, &skip);
+ rc = do_ipsec_out_classify(pkt,
+ ctx,
+ &skip);
if (odp_unlikely(skip)) {
ctx->state = PKT_STATE_TRANSMIT;
} else {
@@ -1119,13 +1134,13 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
case PKT_STATE_IPSEC_OUT_SEQ:
- rc = do_ipsec_out_seq(pkt, ctx);
+ rc = do_ipsec_out_seq(pkt, ctx, &result);
ctx->state = PKT_STATE_IPSEC_OUT_FINISH;
break;
case PKT_STATE_IPSEC_OUT_FINISH:
- rc = do_ipsec_out_finish(pkt, ctx);
+ rc = do_ipsec_out_finish(pkt, ctx, &result);
ctx->state = PKT_STATE_TRANSMIT;
break;
diff --git a/platform/linux-generic/include/api/odp_crypto.h b/platform/linux-generic/include/api/odp_crypto.h
index 337e7cf..3815dee 100644
--- a/platform/linux-generic/include/api/odp_crypto.h
+++ b/platform/linux-generic/include/api/odp_crypto.h
@@ -141,6 +141,7 @@ typedef struct odp_crypto_session_params {
*/
typedef struct odp_crypto_op_params {
odp_crypto_session_t session; /**< Session handle from creation */
+ void *ctx; /**< User context */
odp_packet_t pkt; /**< Input packet buffer */
odp_packet_t out_pkt; /**< Output packet buffer */
uint8_t *override_iv_ptr; /**< Override session IV pointer */
@@ -210,6 +211,21 @@ typedef struct odp_crypto_compl_status {
enum crypto_hw_err hw_err; /**< Hardware specific return code */
} odp_crypto_compl_status_t;
+/**
+ * Cryto API completion event
+ */
+typedef odp_buffer_t odp_crypto_compl_event_t;
+
+/**
+ * Crypto API operation result
+ */
+typedef struct odp_crypto_op_result {
+ odp_bool_t ok; /**< Request completed successfully */
+ void *ctx; /**< User context from request */
+ odp_packet_t pkt; /**< Output packet */
+ odp_crypto_compl_status_t cipher_status; /**< Cipher status */
+ odp_crypto_compl_status_t auth_status; /**< Authentication status */
+} odp_crypto_op_result_t;
/**
* Crypto session creation (synchronous)
@@ -225,76 +241,53 @@ odp_crypto_session_create(odp_crypto_session_params_t
*params,
odp_crypto_session_t *session,
enum odp_crypto_ses_create_err *status);
+/**
+ * Release crypto completion event
+ *
+ * @param completion_event Completion event we are done accessing
+ */
+void
+odp_crypto_release_compl_event(odp_crypto_compl_event_t completion_event);
+
+/**
+ * Convert buffer to completion event
+ *
+ * @param buffer Generic ODP buffer
+ *
+ * @return Completion event
+ */
+odp_crypto_compl_event_t
+odp_crypto_compl_event_from_buffer(odp_buffer_t buffer);
/**
* Crypto per packet operation
*
* Performs the cryptographic operations specified during session creation
* on the packet. If the operation is performed synchronously, "posted"
- * will return FALSE and the result of the operation is immediately available
- * in the completion event. If "posted" returns TRUE the result will be
- * delivered via the completion queue specified when the session was created.
- *
- * @todo Resolve if completion_event is necessary, can/should the output
- * packet buffer always be used instead.
+ * will return FALSE and the result of the operation is immediately available.
+ * If "posted" returns TRUE the result will be delivered via the completion
+ * queue specified when the session was created.
*
* @param params Operation parameters
* @param posted Pointer to return posted, TRUE for async operation
- * @param completion_event Event by which the operation results are delivered.
+ * @param result Results of operation (when posted returns FALSE)
*
* @return 0 if successful else -1
*/
int
odp_crypto_operation(odp_crypto_op_params_t *params,
bool *posted,
- odp_buffer_t completion_event);
+ odp_crypto_op_result_t *result);
/**
- * Crypto per packet operation set user context in completion event
+ * Crypto per packet operation query result from completion event
*
* @param completion_event Event containing operation results
- * @param ctx User data
+ * @param result Pointer to result structure
*/
void
-odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event,
- void *ctx);
-
-/**
- * Crypto per packet operation completion status
- *
- * Accessor function for obtaining operation status from the completion event.
- *
- * @param completion_event Event containing operation results
- * @param auth Pointer to store authentication results
- * @param cipher Pointer to store cipher results
- */
-void
-odp_crypto_get_operation_compl_status(odp_buffer_t completion_event,
- odp_crypto_compl_status_t *auth,
- odp_crypto_compl_status_t *cipher);
-
-/**
- * Crypto per packet operation query completed operation packet
- *
- * Accessor function for obtaining current packet buffer, can be
- * different from input packet buffer on some systems
- *
- * @param completion_event Event containing operation results
- *
- * @return Packet structure where data now resides
- */
-odp_packet_t
-odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event);
-
-/**
- * Crypto per packet operation query user context in completion event
- *
- * @param completion_event Event containing operation results
- *
- * @return User data
- */
-void *
-odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event);
+odp_crypto_get_compl_event_result(odp_crypto_compl_event_t completion_event,
+ odp_crypto_op_result_t *result);
/**
* Generate random byte string
diff --git a/platform/linux-generic/include/odp_crypto_internal.h
b/platform/linux-generic/include/odp_crypto_internal.h
index 2e5a71c..237b1e8 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -59,7 +59,6 @@ struct odp_crypto_generic_session {
} data;
crypto_func_t func;
} auth;
-
};
/**
@@ -67,10 +66,7 @@ struct odp_crypto_generic_session {
*/
typedef struct odp_crypto_generic_op_result {
uint32_t magic;
- odp_crypto_compl_status_t cipher;
- odp_crypto_compl_status_t auth;
- void *op_context;
- odp_packet_t out_pkt;
+ odp_crypto_op_result_t result;
} odp_crypto_generic_op_result_t;
/**
diff --git a/platform/linux-generic/odp_crypto.c
b/platform/linux-generic/odp_crypto.c
index 2f95cbe..f18fa3c 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -340,18 +340,16 @@ odp_crypto_session_create(odp_crypto_session_params_t
*params,
return 0;
}
-
int
odp_crypto_operation(odp_crypto_op_params_t *params,
bool *posted,
- odp_buffer_t completion_event)
+ odp_crypto_op_result_t *result)
{
enum crypto_alg_err rc_cipher = ODP_CRYPTO_ALG_ERR_NONE;
enum crypto_alg_err rc_auth = ODP_CRYPTO_ALG_ERR_NONE;
odp_crypto_generic_session_t *session;
- odp_crypto_generic_op_result_t *result;
+ odp_crypto_op_result_t local_result;
- *posted = 0;
session = (odp_crypto_generic_session_t *)(intptr_t)params->session;
/* Resolve output buffer */
@@ -364,9 +362,6 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
ODP_ABORT();
_odp_packet_copy_to_packet(params->pkt, 0, params->out_pkt, 0,
odp_packet_len(params->pkt));
- if (completion_event == odp_packet_to_buffer(params->pkt))
- completion_event =
- odp_packet_to_buffer(params->out_pkt);
odp_packet_free(params->pkt);
params->pkt = ODP_PACKET_INVALID;
}
@@ -380,19 +375,39 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
rc_cipher = session->cipher.func(params, session);
}
- /* Build Result (no HW so no errors) */
- result = get_op_result_from_buffer(completion_event);
- result->magic = OP_RESULT_MAGIC;
- result->cipher.alg_err = rc_cipher;
- result->cipher.hw_err = ODP_CRYPTO_HW_ERR_NONE;
- result->auth.alg_err = rc_auth;
- result->auth.hw_err = ODP_CRYPTO_HW_ERR_NONE;
- result->out_pkt = params->out_pkt;
+ /* Fill in result */
+ local_result.ctx = params->ctx;
+ local_result.pkt = params->out_pkt;
+ local_result.cipher_status.alg_err = rc_cipher;
+ local_result.cipher_status.hw_err = ODP_CRYPTO_HW_ERR_NONE;
+ local_result.auth_status.alg_err = rc_auth;
+ local_result.auth_status.hw_err = ODP_CRYPTO_HW_ERR_NONE;
+ local_result.ok =
+ (rc_cipher == ODP_CRYPTO_ALG_ERR_NONE) &&
+ (rc_auth == ODP_CRYPTO_ALG_ERR_NONE);
/* If specified during creation post event to completion queue */
if (ODP_QUEUE_INVALID != session->compl_queue) {
+ odp_crypto_compl_event_t completion_event;
+ odp_crypto_generic_op_result_t *op_result;
+
+ /* Linux generic will always use packet for completion event */
+ completion_event = odp_packet_to_buffer(params->out_pkt);
+
+ /* Asynchronous, build result (no HW so no errors) and send it*/
+ op_result = get_op_result_from_buffer(completion_event);
+ op_result->magic = OP_RESULT_MAGIC;
+ op_result->result = local_result;
odp_queue_enq(session->compl_queue, completion_event);
+
+ /* Indicate to caller operation was async */
*posted = 1;
+ } else {
+ /* Synchronous, simply return results */
+ *result = local_result;
+
+ /* Indicate to caller operation was sync */
+ *posted = 0;
}
return 0;
}
@@ -431,55 +446,27 @@ odp_hw_random_get(uint8_t *buf, size_t *len, bool
use_entropy ODP_UNUSED)
}
void
-odp_crypto_get_operation_compl_status(odp_buffer_t completion_event,
- odp_crypto_compl_status_t *auth,
- odp_crypto_compl_status_t *cipher)
+odp_crypto_get_compl_event_result(odp_crypto_compl_event_t completion_event,
+ odp_crypto_op_result_t *result)
{
- odp_crypto_generic_op_result_t *result;
+ odp_crypto_generic_op_result_t *op_result;
- result = get_op_result_from_buffer(completion_event);
+ op_result = get_op_result_from_buffer(completion_event);
- if (OP_RESULT_MAGIC != result->magic)
+ if (OP_RESULT_MAGIC != op_result->magic)
ODP_ABORT();
- memcpy(auth, &result->auth, sizeof(*auth));
- memcpy(cipher, &result->cipher, sizeof(*cipher));
-}
-
-
-void
-odp_crypto_set_operation_compl_ctx(odp_buffer_t completion_event,
- void *ctx)
-{
- odp_crypto_generic_op_result_t *result;
-
- result = get_op_result_from_buffer(completion_event);
- /*
- * Completion event magic can't be checked here, because it is filled
- * later in odp_crypto_operation() function.
- */
-
- result->op_context = ctx;
+ memcpy(result, &op_result->result, sizeof(*result));
}
void
-*odp_crypto_get_operation_compl_ctx(odp_buffer_t completion_event)
+odp_crypto_release_compl_event(odp_crypto_compl_event_t compl_event ODP_UNUSED)
{
- odp_crypto_generic_op_result_t *result;
-
- result = get_op_result_from_buffer(completion_event);
- ODP_ASSERT(OP_RESULT_MAGIC == result->magic, "Bad completion magic");
-
- return result->op_context;
+ /* We use the packet as the completion event so nothing to do here */
}
-odp_packet_t
-odp_crypto_get_operation_compl_packet(odp_buffer_t completion_event)
+odp_crypto_compl_event_t
+odp_crypto_compl_event_from_buffer(odp_buffer_t buffer)
{
- odp_crypto_generic_op_result_t *result;
-
- result = get_op_result_from_buffer(completion_event);
- ODP_ASSERT(OP_RESULT_MAGIC == result->magic, "Bad completion magic");
-
- return result->out_pkt;
+ return (odp_crypto_compl_event_t)buffer;
}
diff --git a/test/validation/crypto/odp_crypto_test_async_inp.c
b/test/validation/crypto/odp_crypto_test_async_inp.c
index 96d4c3f..588592c 100644
--- a/test/validation/crypto/odp_crypto_test_async_inp.c
+++ b/test/validation/crypto/odp_crypto_test_async_inp.c
@@ -25,7 +25,6 @@ static void alg_test(enum odp_crypto_op op,
odp_crypto_key_t cipher_key,
enum odp_auth_alg auth_alg,
odp_crypto_key_t auth_key,
- odp_buffer_t compl_new,
uint8_t *input_vec,
unsigned int input_vec_len,
uint8_t *output_vec,
@@ -35,7 +34,8 @@ static void alg_test(enum odp_crypto_op op,
int rc;
enum odp_crypto_ses_create_err status;
bool posted;
- odp_buffer_t compl_event;
+ odp_buffer_t compl_buff;
+ odp_crypto_op_result_t result;
odp_queue_t compl_queue = odp_queue_lookup("crypto-out");
CU_ASSERT(compl_queue != ODP_QUEUE_INVALID);
@@ -75,6 +75,7 @@ static void alg_test(enum odp_crypto_op op,
op_params.session = session;
op_params.pkt = pkt;
op_params.out_pkt = pkt;
+ op_params.ctx = (void *)0xdeadbeef;
if (cipher_alg != ODP_CIPHER_ALG_NULL &&
auth_alg == ODP_AUTH_ALG_NULL) {
op_params.cipher_range.offset = data_off;
@@ -90,42 +91,30 @@ static void alg_test(enum odp_crypto_op op,
CU_FAIL("%s : not implemented for combined alg mode\n");
}
- if (compl_new == ODP_BUFFER_INVALID) {
- odp_crypto_set_operation_compl_ctx(buf, (void *)0xdeadbeef);
- rc = odp_crypto_operation(&op_params, &posted, buf);
- } else {
- odp_crypto_set_operation_compl_ctx(compl_new,
- (void *)0xdeadbeef);
- rc = odp_crypto_operation(&op_params, &posted, compl_new);
- }
+ rc = odp_crypto_operation(&op_params, &posted, NULL);
CU_ASSERT(posted);
/* Poll completion queue for results */
+ odp_crypto_compl_event_t compl_event;
do {
- compl_event = odp_queue_deq(compl_queue);
- } while (compl_event == ODP_BUFFER_INVALID);
-
- if (compl_new == ODP_BUFFER_INVALID)
- CU_ASSERT(compl_event == buf)
- else
- CU_ASSERT(compl_event == compl_new)
-
- struct odp_crypto_compl_status auth_status, cipher_status;
- odp_crypto_get_operation_compl_status(compl_event,
- &auth_status, &cipher_status);
- CU_ASSERT(auth_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE);
- CU_ASSERT(auth_status.hw_err == ODP_CRYPTO_HW_ERR_NONE);
- CU_ASSERT(cipher_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE);
- CU_ASSERT(cipher_status.hw_err == ODP_CRYPTO_HW_ERR_NONE);
-
- odp_packet_t out_pkt;
- out_pkt = odp_crypto_get_operation_compl_packet(compl_event);
- CU_ASSERT(out_pkt == pkt);
+ compl_buff = odp_queue_deq(compl_queue);
+ } while (compl_buff == ODP_BUFFER_INVALID);
+
+ compl_event = odp_crypto_compl_event_from_buffer(compl_buff);
+ odp_crypto_get_compl_event_result(compl_event, &result);
+ odp_crypto_release_compl_event(compl_event);
+
+ CU_ASSERT(result.ok);
+ CU_ASSERT(result.auth_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE);
+ CU_ASSERT(result.auth_status.hw_err == ODP_CRYPTO_HW_ERR_NONE);
+ CU_ASSERT(result.cipher_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE);
+ CU_ASSERT(result.cipher_status.hw_err == ODP_CRYPTO_HW_ERR_NONE);
+
+ CU_ASSERT(result.pkt == pkt);
CU_ASSERT(!memcmp(data_addr, output_vec, output_vec_len));
- void *ctx = odp_crypto_get_operation_compl_ctx(compl_event);
- CU_ASSERT(ctx == (void *)0xdeadbeef);
+ CU_ASSERT(result.ctx == (void *)0xdeadbeef);
odp_buffer_free(buf);
}
@@ -157,7 +146,6 @@ static void enc_alg_3des_cbc(void)
cipher_key,
ODP_AUTH_ALG_NULL,
auth_key,
- ODP_BUFFER_INVALID,
tdes_cbc_reference_plaintext[i],
tdes_cbc_reference_length[i],
tdes_cbc_reference_ciphertext[i],
@@ -189,7 +177,6 @@ static void enc_alg_3des_cbc_ovr_iv(void)
cipher_key,
ODP_AUTH_ALG_NULL,
auth_key,
- ODP_BUFFER_INVALID,
tdes_cbc_reference_plaintext[i],
tdes_cbc_reference_length[i],
tdes_cbc_reference_ciphertext[i],
@@ -226,7 +213,6 @@ static void dec_alg_3des_cbc(void)
cipher_key,
ODP_AUTH_ALG_NULL,
auth_key,
- ODP_BUFFER_INVALID,
tdes_cbc_reference_ciphertext[i],
tdes_cbc_reference_length[i],
tdes_cbc_reference_plaintext[i],
@@ -260,7 +246,6 @@ static void dec_alg_3des_cbc_ovr_iv(void)
cipher_key,
ODP_AUTH_ALG_NULL,
auth_key,
- ODP_BUFFER_INVALID,
tdes_cbc_reference_ciphertext[i],
tdes_cbc_reference_length[i],
tdes_cbc_reference_plaintext[i],
@@ -298,7 +283,6 @@ static void alg_hmac_md5(void)
cipher_key,
ODP_AUTH_ALG_MD5_96,
auth_key,
- ODP_BUFFER_INVALID,
hmac_md5_reference_plaintext[i],
hmac_md5_reference_length[i],
hmac_md5_reference_digest[i],
@@ -306,55 +290,11 @@ static void alg_hmac_md5(void)
}
}
-/* This test verifies the correctness of encode (plaintext -> ciphertext)
- * operation for 3DES_CBC algorithm. IV for the operation is the session IV.
- * Uses a separate buffer for completion event
- * */
-#define ASYNC_INP_ENC_ALG_3DES_CBC_COMPL_NEW "ENC_ALG_3DES_CBC_COMPL_NEW"
-static void enc_alg_3des_cbc_compl_new(void)
-{
- odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
- auth_key = { .data = NULL, .length = 0 };
- odp_crypto_iv_t iv;
- unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
- sizeof(tdes_cbc_reference_length[0]));
-
- odp_buffer_pool_t pool = odp_buffer_pool_lookup("compl_pool");
- CU_ASSERT(pool != ODP_BUFFER_POOL_INVALID);
-
- unsigned int i;
- odp_buffer_t compl_new;
- for (i = 0; i < test_vec_num; i++) {
- compl_new = odp_buffer_alloc(pool);
- CU_ASSERT(compl_new != ODP_BUFFER_INVALID);
-
- cipher_key.data = tdes_cbc_reference_key[i];
- cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
- iv.data = tdes_cbc_reference_iv[i];
- iv.length = sizeof(tdes_cbc_reference_iv[i]);
-
- alg_test(ODP_CRYPTO_OP_ENCODE,
- ODP_CIPHER_ALG_3DES_CBC,
- iv,
- NULL,
- cipher_key,
- ODP_AUTH_ALG_NULL,
- auth_key,
- compl_new,
- tdes_cbc_reference_plaintext[i],
- tdes_cbc_reference_length[i],
- tdes_cbc_reference_ciphertext[i],
- tdes_cbc_reference_length[i]);
- odp_buffer_free(compl_new);
- }
-}
-
CU_TestInfo test_array_async[] = {
{ASYNC_INP_ENC_ALG_3DES_CBC, enc_alg_3des_cbc },
{ASYNC_INP_DEC_ALG_3DES_CBC, dec_alg_3des_cbc },
{ASYNC_INP_ENC_ALG_3DES_CBC_OVR_IV, enc_alg_3des_cbc_ovr_iv },
{ASYNC_INP_DEC_ALG_3DES_CBC_OVR_IV, dec_alg_3des_cbc_ovr_iv },
{ASYNC_INP_ALG_HMAC_MD5, alg_hmac_md5 },
- {ASYNC_INP_ENC_ALG_3DES_CBC_COMPL_NEW, enc_alg_3des_cbc_compl_new },
CU_TEST_INFO_NULL,
};
diff --git a/test/validation/crypto/odp_crypto_test_sync_inp.c
b/test/validation/crypto/odp_crypto_test_sync_inp.c
index f37ad54..0215b6f 100644
--- a/test/validation/crypto/odp_crypto_test_sync_inp.c
+++ b/test/validation/crypto/odp_crypto_test_sync_inp.c
@@ -24,6 +24,7 @@ static void alg_test(enum odp_crypto_op op,
int rc;
enum odp_crypto_ses_create_err status;
bool posted;
+ odp_crypto_op_result_t result;
odp_queue_t compl_queue = odp_queue_lookup("crypto-out");
CU_ASSERT(compl_queue != ODP_QUEUE_INVALID);
@@ -64,6 +65,7 @@ static void alg_test(enum odp_crypto_op op,
op_params.session = session;
op_params.pkt = pkt;
op_params.out_pkt = pkt;
+ op_params.ctx = (void *)0xdeadbeef;
if (cipher_alg != ODP_CIPHER_ALG_NULL &&
auth_alg == ODP_AUTH_ALG_NULL) {
op_params.cipher_range.offset = data_off;
@@ -80,13 +82,22 @@ static void alg_test(enum odp_crypto_op op,
}
/* TEST : odp_crypto_operation */
- rc = odp_crypto_operation(&op_params, &posted, buf);
+ rc = odp_crypto_operation(&op_params, &posted, &result);
CU_ASSERT(!rc);
/* indication that the operation completed */
CU_ASSERT(!posted);
+ /* TEST: results were ok */
+ CU_ASSERT(result.ok);
+ CU_ASSERT(result.auth_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE);
+ CU_ASSERT(result.auth_status.hw_err == ODP_CRYPTO_HW_ERR_NONE);
+ CU_ASSERT(result.cipher_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE);
+ CU_ASSERT(result.cipher_status.hw_err == ODP_CRYPTO_HW_ERR_NONE);
+
/* TEST : operation output was correct */
CU_ASSERT(!memcmp(data_addr, output_vec, output_vec_len));
+
+ CU_ASSERT(result.ctx == (void *)0xdeadbeef);
}
#define SYNC_INP_ENC_ALG_3DES_CBC "ENC_ALG_3DES_CBC"