mbed TLS v3.1.0
Macros | Typedefs | Functions
psa_util.h File Reference

Utility functions for the use of the PSA Crypto library. More...

#include "mbedtls/private_access.h"
#include "mbedtls/build_info.h"
#include "psa/crypto.h"
#include "mbedtls/ecp.h"
#include "mbedtls/md.h"
#include "mbedtls/pk.h"
#include "mbedtls/oid.h"
#include "mbedtls/error.h"
#include <string.h>
Include dependency graph for psa_util.h:

Go to the source code of this file.

Macros

#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   1
 
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 192 + 7 ) / 8 ) + 1 )
 
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 224 + 7 ) / 8 ) + 1 )
 
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 256 + 7 ) / 8 ) + 1 )
 
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 384 + 7 ) / 8 ) + 1 )
 
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 521 + 7 ) / 8 ) + 1 )
 
#define MBEDTLS_PSA_RANDOM_STATE   NULL
 

Typedefs

typedef int mbedtls_f_rng_t (void *p_rng, unsigned char *output, size_t output_size)
 

Functions

static psa_key_type_t mbedtls_psa_translate_cipher_type (mbedtls_cipher_type_t cipher)
 
static psa_algorithm_t mbedtls_psa_translate_cipher_mode (mbedtls_cipher_mode_t mode, size_t taglen)
 
static psa_key_usage_t mbedtls_psa_translate_cipher_operation (mbedtls_operation_t op)
 
static psa_algorithm_t mbedtls_psa_translate_md (mbedtls_md_type_t md_alg)
 
static int mbedtls_psa_get_ecc_oid_from_id (psa_ecc_family_t curve, size_t bits, char const **oid, size_t *oid_len)
 
static int mbedtls_psa_err_translate_pk (psa_status_t status)
 
static psa_key_type_t mbedtls_psa_parse_tls_ecc_group (uint16_t tls_ecc_grp_reg_id, size_t *bits)
 
static int mbedtls_psa_tls_psa_ec_to_ecpoint (unsigned char *src, size_t srclen, unsigned char **dst, size_t *dstlen)
 
static int mbedtls_psa_tls_ecpoint_to_psa_ec (unsigned char const *src, size_t srclen, unsigned char *dst, size_t dstlen, size_t *olen)
 
int mbedtls_psa_get_random (void *p_rng, unsigned char *output, size_t output_size)
 

Detailed Description

Utility functions for the use of the PSA Crypto library.

Warning
This function is not part of the public API and may change at any time.

Definition in file psa_util.h.

Macro Definition Documentation

#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   1

Definition at line 294 of file psa_util.h.

#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 192 + 7 ) / 8 ) + 1 )

Definition at line 294 of file psa_util.h.

#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 224 + 7 ) / 8 ) + 1 )

Definition at line 294 of file psa_util.h.

#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 256 + 7 ) / 8 ) + 1 )

Definition at line 294 of file psa_util.h.

#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 384 + 7 ) / 8 ) + 1 )

Definition at line 294 of file psa_util.h.

#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH   ( 2 * ( ( 521 + 7 ) / 8 ) + 1 )

Definition at line 294 of file psa_util.h.

#define MBEDTLS_PSA_RANDOM_STATE   NULL

The random generator state for the PSA subsystem.

This macro expands to an expression which is suitable as the p_rng random generator state parameter of many mbedtls_xxx functions. It must be used in combination with the random generator function mbedtls_psa_get_random().

The implementation of this macro depends on the configuration of the library. Do not make any assumption on its nature.

Definition at line 493 of file psa_util.h.

Typedef Documentation

typedef int mbedtls_f_rng_t(void *p_rng, unsigned char *output, size_t output_size)

Definition at line 440 of file psa_util.h.

Function Documentation

static int mbedtls_psa_err_translate_pk ( psa_status_t  status)
inlinestatic
static int mbedtls_psa_get_ecc_oid_from_id ( psa_ecc_family_t  curve,
size_t  bits,
char const **  oid,
size_t *  oid_len 
)
inlinestatic
int mbedtls_psa_get_random ( void *  p_rng,
unsigned char *  output,
size_t  output_size 
)

The random generator function for the PSA subsystem.

This function is suitable as the f_rng random generator function parameter of many mbedtls_xxx functions. Use MBEDTLS_PSA_RANDOM_STATE to obtain the p_rng parameter.

The implementation of this function depends on the configuration of the library.

Note
Depending on the configuration, this may be a function or a pointer to a function.
This function may only be used if the PSA crypto subsystem is active. This means that you must call psa_crypto_init() before any call to this function, and you must not call this function after calling mbedtls_psa_crypto_free().
Parameters
p_rngThe random generator context. This must be MBEDTLS_PSA_RANDOM_STATE. No other state is supported.
outputThe buffer to fill. It must have room for output_size bytes.
output_sizeThe number of bytes to write to output. This function may fail if output_size is too large. It is guaranteed to accept any output size requested by Mbed TLS library functions. The maximum request size depends on the library configuration.
Returns
0 on success.
An MBEDTLS_ERR_ENTROPY_xxx, MBEDTLS_ERR_PLATFORM_xxx, MBEDTLS_ERR_CTR_DRBG_xxxor MBEDTLS_ERR_HMAC_DRBG_xxx` on error.
static psa_key_type_t mbedtls_psa_parse_tls_ecc_group ( uint16_t  tls_ecc_grp_reg_id,
size_t *  bits 
)
inlinestatic
static int mbedtls_psa_tls_ecpoint_to_psa_ec ( unsigned char const *  src,
size_t  srclen,
unsigned char *  dst,
size_t  dstlen,
size_t *  olen 
)
inlinestatic

Definition at line 412 of file psa_util.h.

References MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL.

static int mbedtls_psa_tls_psa_ec_to_ecpoint ( unsigned char *  src,
size_t  srclen,
unsigned char **  dst,
size_t *  dstlen 
)
inlinestatic

Definition at line 397 of file psa_util.h.

static psa_algorithm_t mbedtls_psa_translate_cipher_mode ( mbedtls_cipher_mode_t  mode,
size_t  taglen 
)
inlinestatic
static psa_key_usage_t mbedtls_psa_translate_cipher_operation ( mbedtls_operation_t  op)
inlinestatic
static psa_key_type_t mbedtls_psa_translate_cipher_type ( mbedtls_cipher_type_t  cipher)
inlinestatic
static psa_algorithm_t mbedtls_psa_translate_md ( mbedtls_md_type_t  md_alg)
inlinestatic