Mbed TLS v4.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
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 "
tf-psa-crypto/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
87
static
inline
psa_algorithm_t
mbedtls_md_psa_alg_from_type
(
mbedtls_md_type_t
md_type)
88
{
89
return
PSA_ALG_CATEGORY_HASH
| (
psa_algorithm_t
) md_type;
90
}
91
104
static
inline
mbedtls_md_type_t
mbedtls_md_type_from_psa_alg
(
psa_algorithm_t
psa_alg)
105
{
106
return
(
mbedtls_md_type_t
) (psa_alg &
PSA_ALG_HASH_MASK
);
107
}
108
#endif
/* MBEDTLS_PSA_CRYPTO_CLIENT */
109
110
#if defined(PSA_HAVE_ALG_SOME_ECDSA)
111
122
/*
123
* Ecdsa-Sig-Value ::= SEQUENCE {
124
* r INTEGER,
125
* s INTEGER
126
* }
127
*
128
* For each of r and s, the value (V) may include an extra initial "0" bit.
129
*/
130
#define MBEDTLS_ECDSA_DER_MAX_SIG_LEN(bits) \
131
(
/*T,L of SEQUENCE*/
((bits) >= 61 * 8 ? 3 : 2) + \
132
/*T,L of r,s*/
2 * (((bits) >= 127 * 8 ? 3 : 2) + \
133
/*V of r,s*/
((bits) + 8) / 8))
134
136
#define MBEDTLS_ECDSA_DER_MAX_LEN MBEDTLS_ECDSA_DER_MAX_SIG_LEN(PSA_VENDOR_ECC_MAX_CURVE_BITS)
137
167
int
mbedtls_ecdsa_raw_to_der
(
size_t
bits,
const
unsigned
char
*raw,
size_t
raw_len,
168
unsigned
char
*der,
size_t
der_size,
size_t
*der_len);
169
192
int
mbedtls_ecdsa_der_to_raw
(
size_t
bits,
const
unsigned
char
*der,
size_t
der_len,
193
unsigned
char
*raw,
size_t
raw_size,
size_t
*raw_len);
194
195
#endif
/* PSA_HAVE_ALG_SOME_ECDSA */
196
198
199
#endif
/* MBEDTLS_PSA_UTIL_H */
asn1write.h
ASN.1 buffer writing functionality.
crypto.h
Platform Security Architecture cryptography module.
psa_algorithm_t
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition
crypto_types.h:127
PSA_ALG_HASH_MASK
#define PSA_ALG_HASH_MASK
Definition
crypto_values.h:916
PSA_ALG_CATEGORY_HASH
#define PSA_ALG_CATEGORY_HASH
Definition
crypto_values.h:773
mbedtls_md_type_from_psa_alg
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:104
mbedtls_ecdsa_der_to_raw
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_ecdsa_raw_to_der
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)
mbedtls_md_psa_alg_from_type
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:87
mbedtls_md_type_t
mbedtls_md_type_t
Supported message digests.
Definition
md.h:50
build_info.h
Build-time configuration info.
tf-psa-crypto
include
mbedtls
psa_util.h
Generated on
for Mbed TLS v4.1.1 by
1.17.0