Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Crypto APIs. More...

Topics

 Cipher
 Crypto Cipher APIs.
 Hash
 Crypto Hash APIs.
 Random Function APIs
 Random Function APIs.

Files

file  crypto.h
 Crypto Cipher APIs.

Data Structures

struct  crypto_driver_api
 @driver_ops{Crypto} More...

Functions

static int crypto_query_hwcaps (const struct device *dev)
 Query the crypto hardware capabilities.
typedef int(* crypto_api_query_hw_caps) (const struct device *dev)
 @def_driverbackendgroup{Crypto,crypto}
typedef int(* crypto_api_cipher_begin_session) (const struct device *dev, struct cipher_ctx *ctx, enum cipher_algo algo, enum cipher_mode mode, enum cipher_op op_type)
 Setup a crypto cipher session.
typedef int(* crypto_api_cipher_free_session) (const struct device *dev, struct cipher_ctx *ctx)
 Cleanup a crypto cipher session.
typedef int(* crypto_api_cipher_async_callback_set) (const struct device *dev, cipher_completion_cb cb)
 Register an asynchronous crypto cipher callback.
typedef int(* crypto_api_hash_begin_session) (const struct device *dev, struct hash_ctx *ctx, enum hash_algo algo)
 Setup a crypto hash session.
typedef int(* crypto_api_hash_free_session) (const struct device *dev, struct hash_ctx *ctx)
 Cleanup a crypto hash session.
typedef int(* crypto_api_hash_async_callback_set) (const struct device *dev, hash_completion_cb cb)
 Register an asynchronous crypto hash callback.

Crypto capability flags

Capability flags returned by crypto_query_hwcaps() and selected in cipher_ctx::flags or hash_ctx::flags during session setup.

Not all drivers support all flags. More flags to be added as necessary.

#define CAP_OPAQUE_KEY_HNDL   BIT(0)
 Key material is referenced through an opaque driver-specific handle.
#define CAP_RAW_KEY   BIT(1)
 Key material is supplied as raw key bytes.
#define CAP_KEY_LOADING_API   BIT(2)
 TBD.
#define CAP_INPLACE_OPS   BIT(3)
 In-place operations are supported.
#define CAP_SEPARATE_IO_BUFS   BIT(4)
 Separate input and output buffers are supported.
#define CAP_SYNC_OPS   BIT(5)
 Synchronous operations are supported.
#define CAP_ASYNC_OPS   BIT(6)
 Asynchronous operations with completion notifications are supported.
#define CAP_AUTONONCE   BIT(7)
 Automatic nonce generation is supported.
#define CAP_NO_IV_PREFIX   BIT(8)
 Cipher output does not include a prefixed IV.

Detailed Description

Crypto APIs.

Since
1.7
Version
1.0.0

Macro Definition Documentation

◆ CAP_ASYNC_OPS

#define CAP_ASYNC_OPS   BIT(6)

#include <crypto.h>

Asynchronous operations with completion notifications are supported.

◆ CAP_AUTONONCE

#define CAP_AUTONONCE   BIT(7)

#include <crypto.h>

Automatic nonce generation is supported.

◆ CAP_INPLACE_OPS

#define CAP_INPLACE_OPS   BIT(3)

#include <crypto.h>

In-place operations are supported.

◆ CAP_KEY_LOADING_API

#define CAP_KEY_LOADING_API   BIT(2)

#include <crypto.h>

TBD.

◆ CAP_NO_IV_PREFIX

#define CAP_NO_IV_PREFIX   BIT(8)

#include <crypto.h>

Cipher output does not include a prefixed IV.

◆ CAP_OPAQUE_KEY_HNDL

#define CAP_OPAQUE_KEY_HNDL   BIT(0)

#include <crypto.h>

Key material is referenced through an opaque driver-specific handle.

◆ CAP_RAW_KEY

#define CAP_RAW_KEY   BIT(1)

#include <crypto.h>

Key material is supplied as raw key bytes.

◆ CAP_SEPARATE_IO_BUFS

#define CAP_SEPARATE_IO_BUFS   BIT(4)

#include <crypto.h>

Separate input and output buffers are supported.

◆ CAP_SYNC_OPS

#define CAP_SYNC_OPS   BIT(5)

#include <crypto.h>

Synchronous operations are supported.

Typedef Documentation

◆ crypto_api_cipher_async_callback_set

typedef int(* crypto_api_cipher_async_callback_set) (const struct device *dev, cipher_completion_cb cb)

#include <crypto.h>

Register an asynchronous crypto cipher callback.

See cipher_callback_set() for argument description.

◆ crypto_api_cipher_begin_session

typedef int(* crypto_api_cipher_begin_session) (const struct device *dev, struct cipher_ctx *ctx, enum cipher_algo algo, enum cipher_mode mode, enum cipher_op op_type)

#include <crypto.h>

Setup a crypto cipher session.

See cipher_begin_session() for argument description.

◆ crypto_api_cipher_free_session

typedef int(* crypto_api_cipher_free_session) (const struct device *dev, struct cipher_ctx *ctx)

#include <crypto.h>

Cleanup a crypto cipher session.

See cipher_free_session() for argument description.

◆ crypto_api_hash_async_callback_set

typedef int(* crypto_api_hash_async_callback_set) (const struct device *dev, hash_completion_cb cb)

#include <crypto.h>

Register an asynchronous crypto hash callback.

See hash_callback_set() for argument description.

◆ crypto_api_hash_begin_session

typedef int(* crypto_api_hash_begin_session) (const struct device *dev, struct hash_ctx *ctx, enum hash_algo algo)

#include <crypto.h>

Setup a crypto hash session.

See hash_begin_session() for argument description.

◆ crypto_api_hash_free_session

typedef int(* crypto_api_hash_free_session) (const struct device *dev, struct hash_ctx *ctx)

#include <crypto.h>

Cleanup a crypto hash session.

See hash_free_session() for argument description.

◆ crypto_api_query_hw_caps

typedef int(* crypto_api_query_hw_caps) (const struct device *dev)

#include <crypto.h>

@def_driverbackendgroup{Crypto,crypto}

Query crypto hardware capabilities. See crypto_query_hwcaps() for argument description.

Function Documentation

◆ crypto_query_hwcaps()

int crypto_query_hwcaps ( const struct device * dev)
inlinestatic

#include <crypto.h>

Query the crypto hardware capabilities.

This API is used by the app to query the capabilities supported by the crypto device. Based on this the app can specify a subset of the supported options to be honored for a session during cipher_begin_session().

Parameters
devPointer to the device structure for the driver instance.
Returns
bitmask of supported options.