Mbed TLS v4.1.2
Loading...
Searching...
No Matches
crypto_struct.h File Reference

PSA cryptography module: Mbed TLS structured type implementations. More...

Include dependency graph for crypto_struct.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  psa_hash_operation_s
struct  psa_xof_operation_s
struct  psa_cipher_operation_s
struct  psa_mac_operation_s
struct  psa_aead_operation_s
struct  psa_key_derivation_s
struct  psa_custom_key_parameters_s
struct  psa_key_policy_s
struct  psa_key_attributes_s
struct  psa_sign_hash_interruptible_operation_s
 The context for PSA interruptible hash signing. More...
struct  psa_verify_hash_interruptible_operation_s
 The context for PSA interruptible hash verification. More...
struct  psa_key_agreement_iop_s
 The context for PSA interruptible key agreement. More...
struct  psa_generate_key_iop_s
 The context for PSA interruptible key generation. More...
struct  psa_export_public_key_iop_s
 The context for PSA interruptible export public-key. More...

Macros

#define PSA_HASH_OPERATION_INIT   { 0, { 0 } }
#define PSA_XOF_OPERATION_INIT   { 0, 0, 0, 0, 0, 0, 0, { 0 } }
#define PSA_CIPHER_OPERATION_INIT   { 0, 0, 0, 0, { 0 } }
#define PSA_MAC_OPERATION_INIT   { 0, 0, 0, { 0 } }
#define PSA_AEAD_OPERATION_INIT   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } }
#define PSA_KEY_DERIVATION_OPERATION_INIT   { 0, 0, 0, { 0 } }
#define PSA_CUSTOM_KEY_PARAMETERS_INIT   { 0 }
#define PSA_KEY_POLICY_INIT   { 0, 0, 0 }
#define PSA_KEY_BITS_TOO_LARGE   ((psa_key_bits_t) -1)
#define PSA_MAX_KEY_BITS   0xfff8
#define PSA_KEY_ATTRIBUTES_INIT
#define PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT   { 0, { 0 }, 0, 0 }
#define PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT   { 0, { 0 }, 0, 0 }
#define PSA_KEY_AGREEMENT_IOP_INIT
#define PSA_GENERATE_KEY_IOP_INIT
#define PSA_EXPORT_PUBLIC_KEY_IOP_INIT   { 0, MBEDTLS_PSA_EXPORT_PUBLIC_KEY_IOP_INIT, 0, 0 }

Typedefs

typedef struct psa_key_policy_s psa_key_policy_t
typedef uint16_t psa_key_bits_t

Functions

static struct psa_hash_operation_s psa_hash_operation_init (void)
static struct psa_xof_operation_s psa_xof_operation_init (void)
static struct psa_cipher_operation_s psa_cipher_operation_init (void)
static struct psa_mac_operation_s psa_mac_operation_init (void)
static struct psa_aead_operation_s psa_aead_operation_init (void)
static struct psa_key_derivation_s psa_key_derivation_operation_init (void)
static struct psa_key_policy_s psa_key_policy_init (void)
static struct psa_key_attributes_s psa_key_attributes_init (void)
static void psa_set_key_id (psa_key_attributes_t *attributes, mbedtls_svc_key_id_t key)
static mbedtls_svc_key_id_t psa_get_key_id (const psa_key_attributes_t *attributes)
static void psa_set_key_lifetime (psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
static psa_key_lifetime_t psa_get_key_lifetime (const psa_key_attributes_t *attributes)
static void psa_extend_key_usage_flags (psa_key_usage_t *usage_flags)
static void psa_set_key_usage_flags (psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
static psa_key_usage_t psa_get_key_usage_flags (const psa_key_attributes_t *attributes)
static void psa_set_key_algorithm (psa_key_attributes_t *attributes, psa_algorithm_t alg)
static psa_algorithm_t psa_get_key_algorithm (const psa_key_attributes_t *attributes)
static void psa_set_key_type (psa_key_attributes_t *attributes, psa_key_type_t type)
static psa_key_type_t psa_get_key_type (const psa_key_attributes_t *attributes)
static void psa_set_key_bits (psa_key_attributes_t *attributes, size_t bits)
static size_t psa_get_key_bits (const psa_key_attributes_t *attributes)
static struct psa_sign_hash_interruptible_operation_s psa_sign_hash_interruptible_operation_init (void)
static struct psa_verify_hash_interruptible_operation_s psa_verify_hash_interruptible_operation_init (void)
static struct psa_key_agreement_iop_s psa_key_agreement_iop_init (void)
static struct psa_generate_key_iop_s psa_generate_key_iop_init (void)
static struct psa_export_public_key_iop_s psa_export_public_key_iop_init (void)

Detailed Description

PSA cryptography module: Mbed TLS structured type implementations.

Note
This file may not be included directly. Applications must include psa/crypto.h.

This file contains the definitions of some data structures with implementation-specific definitions.

In implementations with isolation between the application and the cryptography module, it is expected that the front-end and the back-end would have different versions of this file.

Design notes about multipart operation structures

For multipart operations without driver delegation support, each multipart operation structure contains a psa_algorithm_t alg field which indicates which specific algorithm the structure is for. When the structure is not in use, alg is 0. Most of the structure consists of a union which is discriminated by alg.

For multipart operations with driver delegation support, each multipart operation structure contains an unsigned int id field indicating which driver got assigned to do the operation. When the structure is not in use, 'id' is 0. The structure contains also a driver context which is the union of the contexts of all drivers able to handle the type of multipart operation.

Note that when alg or id is 0, the content of other fields is undefined. In particular, it is not guaranteed that a freshly-initialized structure is all-zero: we initialize structures to something like {0, 0}, which is only guaranteed to initializes the first member of the union; GCC and Clang initialize the whole structure to 0 (at the time of writing), but MSVC and CompCert don't.

In Mbed TLS, multipart operation structures live independently from the key. This allows Mbed TLS to free the key objects when destroying a key slot. If a multipart operation needs to remember the key after the setup function returns, the operation structure needs to contain a copy of the key.

Definition in file crypto_struct.h.

Macro Definition Documentation

◆ PSA_CUSTOM_KEY_PARAMETERS_INIT

#define PSA_CUSTOM_KEY_PARAMETERS_INIT   { 0 }

The default production parameters for key generation or key derivation.

Calling psa_generate_key_custom() or psa_key_derivation_output_key_custom() with custom=PSA_CUSTOM_KEY_PARAMETERS_INIT and custom_data_length=0 is equivalent to calling psa_generate_key() or psa_key_derivation_output_key() respectively.

Definition at line 267 of file crypto_struct.h.

◆ PSA_EXPORT_PUBLIC_KEY_IOP_INIT

#define PSA_EXPORT_PUBLIC_KEY_IOP_INIT   { 0, MBEDTLS_PSA_EXPORT_PUBLIC_KEY_IOP_INIT, 0, 0 }

Definition at line 615 of file crypto_struct.h.

Referenced by psa_export_public_key_iop_init().

◆ PSA_GENERATE_KEY_IOP_INIT

#define PSA_GENERATE_KEY_IOP_INIT
Value:
{ 0, MBEDTLS_PSA_GENERATE_KEY_IOP_INIT, PSA_KEY_ATTRIBUTES_INIT, \
0, 0 }
#define PSA_KEY_ATTRIBUTES_INIT

Definition at line 578 of file crypto_struct.h.

Referenced by psa_generate_key_iop_init().

◆ PSA_KEY_AGREEMENT_IOP_INIT

#define PSA_KEY_AGREEMENT_IOP_INIT
Value:
{ 0, MBEDTLS_PSA_KEY_AGREEMENT_IOP_INIT, 0, \

Definition at line 540 of file crypto_struct.h.

Referenced by psa_key_agreement_iop_init().

◆ PSA_KEY_BITS_TOO_LARGE

#define PSA_KEY_BITS_TOO_LARGE   ((psa_key_bits_t) -1)

Definition at line 288 of file crypto_struct.h.

Referenced by psa_set_key_bits().

◆ PSA_KEY_POLICY_INIT

#define PSA_KEY_POLICY_INIT   { 0, 0, 0 }

Definition at line 276 of file crypto_struct.h.

Referenced by psa_key_policy_init().

◆ PSA_MAX_KEY_BITS

#define PSA_MAX_KEY_BITS   0xfff8

Definition at line 294 of file crypto_struct.h.

Referenced by psa_set_key_bits().

◆ PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT

#define PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT   { 0, { 0 }, 0, 0 }

Definition at line 464 of file crypto_struct.h.

Referenced by psa_sign_hash_interruptible_operation_init().

◆ PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT

#define PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT   { 0, { 0 }, 0, 0 }

Definition at line 502 of file crypto_struct.h.

Referenced by psa_verify_hash_interruptible_operation_init().

Typedef Documentation

◆ psa_key_bits_t

typedef uint16_t psa_key_bits_t

Definition at line 285 of file crypto_struct.h.

◆ psa_key_policy_t

Definition at line 274 of file crypto_struct.h.

Function Documentation

◆ psa_aead_operation_init()

struct psa_aead_operation_s psa_aead_operation_init ( void )
inlinestatic

Definition at line 221 of file crypto_struct.h.

References PSA_AEAD_OPERATION_INIT, and psa_aead_operation_init().

◆ psa_cipher_operation_init()

struct psa_cipher_operation_s psa_cipher_operation_init ( void )
inlinestatic

Definition at line 150 of file crypto_struct.h.

References PSA_CIPHER_OPERATION_INIT, and psa_cipher_operation_init().

◆ psa_export_public_key_iop_init()

struct psa_export_public_key_iop_s psa_export_public_key_iop_init ( void )
inlinestatic

◆ psa_extend_key_usage_flags()

◆ psa_generate_key_iop_init()

struct psa_generate_key_iop_s psa_generate_key_iop_init ( void )
inlinestatic

Definition at line 583 of file crypto_struct.h.

References PSA_GENERATE_KEY_IOP_INIT, and psa_generate_key_iop_init().

Referenced by psa_generate_key_iop_init().

◆ psa_get_key_algorithm()

psa_algorithm_t psa_get_key_algorithm ( const psa_key_attributes_t * attributes)
inlinestatic

Definition at line 404 of file crypto_struct.h.

References psa_get_key_algorithm().

◆ psa_get_key_bits()

size_t psa_get_key_bits ( const psa_key_attributes_t * attributes)
inlinestatic

Definition at line 432 of file crypto_struct.h.

References psa_get_key_bits().

◆ psa_get_key_id()

mbedtls_svc_key_id_t psa_get_key_id ( const psa_key_attributes_t * attributes)
inlinestatic

Definition at line 341 of file crypto_struct.h.

References psa_get_key_id().

◆ psa_get_key_lifetime()

psa_key_lifetime_t psa_get_key_lifetime ( const psa_key_attributes_t * attributes)
inlinestatic

Definition at line 368 of file crypto_struct.h.

References psa_get_key_lifetime().

◆ psa_get_key_type()

psa_key_type_t psa_get_key_type ( const psa_key_attributes_t * attributes)
inlinestatic

Definition at line 416 of file crypto_struct.h.

References psa_get_key_type().

◆ psa_get_key_usage_flags()

psa_key_usage_t psa_get_key_usage_flags ( const psa_key_attributes_t * attributes)
inlinestatic

Definition at line 392 of file crypto_struct.h.

References psa_get_key_usage_flags().

◆ psa_hash_operation_init()

struct psa_hash_operation_s psa_hash_operation_init ( void )
inlinestatic

Definition at line 82 of file crypto_struct.h.

References PSA_HASH_OPERATION_INIT, and psa_hash_operation_init().

◆ psa_key_agreement_iop_init()

struct psa_key_agreement_iop_s psa_key_agreement_iop_init ( void )
inlinestatic

◆ psa_key_attributes_init()

struct psa_key_attributes_s psa_key_attributes_init ( void )
inlinestatic

Definition at line 320 of file crypto_struct.h.

References PSA_KEY_ATTRIBUTES_INIT, and psa_key_attributes_init().

◆ psa_key_derivation_operation_init()

struct psa_key_derivation_s psa_key_derivation_operation_init ( void )
inlinestatic

◆ psa_key_policy_init()

struct psa_key_policy_s psa_key_policy_init ( void )
inlinestatic

Definition at line 277 of file crypto_struct.h.

References PSA_KEY_POLICY_INIT, and psa_key_policy_init().

Referenced by psa_key_policy_init().

◆ psa_mac_operation_init()

struct psa_mac_operation_s psa_mac_operation_init ( void )
inlinestatic

Definition at line 182 of file crypto_struct.h.

References PSA_MAC_OPERATION_INIT, and psa_mac_operation_init().

◆ psa_set_key_algorithm()

void psa_set_key_algorithm ( psa_key_attributes_t * attributes,
psa_algorithm_t alg )
inlinestatic

Definition at line 398 of file crypto_struct.h.

References psa_set_key_algorithm().

◆ psa_set_key_bits()

void psa_set_key_bits ( psa_key_attributes_t * attributes,
size_t bits )
inlinestatic

Definition at line 422 of file crypto_struct.h.

References PSA_KEY_BITS_TOO_LARGE, PSA_MAX_KEY_BITS, and psa_set_key_bits().

◆ psa_set_key_id()

◆ psa_set_key_lifetime()

void psa_set_key_lifetime ( psa_key_attributes_t * attributes,
psa_key_lifetime_t lifetime )
inlinestatic

Definition at line 355 of file crypto_struct.h.

References PSA_KEY_LIFETIME_IS_VOLATILE, and psa_set_key_lifetime().

◆ psa_set_key_type()

void psa_set_key_type ( psa_key_attributes_t * attributes,
psa_key_type_t type )
inlinestatic

Definition at line 410 of file crypto_struct.h.

References psa_set_key_type().

◆ psa_set_key_usage_flags()

void psa_set_key_usage_flags ( psa_key_attributes_t * attributes,
psa_key_usage_t usage_flags )
inlinestatic

Definition at line 385 of file crypto_struct.h.

References psa_extend_key_usage_flags(), and psa_set_key_usage_flags().

◆ psa_sign_hash_interruptible_operation_init()

struct psa_sign_hash_interruptible_operation_s psa_sign_hash_interruptible_operation_init ( void )
inlinestatic

◆ psa_verify_hash_interruptible_operation_init()

struct psa_verify_hash_interruptible_operation_s psa_verify_hash_interruptible_operation_init ( void )
inlinestatic

◆ psa_xof_operation_init()

struct psa_xof_operation_s psa_xof_operation_init ( void )
inlinestatic

Definition at line 118 of file crypto_struct.h.

References PSA_XOF_OPERATION_INIT, and psa_xof_operation_init().