File crypto_extra.h

PSA cryptography module: Mbed TLS vendor extensions.

This file is reserved for vendor-specific definitions.

Note

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

Defines

PSA_CRYPTO_ITS_RANDOM_SEED_UID
PSA_PAKE_OUTPUT_SIZE(alg, primitive, output_step)

A sufficient output buffer size for psa_pake_output().

If the size of the output buffer is at least this large, it is guaranteed that psa_pake_output() will not fail due to an insufficient output buffer size. The actual size of the output might be smaller in any given call.

See also PSA_PAKE_OUTPUT_MAX_SIZE

Parameters:
  • alg – A PAKE algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_PAKE(alg) is true).

  • primitive – A primitive of type psa_pake_primitive_t that is compatible with algorithm alg.

  • output_step – A value of type psa_pake_step_t that is valid for the algorithm alg.

Returns:

A sufficient output buffer size for the specified PAKE algorithm, primitive, and output step. If the PAKE algorithm, primitive, or output step is not recognized, or the parameters are incompatible, return 0.

PSA_PAKE_INPUT_SIZE(alg, primitive, input_step)

A sufficient input buffer size for psa_pake_input().

The value returned by this macro is guaranteed to be large enough for any valid input to psa_pake_input() in an operation with the specified parameters.

See also PSA_PAKE_INPUT_MAX_SIZE

Parameters:
  • alg – A PAKE algorithm (PSA_ALG_XXX value such that PSA_ALG_IS_PAKE(alg) is true).

  • primitive – A primitive of type psa_pake_primitive_t that is compatible with algorithm alg.

  • input_step – A value of type psa_pake_step_t that is valid for the algorithm alg.

Returns:

A sufficient input buffer size for the specified input, cipher suite and algorithm. If the cipher suite, the input type or PAKE algorithm is not recognized, or the parameters are incompatible, return 0.

PSA_PAKE_OUTPUT_MAX_SIZE

Output buffer size for psa_pake_output() for any of the supported PAKE algorithm and primitive suites and output step.

This macro must expand to a compile-time constant integer.

The value of this macro must be at least as large as the largest value returned by PSA_PAKE_OUTPUT_SIZE()

See also PSA_PAKE_OUTPUT_SIZE(alg, primitive, output_step).

PSA_PAKE_INPUT_MAX_SIZE

Input buffer size for psa_pake_input() for any of the supported PAKE algorithm and primitive suites and input step.

This macro must expand to a compile-time constant integer.

The value of this macro must be at least as large as the largest value returned by PSA_PAKE_INPUT_SIZE()

See also PSA_PAKE_INPUT_SIZE(alg, primitive, output_step).

PSA_PAKE_CIPHER_SUITE_INIT

Returns a suitable initializer for a PAKE cipher suite object of type psa_pake_cipher_suite_t.

PSA_PAKE_OPERATION_INIT

Returns a suitable initializer for a PAKE operation object of type psa_pake_operation_t.

PSA_JPAKE_EXPECTED_INPUTS(round)
PSA_JPAKE_EXPECTED_OUTPUTS(round)

Typedefs

typedef struct mbedtls_psa_stats_s mbedtls_psa_stats_t

Statistics about resource consumption related to the PSA keystore.

Note

The content of this structure is not part of the stable API and ABI of Mbed TLS and may change arbitrarily from version to version.

typedef enum psa_crypto_driver_pake_step psa_crypto_driver_pake_step_t
typedef enum psa_jpake_round psa_jpake_round_t
typedef enum psa_jpake_io_mode psa_jpake_io_mode_t

Enums

enum psa_crypto_driver_pake_step

Values:

enumerator PSA_JPAKE_STEP_INVALID
enumerator PSA_JPAKE_X1_STEP_KEY_SHARE
enumerator PSA_JPAKE_X1_STEP_ZK_PUBLIC
enumerator PSA_JPAKE_X1_STEP_ZK_PROOF
enumerator PSA_JPAKE_X2_STEP_KEY_SHARE
enumerator PSA_JPAKE_X2_STEP_ZK_PUBLIC
enumerator PSA_JPAKE_X2_STEP_ZK_PROOF
enumerator PSA_JPAKE_X2S_STEP_KEY_SHARE
enumerator PSA_JPAKE_X2S_STEP_ZK_PUBLIC
enumerator PSA_JPAKE_X2S_STEP_ZK_PROOF
enumerator PSA_JPAKE_X4S_STEP_KEY_SHARE
enumerator PSA_JPAKE_X4S_STEP_ZK_PUBLIC
enumerator PSA_JPAKE_X4S_STEP_ZK_PROOF
enum psa_jpake_round

Values:

enumerator PSA_JPAKE_FIRST
enumerator PSA_JPAKE_SECOND
enumerator PSA_JPAKE_FINISHED
enum psa_jpake_io_mode

Values:

enumerator PSA_JPAKE_INPUT
enumerator PSA_JPAKE_OUTPUT

Functions

void mbedtls_psa_crypto_free(void)

Library deinitialization.

This function clears all data associated with the PSA layer, including the whole key store. This function is not thread safe, it wipes every key slot regardless of state and reader count. It should only be called when no slot is in use.

This is an Mbed TLS extension.

void mbedtls_psa_get_stats(mbedtls_psa_stats_t *stats)

Get statistics about resource consumption related to the PSA keystore.

Note

When Mbed TLS is built as part of a service, with isolation between the application and the keystore, the service may or may not expose this function.

psa_status_t mbedtls_psa_inject_entropy(const uint8_t *seed, size_t seed_size)

Inject an initial entropy seed for the random generator into secure storage.

This function injects data to be used as a seed for the random generator used by the PSA Crypto implementation. On devices that lack a trusted entropy source (preferably a hardware random number generator), the Mbed PSA Crypto implementation uses this value to seed its random generator.

On devices without a trusted entropy source, this function must be called exactly once in the lifetime of the device. On devices with a trusted entropy source, calling this function is optional. In all cases, this function may only be called before calling any other function in the PSA Crypto API, including psa_crypto_init().

When this function returns successfully, it populates a file in persistent storage. Once the file has been created, this function can no longer succeed.

If any error occurs, this function does not change the system state. You can call this function again after correcting the reason for the error if possible.

This is an Mbed TLS extension.

Warning

This function can fail! Callers MUST check the return status.

Warning

If you use this function, you should use it as part of a factory provisioning process. The value of the injected seed is critical to the security of the device. It must be secret, unpredictable and (statistically) unique per device. You should be generate it randomly using a cryptographically secure random generator seeded from trusted entropy sources. You should transmit it securely to the device and ensure that its value is not leaked or stored anywhere beyond the needs of transmitting it from the point of generation to the call of this function, and erase all copies of the value once this function returns.

Note

This function is only available on the following platforms:

  • If the compile-time option MBEDTLS_PSA_INJECT_ENTROPY is enabled. Note that you must provide compatible implementations of mbedtls_nv_seed_read and mbedtls_nv_seed_write.

  • In a client-server integration of PSA Cryptography, on the client side, if the server supports this feature.

Parameters:
  • seed – [in] Buffer containing the seed value to inject.

  • seed_size – [in] Size of the seed buffer. The size of the seed in bytes must be greater or equal to both MBEDTLS_ENTROPY_BLOCK_SIZE and the value of MBEDTLS_ENTROPY_MIN_PLATFORM in library/entropy_poll.h in the Mbed TLS source code. It must be less or equal to MBEDTLS_ENTROPY_MAX_SEED_SIZE.

Return values:
  • PSA_SUCCESS – The seed value was injected successfully. The random generator of the PSA Crypto implementation is now ready for use. You may now call psa_crypto_init() and use the PSA Crypto implementation.

  • PSA_ERROR_INVALID_ARGUMENT – seed_size is out of range.

  • PSA_ERROR_STORAGE_FAILURE – There was a failure reading or writing from storage.

  • PSA_ERROR_NOT_PERMITTED – The library has already been initialized. It is no longer possible to call this function.

struct mbedtls_psa_stats_s
#include <crypto_extra.h>

Statistics about resource consumption related to the PSA keystore.

Note

The content of this structure is not part of the stable API and ABI of Mbed TLS and may change arbitrarily from version to version.

Public Members

size_t private_volatile_slots

Number of slots containing key material for a volatile key.

size_t private_persistent_slots

Number of slots containing key material for a key which is in internal persistent storage.

size_t private_external_slots

Number of slots containing a reference to a key in a secure element.

size_t private_half_filled_slots

Number of slots which are occupied, but do not contain key material yet.

size_t private_cache_slots

Number of slots that contain cache data.

size_t private_empty_slots

Number of slots that are not used for anything.

size_t private_locked_slots

Number of slots that are locked.

psa_key_id_t private_max_open_internal_key_id

Largest key id value among open keys in internal persistent storage.

psa_key_id_t private_max_open_external_key_id

Largest key id value among open keys in secure elements.

struct psa_pake_cipher_suite_s
#include <crypto_extra.h>

Public Members

psa_algorithm_t algorithm
psa_pake_primitive_type_t type
psa_pake_family_t family
uint16_t bits
psa_algorithm_t hash
struct psa_crypto_driver_pake_inputs_s
#include <crypto_extra.h>

Public Members

uint8_t *private_password
size_t private_password_len
uint8_t *private_user
size_t private_user_len
uint8_t *private_peer
size_t private_peer_len
psa_key_attributes_t private_attributes
struct psa_pake_cipher_suite_s private_cipher_suite
struct psa_jpake_computation_stage_s
#include <crypto_extra.h>

Public Members

psa_jpake_round_t private_round
psa_jpake_io_mode_t private_io_mode
uint8_t private_inputs
uint8_t private_outputs
psa_pake_step_t private_step
struct psa_pake_operation_s
#include <crypto_extra.h>

Public Members

unsigned int private_id

Unique ID indicating which driver got assigned to do the operation. Since driver contexts are driver-specific, swapping drivers halfway through the operation is not supported. ID values are auto-generated in psa_crypto_driver_wrappers.h ID value zero means the context is not valid or not assigned to any driver (i.e. none of the driver contexts are active).

psa_algorithm_t private_alg
psa_pake_primitive_t private_primitive
uint8_t private_stage
uint8_t private_dummy
union psa_pake_operation_s private_computation_stage
psa_driver_pake_context_t private_ctx
struct psa_crypto_driver_pake_inputs_s private_inputs
union psa_pake_operation_s private_data