device/class/crypto.h header reference
[Devices support library module]

The source code of this header can be browsed online.

Description [link] 

Members [link] 

Types [link] 

Functions [link] 

Constants [link] 

Macros [link] 

Members detail [link] 

#define DEV_CRYPTO_INFO(n) [link] 

This macro is declared in device/class/crypto.h source file, line 317.

See also dev_crypto_info_t.

#define DEV_CRYPTO_REQUEST(n) [link] 

This macro is declared in device/class/crypto.h source file, line 325.

See also dev_crypto_request_t.

#define DEV_STATIC_RES_DEV_CRYPTO(path_) [link] 

This macro is declared in device/class/crypto.h source file, line 478.

Preprocessor condition: defined( CONFIG_DEVICE_CRYPTO )

#define DEV_STATIC_RES_DEV_CRYPTO(path_) [link] 

This macro is declared in device/class/crypto.h source file, line 481.

Preprocessor condition: not defined( CONFIG_DEVICE_CRYPTO )

#define DRIVER_CRYPTO_METHODS(prefix) [link] 

This macro is declared in device/class/crypto.h source file, line 340.

See also struct driver_crypto_s.

#define __DEVICE_CRYPTO_H__ [link] 

This macro is declared in device/class/crypto.h source file, line 31.

const char dev_crypto_capabilities_e[] [link] 

This constant is declared in ENUM_DESCRIPTOR function like macro expansion, line 1 in device/class/crypto.h source file, line 50.

Alternate declarations with same identifier: [1], [2].

enum dev_crypto_capabilities_e [link] 

This enum is declared in device/class/crypto.h source file, line 53.

Alternate declarations with same identifier: [1], [2].

IdentifierDescription
DEV_CRYPTO_CAP_64BITS_KEYAlgorithm can work with 64 bits keys.
DEV_CRYPTO_CAP_128BITS_KEYAlgorithm can work with 128 bits keys.
DEV_CRYPTO_CAP_192BITS_KEYAlgorithm can work with 192 bits keys.
DEV_CRYPTO_CAP_256BITS_KEYAlgorithm can work with 256 bits keys.
DEV_CRYPTO_CAP_VARLEN_KEYAlgorithm can work with any key length.
DEV_CRYPTO_CAP_INPLACEImplementation is able to write output data in the same buffer as input data.
DEV_CRYPTO_CAP_NOTINPLACEImplementation is able to write output data in a different buffer from input data.
DEV_CRYPTO_CAP_STATEFULImplementations is able to handle requests where DEV_CRYPTO_INIT and DEV_CRYPTO_FINALIZE are not both set. This is relevant for mode of operations which can be stateful.
See also dev_crypto_context_s::state_data.
DEV_CRYPTO_CAP_ASSOC_DATAThe authentication operations support associated data.

typedef uint8_t dev_crypto_context_id_t [link] 

This typedef is declared in device/class/crypto.h source file, line 348.

struct dev_crypto_context_s [link] 

This struct is declared in device/class/crypto.h source file, line 222.

FieldDescription
void * cache_ptr;Pointer to the device which last used this key. May be set by the driver to reuse the internally expanded key. This field must be set to NULL when the value of key_data, key_len, mode, iv_len or data field is updated.
void * state_data;Algorithm internal state. Used to store the state when either DEV_CRYPTO_INIT or DEV_CRYPTO_FINALIZE are not set in the request.
See also dev_crypto_info_s::state_size and DEV_CRYPTO_CAP_STATEFUL.
const uint8_t * key_data;Key data
uint8_t key_len;Key length in bytes.
uint8_t cache_id;Context id internal to the driver .
See also dev_crypto_ctx_bind.
uint8_t iv_len;Byte length of the IV/counter/nonce buffer.
uint8_t auth_len;Byte length of the authentication tag. If the length is 0, the tag is not generated/checked.
enum dev_crypto_mode_e mode:8;Used mode of operation
bool_t ephemeral:1;This hint flag can be set if the context will not be used several times. This may prevent the driver from using an internal state cache entry.
bool_t encrypt_only:1;This hint flag can be set if the context will only be used to perform encryption. The driver may skip expanding the key for this purpose.
bool_t decrypt_only:1;This hint flag can be set if the context will only be used to perform decryption.

bool_t dev_crypto_ctx_bind(struct dev_crypto_context_s *ctx, struct dev_crypto_context_s *ctx_array[], dev_crypto_context_id_t *next, dev_crypto_context_id_t count) [link] 

This function is declared in device/class/crypto.h source file, line 373.

This function helper function can be used by the crypto driver to handle binding of its internally cached crypto context data to the struct dev_crypto_context_s of a request. An internal context entry is reused if an existing association is still valid. The ctx->cache_id field is updated to the index of the retained internal context entry.

Parameter list:

  • ctx: crypto context of the request
  • ctx_array: array of pointers to cached contexts in driver private data.
  • next: pointer to next cache victim entry in driver private data.
  • count: total number of entries in the cache.

This function returns true if the retained entry still contains valid data. The driver must perform the key schedule and recompute other context related data again if this function returns false.

struct dev_crypto_info_s [link] 

This struct is declared in device/class/crypto.h source file, line 80.

FieldDescription
const char * name;Name of the algorithm
uint16_t modes_mask;Mask of supported modes of operation.
See also dev_crypto_mode_e.
uint16_t state_size;Byte size of the crypto state data.
See also dev_crypto_context_s::state_data.
uint8_t align_log2;required alignment of data buffers
enum dev_crypto_capabilities_e cap:16;capability flags
uint8_t block_len;algorithm block size in bytes, relevant for block ciphers and hash based algorithms.

typedef error_t (dev_crypto_info_t)(const struct device_crypto_s *accessor, struct dev_crypto_info_s *info) [link] 

This typedef is declared in device/class/crypto.h source file, line 323.

This typedef retrieves information about the cryptographic algorithm implemented by the device.

This declaration involves expansion of the DEV_CRYPTO_INFO macro.

uint8_t dev_crypto_memcmp(const void *a, const void *b, size_t len) [link] 

This function is declared in device/class/crypto.h source file, line 405.

const char dev_crypto_mode_e[] [link] 

This constant is declared in ENUM_DESCRIPTOR function like macro expansion, line 1 in device/class/crypto.h source file, line 103.

Alternate declarations with same identifier: [1], [2].

enum dev_crypto_mode_e [link] 

This enum is declared in device/class/crypto.h source file, line 106.

Alternate declarations with same identifier: [1], [2].

IdentifierDescription
DEV_CRYPTO_MODE_ECBElectronic codebook cipher block mode. When this mode is used, the in, out and len fields of the request are used. The data and iv lengths must be multiple of the cipher block size.
DEV_CRYPTO_MODE_CBCCipher-block chaining mode. When this mode is used, the in, out, len and iv_ctr fields of the request are used. The len and iv_len values must be multiple of the cipher block size. The passed iv_ctr buffer is updated if DEV_CRYPTO_FINALIZE is set.
DEV_CRYPTO_MODE_CFBCipher Feedback mode. Usage is similar to DEV_CRYPTO_MODE_CBC.
DEV_CRYPTO_MODE_OFBOutput Feedback cipher mode. Usage is similar to DEV_CRYPTO_MODE_CBC.
DEV_CRYPTO_MODE_CTRCounter cipher mode. When this mode is used, the in, out, len and iv_ctr fields of the request are used. The value of iv_len can be less than the cipher block size. In this case the msb of the counter padded with 0.
The value of len may not be a multiple of the cipher block size. The counter is not updated after processing of a partial block.
The passed iv_ctr buffer is updated if DEV_CRYPTO_FINALIZE is set.
DEV_CRYPTO_MODE_GCMGalois Counter cipher Mode. When this mode is used, the in, out, len, iv_ctr, ad_len and auth fields of the request are used. If the ad_len field is not 0, the ad field must be a valid pointer to the associated data.
The DEV_CRYPTO_INIT and DEV_CRYPTO_FINALIZE operation flags are relevant and a state buffer must be provided when they are not both set. The auth field must be valid when DEV_CRYPTO_FINALIZE is set. The authentication tag is either stored in the auth buffer or checked against it depending on the DEV_CRYPTO_INVERSE flag.
The len and ad_len values must be multiple of the cipher block size when DEV_CRYPTO_FINALIZE is not set.
DEV_CRYPTO_MODE_CCMUsage is similar to DEV_CRYPTO_MODE_GCM.
DEV_CRYPTO_MODE_BLE_CCMBLE-specific CCM mode. In/Out buffers are BLE packets with full packet type and packet length bytes, but without CRC..
DEV_CRYPTO_MODE_OCB3OCB3 cipher mode as specified in rfc7253. Usage is similar to DEV_CRYPTO_MODE_GCM. The iv_ctr field points to the nonce.
DEV_CRYPTO_MODE_STREAMStream cipher mode. When this mode is used, the in, out, len and iv_ctr fields or the request are used. The input data is xored with the generated key stream and stored to the output buffer. If the out field is NULL, the generated key stream is discarded. If the in field is NULL, the key stream is stored instead of being xored. The cipher is initialized when the DEV_CRYPTO_INIT operation flag is set, taking the IV into account when relevant. The DEV_CRYPTO_FINALIZE flag can be used when a state buffer is not provided.
DEV_CRYPTO_MODE_HASHHash processing mode. When this mode is used, the ad, ad_len, out and len fields are used. No key is required. The DEV_CRYPTO_INIT and DEV_CRYPTO_FINALIZE operation flags are relevant and a state buffer must be provided when they are not both set. The input data is pointed to by ad. The out buffer must be valid when DEV_CRYPTO_FINALIZE is set. Variable length output hash algorithms with a stateful implementation may support extra finalizing requests with a zero length input.
DEV_CRYPTO_MODE_HMACHash based message authentication code. When this mode is used, the in, len and auth fields are used. The DEV_CRYPTO_INIT and DEV_CRYPTO_FINALIZE operation flags are relevant and a state buffer must be provided when they are not both set. The auth field must be valid when DEV_CRYPTO_FINALIZE. The authentication tag is either stored in the auth buffer or checked against it depending on the DEV_CRYPTO_INVERSE flag.
DEV_CRYPTO_MODE_CMACCipher based authentication code. When this mode is used, the in, len, iv_ctr and auth fields are used. The DEV_CRYPTO_FINALIZE operation flag is relevant. The iv_ctr field must always be valid and will be updated when not DEV_CRYPTO_FINALIZE. The auth field must be valid when DEV_CRYPTO_FINALIZE. The authentication tag is either stored in the auth buffer or checked against it depending on the DEV_CRYPTO_INVERSE flag. The data length may not be a multiple of a block size. The iv must be equal to a block size.
DEV_CRYPTO_MODE_RANDOMRandom data generator mode. When the DEV_CRYPTO_INVERSE operation flag is set, the random generator is seeded with data from the buffer specified by the ad and ad_len fields of the request. When the DEV_CRYPTO_FINALIZE operation flag is set, random data is stored in the buffer specified by the out and len fields. A state buffer must always be provided and the DEV_CRYPTO_INIT operation flag must be used to initialize the state on the initial request. No key is used.

const char dev_crypto_op_e[] [link] 

This constant is declared in ENUM_DESCRIPTOR function like macro expansion, line 1 in device/class/crypto.h source file, line 265.

Alternate declarations with same identifier: [1], [2].

enum dev_crypto_op_e [link] 

This enum is declared in device/class/crypto.h source file, line 268.

Alternate declarations with same identifier: [1], [2].

IdentifierDescription
DEV_CRYPTO_INITMust be defined when the first chunk of data is processeced by either a cipher with authentication or a hash algorithm.
DEV_CRYPTO_INVERSEInverse the processing direction. For ciphers, this means performing data decryption.
DEV_CRYPTO_FINALIZEMust be defined when the last chunk of data is processeced by either a cipher with authentication or a hash algorithm.

typedef void (dev_crypto_request_t)(const struct device_crypto_s *accessor, struct dev_crypto_rq_s *rq) [link] 

This typedef is declared in device/class/crypto.h source file, line 333.

This typedef starts cryptographic processing.

The kroutine of the request may be executed from within this function. Please read Nested device request completion.

This declaration involves expansion of the DEV_CRYPTO_REQUEST macro.

void dev_crypto_rq_done(struct dev_crypto_rq_s *rq) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function invokes or schedules execution of the crypto request callback associated to the request. For use in device drivers.

struct dev_crypto_rq_s * dev_crypto_rq_from_kr(struct kroutine_s *kr) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function retrieves a pointer to the request when in the request completion callback routine.

struct dev_crypto_rq_s * dev_crypto_rq_head(dev_request_queue_root_t *q) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function returns the oldest crypto request in the given queue. A NULL pointer is returned if the queue is empty. For use in device drivers.

void dev_crypto_rq_init(struct dev_crypto_rq_s *rq, kroutine_exec_t *exec) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function initializes the given crypto request callback. This must be used before submitting the request to a driver.

This is available when CONFIG_MUTEK_KROUTINE_SCHED is defined.

void dev_crypto_rq_init_immediate(struct dev_crypto_rq_s *rq, kroutine_exec_t *exec) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function initializes the given crypto request callback. This must be used before submitting the request to a driver.

void dev_crypto_rq_init_queue(struct dev_crypto_rq_s *rq, kroutine_exec_t *exec, struct kroutine_queue_s *queue) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function initializes the given crypto request callback. This must be used before submitting the request to a driver.

This is available when CONFIG_MUTEK_KROUTINE_QUEUE is defined.

void dev_crypto_rq_init_seq(struct dev_crypto_rq_s *rq, kroutine_exec_t *exec, struct kroutine_sequence_s *seq) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function initializes the given crypto request callback. This must be used before submitting the request to a driver.

This is available when CONFIG_MUTEK_KROUTINE_SCHED is defined.

struct dev_crypto_rq_s * dev_crypto_rq_pop(dev_request_queue_root_t *q) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function removes and return the oldest crypto request in the queue. A NULL pointer is returned if the queue is empty. For use in device drivers.

void dev_crypto_rq_pushback(dev_request_queue_root_t *q, struct dev_crypto_rq_s *rq) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function insert a new crypto request at the end of the given queue. For use in device drivers.

void dev_crypto_rq_remove(dev_request_queue_root_t *q, struct dev_crypto_rq_s *rq) [link] 

This function is declared in device/class/crypto.h source file, line 315.

This function removes the specified crypto request from the queue. For use in device drivers.

struct dev_crypto_rq_s [link] 

This struct is declared in ble/crypto.h source file, line 62.

FieldDescription
union <anonymous> {
struct dev_request_s base;
typeof(struct dev_request_s::error) error;
typeof(struct dev_request_s::pvdata) pvdata;
};
enum dev_crypto_op_e op:3;
struct dev_crypto_context_s * ctx;Key used for encryption/decryption
size_t len;Size of data in the input and output buffers.
const uint8_t * in;Input data.
uint8_t * out;Output data, may be the same as in.
size_t ad_len;Size of data in the ad buffer.
const uint8_t * ad;Associated data and hash input data.
uint8_t * iv_ctr;Pointer to IV/counter/nonce data relevant to various modes. When the size of the buffer is not fixed for the mode in use, it is defined by dev_crypto_context_s::iv_len.
uint8_t * auth;Pointer to authentication data. The size of the buffer is defined by dev_crypto_context_s::auth_len.

struct dev_request_s * dev_crypto_rq_s_base(struct dev_crypto_rq_s *x) [link] 

This function is declared in device/class/crypto.h source file, line 315.

struct dev_crypto_rq_s * dev_crypto_rq_s_cast(struct dev_request_s *x) [link] 

This function is declared in device/class/crypto.h source file, line 315.

error_t dev_crypto_wait_rq(const struct device_crypto_s *acc, struct dev_crypto_rq_s *rq) [link] 

This function is declared in device/class/crypto.h source file, line 476.

This function use the scheduler api to put current context in wait state during the request. This can only be called from a scheduler context.

This is available when CONFIG_MUTEK_CONTEXT_SCHED is defined.

void dev_rng_cleanup(struct dev_rng_s *rng) [link] 

This function is declared in device/class/crypto.h source file, line 439.

this function releases all objects associated to RNG context

Parameter list:

  • rng: RNG context to close

This is available when CONFIG_DEVICE_CRYPTO is defined.

error_t dev_rng_init(struct dev_rng_s *rng, const char *dev) [link] 

This function is declared in device/class/crypto.h source file, line 431.

this function initializes a random number generator context.

Parameter list:

  • rng: RNG backing device to open
  • dev: Device path to open

The return value is 0 on success, or an error

This is available when CONFIG_DEVICE_CRYPTO is defined.

struct dev_rng_s [link] 

This struct is declared in ble/security_db.h source file, line 42.

A random-number generator context, contains a handle on a device and internal state for a RNG.

FieldDescription
struct device_crypto_s device;
void * state_data;

error_t dev_rng_wait_read(struct dev_rng_s *rng, void *data, size_t size) [link] 

This function is declared in device/class/crypto.h source file, line 450.

this function retrieves a random data stream from device

Parameter list:

  • rng: RNG context to read from
  • data: Data pointer to write to
  • size: Byte size to read

The return value is 0 on success, or an error

This is available when CONFIG_DEVICE_CRYPTO and CONFIG_MUTEK_CONTEXT_SCHED are both defined.

error_t dev_rng_wait_seed(struct dev_rng_s *rng, const void *data, size_t size) [link] 

This function is declared in device/class/crypto.h source file, line 461.

this function seeds the RNG with some data

Parameter list:

  • rng: RNG context to seed
  • data: Data pointer to read from
  • size: Byte size to read

The return value is 0 on success, or an error

This is available when CONFIG_DEVICE_CRYPTO and CONFIG_MUTEK_CONTEXT_SCHED are both defined.

error_t dev_rng_wait_seed_from_other(struct dev_rng_s *rng, struct dev_rng_s *other, size_t size) [link] 

This function is declared in device/class/crypto.h source file, line 474.

this function extracts a random stream from a RNG and uses it as seed for another one.

Parameter list:

  • rng: RNG context to seed
  • other: RNG context to read data from
  • size: Byte size to pass from one to the other

The return value is 0 on success, or an error

This is available when CONFIG_DEVICE_CRYPTO and CONFIG_MUTEK_CONTEXT_SCHED are both defined.

struct device_crypto_s [link] 

This struct is declared in ble/crypto.h source file, line 61.

This struct is the device accessor object type for the crypto device class. This accessor must be initialized by calling the device_get_accessor function.

See also DRIVER_CLASS_CRYPTO, struct device_accessor_s and Device accessor.

FieldDescription
union <anonymous> {
struct device_accessor_s base;
struct <anonymous> {
struct device_s * dev;
struct driver_crypto_s * api;
uint_fast8_t number;
};
};

struct device_accessor_s * device_crypto_s_base(struct device_crypto_s *x) [link] 

This function is declared in DRIVER_CLASS_TYPES function like macro expansion, line 40 in device/class/crypto.h source file, line 338.

This function casts a crypto device accessor to a generic device accessor

struct device_crypto_s * device_crypto_s_cast(struct device_accessor_s *x) [link] 

This function is declared in DRIVER_CLASS_TYPES function like macro expansion, line 33 in device/class/crypto.h source file, line 338.

This function casts a generic device accessor to a crypto device accessor

struct driver_crypto_s [link] 

This struct is declared in DRIVER_CLASS_TYPES function like macro expansion, line 5 in device/class/crypto.h source file, line 338.

This struct is the driver API descriptor for the crypto device class.

See also DRIVER_CLASS_CRYPTO and struct driver_class_s.

Valid XHTML 1.0 StrictGenerated by diaxen on Thu Aug 4 15:44:05 2022 using MkDoc