source: azure_iot_hub_mbedtls/trunk/mbedtls-2.16.1/include/mbedtls/hkdf.h@ 398

Last change on this file since 398 was 398, checked in by coas-nagasima, 5 years ago

mbedTLS版Azure IoT Hub接続サンプルのソースコードを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 5.8 KB
Line 
1/**
2 * \file hkdf.h
3 *
4 * \brief This file contains the HKDF interface.
5 *
6 * The HMAC-based Extract-and-Expand Key Derivation Function (HKDF) is
7 * specified by RFC 5869.
8 */
9/*
10 * Copyright (C) 2016-2018, ARM Limited, All Rights Reserved
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License"); you may
14 * not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 * This file is part of mbed TLS (https://tls.mbed.org)
26 */
27#ifndef MBEDTLS_HKDF_H
28#define MBEDTLS_HKDF_H
29
30#if !defined(MBEDTLS_CONFIG_FILE)
31#include "config.h"
32#else
33#include MBEDTLS_CONFIG_FILE
34#endif
35
36#include "md.h"
37
38/**
39 * \name HKDF Error codes
40 * \{
41 */
42#define MBEDTLS_ERR_HKDF_BAD_INPUT_DATA -0x5F80 /**< Bad input parameters to function. */
43/* \} name */
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/**
50 * \brief This is the HMAC-based Extract-and-Expand Key Derivation Function
51 * (HKDF).
52 *
53 * \param md A hash function; md.size denotes the length of the hash
54 * function output in bytes.
55 * \param salt An optional salt value (a non-secret random value);
56 * if the salt is not provided, a string of all zeros of
57 * md.size length is used as the salt.
58 * \param salt_len The length in bytes of the optional \p salt.
59 * \param ikm The input keying material.
60 * \param ikm_len The length in bytes of \p ikm.
61 * \param info An optional context and application specific information
62 * string. This can be a zero-length string.
63 * \param info_len The length of \p info in bytes.
64 * \param okm The output keying material of \p okm_len bytes.
65 * \param okm_len The length of the output keying material in bytes. This
66 * must be less than or equal to 255 * md.size bytes.
67 *
68 * \return 0 on success.
69 * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid.
70 * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying
71 * MD layer.
72 */
73int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt,
74 size_t salt_len, const unsigned char *ikm, size_t ikm_len,
75 const unsigned char *info, size_t info_len,
76 unsigned char *okm, size_t okm_len );
77
78/**
79 * \brief Take the input keying material \p ikm and extract from it a
80 * fixed-length pseudorandom key \p prk.
81 *
82 * \warning This function should only be used if the security of it has been
83 * studied and established in that particular context (eg. TLS 1.3
84 * key schedule). For standard HKDF security guarantees use
85 * \c mbedtls_hkdf instead.
86 *
87 * \param md A hash function; md.size denotes the length of the
88 * hash function output in bytes.
89 * \param salt An optional salt value (a non-secret random value);
90 * if the salt is not provided, a string of all zeros
91 * of md.size length is used as the salt.
92 * \param salt_len The length in bytes of the optional \p salt.
93 * \param ikm The input keying material.
94 * \param ikm_len The length in bytes of \p ikm.
95 * \param[out] prk A pseudorandom key of at least md.size bytes.
96 *
97 * \return 0 on success.
98 * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid.
99 * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying
100 * MD layer.
101 */
102int mbedtls_hkdf_extract( const mbedtls_md_info_t *md,
103 const unsigned char *salt, size_t salt_len,
104 const unsigned char *ikm, size_t ikm_len,
105 unsigned char *prk );
106
107/**
108 * \brief Expand the supplied \p prk into several additional pseudorandom
109 * keys, which is the output of the HKDF.
110 *
111 * \warning This function should only be used if the security of it has been
112 * studied and established in that particular context (eg. TLS 1.3
113 * key schedule). For standard HKDF security guarantees use
114 * \c mbedtls_hkdf instead.
115 *
116 * \param md A hash function; md.size denotes the length of the hash
117 * function output in bytes.
118 * \param prk A pseudorandom key of at least md.size bytes. \p prk is
119 * usually the output from the HKDF extract step.
120 * \param prk_len The length in bytes of \p prk.
121 * \param info An optional context and application specific information
122 * string. This can be a zero-length string.
123 * \param info_len The length of \p info in bytes.
124 * \param okm The output keying material of \p okm_len bytes.
125 * \param okm_len The length of the output keying material in bytes. This
126 * must be less than or equal to 255 * md.size bytes.
127 *
128 * \return 0 on success.
129 * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid.
130 * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying
131 * MD layer.
132 */
133int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk,
134 size_t prk_len, const unsigned char *info,
135 size_t info_len, unsigned char *okm, size_t okm_len );
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif /* hkdf.h */
Note: See TracBrowser for help on using the repository browser.