1 /***************************************************************************//**
2 * \file cy_cryptolite_hkdf.h
3 * \version 2.30
4 *
5 * \brief
6 *  This file provides constants and function prototypes
7 *  for the API for the HKDF method in the cryptolite block driver.
8 *
9 ********************************************************************************
10 * \copyright
11 * Copyright (c) (2020-2023), Cypress Semiconductor Corporation (an Infineon company) or
12 * an affiliate of Cypress Semiconductor Corporation.
13 * SPDX-License-Identifier: Apache-2.0
14 *
15 * Licensed under the Apache License, Version 2.0 (the "License");
16 * you may not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 *    http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
26 *******************************************************************************/
27 
28 
29 #if !defined (CY_CRYPTOLITE_HKDF__H)
30 #define CY_CRYPTOLITE_HKDF__H
31 
32 #include "cy_device.h"
33 
34 
35 #if defined(CY_IP_MXCRYPTOLITE)
36 
37 #if defined(__cplusplus)
38 extern "C" {
39 #endif
40 
41 #include "cy_cryptolite_common.h"
42 
43 #if (CRYPTOLITE_SHA_PRESENT == 1)
44 #if defined(CY_CRYPTOLITE_CFG_HKDF_C) && defined(CY_CRYPTOLITE_CFG_HMAC_C)
45 
46 #include "cy_cryptolite_hmac.h"
47 
48 
49 /**
50 * \addtogroup group_cryptolite_lld_kdf_functions
51 * \{
52 */
53 
54 /*******************************************************************************
55 * Function Name: Cy_Cryptolite_Hkdf_Extract
56 ****************************************************************************//**
57 *
58 * Performs HKDF Extract calculation.
59 *
60 * \param base
61 * The pointer to the CRYPTOLITE instance.
62 *
63 * \param salt
64 * The pointer to salt.
65 *
66 * \param saltLength
67 * The size of a salt.
68 *
69 * \param ikm
70 * The pointer to the Input Key material.
71 *
72 * \param ikmLength
73 * The length of the IKM.
74 *
75 * \param prk
76 * The pointer to store the generated prk.
77 *
78 * \return
79 * \ref cy_en_cryptolite_status_t
80 *
81 *******************************************************************************/
82 cy_en_cryptolite_status_t Cy_Cryptolite_Hkdf_Extract(CRYPTOLITE_Type *base,
83                                           uint8_t  const *salt,
84                                           uint32_t saltLength,
85                                           uint8_t  const *ikm,
86                                           uint32_t ikmLength,
87                                           uint8_t *prk);
88 
89 
90 /*******************************************************************************
91 * Function Name: Cy_Cryptolite_Hkdf_Expand
92 ****************************************************************************//**
93 *
94 * Performs HKDF Expand calculation.
95 *
96 * \param base
97 * The pointer to the CRYPTOLITE instance.
98 *
99 * \param prk
100 * The pointer to the pseudo random key.
101 *
102 * \param prkLength
103 * The length of the prk.
104 *
105 * \param info
106 * The pointer to info.
107 *
108 * \param infoLength
109 * The length of the info.
110 *
111 * \param okm
112 * The pointer to Output key material.
113 *
114 * \param okmLength
115 * The length of okm to be generated.
116 *
117 * \return
118 * \ref cy_en_cryptolite_status_t
119 *
120 *******************************************************************************/
121 cy_en_cryptolite_status_t Cy_Cryptolite_Hkdf_Expand(CRYPTOLITE_Type *base,
122                                           uint8_t  const *prk,
123                                           uint32_t prkLength,
124                                           uint8_t  const *info,
125                                           uint32_t infoLength,
126                                           uint8_t *okm,
127                                           uint32_t okmLength);
128 
129 
130 /*******************************************************************************
131 * Function Name: Cy_Cryptolite_Hkdf
132 ****************************************************************************//**
133 *
134 * Performs HKDF calculation.
135 *
136 * \param base
137 * The pointer to the CRYPTOLITE instance.
138 *
139 * \param salt
140 * The pointer to salt.
141 *
142 * \param saltLength
143 * The size of a salt.
144 *
145 * \param ikm
146 * The pointer to the Input Key material.
147 *
148 * \param ikmLength
149 * The length of the IKM.
150 *
151 * \param info
152 * The pointer to info.
153 *
154 * \param infoLength
155 * The length of the info.
156 *
157 * \param okm
158 * The pointer to Output key material.
159 *
160 * \param okmLength
161 * The length of okm to be generated.
162 *
163 * \return
164 * \ref cy_en_cryptolite_status_t
165 *
166 *******************************************************************************/
167 cy_en_cryptolite_status_t Cy_Cryptolite_Hkdf(CRYPTOLITE_Type *base,
168                                           uint8_t  const *salt,
169                                           uint32_t saltLength,
170                                           uint8_t  const *ikm,
171                                           uint32_t ikmLength,
172                                           uint8_t  const *info,
173                                           uint32_t infoLength,
174                                           uint8_t *okm,
175                                           uint32_t okmLength);
176 
177 /** \} group_cryptolite_lld_kdf_functions */
178 
179 #endif /* defined(CY_CRYPTOLITE_CFG_HKDF_C) && defined(CY_CRYPTOLITE_CFG_HMAC_C) */
180 #endif /*CRYPTOLITE_SHA_PRESENT*/
181 
182 #if defined(__cplusplus)
183 }
184 #endif
185 
186 #endif /* CY_IP_MXCRYPTOLITE */
187 
188 #endif /* #if !defined (CY_CRYPTOLITE_HKDF__H) */
189 
190 
191 /* [] END OF FILE */
192