When the legacy provider is unavailable, DES ciphers were still reported as supported, causing runtime failures when applications attempted to use them.
Add openssl_pmd_caps_init() to build a filtered capability list at device init, excluding DES-CBC and DES-DOCSISBPI based on legacy provider availability. Log a warning when DES algorithms are unavailable. The active capability list is always populated before the device is registered and queryable, so openssl_pmd_info_get() uses it directly without a fallback. Signed-off-by: Pratik Senapati <[email protected]> --- v2: - Remove unreachable fallback in openssl_pmd_info_get(): caps_active is always populated before the device is registered and queryable, so the check for RTE_CRYPTO_OP_TYPE_UNDEFINED is dead code - openssl_pmd_caps_init() call moved to patch 2 along with provider load restructure; this patch only introduces the filtering and active list drivers/crypto/openssl/openssl_pmd_private.h | 2 ++ drivers/crypto/openssl/rte_openssl_pmd.c | 1 + drivers/crypto/openssl/rte_openssl_pmd_ops.c | 27 +++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/openssl/openssl_pmd_private.h b/drivers/crypto/openssl/openssl_pmd_private.h index 059a14ef9f..e5dbe8f24b 100644 --- a/drivers/crypto/openssl/openssl_pmd_private.h +++ b/drivers/crypto/openssl/openssl_pmd_private.h @@ -261,4 +261,6 @@ extern struct rte_cryptodev_ops *rte_openssl_pmd_ops; /** ML parameter type names */ extern const char *ml_kem_type_names[]; extern const char *ml_dsa_type_names[]; +/** Initialize filtered capability list based on legacy provider availability */ +extern void openssl_pmd_caps_init(void); #endif /* _OPENSSL_PMD_PRIVATE_H_ */ diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 8791186fec..b1ede62da2 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -4204,6 +4204,7 @@ cryptodev_openssl_create(const char *name, * unless the legacy provider explicitly loaded. e.g. DES */ ossl_legacy_provider_load(); + openssl_pmd_caps_init(); return 0; diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index d3718c28e4..d7a48665d5 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -954,6 +954,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = { RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() }; +static struct rte_cryptodev_capabilities openssl_pmd_caps_active[RTE_DIM(openssl_pmd_capabilities)]; + const char *ml_kem_type_names[] = { NULL, "ML-KEM-512", @@ -968,6 +970,29 @@ const char *ml_dsa_type_names[] = { "ML-DSA-87", }; +/** Initialize active capability list, filtering unsupported entries. */ +void +openssl_pmd_caps_init(void) +{ + uint32_t i, j = 0; + + for (i = 0; openssl_pmd_capabilities[i].op != RTE_CRYPTO_OP_TYPE_UNDEFINED; i++) { + const struct rte_cryptodev_capabilities *cap = &openssl_pmd_capabilities[i]; + + if (cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC && + cap->sym.xform_type == RTE_CRYPTO_SYM_XFORM_CIPHER && + (cap->sym.cipher.algo == RTE_CRYPTO_CIPHER_DES_CBC || + cap->sym.cipher.algo == RTE_CRYPTO_CIPHER_DES_DOCSISBPI)) { + EVP_CIPHER *des_cbc = EVP_CIPHER_fetch(NULL, "DES-CBC", "provider=legacy"); + if (des_cbc == NULL) + continue; + EVP_CIPHER_free(des_cbc); + } + openssl_pmd_caps_active[j++] = *cap; + } + openssl_pmd_caps_active[j] = openssl_pmd_capabilities[i]; +} + /** Configure device */ static int openssl_pmd_config(__rte_unused struct rte_cryptodev *dev, @@ -1039,7 +1064,7 @@ openssl_pmd_info_get(struct rte_cryptodev *dev, if (dev_info != NULL) { dev_info->driver_id = dev->driver_id; dev_info->feature_flags = dev->feature_flags; - dev_info->capabilities = openssl_pmd_capabilities; + dev_info->capabilities = openssl_pmd_caps_active; dev_info->max_nb_queue_pairs = internals->max_nb_qpairs; /* No limit of number of sessions */ dev_info->sym.max_nb_sessions = 0; -- 2.43.0

