blob: e3b1dc7c59c5d3423f2b256327273ead516f0481 [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
23#if defined(MBEDTLS_PSA_CRYPTO_C)
24#include "psa/crypto.h"
25#endif
26
27#if defined(MBEDTLS_TEST_HOOKS)
28
29#if defined(MBEDTLS_PSA_CRYPTO_C)
30
Gabor Mezei9f4bb312022-01-31 16:33:47 +010031int mbedtls_psa_hkdf_extract( psa_algorithm_t alg,
32 const unsigned char *salt, size_t salt_len,
33 const unsigned char *ikm, size_t ikm_len,
34 unsigned char *prk );
35
Gabor Mezeia3eecd22022-02-09 16:57:26 +010036/**
37 * \brief Expand the supplied \p prk into several additional pseudorandom
38 * keys, which is the output of the HKDF.
39 *
40 * \param alg The HMAC algorithm to use (\c #PSA_ALG_HMAC( PSA_ALG_XXX )
41 * value such that PSA_ALG_XXX is a hash algorithm and
42 * #PSA_ALG_IS_HMAC(\p alg) is true).
43 * \param prk A pseudorandom key of \p prk_len bytes. \p prk is
44 * usually the output from the HKDF extract step.
45 * \param prk_len The length in bytes of \p prk.
46 * \param info An optional context and application specific information
47 * string. This can be a zero-length string.
48 * \param info_len The length of \p info in bytes.
49 * \param okm The output keying material of \p okm_len bytes.
50 * \param okm_len The length of the output keying material in bytes. This
51 * must be less than or equal to
52 * 255 * #PSA_HASH_LENGTH( \p alg ) bytes.
53 *
54 * \return 0 on success.
55 * \return #PSA_ERROR_INVALID_ARGUMENT when the parameters are invalid.
56 * \return An PSA_ERROR_* error for errors returned from the underlying
57 * PSA layer.
58 */
59psa_status_t mbedtls_psa_hkdf_expand( psa_algorithm_t alg,
60 const unsigned char *prk, size_t prk_len,
61 const unsigned char *info, size_t info_len,
62 unsigned char *okm, size_t okm_len );
63
64#endif /* MBEDTLS_PSA_CRYPTO_C */
65
66#endif /* MBEDTLS_TEST_HOOKS */
67
68#endif /* MBEDTLS_SSL_TLS13_INVASIVE_H */