Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
cipher_structs.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
17#ifndef ZEPHYR_INCLUDE_CRYPTO_CIPHER_STRUCTS_H_
18#define ZEPHYR_INCLUDE_CRYPTO_CIPHER_STRUCTS_H_
19
20#include <device.h>
21#include <sys/util.h>
31};
32
37};
38
50};
51
52/* Forward declarations */
53struct cipher_aead_pkt;
54struct cipher_ctx;
55struct cipher_pkt;
56
57typedef int (*block_op_t)(struct cipher_ctx *ctx, struct cipher_pkt *pkt);
58
59/* Function signatures for encryption/ decryption using standard cipher modes
60 * like CBC, CTR, CCM.
61 */
62typedef int (*cbc_op_t)(struct cipher_ctx *ctx, struct cipher_pkt *pkt,
63 uint8_t *iv);
64
65typedef int (*ctr_op_t)(struct cipher_ctx *ctx, struct cipher_pkt *pkt,
66 uint8_t *ctr);
67
68typedef int (*ccm_op_t)(struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt,
69 uint8_t *nonce);
70
71typedef int (*gcm_op_t)(struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt,
72 uint8_t *nonce);
73
74struct cipher_ops {
75
77
78 union {
84 };
85};
86
87struct ccm_params {
90};
91
92struct ctr_params {
93 /* CTR mode counter is a split counter composed of iv and counter
94 * such that ivlen + ctr_len = keylen
95 */
97};
98
99struct gcm_params {
102};
103
111
117
119 union {
120 /* Cryptographic key to be used in this session */
122 /* For cases where key is protected and is not
123 * available to caller
124 */
125 void *handle;
127
131 const struct device *device;
132
141
147
152 union {
157
162
170};
171
172/* cipher_ctx.flags values. Not all drivers support all flags.
173 * A user app can query the supported hw / driver
174 * capabilities via provided API (cipher_query_hwcaps()), and choose a
175 * supported config during the session setup.
176 */
177#define CAP_OPAQUE_KEY_HNDL BIT(0)
178#define CAP_RAW_KEY BIT(1)
179
180/* TBD to define */
181#define CAP_KEY_LOADING_API BIT(2)
182
184#define CAP_INPLACE_OPS BIT(3)
185#define CAP_SEPARATE_IO_BUFS BIT(4)
186
191#define CAP_SYNC_OPS BIT(5)
192#define CAP_ASYNC_OPS BIT(6)
193
195#define CAP_AUTONONCE BIT(7)
196
198#define CAP_NO_IV_PREFIX BIT(8)
199
200/* More flags to be added as necessary */
201
202
212
215
218
224
229
234
240};
241
249 /* IO buffers for encryption. This has to be supplied by the app. */
251
256
259
265};
266
267/* Prototype for the application function to be invoked by the crypto driver
268 * on completion of an async request. The app may get the session context
269 * via the pkt->ctx field. For CCM ops the encompassing AEAD packet may be
270 * accessed via container_of(). The type of a packet can be determined via
271 * pkt->ctx.ops.mode .
272 */
273typedef void (*crypto_completion_cb)(struct cipher_pkt *completed, int status);
274
278#endif /* ZEPHYR_INCLUDE_CRYPTO_CIPHER_STRUCTS_H_ */
void
Definition: eswifi_shell.c:15
cipher_op
Definition: cipher_structs.h:34
int(* ccm_op_t)(struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt, uint8_t *nonce)
Definition: cipher_structs.h:68
int(* block_op_t)(struct cipher_ctx *ctx, struct cipher_pkt *pkt)
Definition: cipher_structs.h:57
void(* crypto_completion_cb)(struct cipher_pkt *completed, int status)
Definition: cipher_structs.h:273
cipher_algo
Definition: cipher_structs.h:29
int(* cbc_op_t)(struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *iv)
Definition: cipher_structs.h:62
int(* ctr_op_t)(struct cipher_ctx *ctx, struct cipher_pkt *pkt, uint8_t *ctr)
Definition: cipher_structs.h:65
int(* gcm_op_t)(struct cipher_ctx *ctx, struct cipher_aead_pkt *pkt, uint8_t *nonce)
Definition: cipher_structs.h:71
cipher_mode
Definition: cipher_structs.h:44
@ CRYPTO_CIPHER_OP_DECRYPT
Definition: cipher_structs.h:35
@ CRYPTO_CIPHER_OP_ENCRYPT
Definition: cipher_structs.h:36
@ CRYPTO_CIPHER_ALGO_AES
Definition: cipher_structs.h:30
@ CRYPTO_CIPHER_MODE_GCM
Definition: cipher_structs.h:49
@ CRYPTO_CIPHER_MODE_ECB
Definition: cipher_structs.h:45
@ CRYPTO_CIPHER_MODE_CCM
Definition: cipher_structs.h:48
@ CRYPTO_CIPHER_MODE_CTR
Definition: cipher_structs.h:47
@ CRYPTO_CIPHER_MODE_CBC
Definition: cipher_structs.h:46
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Definition: cipher_structs.h:87
uint16_t tag_len
Definition: cipher_structs.h:88
uint16_t nonce_len
Definition: cipher_structs.h:89
Definition: cipher_structs.h:248
uint8_t * ad
Definition: cipher_structs.h:255
uint32_t ad_len
Definition: cipher_structs.h:258
uint8_t * tag
Definition: cipher_structs.h:264
struct cipher_pkt * pkt
Definition: cipher_structs.h:250
Definition: cipher_structs.h:110
void * app_sessn_state
Definition: cipher_structs.h:146
uint16_t keylen
Definition: cipher_structs.h:161
struct ccm_params ccm_info
Definition: cipher_structs.h:153
const struct device * device
Definition: cipher_structs.h:131
uint16_t flags
Definition: cipher_structs.h:169
void * drv_sessn_state
Definition: cipher_structs.h:140
void * handle
Definition: cipher_structs.h:125
struct ctr_params ctr_info
Definition: cipher_structs.h:154
union cipher_ctx::@93 key
union cipher_ctx::@94 mode_params
struct gcm_params gcm_info
Definition: cipher_structs.h:155
uint8_t * bit_stream
Definition: cipher_structs.h:121
struct cipher_ops ops
Definition: cipher_structs.h:116
Definition: cipher_structs.h:74
block_op_t block_crypt_hndlr
Definition: cipher_structs.h:79
gcm_op_t gcm_crypt_hndlr
Definition: cipher_structs.h:83
enum cipher_mode cipher_mode
Definition: cipher_structs.h:76
cbc_op_t cbc_crypt_hndlr
Definition: cipher_structs.h:80
ctr_op_t ctr_crypt_hndlr
Definition: cipher_structs.h:81
ccm_op_t ccm_crypt_hndlr
Definition: cipher_structs.h:82
Definition: cipher_structs.h:211
struct cipher_ctx * ctx
Definition: cipher_structs.h:239
uint8_t * in_buf
Definition: cipher_structs.h:214
int out_buf_max
Definition: cipher_structs.h:228
uint8_t * out_buf
Definition: cipher_structs.h:223
int out_len
Definition: cipher_structs.h:233
int in_len
Definition: cipher_structs.h:217
Definition: cipher_structs.h:92
uint32_t ctr_len
Definition: cipher_structs.h:96
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
Definition: cipher_structs.h:99
uint16_t tag_len
Definition: cipher_structs.h:100
uint16_t nonce_len
Definition: cipher_structs.h:101
Misc utilities.