---
name: "rte_crypto.h"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_crypto.h"
---

# rte\_crypto.h(3)

## NAME

rte\_crypto.h

## SYNOPSIS

`#include <rte_mbuf.h>`\
 `#include <rte_memory.h>`\
 `#include <rte_mempool.h>`\
 `#include <rte_common.h>`\
 `#include 'rte_crypto_sym.h'`\
 `#include 'rte_crypto_asym.h'`\

### Data Structures

struct **rte\_crypto\_op**\
 struct **rte\_crypto\_op\_pool\_private**\

### Macros

\#define **RTE\_CRYPTO\_OP\_AUX\_FLAGS\_SESS\_SOFT\_EXPIRY**   (1 \<\< 0)\
 \#define **RTE\_CRYPTO\_OP\_AUX\_FLAGS\_IPSEC\_SOFT\_EXPIRY**   **RTE\_CRYPTO\_OP\_AUX\_FLAGS\_SESS\_SOFT\_EXPIRY**\

### Enumerations

enum **rte\_crypto\_op\_type** { **RTE\_CRYPTO\_OP\_TYPE\_UNDEFINED**, **RTE\_CRYPTO\_OP\_TYPE\_SYMMETRIC**, **RTE\_CRYPTO\_OP\_TYPE\_ASYMMETRIC** }\
 enum **rte\_crypto\_op\_status** { **RTE\_CRYPTO\_OP\_STATUS\_SUCCESS**, **RTE\_CRYPTO\_OP\_STATUS\_NOT\_PROCESSED**, **RTE\_CRYPTO\_OP\_STATUS\_AUTH\_FAILED**, **RTE\_CRYPTO\_OP\_STATUS\_INVALID\_SESSION**, **RTE\_CRYPTO\_OP\_STATUS\_INVALID\_ARGS**, **RTE\_CRYPTO\_OP\_STATUS\_ERROR** }\
 enum **rte\_crypto\_op\_sess\_type** { **RTE\_CRYPTO\_OP\_WITH\_SESSION**, **RTE\_CRYPTO\_OP\_SESSIONLESS**, **RTE\_CRYPTO\_OP\_SECURITY\_SESSION** }\

### Functions

static void **\_\_rte\_crypto\_op\_reset** (struct **rte\_crypto\_op** \*op, enum **rte\_crypto\_op\_type** type)\
 static uint16\_t **\_\_rte\_crypto\_op\_get\_priv\_data\_size** (struct **rte\_mempool** \*mempool)\
 struct **rte\_mempool** \* **rte\_crypto\_op\_pool\_create** (const char \*name, enum **rte\_crypto\_op\_type** type, unsigned nb\_elts, unsigned cache\_size, uint16\_t priv\_size, int socket\_id)\
 static int **\_\_rte\_crypto\_op\_raw\_bulk\_alloc** (struct **rte\_mempool** \*mempool, enum **rte\_crypto\_op\_type** type, struct **rte\_crypto\_op** \*\*ops, uint16\_t nb\_ops)\
 static struct **rte\_crypto\_op** \* **rte\_crypto\_op\_alloc** (struct **rte\_mempool** \*mempool, enum **rte\_crypto\_op\_type** type)\
 static unsigned **rte\_crypto\_op\_bulk\_alloc** (struct **rte\_mempool** \*mempool, enum **rte\_crypto\_op\_type** type, struct **rte\_crypto\_op** \*\*ops, uint16\_t nb\_ops)\
 static void \* **\_\_rte\_crypto\_op\_get\_priv\_data** (struct **rte\_crypto\_op** \*op, uint32\_t size)\
 static void **rte\_crypto\_op\_free** (struct **rte\_crypto\_op** \*op)\
 static struct **rte\_crypto\_op** \* **rte\_crypto\_sym\_op\_alloc\_from\_mbuf\_priv\_data** (struct **rte\_mbuf** \*m)\
 static struct **rte\_crypto\_sym\_xform** \* **rte\_crypto\_op\_sym\_xforms\_alloc** (struct **rte\_crypto\_op** \*op, uint8\_t nb\_xforms)\
 static int **rte\_crypto\_op\_attach\_sym\_session** (struct **rte\_crypto\_op** \*op, void \*sess)\
 static int **rte\_crypto\_op\_attach\_asym\_session** (struct **rte\_crypto\_op** \*op, struct rte\_cryptodev\_asym\_session \*sess)\

## Detailed Description

RTE Cryptography Common Definitions

Definition in file **rte\_crypto.h**.

## Macro Definition Documentation

### #define RTE\_CRYPTO\_OP\_AUX\_FLAGS\_SESS\_SOFT\_EXPIRY (1 \<\< 0)

Session soft expiry limit has been reached. Applicable for any session that has a soft lifetime feature supported.

**See also**

**rte\_security\_ipsec\_lifetime**

**rte\_security\_tls\_record\_lifetime**

Definition at line **74** of file **rte\_crypto.h**.

### #define RTE\_CRYPTO\_OP\_AUX\_FLAGS\_IPSEC\_SOFT\_EXPIRY RTE\_CRYPTO\_OP\_AUX\_FLAGS\_SESS\_SOFT\_EXPIRY

SA soft expiry limit has been reached

Definition at line **79** of file **rte\_crypto.h**.

## Enumeration Type Documentation

### enum rte\_crypto\_op\_type

Crypto operation types

**Enumerator**

- *RTE\_CRYPTO\_OP\_TYPE\_UNDEFINED*

  *Undefined operation type*

- *RTE\_CRYPTO\_OP\_TYPE\_SYMMETRIC*

  *Symmetric operation*

- *RTE\_CRYPTO\_OP\_TYPE\_ASYMMETRIC*

  *Asymmetric operation*

*Definition at line* **28** *of file* **rte\_crypto.h***.*

### enum rte\_crypto\_op\_status

*Status of crypto operation*

**Enumerator**

- *RTE\_CRYPTO\_OP\_STATUS\_SUCCESS*

  *Operation completed successfully*

- *RTE\_CRYPTO\_OP\_STATUS\_NOT\_PROCESSED*

  *Operation has not yet been processed by a crypto device*

- *RTE\_CRYPTO\_OP\_STATUS\_AUTH\_FAILED*

  *Authentication verification failed*

- *RTE\_CRYPTO\_OP\_STATUS\_INVALID\_SESSION*

  *Symmetric operation failed due to invalid session arguments, or if in session-less mode, failed to allocate private operation material.*

- *RTE\_CRYPTO\_OP\_STATUS\_INVALID\_ARGS*

  *Operation failed due to invalid arguments in request*

- *RTE\_CRYPTO\_OP\_STATUS\_ERROR*

  *Error handling operation*

*Definition at line* **38** *of file* **rte\_crypto.h***.*

### enum rte\_crypto\_op\_sess\_type

*Crypto operation session type. This is used to specify whether a crypto operation has session structure attached for immutable parameters or if all operation information is included in the operation data structure.*

**Enumerator**

- *RTE\_CRYPTO\_OP\_WITH\_SESSION*

  *Session based crypto operation*

- *RTE\_CRYPTO\_OP\_SESSIONLESS*

  *Session-less crypto operation*

- *RTE\_CRYPTO\_OP\_SECURITY\_SESSION*

  *Security session crypto operation*

*Definition at line* **61** *of file* **rte\_crypto.h***.*

## Function Documentation

### static void \_\_rte\_crypto\_op\_reset (struct rte\_crypto\_op \* op, enum rte\_crypto\_op\_type type)` [inline]`, ` [static]`

*Reset the fields of a crypto operation to their default values.*

**Parameters**

*op The crypto operation to be reset.* \
 *type The crypto operation type.*

*Definition at line* **196** *of file* **rte\_crypto.h***.*

### static uint16\_t \_\_rte\_crypto\_op\_get\_priv\_data\_size (struct rte\_mempool \* mempool)` [inline]`, ` [static]`

*Returns the size of private data allocated with each* **rte\_crypto\_op** *object by the mempool*

**Parameters**

*mempool* **rte\_crypto\_op** *mempool*

**Returns**

*private data size*

*Definition at line* **235** *of file* **rte\_crypto.h***.*

### struct rte\_mempool \* rte\_crypto\_op\_pool\_create (const char \* name, enum rte\_crypto\_op\_type type, unsigned nb\_elts, unsigned cache\_size, uint16\_t priv\_size, int socket\_id)

*Creates a crypto operation pool*

**Parameters**

*name pool name* \
 *type crypto operation type, use RTE\_CRYPTO\_OP\_TYPE\_UNDEFINED for a pool which supports all operation types* \
 *nb\_elts number of elements in pool* \
 *cache\_size Number of elements to cache on lcore, see rte\_mempool\_create for further details about cache size* \
 *priv\_size Size of private data to allocate with each operation* \
 *socket\_id Socket to allocate memory on*

**Returns**

- •

  *On success pointer to mempool*

- •

  *On failure NULL*

### static int \_\_rte\_crypto\_op\_raw\_bulk\_alloc (struct rte\_mempool \* mempool, enum rte\_crypto\_op\_type type, struct rte\_crypto\_op \*\* ops, uint16\_t nb\_ops)` [inline]`, ` [static]`

*Bulk allocate raw element from mempool and return as crypto operations*

**Parameters**

*mempool crypto operation mempool.* \
 *type crypto operation type.* \
 *ops Array to place allocated crypto operations* \
 *nb\_ops Number of crypto operations to allocate*

**Returns**

- •

  *On success returns number of ops allocated*

*Definition at line* **280** *of file* **rte\_crypto.h***.*

### static struct rte\_crypto\_op \* rte\_crypto\_op\_alloc (struct rte\_mempool \* mempool, enum rte\_crypto\_op\_type type)` [inline]`, ` [static]`

*Allocate a crypto operation from a mempool with default parameters set*

**Parameters**

*mempool crypto operation mempool* \
 *type operation type to allocate*

**Returns**

- •

  *On success returns a valid* **rte\_crypto\_op** *structure*

- •

  *On failure returns NULL*

*Definition at line* **308** *of file* **rte\_crypto.h***.*

### static unsigned rte\_crypto\_op\_bulk\_alloc (struct rte\_mempool \* mempool, enum rte\_crypto\_op\_type type, struct rte\_crypto\_op \*\* ops, uint16\_t nb\_ops)` [inline]`, ` [static]`

*Bulk allocate crypto operations from a mempool with default parameters set*

**Parameters**

*mempool crypto operation mempool* \
 *type operation type to allocate* \
 *ops Array to place allocated crypto operations* \
 *nb\_ops Number of crypto operations to allocate*

**Returns**

- •

  *nb\_ops if the number of operations requested were allocated.*

- •

  *0 if the requested number of ops are not available. None are allocated in this case.*

*Definition at line* **338** *of file* **rte\_crypto.h***.*

### static void \* \_\_rte\_crypto\_op\_get\_priv\_data (struct rte\_crypto\_op \* op, uint32\_t size)` [inline]`, ` [static]`

*Returns a pointer to the private data of a crypto operation if that operation has enough capacity for requested size.*

**Parameters**

*op crypto operation.* \
 *size size of space requested in private data.*

**Returns**

- •

  *if sufficient space available returns pointer to start of private data*

- •

  *if insufficient space returns NULL*

*Definition at line* **368** *of file* **rte\_crypto.h***.*

### static void rte\_crypto\_op\_free (struct rte\_crypto\_op \* op)` [inline]`, ` [static]`

*free crypto operation structure If operation has been allocate from a* **rte\_mempool***, then the operation will be returned to the mempool.*

**Parameters**

*op Pointer to symmetric crypto operation allocated with* **rte\_crypto\_op\_alloc()** *If op is NULL, no operation is performed.*

*Definition at line* **398** *of file* **rte\_crypto.h***.*

### static struct rte\_crypto\_op \* rte\_crypto\_sym\_op\_alloc\_from\_mbuf\_priv\_data (struct rte\_mbuf \* m)` [inline]`, ` [static]`

*Allocate a symmetric crypto operation in the private data of an mbuf.*

**Parameters**

*m mbuf which is associated with the crypto operation, the operation will be allocated in the private data of that mbuf.*

**Returns**

- •

  *On success returns a pointer to the crypto operation.*

- •

  *On failure returns NULL.*

*Definition at line* **416** *of file* **rte\_crypto.h***.*

### static struct rte\_crypto\_sym\_xform \* rte\_crypto\_op\_sym\_xforms\_alloc (struct rte\_crypto\_op \* op, uint8\_t nb\_xforms)` [inline]`, ` [static]`

*Allocate space for symmetric crypto xforms in the private data space of the crypto operation. This also defaults the crypto xform type and configures the chaining of the xforms in the crypto operation*

**Returns**

- •

  *On success returns pointer to first crypto xform in crypto operations chain*

- •

  *On failure returns NULL*

*Definition at line* **450** *of file* **rte\_crypto.h***.*

### static int rte\_crypto\_op\_attach\_sym\_session (struct rte\_crypto\_op \* op, void \* sess)` [inline]`, ` [static]`

*Attach a session to a crypto operation*

**Parameters**

*op crypto operation, must be of type symmetric* \
 *sess cryptodev session*

*Definition at line* **476** *of file* **rte\_crypto.h***.*

### static int rte\_crypto\_op\_attach\_asym\_session (struct rte\_crypto\_op \* op, struct rte\_cryptodev\_asym\_session \* sess)` [inline]`, ` [static]`

*Attach a asymmetric session to a crypto operation*

**Parameters**

*op crypto operation, must be of type asymmetric* \
 *sess cryptodev session*

*Definition at line* **493** *of file* **rte\_crypto.h***.*

## Author

*Generated automatically by Doxygen for DPDK from the source code.*
