Mbed TLS v3.6.1
psa_util.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  */
10 
11 #ifndef MBEDTLS_PSA_UTIL_H
12 #define MBEDTLS_PSA_UTIL_H
13 #include "mbedtls/private_access.h"
14 
15 #include "mbedtls/build_info.h"
16 
17 #include "psa/crypto.h"
18 
19 /* ASN1 defines used in the ECDSA conversion functions.
20  * Note: intentionally not adding MBEDTLS_ASN1_[PARSE|WRITE]_C guards here
21  * otherwise error codes would be unknown in test_suite_psa_crypto_util.data.*/
22 #include <mbedtls/asn1write.h>
23 
24 #if defined(MBEDTLS_PSA_CRYPTO_CLIENT)
25 
57 int mbedtls_psa_get_random(void *p_rng,
58  unsigned char *output,
59  size_t output_size);
60 
67 #define MBEDTLS_PSA_RANDOM_STATE NULL
68 
72 #if defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)
73 #include <mbedtls/ecp.h>
74 
88  size_t *bits);
89 
103  size_t bits);
104 #endif /* PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY */
105 
122 {
123  return PSA_ALG_CATEGORY_HASH | (psa_algorithm_t) md_type;
124 }
125 
139 {
140  return (mbedtls_md_type_t) (psa_alg & PSA_ALG_HASH_MASK);
141 }
142 #endif /* MBEDTLS_PSA_CRYPTO_CLIENT */
143 
144 #if defined(MBEDTLS_PSA_UTIL_HAVE_ECDSA)
145 
165 int mbedtls_ecdsa_raw_to_der(size_t bits, const unsigned char *raw, size_t raw_len,
166  unsigned char *der, size_t der_size, size_t *der_len);
167 
181 int mbedtls_ecdsa_der_to_raw(size_t bits, const unsigned char *der, size_t der_len,
182  unsigned char *raw, size_t raw_size, size_t *raw_len);
183 
184 #endif /* MBEDTLS_PSA_UTIL_HAVE_ECDSA */
185 
188 #endif /* MBEDTLS_PSA_UTIL_H */
ASN.1 buffer writing functionality.
Platform Security Architecture cryptography module.
This file provides an API for Elliptic Curves over GF(P) (ECP).
mbedtls_ecp_group_id
Definition: ecp.h:102
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:134
#define PSA_ALG_HASH_MASK
uint8_t psa_ecc_family_t
Definition: crypto_types.h:97
#define PSA_ALG_CATEGORY_HASH
static mbedtls_md_type_t mbedtls_md_type_from_psa_alg(psa_algorithm_t psa_alg)
This function returns the given digest type associated with the PSA algorithm identifier.
Definition: psa_util.h:138
int mbedtls_ecdsa_der_to_raw(size_t bits, const unsigned char *der, size_t der_len, unsigned char *raw, size_t raw_size, size_t *raw_len)
mbedtls_ecp_group_id mbedtls_ecc_group_from_psa(psa_ecc_family_t family, size_t bits)
int mbedtls_ecdsa_raw_to_der(size_t bits, const unsigned char *raw, size_t raw_len, unsigned char *der, size_t der_size, size_t *der_len)
psa_ecc_family_t mbedtls_ecc_group_to_psa(mbedtls_ecp_group_id grpid, size_t *bits)
static psa_algorithm_t mbedtls_md_psa_alg_from_type(mbedtls_md_type_t md_type)
This function returns the PSA algorithm identifier associated with the given digest type.
Definition: psa_util.h:121
Build-time configuration info.
mbedtls_md_type_t
Supported message digests.
Definition: md.h:47
Macro wrapper for struct's members.
int mbedtls_psa_get_random(void *p_rng, unsigned char *output, size_t output_size)