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

Crypto Hash APIs. More...

Data Structures

struct  hash_ctx
 Structure encoding session parameters. More...
 
struct  hash_pkt
 Structure encoding IO parameters of a hash operation. More...
 

Typedefs

typedef int(* hash_op_t) (struct hash_ctx *ctx, struct hash_pkt *pkt, bool finish)
 
typedef void(* hash_completion_cb) (struct hash_pkt *completed, int status)
 

Enumerations

enum  hash_algo { CRYPTO_HASH_ALGO_SHA224 = 1 , CRYPTO_HASH_ALGO_SHA256 = 2 , CRYPTO_HASH_ALGO_SHA384 = 3 , CRYPTO_HASH_ALGO_SHA512 = 4 }
 Hash algorithm. More...
 

Functions

static int hash_begin_session (const struct device *dev, struct hash_ctx *ctx, enum hash_algo algo)
 Setup a hash session.
 
static int hash_free_session (const struct device *dev, struct hash_ctx *ctx)
 Cleanup a hash session.
 
static int hash_callback_set (const struct device *dev, hash_completion_cb cb)
 Registers an async hash completion callback with the driver.
 
static int hash_compute (struct hash_ctx *ctx, struct hash_pkt *pkt)
 Perform a cryptographic hash function.
 
static int hash_update (struct hash_ctx *ctx, struct hash_pkt *pkt)
 Perform a cryptographic multipart hash operation.
 

Detailed Description

Crypto Hash APIs.

Typedef Documentation

◆ hash_completion_cb

typedef void(* hash_completion_cb) (struct hash_pkt *completed, int status)

◆ hash_op_t

typedef int(* hash_op_t) (struct hash_ctx *ctx, struct hash_pkt *pkt, bool finish)

Enumeration Type Documentation

◆ hash_algo

enum hash_algo

#include <include/zephyr/crypto/hash.h>

Hash algorithm.

Enumerator
CRYPTO_HASH_ALGO_SHA224 
CRYPTO_HASH_ALGO_SHA256 
CRYPTO_HASH_ALGO_SHA384 
CRYPTO_HASH_ALGO_SHA512 

Function Documentation

◆ hash_begin_session()

static int hash_begin_session ( const struct device dev,
struct hash_ctx ctx,
enum hash_algo  algo 
)
inlinestatic

#include <include/zephyr/crypto/crypto.h>

Setup a hash session.

Initializes one time parameters, like the algorithm which may remain constant for all operations in the session. The state may be cached in hardware and/or driver data state variables.

Parameters
devPointer to the device structure for the driver instance.
ctxPointer to the context structure. Various one time parameters like session capabilities and algorithm are supplied via this structure. The structure documentation specifies which fields are to be populated by the app before making this call.
algoThe hash algorithm to be used in this session. e.g sha256
Returns
0 on success, negative errno code on fail.

◆ hash_callback_set()

static int hash_callback_set ( const struct device dev,
hash_completion_cb  cb 
)
inlinestatic

#include <include/zephyr/crypto/crypto.h>

Registers an async hash completion callback with the driver.

The application can register an async hash completion callback handler to be invoked by the driver, on completion of a prior request submitted via hash_compute(). Based on crypto device hardware semantics, this is likely to be invoked from an ISR context.

Parameters
devPointer to the device structure for the driver instance.
cbPointer to application callback to be called by the driver.
Returns
0 on success, -ENOTSUP if the driver does not support async op, negative errno code on other error.

◆ hash_compute()

static int hash_compute ( struct hash_ctx ctx,
struct hash_pkt pkt 
)
inlinestatic

#include <include/zephyr/crypto/crypto.h>

Perform a cryptographic hash function.

Parameters
ctxPointer to the hash context of this op.
pktStructure holding the input/output.
Returns
0 on success, negative errno code on fail.

◆ hash_free_session()

static int hash_free_session ( const struct device dev,
struct hash_ctx ctx 
)
inlinestatic

#include <include/zephyr/crypto/crypto.h>

Cleanup a hash session.

Clears the hardware and/or driver state of a session.

See also
hash_begin_session
Parameters
devPointer to the device structure for the driver instance.
ctxPointer to the crypto hash context structure of the session to be freed.
Returns
0 on success, negative errno code on fail.

◆ hash_update()

static int hash_update ( struct hash_ctx ctx,
struct hash_pkt pkt 
)
inlinestatic

#include <include/zephyr/crypto/crypto.h>

Perform a cryptographic multipart hash operation.

This function can be called zero or more times, passing a slice of the data. The hash is calculated using all the given pieces. To calculate the hash call hash_compute().

Parameters
ctxPointer to the hash context of this op.
pktStructure holding the input.
Returns
0 on success, negative errno code on fail.