The hardware does not support DHKEM IKM-based key derivation. When OSSL_PKEY_PARAM_DHKEM_IKM is set on the key generation context, fall back to the default provider's software implementation for EC, X25519 and X448 key generation. Signed-off-by: Weili Qian <qianweili@huawei.com> --- src/uadk_prov_ec_kmgmt.c | 8 ++++++++ src/uadk_prov_ecx.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/uadk_prov_ec_kmgmt.c b/src/uadk_prov_ec_kmgmt.c index f143b77..2b44d20 100644 --- a/src/uadk_prov_ec_kmgmt.c +++ b/src/uadk_prov_ec_kmgmt.c @@ -374,6 +374,14 @@ static void *uadk_keymgmt_ec_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbar goto free_ec_key; } +# if OPENSSL_VERSION_NUMBER >= 0x30200000L + /* DHKEM IKM-based key derivation is not supported by hardware */ + if (gctx->dhkem_ikm) { + ret = UADK_DO_SOFT; + goto free_ec_key; + } +# endif + /* Whether you want it or not, you get a keypair, not just one half */ if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) { ret = ec_hw_keygen(ec, gctx->priv_key); diff --git a/src/uadk_prov_ecx.c b/src/uadk_prov_ecx.c index e76d646..9f0335f 100644 --- a/src/uadk_prov_ecx.c +++ b/src/uadk_prov_ecx.c @@ -841,6 +841,13 @@ static void *uadk_keymgmt_x448_gen(void *genctx, OSSL_CALLBACK *cb, void *cb_par return NULL; } +# if OPENSSL_VERSION_NUMBER >= 0x30200000L + if (gctx->dhkem_ikm) { + ret = UADK_DO_SOFT; + goto exe_soft; + } +# endif + ret = uadk_prov_keymgmt_get_support_state(KEYMGMT_X448); if (ret == UADK_P_FAIL) { UADK_ERR("failed to get hardware x448 keygen support\n"); @@ -1474,6 +1481,13 @@ static void *uadk_keymgmt_x25519_gen(void *genctx, OSSL_CALLBACK *cb, void *cb_p return NULL; } +# if OPENSSL_VERSION_NUMBER >= 0x30200000L + if (gctx->dhkem_ikm) { + ret = UADK_DO_SOFT; + goto exe_soft; + } +# endif + ret = uadk_prov_keymgmt_get_support_state(KEYMGMT_X25519); if (ret == UADK_P_FAIL) { UADK_ERR("failed to get hardware x25519 keygen support\n"); -- 2.43.0