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