1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/*!
\ingroup SrtpKdf
\brief This function derives keys using SRTP KDF algorithm.
\return 0 Returned upon successful key derivation.
\return BAD_FUNC_ARG Returned when key or salt is NULL
\return BAD_FUNC_ARG Returned when key length is not 16, 24 or 32.
\return BAD_FUNC_ARG Returned when saltSz is larger than 14.
\return BAD_FUNC_ARG Returned when kdrIdx is less than -1 or larger than 24.
\return MEMORY_E on dynamic memory allocation failure.
\param [in] key Key to use with encryption.
\param [in] keySz Size of key in bytes.
\param [in] salt Random non-secret value.
\param [in] saltSz Size of random in bytes.
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
\param [in] idx Index value to XOR in.
\param [out] key1 First key. Label value of 0x00.
\param [in] key1Sz Size of first key in bytes.
\param [out] key2 Second key. Label value of 0x01.
\param [in] key2Sz Size of second key in bytes.
\param [out] key3 Third key. Label value of 0x02.
\param [in] key3Sz Size of third key in bytes.
_Example_
\code
unsigned char key[16] = { ... };
unsigned char salt[14] = { ... };
unsigned char idx[6] = { ... };
unsigned char keyE[16];
unsigned char keyA[20];
unsigned char keyS[14];
int kdrIdx = 0; // Use all of index
int ret;
ret = wc_SRTP_KDF(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
keyE, sizeof(keyE), keyA, sizeof(keyA), keyS, sizeof(keyS));
if (ret != 0) {
WOLFSSL_MSG("wc_SRTP_KDF failed");
}
\endcode
\sa wc_SRTCP_KDF
\sa wc_SRTP_KDF_label
\sa wc_SRTCP_KDF_label
\sa wc_SRTP_KDF_kdr_to_idx
*/
int ;
/*!
\ingroup SrtpKdf
\brief This function derives keys using SRTCP KDF algorithm.
\return 0 Returned upon successful key derivation.
\return BAD_FUNC_ARG Returned when key or salt is NULL
\return BAD_FUNC_ARG Returned when key length is not 16, 24 or 32.
\return BAD_FUNC_ARG Returned when saltSz is larger than 14.
\return BAD_FUNC_ARG Returned when kdrIdx is less than -1 or larger than 24.
\return MEMORY_E on dynamic memory allocation failure.
\param [in] key Key to use with encryption.
\param [in] keySz Size of key in bytes.
\param [in] salt Random non-secret value.
\param [in] saltSz Size of random in bytes.
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
\param [in] idx Index value to XOR in.
\param [out] key1 First key. Label value of 0x00.
\param [in] key1Sz Size of first key in bytes.
\param [out] key2 Second key. Label value of 0x01.
\param [in] key2Sz Size of second key in bytes.
\param [out] key3 Third key. Label value of 0x02.
\param [in] key3Sz Size of third key in bytes.
_Example_
\code
unsigned char key[16] = { ... };
unsigned char salt[14] = { ... };
unsigned char idx[4] = { ... };
unsigned char keyE[16];
unsigned char keyA[20];
unsigned char keyS[14];
int kdrIdx = 0; // Use all of index
int ret;
ret = wc_SRTCP_KDF(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
keyE, sizeof(keyE), keyA, sizeof(keyA), keyS, sizeof(keyS));
if (ret != 0) {
WOLFSSL_MSG("wc_SRTP_KDF failed");
}
\endcode
\sa wc_SRTP_KDF
\sa wc_SRTP_KDF_label
\sa wc_SRTCP_KDF_label
\sa wc_SRTP_KDF_kdr_to_idx
*/
int ;
/*!
\ingroup SrtpKdf
\brief This function derives a key with label using SRTP KDF algorithm.
\return 0 Returned upon successful key derivation.
\return BAD_FUNC_ARG Returned when key, salt or outKey is NULL
\return BAD_FUNC_ARG Returned when key length is not 16, 24 or 32.
\return BAD_FUNC_ARG Returned when saltSz is larger than 14.
\return BAD_FUNC_ARG Returned when kdrIdx is less than -1 or larger than 24.
\return MEMORY_E on dynamic memory allocation failure.
\param [in] key Key to use with encryption.
\param [in] keySz Size of key in bytes.
\param [in] salt Random non-secret value.
\param [in] saltSz Size of random in bytes.
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
\param [in] idx Index value to XOR in.
\param [in] label Label to use when deriving key.
\param [out] outKey Derived key.
\param [in] outKeySz Size of derived key in bytes.
_Example_
\code
unsigned char key[16] = { ... };
unsigned char salt[14] = { ... };
unsigned char idx[6] = { ... };
unsigned char keyE[16];
int kdrIdx = 0; // Use all of index
int ret;
ret = wc_SRTP_KDF_label(key, sizeof(key), salt, sizeof(salt), kdrIdx, idx,
WC_SRTP_LABEL_ENCRYPTION, keyE, sizeof(keyE));
if (ret != 0) {
WOLFSSL_MSG("wc_SRTP_KDF failed");
}
\endcode
\sa wc_SRTP_KDF
\sa wc_SRTCP_KDF
\sa wc_SRTCP_KDF_label
\sa wc_SRTP_KDF_kdr_to_idx
*/
int ;
/*!
\ingroup SrtpKdf
\brief This function derives key with label using SRTCP KDF algorithm.
\return 0 Returned upon successful key derivation.
\return BAD_FUNC_ARG Returned when key, salt or outKey is NULL
\return BAD_FUNC_ARG Returned when key length is not 16, 24 or 32.
\return BAD_FUNC_ARG Returned when saltSz is larger than 14.
\return BAD_FUNC_ARG Returned when kdrIdx is less than -1 or larger than 24.
\return MEMORY_E on dynamic memory allocation failure.
\param [in] key Key to use with encryption.
\param [in] keySz Size of key in bytes.
\param [in] salt Random non-secret value.
\param [in] saltSz Size of random in bytes.
\param [in] kdrIdx Key derivation rate. kdr = 0 when -1, otherwise kdr = 2^kdrIdx.
\param [in] idx Index value to XOR in.
\param [in] label Label to use when deriving key.
\param [out] outKey Derived key.
\param [in] outKeySz Size of derived key in bytes.
_Example_
\code
unsigned char key[16] = { ... };
unsigned char salt[14] = { ... };
unsigned char idx[4] = { ... };
unsigned char keyE[16];
int kdrIdx = 0; // Use all of index
int ret;
ret = wc_SRTCP_KDF_label(key, sizeof(key), salt, sizeof(salt), kdrIdx,
idx, WC_SRTCP_LABEL_ENCRYPTION, keyE, sizeof(keyE));
if (ret != 0) {
WOLFSSL_MSG("wc_SRTP_KDF failed");
}
\endcode
\sa wc_SRTP_KDF
\sa wc_SRTCP_KDF
\sa wc_SRTP_KDF_label
\sa wc_SRTP_KDF_kdr_to_idx
*/
int ;
/*!
\ingroup SrtpKdf
\brief This function converts a kdr value to an index to use in SRTP/SRTCP KDF API.
\return Key derivation rate as an index.
\param [in] kdr Key derivation rate to convert.
_Example_
\code
word32 kdr = 0x00000010;
int kdrIdx;
int ret;
kdrIdx = wc_SRTP_KDF_kdr_to_idx(kdr);
\endcode
\sa wc_SRTP_KDF
\sa wc_SRTCP_KDF
\sa wc_SRTP_KDF_label
\sa wc_SRTCP_KDF_label
*/
int ;
/**
* \brief Performs the single-step key derivation function (KDF) as specified in
* SP800-56C option 1.
*
* \param [in] z The input keying material.
* \param [in] zSz The size of the input keying material.
* \param [in] fixedInfo The fixed information to be included in the KDF.
* \param [in] fixedInfoSz The size of the fixed information.
* \param [in] derivedSecretSz The desired size of the derived secret.
* \param [in] hashType The hash algorithm to be used in the KDF.
* \param [out] output The buffer to store the derived secret.
* \param [in] outputSz The size of the output buffer.
*
* \return 0 if the KDF operation is successful,
* \return BAD_FUNC_ARG if the input parameters are invalid.
* \return negative error code if the KDF operation fails.
*
* _Example_
\code
unsigned char z[32] = { ... };
unsigned char fixedInfo[16] = { ... };
unsigned char output[32];
int ret;
ret = wc_KDA_KDF_onestep(z, sizeof(z), fixedInfo, sizeof(fixedInfo),
sizeof(output), WC_HASH_TYPE_SHA256, output, sizeof(output));
if (ret != 0) {
WOLFSSL_MSG("wc_KDA_KDF_onestep failed");
}
\endcode
*/
int ;