|
Zephyr API Documentation 4.4.0
A Scalable Open Source RTOS
|
Crypto Cipher APIs. More...
Data Structures | |
| struct | cipher_ops |
| Cipher operation handlers selected for a session. More... | |
| struct | ccm_params |
| struct | ctr_params |
| struct | gcm_params |
| struct | ctr_drbg_params |
| struct | cipher_ctx |
| Structure encoding session parameters. More... | |
| struct | cipher_pkt |
| Structure encoding IO parameters of one cryptographic operation like encrypt/decrypt. More... | |
| struct | cipher_aead_pkt |
| Structure encoding IO parameters in AEAD (Authenticated Encryption with Associated Data) scenario like in CCM. More... | |
Typedefs | |
| typedef int(* | block_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt) |
| typedef int(* | cbc_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
| typedef int(* | ctr_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *ctr) |
| typedef int(* | ccm_op_t) (struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt, uint8_t *nonce) |
| typedef int(* | gcm_op_t) (struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt, uint8_t *nonce) |
| typedef int(* | ctr_drbg_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *ctr) |
| typedef int(* | cfb_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
| Perform a CFB cipher operation. | |
| typedef int(* | ofb_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
| Perform an OFB cipher operation. | |
| typedef void(* | cipher_completion_cb) (struct cipher_pkt *completed, int status) |
Enumerations | |
| enum | cipher_algo { CRYPTO_CIPHER_ALGO_AES = 1 } |
| Cipher Algorithm. More... | |
| enum | cipher_op { CRYPTO_CIPHER_OP_DECRYPT = 0 , CRYPTO_CIPHER_OP_ENCRYPT = 1 } |
| Cipher Operation. More... | |
| enum | cipher_mode { CRYPTO_CIPHER_MODE_ECB = 1 , CRYPTO_CIPHER_MODE_CBC = 2 , CRYPTO_CIPHER_MODE_CTR = 3 , CRYPTO_CIPHER_MODE_CCM = 4 , CRYPTO_CIPHER_MODE_GCM = 5 , CRYPTO_CIPHER_MODE_CFB = 6 , CRYPTO_CIPHER_MODE_OFB = 7 , CRYPTO_CIPHER_MODE_CTR_DRBG = 6 } |
| Possible cipher mode options. More... | |
Functions | |
| static int | cipher_begin_session (const struct device *dev, struct cipher_ctx *ctx, enum cipher_algo algo, enum cipher_mode mode, enum cipher_op optype) |
| Setup a crypto session. | |
| static int | cipher_free_session (const struct device *dev, struct cipher_ctx *ctx) |
| Cleanup a crypto session. | |
| static int | cipher_callback_set (const struct device *dev, cipher_completion_cb cb) |
| Registers an async crypto op completion callback with the driver. | |
| static int | cipher_block_op (struct cipher_ctx *ctx, struct cipher_pkt *pkt) |
| Perform single-block crypto operation (ECB cipher mode). | |
| static int | cipher_cbc_op (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
| Perform Cipher Block Chaining (CBC) crypto operation. | |
| static int | cipher_cfb_op (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
| Perform Cipher Feedback (CFB) crypto operation. | |
| static int | cipher_ofb_op (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
| Perform Output Feedback (OFB) mode crypto operation. | |
| static int | cipher_ctr_op (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
| Perform Counter (CTR) mode crypto operation. | |
| static int | cipher_ccm_op (struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt, uint8_t *nonce) |
| Perform Counter with CBC-MAC (CCM) mode crypto operation. | |
| static int | cipher_gcm_op (struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt, uint8_t *nonce) |
| Perform Galois/Counter Mode (GCM) crypto operation. | |
| static int | cipher_ctr_drbg_op (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
| Perform Counter-Deterministic Random Bit Generator (CTR-DRBG) mode crypto operation. | |
Crypto Cipher APIs.
| typedef int(* block_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt) |
#include <zephyr/crypto/cipher.h>
| typedef int(* cbc_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
#include <zephyr/crypto/cipher.h>
| typedef int(* ccm_op_t) (struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt, uint8_t *nonce) |
#include <zephyr/crypto/cipher.h>
| typedef int(* cfb_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
#include <zephyr/crypto/cipher.h>
Perform a CFB cipher operation.
| ctx | Cipher session context. |
| pkt | Packet containing input and output buffers. |
| iv | Initialization vector for this operation. |
| 0 | Operation completed successfully. |
| -errno | Negative errno code on failure. |
| typedef void(* cipher_completion_cb) (struct cipher_pkt *completed, int status) |
#include <zephyr/crypto/cipher.h>
| typedef int(* ctr_drbg_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *ctr) |
#include <zephyr/crypto/cipher.h>
| typedef int(* ctr_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *ctr) |
#include <zephyr/crypto/cipher.h>
| typedef int(* gcm_op_t) (struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt, uint8_t *nonce) |
#include <zephyr/crypto/cipher.h>
| typedef int(* ofb_op_t) (struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv) |
#include <zephyr/crypto/cipher.h>
Perform an OFB cipher operation.
| ctx | Cipher session context. |
| pkt | Packet containing input and output buffers. |
| iv | Initialization vector for this operation. |
| 0 | Operation completed successfully. |
| -errno | Negative errno code on failure. |
| enum cipher_algo |
| enum cipher_mode |
#include <zephyr/crypto/cipher.h>
Possible cipher mode options.
More to be added as required.
| enum cipher_op |
#include <zephyr/crypto/cipher.h>
Cipher Operation.
| Enumerator | |
|---|---|
| CRYPTO_CIPHER_OP_DECRYPT | |
| CRYPTO_CIPHER_OP_ENCRYPT | |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Setup a crypto session.
Initializes one time parameters, like the session key, algorithm and cipher mode which may remain constant for all operations in the session. The state may be cached in hardware and/or driver data state variables.
| dev | Pointer to the device structure for the driver instance. |
| ctx | Pointer to the context structure. Various one time parameters like key, keylength, etc. are supplied via this structure. The structure documentation specifies which fields are to be populated by the app before making this call. |
| algo | The crypto algorithm to be used in this session. e.g AES |
| mode | The cipher mode to be used in this session. e.g CBC, CTR |
| optype | Whether we should encrypt or decrypt in this session |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Perform single-block crypto operation (ECB cipher mode).
This should not be overloaded to operate on multiple blocks for security reasons.
| ctx | Pointer to the crypto context of this op. |
| pkt | Structure holding the input/output buffer pointers. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Registers an async crypto op completion callback with the driver.
The application can register an async crypto op completion callback handler to be invoked by the driver, on completion of a prior request submitted via cipher_do_op(). Based on crypto device hardware semantics, this is likely to be invoked from an ISR context.
| dev | Pointer to the device structure for the driver instance. |
| cb | Pointer to application callback to be called by the driver. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Perform Cipher Block Chaining (CBC) crypto operation.
| ctx | Pointer to the crypto context of this op. |
| pkt | Structure holding the input/output buffer pointers. |
| iv | Initialization Vector (IV) for the operation. Same IV value should not be reused across multiple operations (within a session context) for security. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Perform Counter with CBC-MAC (CCM) mode crypto operation.
| ctx | Pointer to the crypto context of this op. |
| pkt | Structure holding the input/output, Associated Data (AD) and auth tag buffer pointers. |
| nonce | Nonce for the operation. Same nonce value should not be reused across multiple operations (within a session context) for security. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Perform Cipher Feedback (CFB) crypto operation.
| ctx | Pointer to the crypto context of this op. |
| pkt | Structure holding the input/output buffer pointers. |
| iv | Initialization Vector (IV) for the operation. Same IV value should not be reused across multiple operations (within a session context) for security. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Perform Counter-Deterministic Random Bit Generator (CTR-DRBG) mode crypto operation.
CTR-DRBG is not a standalone algorithm but a mechanism to generate random numbers using an existing block cipher algorithm like AES in CTR mode. While AES is a block cipher used for encryption and decryption, CTR-DRBG leverages the properties of AES in CTR mode to produce pseudorandom numbers.
| ctx | Pointer to the crypto context of this op. |
| pkt | Structure holding the input/output buffer pointers (input buffer is not used). |
| iv | Initialization Vector (IV) for the operation. We use a split counter formed by appending IV and ctr. Consequently ivlen = keylen - ctrlen. 'ctrlen' is specified during session setup through the 'ctx.mode_params.ctr_drbg_params.ctr_len' parameter. IV should not be reused across multiple operations (within a session context) for security. The non-IV part of the split counter is transparent to the caller and is fully managed by the crypto provider. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Perform Counter (CTR) mode crypto operation.
| ctx | Pointer to the crypto context of this op. |
| pkt | Structure holding the input/output buffer pointers. |
| iv | Initialization Vector (IV) for the operation. We use a split counter formed by appending IV and ctr. Consequently ivlen = keylen - ctrlen. 'ctrlen' is specified during session setup through the 'ctx.mode_params.ctr_params.ctr_len' parameter. IV should not be reused across multiple operations (within a session context) for security. The non-IV part of the split counter is transparent to the caller and is fully managed by the crypto provider. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Cleanup a crypto session.
Clears the hardware and/or driver state of a previous session.
| dev | Pointer to the device structure for the driver instance. |
| ctx | Pointer to the crypto context structure of the session to be freed. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Perform Galois/Counter Mode (GCM) crypto operation.
| ctx | Pointer to the crypto context of this op. |
| pkt | Structure holding the input/output, Associated Data (AD) and auth tag buffer pointers. |
| nonce | Nonce for the operation. Same nonce value should not be reused across multiple operations (within a session context) for security. |
|
inlinestatic |
#include <zephyr/crypto/crypto.h>
Perform Output Feedback (OFB) mode crypto operation.
| ctx | Pointer to the crypto context of this op. |
| pkt | Structure holding the input/output buffer pointers. |
| iv | Initialization Vector (IV) for the operation. Same IV value should not be reused across multiple operations (within a session context) for security. |