Skip to content

add support for WOLF_CRYPTO_CB_ONLY_SHA512#10550

Open
rizlik wants to merge 4 commits into
wolfSSL:masterfrom
rizlik:sha512_only
Open

add support for WOLF_CRYPTO_CB_ONLY_SHA512#10550
rizlik wants to merge 4 commits into
wolfSSL:masterfrom
rizlik:sha512_only

Conversation

@rizlik
Copy link
Copy Markdown
Contributor

@rizlik rizlik commented May 28, 2026

Description

  • WOLF_CRYPTO_CB_ONLY_SHA512 support
  • Support SHA384 with cryptocb device that only support SHA512 call

@rizlik rizlik self-assigned this May 28, 2026
Copilot AI review requested due to automatic review settings May 28, 2026 13:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “crypto-callback-only” build mode for the SHA-512 family (WOLF_CRYPTO_CB_ONLY_SHA512) and extends the crypto-callback dispatcher to support SHA-384 via a SHA-512-only device callback (by using SHA-512 core + truncation fallback behavior).

Changes:

  • Introduces WOLF_CRYPTO_CB_ONLY_SHA512 settings/header gating to strip SHA-512-family software paths and disable raw/transform APIs accordingly.
  • Implements a CB-only SHA-512-family backend in sha512.c that dispatches public SHA-512/SHA-384/SHA-512/224/SHA-512/256 APIs through wc_CryptoCb_*Hash.
  • Updates wc_CryptoCb_Sha384Hash() to fall back to a SHA-512 callback (and truncate) when a SHA-384 callback is unavailable; adds CI coverage + an API test for this fallback path.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
wolfssl/wolfcrypt/sha512.h Disables raw/transform entry points when CB-only SHA-512 is enabled.
wolfssl/wolfcrypt/settings.h Adds config validation for WOLF_CRYPTO_CB_ONLY_SHA512 (requires CB; incompatible with FIPS).
wolfcrypt/test/test.c Extends CB-only test callback routing logic for SHA-384/SHA-512.
wolfcrypt/src/sha512.c Adds a new CB-only SHA-512-family backend implementation.
wolfcrypt/src/cryptocb.c Adds SHA-384 → SHA-512 fallback (with truncation) in the crypto callback dispatcher.
tests/swdev/user_settings.h Ensures swdev build undefines WOLF_CRYPTO_CB_ONLY_SHA512 so swdev retains software hashing.
tests/swdev/swdev.c Adds SHA-512-family handling in swdev callback to support CB-only test matrices.
tests/api/test_sha512.h Registers new SHA-384 fallback test.
tests/api/test_sha512.c Adds a unit test to validate SHA-384 fallback-to-SHA-512 behavior and state restoration.
tests/api.c Excludes CB-only SHA-512 configs from certain crypto-callback API tests (like other ONLY_* modes).
.github/workflows/cryptocb-only.yml Adds CI matrix entries for CB-only SHA-512 and a “general-only” variant to exercise fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfcrypt/src/sha512.c Outdated
Comment thread wolfcrypt/src/sha512.c Outdated
Comment thread wolfcrypt/src/sha512.c Outdated
Comment thread wolfcrypt/src/sha512.c Outdated
Comment thread wolfcrypt/src/sha512.c Outdated
@rizlik rizlik marked this pull request as draft May 28, 2026 16:26
rizlik added 3 commits June 4, 2026 12:06
After the SHA-512/224 and /256 fallback to the generic SHA-512 callback,
restore the variant initial state so the object is reset for reuse, and
exercise the path in cryptocb_test.
@rizlik rizlik marked this pull request as ready for review June 4, 2026 14:26
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

retest this please

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread wolfcrypt/src/cryptocb.c Outdated
Comment thread wolfcrypt/src/cryptocb.c Outdated
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