Mbed TLS v4.1.1
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
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
57int 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
91
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
167int 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
192int 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 */
ASN.1 buffer writing functionality.
Platform Security Architecture cryptography module.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
#define PSA_ALG_HASH_MASK
#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:104
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)
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)
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
Supported message digests.
Definition md.h:50
Build-time configuration info.