blob: 55fc95836c3128c7712ed79f974e131e9983dbee [file] [log] [blame]
Gabor Mezeia3eecd22022-02-09 16:57:26 +01001/*
2 * Copyright The Mbed TLS Contributors
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef MBEDTLS_SSL_TLS13_INVASIVE_H
19#define MBEDTLS_SSL_TLS13_INVASIVE_H
20
21#include "common.h"
22
Gabor Mezei5d9a1fe2022-03-24 17:49:14 +010023#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
24
Gabor Mezeia3eecd22022-02-09 16:57:26 +010025#include "psa/crypto.h"
Gabor Mezeia3eecd22022-02-09 16:57:26 +010026
27#if defined(MBEDTLS_TEST_HOOKS)
28
Gabor Mezeib1f53972022-02-07 18:18:16 +010029/**
30 * \brief Take the input keying material \p ikm and extract from it a
31 * fixed-length pseudorandom key \p prk.
32 *
Gabor Mezeied6d6582022-03-26 17:28:06 +010033 * \param hash_alg Hash algorithm to use.
Gabor Mezeib1f53972022-02-07 18:18:16 +010034 * \param salt An optional salt value (a non-secret random value);
35 * if the salt is not provided, a string of all zeros
36 * of the length of the hash provided by \p alg is used
37 * as the salt.
38 * \param salt_len The length in bytes of the optional \p salt.
39 * \param ikm The input keying material.
40 * \param ikm_len The length in bytes of \p ikm.
41 * \param[out] prk A pseudorandom key of \p prk_len bytes.
42 * \param prk_size Size of the \p prk buffer in bytes.
43 * \param[out] prk_len On success, the length in bytes of the
44 * pseudorandom key in \p prk.
45 *
46 * \return 0 on success.
Gabor Mezeic5efb8e2022-02-08 13:15:45 +010047 * \return #PSA_ERROR_INVALID_ARGUMENT when the parameters are invalid.
Gabor Mezeib1f53972022-02-07 18:18:16 +010048 * \return An PSA_ERROR_* error for errors returned from the underlying
49 * PSA layer.
50 */
Gabor Mezeied6d6582022-03-26 17:28:06 +010051psa_status_t mbedtls_psa_hkdf_extract( psa_algorithm_t hash_alg,
Gabor Mezei62bf0242022-02-07 18:12:07 +010052 const unsigned char *salt, size_t salt_len,
53 const unsigned char *ikm, size_t ikm_len,
54 unsigned char *prk, size_t prk_size,
55 size_t *prk_len );
Gabor Mezei9f4bb312022-01-31 16:33:47 +010056
Gabor Mezeia3eecd22022-02-09 16:57:26 +010057/**
58 * \brief Expand the supplied \p prk into several additional pseudorandom
59 * keys, which is the output of the HKDF.
60 *
Gabor Mezeied6d6582022-03-26 17:28:06 +010061 * \param hash_alg Hash algorithm to use.
Gabor Mezeia3eecd22022-02-09 16:57:26 +010062 * \param prk A pseudorandom key of \p prk_len bytes. \p prk is
63 * usually the output from the HKDF extract step.
64 * \param prk_len The length in bytes of \p prk.
65 * \param info An optional context and application specific information
66 * string. This can be a zero-length string.
67 * \param info_len The length of \p info in bytes.
68 * \param okm The output keying material of \p okm_len bytes.
69 * \param okm_len The length of the output keying material in bytes. This
70 * must be less than or equal to
71 * 255 * #PSA_HASH_LENGTH( \p alg ) bytes.
72 *
73 * \return 0 on success.
74 * \return #PSA_ERROR_INVALID_ARGUMENT when the parameters are invalid.
75 * \return An PSA_ERROR_* error for errors returned from the underlying
76 * PSA layer.
77 */
Gabor Mezeied6d6582022-03-26 17:28:06 +010078psa_status_t mbedtls_psa_hkdf_expand( psa_algorithm_t hash_alg,
Gabor Mezeia3eecd22022-02-09 16:57:26 +010079 const unsigned char *prk, size_t prk_len,
80 const unsigned char *info, size_t info_len,
81 unsigned char *okm, size_t okm_len );
82
Ronald Crone3dac4a2022-06-10 17:21:51 +020083MBEDTLS_CHECK_RETURN_CRITICAL
84int mbedtls_ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl,
85 const unsigned char *buf,
86 const unsigned char *end );
Gabor Mezeia3eecd22022-02-09 16:57:26 +010087#endif /* MBEDTLS_TEST_HOOKS */
88
Gabor Mezei5d9a1fe2022-03-24 17:49:14 +010089#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
90
Gabor Mezeia3eecd22022-02-09 16:57:26 +010091#endif /* MBEDTLS_SSL_TLS13_INVASIVE_H */