Loading...
Searching...
No Matches
psa_util.h
Go to the documentation of this file.
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#ifndef MBEDTLS_PSA_UTIL_H
#define MBEDTLS_PSA_UTIL_H
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#if defined(MBEDTLS_USE_PSA_CRYPTO)
#include "psa/crypto.h"
#include "mbedtls/ecp.h"
#include "mbedtls/md.h"
#include "mbedtls/pk.h"
#include "mbedtls/oid.h"
#include <string.h>
/* Translations for symmetric crypto. */
static inline psa_key_type_t mbedtls_psa_translate_cipher_type(
mbedtls_cipher_type_t cipher)
{
switch (cipher) {
case MBEDTLS_CIPHER_AES_128_CCM:
case MBEDTLS_CIPHER_AES_192_CCM:
case MBEDTLS_CIPHER_AES_256_CCM:
case MBEDTLS_CIPHER_AES_128_GCM:
case MBEDTLS_CIPHER_AES_192_GCM:
case MBEDTLS_CIPHER_AES_256_GCM:
case MBEDTLS_CIPHER_AES_128_CBC:
case MBEDTLS_CIPHER_AES_192_CBC:
case MBEDTLS_CIPHER_AES_256_CBC:
case MBEDTLS_CIPHER_AES_128_ECB:
case MBEDTLS_CIPHER_AES_192_ECB:
case MBEDTLS_CIPHER_AES_256_ECB:
return PSA_KEY_TYPE_AES;
/* ARIA not yet supported in PSA. */
/* case MBEDTLS_CIPHER_ARIA_128_CCM:
case MBEDTLS_CIPHER_ARIA_192_CCM:
case MBEDTLS_CIPHER_ARIA_256_CCM:
case MBEDTLS_CIPHER_ARIA_128_GCM:
case MBEDTLS_CIPHER_ARIA_192_GCM:
case MBEDTLS_CIPHER_ARIA_256_GCM:
case MBEDTLS_CIPHER_ARIA_128_CBC:
case MBEDTLS_CIPHER_ARIA_192_CBC:
case MBEDTLS_CIPHER_ARIA_256_CBC:
return( PSA_KEY_TYPE_ARIA ); */
default:
return 0;
}
}
static inline psa_algorithm_t mbedtls_psa_translate_cipher_mode(
mbedtls_cipher_mode_t mode, size_t taglen)
{
switch (mode) {
case MBEDTLS_MODE_ECB:
return PSA_ALG_ECB_NO_PADDING;
case MBEDTLS_MODE_GCM:
return PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM, taglen);
case MBEDTLS_MODE_CCM:
return PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, taglen);
case MBEDTLS_MODE_CBC:
if (taglen == 0) {
return PSA_ALG_CBC_NO_PADDING;
} else {
return 0;
}
default:
return 0;
}
}
static inline psa_key_usage_t mbedtls_psa_translate_cipher_operation(
mbedtls_operation_t op)
{
switch (op) {
case MBEDTLS_ENCRYPT:
return PSA_KEY_USAGE_ENCRYPT;
case MBEDTLS_DECRYPT:
return PSA_KEY_USAGE_DECRYPT;
default:
return 0;
}
}
/* Translations for hashing. */
static inline psa_algorithm_t mbedtls_psa_translate_md(mbedtls_md_type_t md_alg)
{
switch (md_alg) {
#if defined(MBEDTLS_MD2_C)
case MBEDTLS_MD_MD2:
return PSA_ALG_MD2;
#endif
#if defined(MBEDTLS_MD4_C)
case MBEDTLS_MD_MD4:
return PSA_ALG_MD4;
#endif
#if defined(MBEDTLS_MD5_C)
case MBEDTLS_MD_MD5:
return PSA_ALG_MD5;
#endif
#if defined(MBEDTLS_SHA1_C)
case MBEDTLS_MD_SHA1:
return PSA_ALG_SHA_1;
#endif
#if defined(MBEDTLS_SHA256_C)
case MBEDTLS_MD_SHA224:
return PSA_ALG_SHA_224;
case MBEDTLS_MD_SHA256:
return PSA_ALG_SHA_256;
#endif
#if defined(MBEDTLS_SHA512_C)
case MBEDTLS_MD_SHA384:
return PSA_ALG_SHA_384;
case MBEDTLS_MD_SHA512:
return PSA_ALG_SHA_512;
#endif
#if defined(MBEDTLS_RIPEMD160_C)
case MBEDTLS_MD_RIPEMD160:
return PSA_ALG_RIPEMD160;
#endif
case MBEDTLS_MD_NONE:
return 0;
default:
return 0;
}
}
/* Translations for ECC. */
static inline int mbedtls_psa_get_ecc_oid_from_id(
psa_ecc_family_t curve, size_t bits,
char const **oid, size_t *oid_len)
{
switch (curve) {
case PSA_ECC_FAMILY_SECP_R1:
switch (bits) {
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
case 192:
*oid = MBEDTLS_OID_EC_GRP_SECP192R1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_SECP192R1);
return 0;
#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
case 224:
*oid = MBEDTLS_OID_EC_GRP_SECP224R1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_SECP224R1);
return 0;
#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
case 256:
*oid = MBEDTLS_OID_EC_GRP_SECP256R1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_SECP256R1);
return 0;
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
case 384:
*oid = MBEDTLS_OID_EC_GRP_SECP384R1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_SECP384R1);
return 0;
#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
case 521:
*oid = MBEDTLS_OID_EC_GRP_SECP521R1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_SECP521R1);
return 0;
#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */
}
break;
case PSA_ECC_FAMILY_SECP_K1:
switch (bits) {
#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
case 192:
*oid = MBEDTLS_OID_EC_GRP_SECP192K1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_SECP192K1);
return 0;
#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
case 224:
*oid = MBEDTLS_OID_EC_GRP_SECP224K1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_SECP224K1);
return 0;
#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
case 256:
*oid = MBEDTLS_OID_EC_GRP_SECP256K1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_SECP256K1);
return 0;
#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
}
break;
case PSA_ECC_FAMILY_BRAINPOOL_P_R1:
switch (bits) {
#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
case 256:
*oid = MBEDTLS_OID_EC_GRP_BP256R1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_BP256R1);
return 0;
#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
case 384:
*oid = MBEDTLS_OID_EC_GRP_BP384R1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_BP384R1);
return 0;
#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
case 512:
*oid = MBEDTLS_OID_EC_GRP_BP512R1;
*oid_len = MBEDTLS_OID_SIZE(MBEDTLS_OID_EC_GRP_BP512R1);
return 0;
#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */
}
break;
}
(void) oid;
(void) oid_len;
return -1;
}
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH 1
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((192 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((192 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((224 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((224 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((256 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((256 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((384 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((384 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((521 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((521 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((192 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((192 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((224 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((224 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((256 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((256 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((256 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((256 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((384 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((384 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */
#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < (2 * ((512 + 7) / 8) + 1)
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH (2 * ((512 + 7) / 8) + 1)
#endif
#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */
/* Translations for PK layer */
static inline int mbedtls_psa_err_translate_pk(psa_status_t status)
{
switch (status) {
case PSA_SUCCESS:
return 0;
case PSA_ERROR_NOT_SUPPORTED:
return MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE;
case PSA_ERROR_INSUFFICIENT_MEMORY:
return MBEDTLS_ERR_PK_ALLOC_FAILED;
case PSA_ERROR_INSUFFICIENT_ENTROPY:
return MBEDTLS_ERR_ECP_RANDOM_FAILED;
case PSA_ERROR_BAD_STATE:
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
/* All other failures */
case PSA_ERROR_COMMUNICATION_FAILURE:
case PSA_ERROR_HARDWARE_FAILURE:
case PSA_ERROR_CORRUPTION_DETECTED:
return MBEDTLS_ERR_PK_HW_ACCEL_FAILED;
default: /* We return the same as for the 'other failures',
* but list them separately nonetheless to indicate
* which failure conditions we have considered. */
return MBEDTLS_ERR_PK_HW_ACCEL_FAILED;
}
}
/* Translations for ECC */
/* This function transforms an ECC group identifier from
* https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8
* into a PSA ECC group identifier. */
#if defined(MBEDTLS_ECP_C)
static inline psa_key_type_t mbedtls_psa_parse_tls_ecc_group(
uint16_t tls_ecc_grp_reg_id, size_t *bits)
{
const mbedtls_ecp_curve_info *curve_info =
mbedtls_ecp_curve_info_from_tls_id(tls_ecc_grp_reg_id);
if (curve_info == NULL) {
return 0;
}
return PSA_KEY_TYPE_ECC_KEY_PAIR(
mbedtls_ecc_group_to_psa(curve_info->grp_id, bits));
}
#endif /* MBEDTLS_ECP_C */
/* This function takes a buffer holding an EC public key
* exported through psa_export_public_key(), and converts
* it into an ECPoint structure to be put into a ClientKeyExchange
* message in an ECDHE exchange.
*
* Both the present and the foreseeable future format of EC public keys
* used by PSA have the ECPoint structure contained in the exported key
* as a subbuffer, and the function merely selects this subbuffer instead
* of making a copy.
*/
static inline int mbedtls_psa_tls_psa_ec_to_ecpoint(unsigned char *src,
size_t srclen,
unsigned char **dst,
size_t *dstlen)
{
*dst = src;
*dstlen = srclen;
return 0;
}
/* This function takes a buffer holding an ECPoint structure
* (as contained in a TLS ServerKeyExchange message for ECDHE
* exchanges) and converts it into a format that the PSA key
* agreement API understands.
*/
static inline int mbedtls_psa_tls_ecpoint_to_psa_ec(unsigned char const *src,
size_t srclen,
unsigned char *dst,
size_t dstlen,
size_t *olen)
{
if (srclen > dstlen) {
return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
}
memcpy(dst, src, srclen);
*olen = srclen;
return 0;
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
/* Expose whatever RNG the PSA subsystem uses to applications using the
* mbedtls_xxx API. The declarations and definitions here need to be
* consistent with the implementation in library/psa_crypto_random_impl.h.
* See that file for implementation documentation. */
#if defined(MBEDTLS_PSA_CRYPTO_C)
/* The type of a `f_rng` random generator function that many library functions
* take.
*
* This type name is not part of the Mbed TLS stable API. It may be renamed
* or moved without warning.
*/
typedef int mbedtls_f_rng_t(void *p_rng, unsigned char *output, size_t output_size);
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
int mbedtls_psa_get_random(void *p_rng,
unsigned char *output,
size_t output_size);
#define MBEDTLS_PSA_RANDOM_STATE NULL
#else /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
#if defined(MBEDTLS_CTR_DRBG_C)
#include "mbedtls/ctr_drbg.h"
typedef mbedtls_ctr_drbg_context mbedtls_psa_drbg_context_t;
static mbedtls_f_rng_t *const mbedtls_psa_get_random = mbedtls_ctr_drbg_random;
#elif defined(MBEDTLS_HMAC_DRBG_C)
#include "mbedtls/hmac_drbg.h"
typedef mbedtls_hmac_drbg_context mbedtls_psa_drbg_context_t;
static mbedtls_f_rng_t *const mbedtls_psa_get_random = mbedtls_hmac_drbg_random;
#endif
extern mbedtls_psa_drbg_context_t *const mbedtls_psa_random_state;
#define MBEDTLS_PSA_RANDOM_STATE mbedtls_psa_random_state
#endif /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
#endif /* MBEDTLS_PSA_CRYPTO_C */
#endif /* MBEDTLS_PSA_UTIL_H */
mbedtls_cipher_type_t
mbedtls_cipher_type_t
Supported {cipher type, cipher mode} pairs.
Definition cipher.h:98
MBEDTLS_CIPHER_AES_128_ECB
@ MBEDTLS_CIPHER_AES_128_ECB
Definition cipher.h:101
MBEDTLS_CIPHER_AES_128_CBC
@ MBEDTLS_CIPHER_AES_128_CBC
Definition cipher.h:104
MBEDTLS_CIPHER_AES_192_GCM
@ MBEDTLS_CIPHER_AES_192_GCM
Definition cipher.h:114
MBEDTLS_CIPHER_AES_256_ECB
@ MBEDTLS_CIPHER_AES_256_ECB
Definition cipher.h:103
MBEDTLS_CIPHER_AES_192_CCM
@ MBEDTLS_CIPHER_AES_192_CCM
Definition cipher.h:143
MBEDTLS_CIPHER_AES_256_GCM
@ MBEDTLS_CIPHER_AES_256_GCM
Definition cipher.h:115
MBEDTLS_CIPHER_AES_256_CCM
@ MBEDTLS_CIPHER_AES_256_CCM
Definition cipher.h:144
MBEDTLS_CIPHER_AES_128_GCM
@ MBEDTLS_CIPHER_AES_128_GCM
Definition cipher.h:113
MBEDTLS_CIPHER_AES_192_CBC
@ MBEDTLS_CIPHER_AES_192_CBC
Definition cipher.h:105
MBEDTLS_CIPHER_AES_128_CCM
@ MBEDTLS_CIPHER_AES_128_CCM
Definition cipher.h:142
MBEDTLS_CIPHER_AES_256_CBC
@ MBEDTLS_CIPHER_AES_256_CBC
Definition cipher.h:106
MBEDTLS_CIPHER_AES_192_ECB
@ MBEDTLS_CIPHER_AES_192_ECB
Definition cipher.h:102
mbedtls_operation_t
mbedtls_operation_t
Definition cipher.h:208
MBEDTLS_DECRYPT
@ MBEDTLS_DECRYPT
Definition cipher.h:210
MBEDTLS_ENCRYPT
@ MBEDTLS_ENCRYPT
Definition cipher.h:211
mbedtls_cipher_mode_t
mbedtls_cipher_mode_t
Definition cipher.h:182
MBEDTLS_MODE_ECB
@ MBEDTLS_MODE_ECB
Definition cipher.h:184
MBEDTLS_MODE_CCM
@ MBEDTLS_MODE_CCM
Definition cipher.h:191
MBEDTLS_MODE_GCM
@ MBEDTLS_MODE_GCM
Definition cipher.h:189
MBEDTLS_MODE_CBC
@ MBEDTLS_MODE_CBC
Definition cipher.h:185
config.h
Configuration options (set of defines)
crypto.h
Platform Security Architecture cryptography module.
ctr_drbg.h
This file contains definitions and functions for the CTR_DRBG pseudorandom generator.
mbedtls_ctr_drbg_random
int mbedtls_ctr_drbg_random(void *p_rng, unsigned char *output, size_t output_len)
This function uses CTR_DRBG to generate random data.
ecp.h
This file provides an API for Elliptic Curves over GF(P) (ECP).
MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL
#define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL
Definition ecp.h:44
MBEDTLS_ERR_ECP_RANDOM_FAILED
#define MBEDTLS_ERR_ECP_RANDOM_FAILED
Definition ecp.h:52
mbedtls_ecp_curve_info_from_tls_id
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_tls_id(uint16_t tls_id)
This function retrieves curve information from a TLS NamedCurve value.
MBEDTLS_OID_SIZE
#define MBEDTLS_OID_SIZE(x)
Definition asn1.h:115
PSA_KEY_TYPE_ECC_KEY_PAIR
#define PSA_KEY_TYPE_ECC_KEY_PAIR(curve)
Definition crypto_values.h:504
PSA_ALG_GCM
#define PSA_ALG_GCM
Definition crypto_values.h:1199
PSA_ALG_SHA_224
#define PSA_ALG_SHA_224
Definition crypto_values.h:850
PSA_ALG_SHA_1
#define PSA_ALG_SHA_1
Definition crypto_values.h:848
PSA_ECC_FAMILY_SECP_R1
#define PSA_ECC_FAMILY_SECP_R1
Definition crypto_values.h:559
PSA_ALG_SHA_384
#define PSA_ALG_SHA_384
Definition crypto_values.h:854
PSA_ECC_FAMILY_SECP_K1
#define PSA_ECC_FAMILY_SECP_K1
Definition crypto_values.h:549
PSA_ALG_SHA_256
#define PSA_ALG_SHA_256
Definition crypto_values.h:852
psa_key_type_t
uint16_t psa_key_type_t
Encoding of a key type.
Definition crypto_types.h:69
PSA_ALG_RIPEMD160
#define PSA_ALG_RIPEMD160
Definition crypto_values.h:846
PSA_KEY_TYPE_AES
#define PSA_KEY_TYPE_AES
Definition crypto_values.h:442
PSA_ALG_MD4
#define PSA_ALG_MD4
Definition crypto_values.h:842
PSA_ALG_MD2
#define PSA_ALG_MD2
Definition crypto_values.h:840
PSA_ALG_ECB_NO_PADDING
#define PSA_ALG_ECB_NO_PADDING
Definition crypto_values.h:1155
PSA_ALG_AEAD_WITH_SHORTENED_TAG
#define PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length)
Definition crypto_values.h:1245
PSA_ECC_FAMILY_BRAINPOOL_P_R1
#define PSA_ECC_FAMILY_BRAINPOOL_P_R1
Definition crypto_values.h:609
PSA_ALG_CCM
#define PSA_ALG_CCM
Definition crypto_values.h:1193
psa_algorithm_t
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition crypto_types.h:125
PSA_ALG_CBC_NO_PADDING
#define PSA_ALG_CBC_NO_PADDING
Definition crypto_values.h:1164
PSA_ALG_MD5
#define PSA_ALG_MD5
Definition crypto_values.h:844
psa_ecc_family_t
uint8_t psa_ecc_family_t
Definition crypto_types.h:88
PSA_ALG_SHA_512
#define PSA_ALG_SHA_512
Definition crypto_values.h:856
psa_status_t
int32_t psa_status_t
Function return status.
Definition crypto_types.h:50
PSA_ERROR_HARDWARE_FAILURE
#define PSA_ERROR_HARDWARE_FAILURE
Definition crypto_values.h:199
PSA_ERROR_CORRUPTION_DETECTED
#define PSA_ERROR_CORRUPTION_DETECTED
Definition crypto_values.h:230
PSA_ERROR_NOT_SUPPORTED
#define PSA_ERROR_NOT_SUPPORTED
Definition crypto_values.h:72
PSA_SUCCESS
#define PSA_SUCCESS
Definition crypto_values.h:56
PSA_ERROR_INSUFFICIENT_ENTROPY
#define PSA_ERROR_INSUFFICIENT_ENTROPY
Definition crypto_values.h:249
PSA_ERROR_COMMUNICATION_FAILURE
#define PSA_ERROR_COMMUNICATION_FAILURE
Definition crypto_values.h:168
PSA_ERROR_INSUFFICIENT_MEMORY
#define PSA_ERROR_INSUFFICIENT_MEMORY
Definition crypto_values.h:142
PSA_ERROR_BAD_STATE
#define PSA_ERROR_BAD_STATE
Definition crypto_values.h:125
PSA_KEY_USAGE_ENCRYPT
#define PSA_KEY_USAGE_ENCRYPT
Definition crypto_values.h:2263
psa_key_usage_t
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
Definition crypto_types.h:314
PSA_KEY_USAGE_DECRYPT
#define PSA_KEY_USAGE_DECRYPT
Definition crypto_values.h:2274
mbedtls_ecc_group_to_psa
static psa_ecc_family_t mbedtls_ecc_group_to_psa(mbedtls_ecp_group_id grpid, size_t *bits)
Definition crypto_extra.h:574
hmac_drbg.h
The HMAC_DRBG pseudorandom generator.
mbedtls_hmac_drbg_random
int mbedtls_hmac_drbg_random(void *p_rng, unsigned char *output, size_t out_len)
This function uses HMAC_DRBG to generate random data.
md.h
This file contains the generic message-digest wrapper.
mbedtls_md_type_t
mbedtls_md_type_t
Supported message digests.
Definition md.h:50
MBEDTLS_MD_SHA512
@ MBEDTLS_MD_SHA512
Definition md.h:59
MBEDTLS_MD_MD5
@ MBEDTLS_MD_MD5
Definition md.h:54
MBEDTLS_MD_RIPEMD160
@ MBEDTLS_MD_RIPEMD160
Definition md.h:60
MBEDTLS_MD_SHA384
@ MBEDTLS_MD_SHA384
Definition md.h:58
MBEDTLS_MD_NONE
@ MBEDTLS_MD_NONE
Definition md.h:51
MBEDTLS_MD_SHA256
@ MBEDTLS_MD_SHA256
Definition md.h:57
MBEDTLS_MD_SHA224
@ MBEDTLS_MD_SHA224
Definition md.h:56
MBEDTLS_MD_SHA1
@ MBEDTLS_MD_SHA1
Definition md.h:55
MBEDTLS_MD_MD4
@ MBEDTLS_MD_MD4
Definition md.h:53
MBEDTLS_MD_MD2
@ MBEDTLS_MD_MD2
Definition md.h:52
oid.h
Object Identifier (OID) database.
MBEDTLS_OID_EC_GRP_SECP521R1
#define MBEDTLS_OID_EC_GRP_SECP521R1
Definition oid.h:359
MBEDTLS_OID_EC_GRP_SECP224R1
#define MBEDTLS_OID_EC_GRP_SECP224R1
Definition oid.h:347
MBEDTLS_OID_EC_GRP_SECP256K1
#define MBEDTLS_OID_EC_GRP_SECP256K1
Definition oid.h:371
MBEDTLS_OID_EC_GRP_SECP384R1
#define MBEDTLS_OID_EC_GRP_SECP384R1
Definition oid.h:355
MBEDTLS_OID_EC_GRP_SECP192K1
#define MBEDTLS_OID_EC_GRP_SECP192K1
Definition oid.h:363
MBEDTLS_OID_EC_GRP_BP384R1
#define MBEDTLS_OID_EC_GRP_BP384R1
Definition oid.h:385
MBEDTLS_OID_EC_GRP_SECP224K1
#define MBEDTLS_OID_EC_GRP_SECP224K1
Definition oid.h:367
MBEDTLS_OID_EC_GRP_BP512R1
#define MBEDTLS_OID_EC_GRP_BP512R1
Definition oid.h:388
MBEDTLS_OID_EC_GRP_SECP256R1
#define MBEDTLS_OID_EC_GRP_SECP256R1
Definition oid.h:351
MBEDTLS_OID_EC_GRP_SECP192R1
#define MBEDTLS_OID_EC_GRP_SECP192R1
Definition oid.h:343
MBEDTLS_OID_EC_GRP_BP256R1
#define MBEDTLS_OID_EC_GRP_BP256R1
Definition oid.h:382
pk.h
Public Key abstraction layer.
MBEDTLS_ERR_PK_HW_ACCEL_FAILED
#define MBEDTLS_ERR_PK_HW_ACCEL_FAILED
Definition pk.h:74
MBEDTLS_ERR_PK_BAD_INPUT_DATA
#define MBEDTLS_ERR_PK_BAD_INPUT_DATA
Definition pk.h:48
MBEDTLS_ERR_PK_ALLOC_FAILED
#define MBEDTLS_ERR_PK_ALLOC_FAILED
Definition pk.h:44
MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE
Definition pk.h:68
mbedtls_psa_drbg_context_t
mbedtls_ctr_drbg_context mbedtls_psa_drbg_context_t
Definition psa_util.h:479
mbedtls_psa_get_random
static mbedtls_f_rng_t *const mbedtls_psa_get_random
Definition psa_util.h:480
mbedtls_psa_random_state
mbedtls_psa_drbg_context_t *const mbedtls_psa_random_state
mbedtls_f_rng_t
int mbedtls_f_rng_t(void *p_rng, unsigned char *output, size_t output_size)
Definition psa_util.h:420
mbedtls_ctr_drbg_context
The CTR_DRBG context structure.
Definition ctr_drbg.h:161
mbedtls_ecp_curve_info
Definition ecp.h:149
mbedtls_ecp_curve_info::grp_id
mbedtls_ecp_group_id grp_id
Definition ecp.h:150
mbedtls_hmac_drbg_context
Definition hmac_drbg.h:77