API Reference Manual
1.46.0
|
Data ciphering and authentication.
Data Structures | |
union | odp_crypto_cipher_algos_t |
Cipher algorithms in a bit field structure. More... | |
union | odp_crypto_auth_algos_t |
Authentication algorithms in a bit field structure. More... | |
struct | odp_crypto_key |
Crypto API key structure. More... | |
struct | odp_crypto_session_param_t |
Crypto API session creation parameters. More... | |
struct | odp_crypto_packet_op_param_t |
Crypto packet API per packet operation parameters. More... | |
struct | odp_crypto_op_status |
Crypto API per packet operation completion status. More... | |
struct | odp_crypto_packet_result_t |
Crypto packet API operation result. More... | |
struct | odp_crypto_capability_t |
Crypto capabilities. More... | |
struct | odp_crypto_cipher_capability_t |
Cipher algorithm capabilities. More... | |
struct | odp_crypto_auth_capability_t |
Authentication algorithm capabilities. More... | |
Macros | |
#define | ODP_CRYPTO_SESSION_INVALID (0xffffffffffffffffULL) |
Invalid session handle. | |
Typedefs | |
typedef uint64_t | odp_crypto_session_t |
Crypto API opaque session handle. | |
typedef union odp_crypto_cipher_algos_t | odp_crypto_cipher_algos_t |
Cipher algorithms in a bit field structure. | |
typedef union odp_crypto_auth_algos_t | odp_crypto_auth_algos_t |
Authentication algorithms in a bit field structure. | |
typedef struct odp_crypto_key | odp_crypto_key_t |
Crypto API key structure. | |
typedef enum odp_crypto_op_type_t | odp_crypto_op_type_t |
Type of odp_crypto_op()/odp_crypto_op_enq() calls. | |
typedef struct odp_crypto_session_param_t | odp_crypto_session_param_t |
Crypto API session creation parameters. | |
typedef struct odp_crypto_packet_op_param_t | odp_crypto_packet_op_param_t |
Crypto packet API per packet operation parameters. | |
typedef struct odp_crypto_op_status | odp_crypto_op_status_t |
Crypto API per packet operation completion status. | |
typedef struct odp_crypto_packet_result_t | odp_crypto_packet_result_t |
Crypto packet API operation result. | |
typedef struct odp_crypto_capability_t | odp_crypto_capability_t |
Crypto capabilities. | |
typedef struct odp_crypto_cipher_capability_t | odp_crypto_cipher_capability_t |
Cipher algorithm capabilities. | |
typedef struct odp_crypto_auth_capability_t | odp_crypto_auth_capability_t |
Authentication algorithm capabilities. | |
Functions | |
int | odp_crypto_capability (odp_crypto_capability_t *capa) |
Query crypto capabilities. More... | |
int | odp_crypto_cipher_capability (odp_cipher_alg_t cipher, odp_crypto_cipher_capability_t capa[], int num) |
Query supported cipher algorithm capabilities. More... | |
int | odp_crypto_auth_capability (odp_auth_alg_t auth, odp_crypto_auth_capability_t capa[], int num) |
Query supported authentication algorithm capabilities. More... | |
int | odp_crypto_session_create (const odp_crypto_session_param_t *param, odp_crypto_session_t *session, odp_crypto_ses_create_err_t *status) |
Crypto session creation. More... | |
int | odp_crypto_session_destroy (odp_crypto_session_t session) |
Crypto session destroy. More... | |
uint64_t | odp_crypto_session_to_u64 (odp_crypto_session_t hdl) |
Get printable value for an odp_crypto_session_t. More... | |
void | odp_crypto_session_param_init (odp_crypto_session_param_t *param) |
Initialize crypto session parameters. More... | |
odp_packet_t | odp_crypto_packet_from_event (odp_event_t ev) |
Return crypto processed packet that is associated with event. More... | |
odp_event_t | odp_crypto_packet_to_event (odp_packet_t pkt) |
Convert crypto packet handle to event. More... | |
int | odp_crypto_result (odp_crypto_packet_result_t *result, odp_packet_t packet) |
Get crypto operation results from a crypto processed packet. More... | |
int | odp_crypto_op (const odp_packet_t pkt_in[], odp_packet_t pkt_out[], const odp_crypto_packet_op_param_t param[], int num_pkt) |
Crypto packet operation. More... | |
int | odp_crypto_op_enq (const odp_packet_t pkt_in[], const odp_packet_t pkt_out[], const odp_crypto_packet_op_param_t param[], int num_pkt) |
Crypto packet operation. More... | |
enum odp_crypto_op_mode_t |
Crypto API operation mode.
Enumerator | |
---|---|
ODP_CRYPTO_SYNC | Synchronous, return results immediately. |
ODP_CRYPTO_ASYNC | Asynchronous, return results via posted event. |
Definition at line 41 of file api/spec/crypto_types.h.
enum odp_crypto_op_t |
Crypto API operation.
Enumerator | |
---|---|
ODP_CRYPTO_OP_ENCODE | Encrypt and/or compute authentication ICV. |
ODP_CRYPTO_OP_DECODE | Decrypt and/or verify authentication ICV. |
Definition at line 51 of file api/spec/crypto_types.h.
enum odp_cipher_alg_t |
Crypto API cipher algorithm.
Definition at line 61 of file api/spec/crypto_types.h.
enum odp_auth_alg_t |
Crypto API authentication algorithm.
Definition at line 208 of file api/spec/crypto_types.h.
enum odp_crypto_op_type_t |
Type of odp_crypto_op()/odp_crypto_op_enq() calls.
Enumerator | |
---|---|
ODP_CRYPTO_OP_TYPE_LEGACY | Input packet data and metadata are copied to the output packet and then processed. Output packet is allocated by the caller or by ODP.
|
ODP_CRYPTO_OP_TYPE_BASIC | Input packet data and metadata are copied to the output packet and then processed. Output packet is allocated by ODP. |
ODP_CRYPTO_OP_TYPE_OOP | Out-of-place crypto operation. Output packet is provided by the caller and the input packet is not consumed nor modified. Output of the crypto operation is written in the caller provided output packet without affecting other data and metadata of the output packet. Memory layout of the output packet may change during the operation. Crypto output is the processed crypto_range, auth_range and MAC/digest (in encode sessions) of the input packet. |
ODP_CRYPTO_OP_TYPE_BASIC_AND_OOP | Basic or out-of-place crypto operation depending on op params. If the output packet specified in a crypto operation (i.e. pkt_out[i] is ODP_PACKET_INVALID) then the packet is processed the same way as in the ODP_CRYPTO_OP_TYPE_BASIC operation type. Otherwise the packet is processed as in the ODP_CRYPTO_OP_TYPE_OOP operation type. Sessions of this operation type may have lower performance than the more specific operation types. |
Definition at line 694 of file api/spec/crypto_types.h.
Crypto API session creation return code.
Definition at line 1033 of file api/spec/crypto_types.h.
enum odp_crypto_alg_err_t |
Crypto API algorithm return code.
Definition at line 1073 of file api/spec/crypto_types.h.
int odp_crypto_capability | ( | odp_crypto_capability_t * | capa | ) |
Query crypto capabilities.
Outputs crypto capabilities on success.
[out] | capa | Pointer to capability structure for output |
0 | on success |
<0 | on failure |
int odp_crypto_cipher_capability | ( | odp_cipher_alg_t | cipher, |
odp_crypto_cipher_capability_t | capa[], | ||
int | num | ||
) |
Query supported cipher algorithm capabilities.
Outputs all supported configuration options for the algorithm. Output is sorted (from the smallest to the largest) first by key length, then by IV length.
cipher | Cipher algorithm | |
[out] | capa | Array of capability structures for output |
num | Maximum number of capability structures to output |
<0 | on failure |
int odp_crypto_auth_capability | ( | odp_auth_alg_t | auth, |
odp_crypto_auth_capability_t | capa[], | ||
int | num | ||
) |
Query supported authentication algorithm capabilities.
Outputs all supported configuration options for the algorithm. Output is sorted (from the smallest to the largest) first by digest length, then by key length.
auth | Authentication algorithm | |
[out] | capa | Array of capability structures for output |
num | Maximum number of capability structures to output |
<0 | on failure |
int odp_crypto_session_create | ( | const odp_crypto_session_param_t * | param, |
odp_crypto_session_t * | session, | ||
odp_crypto_ses_create_err_t * | status | ||
) |
Crypto session creation.
Create a crypto session according to the session parameters. Use odp_crypto_session_param_init() to initialize parameters into their default values. If call ends up with an error no new session will be created.
The parameter structure as well as the key and IV data pointed to by it can be freed after the call.
param | Session parameters | |
[out] | session | Created session else ODP_CRYPTO_SESSION_INVALID |
[out] | status | Failure code if unsuccessful |
0 | on success |
<0 | on failure |
int odp_crypto_session_destroy | ( | odp_crypto_session_t | session | ) |
Crypto session destroy.
Destroy an unused session. Result is undefined if session is being used (i.e. asynchronous operation is in progress).
session | Session handle |
0 | on success |
<0 | on failure |
uint64_t odp_crypto_session_to_u64 | ( | odp_crypto_session_t | hdl | ) |
Get printable value for an odp_crypto_session_t.
hdl | odp_crypto_session_t handle to be printed |
void odp_crypto_session_param_init | ( | odp_crypto_session_param_t * | param | ) |
Initialize crypto session parameters.
Initialize an odp_crypto_session_param_t to its default values for all fields.
param | Pointer to odp_crypto_session_param_t to be initialized |
odp_packet_t odp_crypto_packet_from_event | ( | odp_event_t | ev | ) |
Return crypto processed packet that is associated with event.
Get packet handle to an crypto processed packet event. Event subtype must be ODP_EVENT_PACKET_CRYPTO. Crypto operation results can be examined with odp_crypto_result().
Note: any invalid parameters will cause undefined behavior and may cause the application to abort or crash.
ev | Event handle |
odp_event_t odp_crypto_packet_to_event | ( | odp_packet_t | pkt | ) |
Convert crypto packet handle to event.
The packet handle must be an output of an crypto operation.
pkt | Packet handle from crypto operation |
int odp_crypto_result | ( | odp_crypto_packet_result_t * | result, |
odp_packet_t | packet | ||
) |
Get crypto operation results from a crypto processed packet.
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.
packet | A crypto processed packet (ODP_EVENT_PACKET_CRYPTO) | |
[out] | result | Pointer to operation result for output or NULL |
0 | Crypto operation succeeded |
-1 | Crypto operation failed |
<-1 | Failed to get crypto operation status of the packet |
int odp_crypto_op | ( | const odp_packet_t | pkt_in[], |
odp_packet_t | pkt_out[], | ||
const odp_crypto_packet_op_param_t | param[], | ||
int | num_pkt | ||
) |
Crypto packet operation.
Performs the SYNC cryptographic operations specified during session creation on the packets. All arrays should be of num_pkt size.
Result of the crypto operation can be checked using odp_crypto_result(). Parse flags in packet metadata are not affected by the crypto operation. In particular, odp_packet_has_error() can not be used for checking if the crypto operation succeeded.
Use of the pkt_out parameter depends on the configured crypto operation type as described below.
ODP_CRYPTO_OP_TYPE_LEGACY:
Caller should initialize each element of pkt_out either with the desired output packet handle or with ODP_PACKET_INVALID to make ODP allocate a new packet from provided pool.
All packet data and metadata are copied from the input packet to the output packet before the requested crypto operation is performed to the output packet. If an output packet is given to the operation, it must be at least as long as the input packet and, in encode operations, long enough for the hash result to be fully inside the packet data. Memory layout of the output packet may change during the crypto operation. If the output packet is longer than needed, it is not truncated and the extra data bytes retain their content.
It is ok to pass the same packet handle as both the input packet and the output packet for the same crypto operation. In that case the input packet is consumed but returned as the output packet (with possibly different memory layout).
ODP_CRYPTO_OP_TYPE_BASIC:
ODP allocates the output packet from the pool from which the input packet was allocated. The processed input packet is consumed. All packet data and metadata are copied from the input packet to the output packet before the requested crypto operation is applied to the output packet. Memory layout (including packet data pointers, head and tail room, segmentation) of the output packet may differ from that of the input packet.
The value of pkt_out[n] is ignored as pkt_out[n] is used purely as an output parameter that returns the handle of the newly allocated packet.
ODP_CRYPTO_OP_TYPE_OOP:
Writes the output bytes of the crypto operation in a caller provided output packet passed through pkt_out[n]. Input packets are not consumed nor modified. Memory layout (including packet data pointers, head and tail room, segmentation) of the output packet may change during the operation.
Crypto output is the processed crypto_range, auth_range and MAC/digest (in encode sessions) of the input packet. The operation behaves as if crypto range and auth range were first copied from the input packet to the output packet and then the crypto operation was applied to the output packet.
Auth range of (AEAD) algorithms that ignore auth range is not copied.
The offset of the crypto range and auth range in the output packet is the same as in the input packet, adjusted by dst_offset_shift operation parameter.
pkt_out[n] must be a valid handle to a packet that is long enough to contain the shifted crypto range, auth range and, in encode sessions, the MAC/digest result. pkt_out[n] must not be the same as any input packet or any other output packet.
OOP_CRYPTO_OP_TYPE_BASIC_AND_OOP:
Behaves as the ODP_CRYPTO_OP_TYPE_BASIC operation type if pkt_out[n] is ODP_PACKET_INVALID. Otherwise behaves as the ODP_CRYPTO_OP_TYPE_OOP operation type.
pkt_in | Packets to be processed | |
[in,out] | pkt_out | Packet handle array for resulting packets |
param | Operation parameters array | |
num_pkt | Number of packets to be processed |
<0 | on failure |
int odp_crypto_op_enq | ( | const odp_packet_t | pkt_in[], |
const odp_packet_t | pkt_out[], | ||
const odp_crypto_packet_op_param_t | param[], | ||
int | num_pkt | ||
) |
Crypto packet operation.
Performs the ASYNC cryptographic operations specified during session creation on the packets. Behaves otherwise like odp_crypto_op() but returns output packets through events.
With operation types other than ODP_CRYPTO_OP_TYPE_LEGACY, packet data of processed packets may not be valid before odp_crypto_result() has been called.
With ODP_CRYPTO_OP_TYPE_OOP, an enqueued input packet is consumed but returned back unmodified after the crypto operation is complete. The caller may not access the input packet until getting the handle back through odp_crypto_result().
All arrays should be of num_pkt size, except that pkt_out parameter is ignored when the crypto operation type is ODP_CRYPTO_OP_TYPE_BASIC.
From packet ordering perspective this function behaves as if each input packet was enqueued to a crypto session specific ODP queue in the order the packets appear in the parameter array. The conceptual session input queue has the same order type (ODP_QUEUE_ORDER_KEEP or ODP_QUEUE_ORDER_IGNORE) as the completion queue of the session. The order of output events of a crypto session in a completion queue is the same as the order of the corresponding input packets in the conceptual session input queue. The order of output events of different crypto sessions is not defined even when they go through the same crypto completion queue.
pkt_in | Packets to be processed |
pkt_out | Packet handle array for resulting packets |
param | Operation parameters array |
num_pkt | Number of packets to be processed |
<0 | on failure |