1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 
5 /**
6  *****************************************************************************
7  * @file lac_sym_qat_key.h
8  *
9  * @defgroup LacSymQatKey  Key QAT
10  *
11  * @ingroup LacSymQat
12  *
13  * interfaces for populating qat structures for a key operation
14  *
15  *****************************************************************************/
16 
17 #ifndef LAC_SYM_QAT_KEY_H
18 #define LAC_SYM_QAT_KEY_H
19 
20 #include "cpa.h"
21 #include "lac_sym.h"
22 #include "icp_qat_fw_la.h"
23 
24 /**
25 ******************************************************************************
26 * @ingroup LacSymQatKey
27 *      Number of bytes generated per iteration
28 * @description
29 *      This define is the number of bytes generated per iteration
30 *****************************************************************************/
31 #define LAC_SYM_QAT_KEY_SSL_BYTES_PER_ITERATION (16)
32 
33 /**
34 ******************************************************************************
35 * @ingroup LacSymQatKey
36 *      Shift to calculate the number of iterations
37 * @description
38 *      This define is the shift to calculate the number of iterations
39 *****************************************************************************/
40 #define LAC_SYM_QAT_KEY_SSL_ITERATIONS_SHIFT LAC_16BYTE_ALIGNMENT_SHIFT
41 
42 /**
43 *******************************************************************************
44 * @ingroup LacSymKey
45 *      Populate the SSL request
46 *
47 * @description
48 *      Populate the SSL request
49 *
50 * @param[out] pKeyGenReqHdr            Pointer to Key Generation request Header
51 * @param[out] pKeyGenReqMid            Pointer to LW's 14/15 of Key Gen request
52 * @param[in] generatedKeyLenInBytes    Length of Key generated
53 * @param[in] labelLenInBytes           Length of Label
54 * @param[in] secretLenInBytes          Length of Secret
55 * @param[in] iterations                Number of iterations. This is related
56 *                                      to the label length.
57 *
58 * @return None
59 *
60 *****************************************************************************/
61 void
62 LacSymQat_KeySslRequestPopulate(icp_qat_la_bulk_req_hdr_t *pKeyGenReqHdr,
63 				icp_qat_fw_la_key_gen_common_t *pKeyGenReqMid,
64 				Cpa32U generatedKeyLenInBytes,
65 				Cpa32U labelLenInBytes,
66 				Cpa32U secretLenInBytes,
67 				Cpa32U iterations);
68 
69 /**
70 *******************************************************************************
71 * @ingroup LacSymKey
72 *      Populate the TLS request
73 *
74 * @description
75 *      Populate the TLS request
76 *
77 * @param[out] pKeyGenReq               Pointer to Key Generation request
78 * @param[in] generatedKeyLenInBytes    Length of Key generated
79 * @param[in] labelLenInBytes           Length of Label
80 * @param[in] secretLenInBytes          Length of Secret
81 * @param[in] seedLenInBytes            Length of Seed
82 * @param[in] cmdId                     Command Id to differentiate TLS versions
83 *
84 * @return None
85 *
86 *****************************************************************************/
87 void LacSymQat_KeyTlsRequestPopulate(
88     icp_qat_fw_la_key_gen_common_t *pKeyGenReqParams,
89     Cpa32U generatedKeyLenInBytes,
90     Cpa32U labelLenInBytes,
91     Cpa32U secretLenInBytes,
92     Cpa8U seedLenInBytes,
93     icp_qat_fw_la_cmd_id_t cmdId);
94 
95 /**
96 *******************************************************************************
97 * @ingroup LacSymKey
98 *      Populate MGF request
99 *
100 * @description
101 *      Populate MGF request
102 *
103 * @param[out] pKeyGenReqHdr      Pointer to Key Generation request Header
104 * @param[out] pKeyGenReqMid      Pointer to LW's 14/15 of Key Gen request
105 * @param[in] seedLenInBytes      Length of Seed
106 * @param[in] maskLenInBytes      Length of Mask
107 * @param[in] hashLenInBytes      Length of hash
108 *
109 * @return None
110 *
111 *****************************************************************************/
112 void
113 LacSymQat_KeyMgfRequestPopulate(icp_qat_la_bulk_req_hdr_t *pKeyGenReqHdr,
114 				icp_qat_fw_la_key_gen_common_t *pKeyGenReqMid,
115 				Cpa8U seedLenInBytes,
116 				Cpa16U maskLenInBytes,
117 				Cpa8U hashLenInBytes);
118 
119 /**
120 *******************************************************************************
121 * @ingroup LacSymKey
122 *      Populate the SSL key material input
123 *
124 * @description
125 *      Populate the SSL key material input
126 *
127 * @param[in] pService                  Pointer to service
128 * @param[out] pSslKeyMaterialInput     Pointer to SSL key material input
129 * @param[in] pSeed                     Pointer to Seed
130 * @param[in] labelPhysAddr             Physical address of the label
131 * @param[in] pSecret                   Pointer to Secret
132 *
133 * @return None
134 *
135 *****************************************************************************/
136 void LacSymQat_KeySslKeyMaterialInputPopulate(
137     sal_service_t *pService,
138     icp_qat_fw_la_ssl_key_material_input_t *pSslKeyMaterialInput,
139     void *pSeed,
140     Cpa64U labelPhysAddr,
141     void *pSecret);
142 
143 /**
144 *******************************************************************************
145 * @ingroup LacSymKey
146 *      Populate the TLS key material input
147 *
148 * @description
149 *      Populate the TLS key material input
150 *
151 * @param[in] pService                  Pointer to service
152 * @param[out] pTlsKeyMaterialInput   Pointer to TLS key material input
153 * @param[in] pSeed                   Pointer to Seed
154 * @param[in] labelPhysAddr             Physical address of the label
155 *
156 * @return None
157 *
158 *****************************************************************************/
159 void LacSymQat_KeyTlsKeyMaterialInputPopulate(
160     sal_service_t *pService,
161     icp_qat_fw_la_tls_key_material_input_t *pTlsKeyMaterialInput,
162     void *pSeed,
163     Cpa64U labelPhysAddr);
164 
165 /**
166 *******************************************************************************
167 * @ingroup LacSymKey
168 *      Populate the TLS HKDF key material input
169 *
170 * @description
171 *      Populate the TLS HKDF key material input
172 *
173 * @param[in] pService                  Pointer to service
174 * @param[out] pTlsKeyMaterialInput     Pointer to TLS key material input
175 * @param[in] pSeed                     Pointer to Seed
176 * @param[in] labelPhysAddr             Physical address of the label
177 * @param[in] cmdId                     Command ID
178 *
179 * @return None
180 *
181 *****************************************************************************/
182 void LacSymQat_KeyTlsHKDFKeyMaterialInputPopulate(
183     sal_service_t *pService,
184     icp_qat_fw_la_hkdf_key_material_input_t *pTlsKeyMaterialInput,
185     CpaCyKeyGenHKDFOpData *pKeyGenTlsOpData,
186     Cpa64U subLabelsPhysAddr,
187     icp_qat_fw_la_cmd_id_t cmdId);
188 
189 #endif /* LAC_SYM_QAT_KEY_H */
190