@@ -222,6 +222,54 @@ static int wp_kdf_set_ctx_params(wp_KdfCtx* ctx, const OSSL_PARAM params[])
222222 return EVP_KDF_CTX_set_params (ctx -> kdfCtx , params );
223223}
224224
225+ /**
226+ * Get the KDF key exchange parameters.
227+ *
228+ * @param [in] ctx KDF key exchange context object.
229+ * @param [in, out] params Array of parameters.
230+ * @return 1 on success.
231+ * @return 0 on failure.
232+ */
233+ static int wp_kdf_get_ctx_params (wp_KdfCtx * ctx , OSSL_PARAM params [])
234+ {
235+ int ok = 1 ;
236+
237+ WOLFPROV_ENTER (WP_LOG_KDF , "wp_kdf_get_ctx_params" );
238+
239+ if (!wolfssl_prov_is_running ()) {
240+ ok = 0 ;
241+ }
242+ if (ok && !EVP_KDF_CTX_get_params (ctx -> kdfCtx , params )) {
243+ ok = 0 ;
244+ }
245+
246+ WOLFPROV_LEAVE (WP_LOG_KDF , __FILE__ ":" WOLFPROV_STRINGIZE (__LINE__ ), ok );
247+ return ok ;
248+ }
249+
250+ /**
251+ * Get the list of gettable parameters for a KDF context.
252+ *
253+ * @param [in] ctx KDF key exchange context object. Unused.
254+ * @param [in] provCtx Provider context object.
255+ * @param [in] kdfName Name of the KDF.
256+ * @return Array of parameters with data type.
257+ */
258+ static const OSSL_PARAM * wp_kdf_gettable_ctx_params (wp_KdfCtx * ctx ,
259+ WOLFPROV_CTX * provCtx , const char * kdfName )
260+ {
261+ const OSSL_PARAM * params = NULL ;
262+
263+ (void )provCtx ;
264+ (void )kdfName ;
265+
266+ if (wolfssl_prov_is_running () && ctx != NULL && ctx -> kdfCtx != NULL ) {
267+ params = EVP_KDF_CTX_gettable_params (ctx -> kdfCtx );
268+ }
269+
270+ return params ;
271+ }
272+
225273/**
226274 * Return an array of supported settable parameters for the HKDF ke context.
227275 *
@@ -269,6 +317,32 @@ static const OSSL_PARAM* wp_tls1_prf_settable_ctx_params(wp_KdfCtx* ctx,
269317 return settable_ctx_params ;
270318}
271319
320+ /**
321+ * Return an array of supported gettable parameters for the HKDF ke context.
322+ *
323+ * @param [in] ctx KDF key exchange context object. Unused.
324+ * @param [in] provCtx Provider context object.
325+ * @return Array of parameters with data type.
326+ */
327+ static const OSSL_PARAM * wp_hkdf_gettable_ctx_params (wp_KdfCtx * ctx ,
328+ WOLFPROV_CTX * provCtx )
329+ {
330+ return wp_kdf_gettable_ctx_params (ctx , provCtx , "HKDF" );
331+ }
332+
333+ /**
334+ * Return an array of supported gettable parameters for the TLS1-PRF ke context.
335+ *
336+ * @param [in] ctx KDF key exchange context object. Unused.
337+ * @param [in] provCtx Provider context object.
338+ * @return Array of parameters with data type.
339+ */
340+ static const OSSL_PARAM * wp_tls1_prf_gettable_ctx_params (wp_KdfCtx * ctx ,
341+ WOLFPROV_CTX * provCtx )
342+ {
343+ return wp_kdf_gettable_ctx_params (ctx , provCtx , "TLS1-PRF" );
344+ }
345+
272346/*
273347 * HKDF
274348 */
@@ -293,8 +367,11 @@ const OSSL_DISPATCH wp_hkdf_keyexch_functions[] = {
293367 { OSSL_FUNC_KEYEXCH_INIT , (DFUNC )wp_kdf_init },
294368 { OSSL_FUNC_KEYEXCH_DERIVE , (DFUNC )wp_kdf_derive },
295369 { OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS , (DFUNC )wp_kdf_set_ctx_params },
370+ { OSSL_FUNC_KEYEXCH_GET_CTX_PARAMS , (DFUNC )wp_kdf_get_ctx_params },
296371 { OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS ,
297372 (DFUNC )wp_hkdf_settable_ctx_params },
373+ { OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS ,
374+ (DFUNC )wp_hkdf_gettable_ctx_params },
298375 { 0 , NULL }
299376};
300377
@@ -322,8 +399,11 @@ const OSSL_DISPATCH wp_tls1_prf_keyexch_functions[] = {
322399 { OSSL_FUNC_KEYEXCH_INIT , (DFUNC )wp_kdf_init },
323400 { OSSL_FUNC_KEYEXCH_DERIVE , (DFUNC )wp_kdf_derive },
324401 { OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS , (DFUNC )wp_kdf_set_ctx_params },
402+ { OSSL_FUNC_KEYEXCH_GET_CTX_PARAMS , (DFUNC )wp_kdf_get_ctx_params },
325403 { OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS ,
326404 (DFUNC )wp_tls1_prf_settable_ctx_params },
405+ { OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS ,
406+ (DFUNC )wp_tls1_prf_gettable_ctx_params },
327407 { 0 , NULL }
328408};
329409
0 commit comments