Skip to content

[PWCI] "crypto/openssl: Add support for SHA3 algorithms"#596

Open
ovsrobot wants to merge 1 commit intomainfrom
series_36970
Open

[PWCI] "crypto/openssl: Add support for SHA3 algorithms"#596
ovsrobot wants to merge 1 commit intomainfrom
series_36970

Conversation

@ovsrobot
Copy link
Owner

@ovsrobot ovsrobot commented Jan 6, 2026

NOTE: This is an auto submission for "crypto/openssl: Add support for SHA3 algorithms".

See "http://patchwork.dpdk.org/project/dpdk/list/?series=36970" for details.

Summary by Sourcery

Add SHA3 hash and HMAC authentication support to the OpenSSL crypto PMD.

New Features:

  • Advertise SHA3-224/256/384/512 and corresponding HMAC algorithms in the OpenSSL PMD capabilities.
  • Enable SHA3-224/256/384/512 and their HMAC variants via OpenSSL EVP integration and session authentication parameter handling.

Summary by CodeRabbit

  • New Features
    • Added SHA3 family hash algorithm support to the OpenSSL cryptographic driver, including SHA3-224, SHA3-256, SHA3-384, and SHA3-512 in both HMAC and standard variants.

✏️ Tip: You can customize this high-level summary in your review settings.

openssl 3.X supports SHA3. Hence adding SHA3-224, SHA3-256,
SHA3-384 and SHA3-512 support to the PMD.

Signed-off-by: Emma Finn <emma.finn@intel.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 6, 2026

Reviewer's Guide

Adds SHA3-{224,256,384,512} and corresponding HMAC algorithm support to the OpenSSL crypto PMD, wiring them into the capability table, digest name mapping, OpenSSL EVP selection, and session authentication parameter handling.

Sequence diagram for SHA3 HMAC session setup in OpenSSL PMD

sequenceDiagram
    actor App
    participant CryptoDev as rte_cryptodev
    participant OpensslPmd as openssl_pmd
    participant OpenSSL as openssl_evp

    App->>CryptoDev: rte_cryptodev_configure()
    App->>CryptoDev: rte_cryptodev_sym_session_create()
    App->>CryptoDev: rte_cryptodev_sym_session_init(xform: RTE_CRYPTO_AUTH_SHA3_256_HMAC)

    CryptoDev->>OpensslPmd: openssl_set_session_auth_parameters(sess, xform)
    activate OpensslPmd

    OpensslPmd->>OpensslPmd: switch xform->auth.algo
    Note right of OpensslPmd: Case RTE_CRYPTO_AUTH_SHA3_256_HMAC

    OpensslPmd->>OpensslPmd: sess->auth.mode = OPENSSL_AUTH_AS_HMAC

    OpensslPmd->>OpensslPmd: algo = digest_name_get(RTE_CRYPTO_AUTH_SHA3_256_HMAC)
    OpensslPmd-->>OpensslPmd: algo = OSSL_DIGEST_NAME_SHA3_256

    OpensslPmd->>OpenSSL: get_auth_algo(RTE_CRYPTO_AUTH_SHA3_256_HMAC, evp_algo)
    activate OpenSSL
    OpenSSL->>OpenSSL: switch sessalgo
    OpenSSL-->>OpensslPmd: evp_algo = EVP_sha3_256()
    deactivate OpenSSL

    OpensslPmd-->>CryptoDev: session configured with SHA3_256_HMAC
    deactivate OpensslPmd

    App->>CryptoDev: rte_cryptodev_enqueue_burst(crypto_ops)
    CryptoDev->>OpensslPmd: process crypto_ops with sess->auth.evp_algo (EVP_sha3_256)
Loading

File-Level Changes

Change Details Files
Expose SHA3 and SHA3-HMAC algorithms as supported capabilities of the OpenSSL cryptodev PMD.
  • Extend openssl_pmd_capabilities with SHA3-224/256/384/512 HMAC capability entries with configurable key and digest sizes.
  • Add corresponding SHA3-224/256/384/512 non-HMAC digest capability entries with fixed digest sizes and no key requirements.
  • Use appropriate SHA3 sponge block sizes per variant for block_size fields.
drivers/crypto/openssl/rte_openssl_pmd_ops.c
Integrate SHA3 and SHA3-HMAC algorithms into OpenSSL PMD runtime mapping and session setup.
  • Update digest_name_get() to map SHA3-HMAC rte_crypto auth algorithms to the correct OpenSSL SHA3 digest names.
  • Extend get_auth_algo() to return the appropriate EVP_sha3_*() function for SHA3 and SHA3-HMAC algorithms.
  • Update openssl_set_session_auth_parameters() to treat SHA3 digests as AUTH-only and SHA3-HMAC as HMAC modes for both crypto-op and session creation paths, reusing existing SHA2 handling patterns.
drivers/crypto/openssl/rte_openssl_pmd.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

The changes extend the OpenSSL PMD crypto driver to support SHA-3 family algorithms (SHA3-224, SHA3-256, SHA3-384, SHA3-512) in both plain and HMAC modes. Updates include digest name mappings, algorithm validation, session parameter handling, and capability declarations.

Changes

Cohort / File(s) Summary
SHA-3 Algorithm Support
drivers/crypto/openssl/rte_openssl_pmd.c
Added digest name mappings for SHA3-224/256/384/512 HMAC variants; extended get_auth_algo() to validate SHA3 EVP selections; expanded openssl_set_session_auth_parameters() switch cases to handle SHA3 variants in both AUTH and HMAC branches with proper EVP_MD/EVP_MAC context setup.
SHA-3 Capability Declarations
drivers/crypto/openssl/rte_openssl_pmd_ops.c
Added eight new symmetric auth capability entries for SHA3-224_HMAC, SHA3-224, SHA3-256_HMAC, SHA3-256, SHA3-384_HMAC, SHA3-384, SHA3-512_HMAC, and SHA3-512, each specifying block size, key size range, digest size range, and IV size parameters.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops with glee through crypto lanes,
SHA-3's now on the scene!
Three-two-four to five-one-twos,
HMAC blooms in golden sheen,
OpenSSL's rabbit path runs clean!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the primary change: adding SHA3 algorithm support to the OpenSSL crypto PMD. It is concise and specific enough to understand the main modification at a glance.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI Agents
In @drivers/crypto/openssl/rte_openssl_pmd.c:
- Around line 686-689: The SHA3 auth case labels (RTE_CRYPTO_AUTH_SHA3_224,
RTE_CRYPTO_AUTH_SHA3_256, RTE_CRYPTO_AUTH_SHA3_384, RTE_CRYPTO_AUTH_SHA3_512)
must be guarded by an OpenSSL version check because get_auth_algo calls
EVP_sha3_* which only exists in OpenSSL 1.1.1+; wrap those case labels and any
associated handling in an #if OPENSSL_VERSION_NUMBER >= 0x10101000L / #endif
block (include/open with opensslv.h if not already) so builds against older
OpenSSL skip these cases and avoid compilation errors.
- Around line 779-782: The switch branch adding SHA3 HMAC cases
(RTE_CRYPTO_AUTH_SHA3_224_HMAC, RTE_CRYPTO_AUTH_SHA3_256_HMAC,
RTE_CRYPTO_AUTH_SHA3_384_HMAC, RTE_CRYPTO_AUTH_SHA3_512_HMAC) is inside the
legacy OpenSSL < 3.0 path but lacks a guard for OpenSSL 1.1.1+, so compilation
fails on OpenSSL 1.0.x / 1.1.0; wrap those case labels and their handling with a
preprocessor check using OPENSSL_VERSION_NUMBER >= 0x10101000L (and close the
guard) so the SHA3 HMAC code is only compiled when OpenSSL is at least 1.1.1 in
the legacy branch.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd60dcd and a42bd38.

📒 Files selected for processing (2)
  • drivers/crypto/openssl/rte_openssl_pmd.c
  • drivers/crypto/openssl/rte_openssl_pmd_ops.c
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (2)
drivers/crypto/openssl/rte_openssl_pmd.c (1)

95-102: LGTM - SHA3 HMAC digest name mappings are correctly guarded.

The SHA3 HMAC digest name mappings are properly placed within the OpenSSL 3.0+ version guard and correctly map to OSSL_DIGEST_NAME_SHA3_* constants.

drivers/crypto/openssl/rte_openssl_pmd_ops.c (1)

272-439: Consider conditionally including SHA3 capability entries based on OpenSSL version.

The SHA3 capability definitions are correct (block sizes, digest sizes, key sizes all match SHA3 specifications). However, these capabilities are advertised unconditionally even when compiled against OpenSSL versions < 1.1.1 that don't support SHA3. While EVP_sha3_* functions are called at runtime in rte_openssl_pmd.c without version guards, the capabilities array itself could be wrapped with conditional compilation to prevent advertising unsupported algorithms.

Comment on lines +281 to +296
case RTE_CRYPTO_AUTH_SHA3_224:
case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
*algo = EVP_sha3_224();
break;
case RTE_CRYPTO_AUTH_SHA3_256:
case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
*algo = EVP_sha3_256();
break;
case RTE_CRYPTO_AUTH_SHA3_384:
case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
*algo = EVP_sha3_384();
break;
case RTE_CRYPTO_AUTH_SHA3_512:
case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
*algo = EVP_sha3_512();
break;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Missing version guard for SHA3 functions will cause compilation errors.

EVP_sha3_224/256/384/512 functions were introduced in OpenSSL 1.1.1, but these cases are not version-guarded. Since the codebase supports OpenSSL 1.0.x (see guards at line 26), this will cause compilation failures on older OpenSSL versions.

Suggested fix
 		*algo = EVP_sha512();
 		break;
+#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
 	case RTE_CRYPTO_AUTH_SHA3_224:
 	case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
 		*algo = EVP_sha3_224();
 		break;
 	case RTE_CRYPTO_AUTH_SHA3_256:
 	case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
 		*algo = EVP_sha3_256();
 		break;
 	case RTE_CRYPTO_AUTH_SHA3_384:
 	case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
 		*algo = EVP_sha3_384();
 		break;
 	case RTE_CRYPTO_AUTH_SHA3_512:
 	case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
 		*algo = EVP_sha3_512();
 		break;
+#endif
 	default:
 		res = -EINVAL;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case RTE_CRYPTO_AUTH_SHA3_224:
case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
*algo = EVP_sha3_224();
break;
case RTE_CRYPTO_AUTH_SHA3_256:
case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
*algo = EVP_sha3_256();
break;
case RTE_CRYPTO_AUTH_SHA3_384:
case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
*algo = EVP_sha3_384();
break;
case RTE_CRYPTO_AUTH_SHA3_512:
case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
*algo = EVP_sha3_512();
break;
*algo = EVP_sha512();
break;
#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
case RTE_CRYPTO_AUTH_SHA3_224:
case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
*algo = EVP_sha3_224();
break;
case RTE_CRYPTO_AUTH_SHA3_256:
case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
*algo = EVP_sha3_256();
break;
case RTE_CRYPTO_AUTH_SHA3_384:
case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
*algo = EVP_sha3_384();
break;
case RTE_CRYPTO_AUTH_SHA3_512:
case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
*algo = EVP_sha3_512();
break;
#endif
default:
res = -EINVAL;

Comment on lines +686 to +689
case RTE_CRYPTO_AUTH_SHA3_224:
case RTE_CRYPTO_AUTH_SHA3_256:
case RTE_CRYPTO_AUTH_SHA3_384:
case RTE_CRYPTO_AUTH_SHA3_512:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Plain SHA3 authentication requires OpenSSL 1.1.1+ version guard.

These SHA3 auth cases call get_auth_algo which uses EVP_sha3_* functions only available in OpenSSL 1.1.1+. Add version guards to prevent compilation errors on older versions.

Suggested fix
 	case RTE_CRYPTO_AUTH_SHA384:
 	case RTE_CRYPTO_AUTH_SHA512:
+#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
 	case RTE_CRYPTO_AUTH_SHA3_224:
 	case RTE_CRYPTO_AUTH_SHA3_256:
 	case RTE_CRYPTO_AUTH_SHA3_384:
 	case RTE_CRYPTO_AUTH_SHA3_512:
+#endif
 		sess->auth.mode = OPENSSL_AUTH_AS_AUTH;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case RTE_CRYPTO_AUTH_SHA3_224:
case RTE_CRYPTO_AUTH_SHA3_256:
case RTE_CRYPTO_AUTH_SHA3_384:
case RTE_CRYPTO_AUTH_SHA3_512:
case RTE_CRYPTO_AUTH_SHA384:
case RTE_CRYPTO_AUTH_SHA512:
#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
case RTE_CRYPTO_AUTH_SHA3_224:
case RTE_CRYPTO_AUTH_SHA3_256:
case RTE_CRYPTO_AUTH_SHA3_384:
case RTE_CRYPTO_AUTH_SHA3_512:
#endif
sess->auth.mode = OPENSSL_AUTH_AS_AUTH;
🤖 Prompt for AI Agents
In @drivers/crypto/openssl/rte_openssl_pmd.c around lines 686 - 689, The SHA3
auth case labels (RTE_CRYPTO_AUTH_SHA3_224, RTE_CRYPTO_AUTH_SHA3_256,
RTE_CRYPTO_AUTH_SHA3_384, RTE_CRYPTO_AUTH_SHA3_512) must be guarded by an
OpenSSL version check because get_auth_algo calls EVP_sha3_* which only exists
in OpenSSL 1.1.1+; wrap those case labels and any associated handling in an #if
OPENSSL_VERSION_NUMBER >= 0x10101000L / #endif block (include/open with
opensslv.h if not already) so builds against older OpenSSL skip these cases and
avoid compilation errors.

Comment on lines +779 to +782
case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

SHA3 HMAC in legacy branch requires version guard for OpenSSL 1.1.1+.

This else branch handles OpenSSL < 3.0, but SHA3 support still requires OpenSSL 1.1.1+. The code will fail to compile on OpenSSL 1.0.x and 1.1.0.

Suggested fix
 	case RTE_CRYPTO_AUTH_SHA256_HMAC:
 	case RTE_CRYPTO_AUTH_SHA384_HMAC:
 	case RTE_CRYPTO_AUTH_SHA512_HMAC:
+#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
 	case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
 	case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
 	case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
 	case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
+#endif
 		sess->auth.mode = OPENSSL_AUTH_AS_HMAC;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
case RTE_CRYPTO_AUTH_SHA256_HMAC:
case RTE_CRYPTO_AUTH_SHA384_HMAC:
case RTE_CRYPTO_AUTH_SHA512_HMAC:
#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
case RTE_CRYPTO_AUTH_SHA3_224_HMAC:
case RTE_CRYPTO_AUTH_SHA3_256_HMAC:
case RTE_CRYPTO_AUTH_SHA3_384_HMAC:
case RTE_CRYPTO_AUTH_SHA3_512_HMAC:
#endif
sess->auth.mode = OPENSSL_AUTH_AS_HMAC;
🤖 Prompt for AI Agents
In @drivers/crypto/openssl/rte_openssl_pmd.c around lines 779 - 782, The switch
branch adding SHA3 HMAC cases (RTE_CRYPTO_AUTH_SHA3_224_HMAC,
RTE_CRYPTO_AUTH_SHA3_256_HMAC, RTE_CRYPTO_AUTH_SHA3_384_HMAC,
RTE_CRYPTO_AUTH_SHA3_512_HMAC) is inside the legacy OpenSSL < 3.0 path but lacks
a guard for OpenSSL 1.1.1+, so compilation fails on OpenSSL 1.0.x / 1.1.0; wrap
those case labels and their handling with a preprocessor check using
OPENSSL_VERSION_NUMBER >= 0x10101000L (and close the guard) so the SHA3 HMAC
code is only compiled when OpenSSL is at least 1.1.1 in the legacy branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants