aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJanne Peltonen <janne.peltonen@nokia.com>2023-02-20 19:29:41 +0200
committerMatias Elo <matias.elo@nokia.com>2023-04-12 15:52:37 +0300
commit0be8f3cf50a84b6baaa80c962b6b2496df9a0136 (patch)
tree4f768f17baa6113bb03c78c822a6ce91c09e1e5b /include
parenta62bd4553adf996a3305a64dc638f97ce1617122 (diff)
api: crypto: simplify operation result reporting
Make the return value of odp_crypto_result() indicate crypto operation success/failure too. Deprecate the ok field of odp_crypto_packet_result_t. Specify that the status fields of odp_crypto_packet_result_t are valid only when the operation failed, odp_crypto_result() returned -1. This way an implementation does not need to fill the status fields in the typical case when the operation succeeds. Allow the result pointer to be null, making filling the result structure optional. Deprecate odp_crypto_hw_err_t type and the hw_err field of odp_crypto_op_status_t. It is simpler to have all errors reported through the alg_err field. Deprecate ODP_CRYPTO_ALG_ERR_KEY_SIZE and ODP_CRYPTO_ALG_ERR_IV_INVALID error codes. Key length is a session parameter and an error in key size can be reported at session creation time. IV is now a mandatory operation parameter so a specific error code for null IV pointer is less useful than it was when it was possible to provide IV at session creation. Clarify the description of ODP_CRYPTO_ALG_ERR_DATA_SIZE. Add a new crypto operation error ODP_CRYPTO_ALG_ERR_OTHER to cover cases for which the other errors do not fit. Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com> Reviewed-by: Anoob Joseph <anoobj@marvell.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'include')
-rw-r--r--include/odp/api/spec/crypto.h27
-rw-r--r--include/odp/api/spec/crypto_types.h26
2 files changed, 34 insertions, 19 deletions
diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index 4292b78c1..d9265c57e 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -259,17 +259,28 @@ odp_event_t odp_crypto_packet_to_event(odp_packet_t pkt);
/**
* Get crypto operation results from a crypto processed packet
*
- * Successful crypto operations of all types (SYNC and ASYNC) produce packets
- * which contain crypto result metadata. This function copies the operation
- * results from a crypto processed packet. Event subtype of this kind of
- * packet is ODP_EVENT_PACKET_CRYPTO. Results are undefined if a non-crypto
- * processed packet is passed as input.
+ * Crypto operations of all types (SYNC and ASYNC) produce packets which
+ * contain crypto result metadata. This function returns success status
+ * of the crypto operation that was applied to a packet and optionally
+ * writes additional information in a result structure.
+ *
+ * If the crypto operation succeeded, zero is returned and the values
+ * written in the cipher_status and auth_status fields of the result
+ * structure have undefined values.
+ *
+ * If the crypto operation failed, -1 is returned and the cipher_status
+ * and auth_status fields of the result structure indicate the reason for
+ * the failure.
+ *
+ * The subtype of the passed packet must be ODP_EVENT_PACKET_CRYPTO,
+ * otherwise the result of the call is undefined.
*
* @param packet A crypto processed packet (ODP_EVENT_PACKET_CRYPTO)
- * @param[out] result Pointer to operation result for output
+ * @param[out] result Pointer to operation result for output or NULL
*
- * @retval 0 On success
- * @retval <0 On failure
+ * @retval 0 Crypto operation succeeded
+ * @retval -1 Crypto operation failed
+ * @retval <-1 Failed to get crypto operation status of the packet
*/
int odp_crypto_result(odp_crypto_packet_result_t *result,
odp_packet_t packet);
diff --git a/include/odp/api/spec/crypto_types.h b/include/odp/api/spec/crypto_types.h
index ae232db78..24b9fbbfd 100644
--- a/include/odp/api/spec/crypto_types.h
+++ b/include/odp/api/spec/crypto_types.h
@@ -897,14 +897,16 @@ typedef enum {
typedef enum {
/** Algorithm successful */
ODP_CRYPTO_ALG_ERR_NONE,
- /** Invalid data block size */
+ /** Invalid range or packet size */
ODP_CRYPTO_ALG_ERR_DATA_SIZE,
/** Key size invalid for algorithm */
- ODP_CRYPTO_ALG_ERR_KEY_SIZE,
+ ODP_DEPRECATE(ODP_CRYPTO_ALG_ERR_KEY_SIZE),
/** Computed ICV value mismatch */
ODP_CRYPTO_ALG_ERR_ICV_CHECK,
/** IV value not specified */
- ODP_CRYPTO_ALG_ERR_IV_INVALID,
+ ODP_DEPRECATE(ODP_CRYPTO_ALG_ERR_IV_INVALID),
+ /** Other error */
+ ODP_CRYPTO_ALG_ERR_OTHER,
} odp_crypto_alg_err_t;
/**
@@ -912,12 +914,12 @@ typedef enum {
*/
typedef enum {
/** Operation completed successfully */
- ODP_CRYPTO_HW_ERR_NONE,
+ ODP_DEPRECATE(ODP_CRYPTO_HW_ERR_NONE),
/** Error detected during DMA of data */
- ODP_CRYPTO_HW_ERR_DMA,
+ ODP_DEPRECATE(ODP_CRYPTO_HW_ERR_DMA),
/** Operation failed due to pool depletion */
- ODP_CRYPTO_HW_ERR_BP_DEPLETED,
-} odp_crypto_hw_err_t;
+ ODP_DEPRECATE(ODP_CRYPTO_HW_ERR_BP_DEPLETED),
+} ODP_DEPRECATE(odp_crypto_hw_err_t);
/**
* Cryto API per packet operation completion status
@@ -927,8 +929,7 @@ typedef struct odp_crypto_op_status {
odp_crypto_alg_err_t alg_err;
/** Hardware specific return code */
- odp_crypto_hw_err_t hw_err;
-
+ ODP_DEPRECATE(odp_crypto_hw_err_t) ODP_DEPRECATE(hw_err);
} odp_crypto_op_status_t;
/**
@@ -958,8 +959,11 @@ typedef struct odp_crypto_op_result {
* Crypto packet API operation result
*/
typedef struct odp_crypto_packet_result_t {
- /** Request completed successfully */
- odp_bool_t ok;
+ /** Request completed successfully.
+ *
+ * @deprecated Check the return value of odp_crypto_result() instead.
+ */
+ odp_bool_t ODP_DEPRECATE(ok);
/** Input packet passed to odp_crypo_op_enq() when the operation
* type of the session is ODP_CRYPTO_OP_TYPE_OOP. In other cases