Skip to content

Add crypto callback only mode for ed25519#10830

Merged
philljj merged 8 commits into
wolfSSL:masterfrom
padelsbach:ed25519-cryptocb-only
Jul 17, 2026
Merged

Add crypto callback only mode for ed25519#10830
philljj merged 8 commits into
wolfSSL:masterfrom
padelsbach:ed25519-cryptocb-only

Conversation

@padelsbach

@padelsbach padelsbach commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

Expand existing ed25519 crypto callback to support the "only" mode which strips the software implementation for use with HSM or other hardware accelerators.

make_key, check_key, make_pub, sign_msg and verify_msg supported. No streaming support.

Testing

Added unit test and updated CI workflow

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Comment thread wolfcrypt/src/ed25519.c
@padelsbach padelsbach self-assigned this Jul 1, 2026
@padelsbach

Copy link
Copy Markdown
Contributor Author

Jenkins retest this please

@padelsbach
padelsbach marked this pull request as ready for review July 1, 2026 19:51
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

retest this please

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10830

Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src

No new issues found in the changed files. ✅

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m4

  • FLASH: .rodata.CSWTCH.1 +20 B, .rodata.str1.1 +250 B (+0.1%, 200,654 B / 262,144 B, total: 77% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .rodata.CSWTCH.1 +20 B, .rodata.str1.1 +250 B (+0.2%, 174,838 B / 262,144 B, total: 67% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +64 B (+0.0%, 180,952 B / 1,048,576 B, total: 17% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .rodata +280 B, .text +64 B (+0.0%, 771,556 B / 1,048,576 B, total: 74% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .rodata.CSWTCH.1 +20 B, .rodata.str1.1 +250 B, .text -64 B (+0.1%, 212,986 B / 262,144 B, total: 81% used)

gcc-arm-cortex-m4-pq

  • FLASH: .rodata +276 B, .text +64 B (+0.1%, 279,800 B / 1,048,576 B, total: 27% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .rodata +280 B, .text +64 B (+0.1%, 325,400 B / 1,048,576 B, total: 31% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .rodata.CSWTCH.1 +20 B, .rodata.str1.1 +250 B, .text +64 B (+0.1%, 236,480 B / 262,144 B, total: 90% used)

gcc-arm-cortex-m7

  • FLASH: .rodata.CSWTCH.1 +20 B, .rodata.str1.1 +250 B (+0.1%, 200,590 B / 262,144 B, total: 77% used)

gcc-arm-cortex-m7-pq

  • FLASH: .rodata +276 B, .text +64 B (+0.1%, 280,376 B / 1,048,576 B, total: 27% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .rodata.CSWTCH.1 +20 B, .rodata.str1.1 +250 B, .text +64 B (+0.1%, 236,480 B / 262,144 B, total: 90% used)

linuxkm-pie

  • Data: __patchable_function_entries +16 B (+0.1%, 25,576 B)

linuxkm-standard

  • Data: __patchable_function_entries +16 B (+0.0%, 48,264 B)

stm32-sim-stm32h753

@padelsbach
padelsbach force-pushed the ed25519-cryptocb-only branch from 80c6f68 to 37b0c37 Compare July 6, 2026 15:34
@padelsbach
padelsbach requested review from bigbrett and rizlik July 6, 2026 18:10
@padelsbach padelsbach removed their assignment Jul 6, 2026
@padelsbach
padelsbach requested a review from Frauschi July 6, 2026 18:10
@bigbrett bigbrett assigned padelsbach and unassigned rizlik Jul 6, 2026
@padelsbach

Copy link
Copy Markdown
Contributor Author

jenkins retest this please

@rizlik rizlik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work, but the problem is that make_public and check-key survives and so ge_operations can't be removed from the build.
Given that the main goal of ONLY_ED25519 is to reduce code/data size, we should aim at removing all the software math.

I see two options:

  1. Gating out the make_public and check_key with new gating macros
  2. Adding two crypto callbacks for make_public and check_key

Comment thread wolfcrypt/src/ed25519.c Outdated

@Frauschi Frauschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🐺 Skoll Code Review

Overall recommendation: COMMENT
Findings: 1 total — 1 posted, 0 skipped

Posted findings

  • [Low] Sign CB_ONLY path omits (void)ed25519Ctx suppression present in verify pathwolfcrypt/src/ed25519.c:445

Review generated by Skoll via Claude/Codex

Comment thread wolfcrypt/src/ed25519.c
@padelsbach
padelsbach force-pushed the ed25519-cryptocb-only branch from 67cd0ad to d4cb29c Compare July 9, 2026 16:48
@padelsbach

Copy link
Copy Markdown
Contributor Author

Great work, but the problem is that make_public and check-key survives and so ge_operations can't be removed from the build. Given that the main goal of ONLY_ED25519 is to reduce code/data size, we should aim at removing all the software math.

I see two options:

  1. Gating out the make_public and check_key with new gating macros
  2. Adding two crypto callbacks for make_public and check_key

Option 2 added, following the pattern from ECC. The ge operations are completely gone, but I did have to inline a small chunk of math.

@padelsbach padelsbach assigned rizlik and unassigned padelsbach Jul 9, 2026
@padelsbach
padelsbach force-pushed the ed25519-cryptocb-only branch from 8379f8d to ef4e304 Compare July 9, 2026 17:14

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10830

Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src

Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread wolfcrypt/test/test.c
Comment thread wolfcrypt/test/test.c Outdated
Comment thread tests/swdev/swdev.c
@padelsbach
padelsbach force-pushed the ed25519-cryptocb-only branch 2 times, most recently from 031d58b to 9a941fb Compare July 9, 2026 21:12
@padelsbach

Copy link
Copy Markdown
Contributor Author

@Frauschi @rizlik CI finally green. Please re-review

Frauschi
Frauschi previously approved these changes Jul 13, 2026

@Frauschi Frauschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@rizlik rizlik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WOLFSSL_CURVE25519_USE_ED25519 auto-define in fe_operations.h re-enable the math.

The config --enable-ed25519 --enable-cryptocb --disable-curve25519 + ONLY_ED25519 fails the linkage.

Probably disabling blinding also re-enable the math silently.

My suggestion is to gate the USE_ED25519 to !CB_ONLY_ED25519

@rizlik

rizlik commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

My suggestion is to gate the USE_ED25519 to !CB_ONLY_ED25519

If you prefer to do that in a follow-up PR I'm OK also to merge as it is now

@padelsbach

Copy link
Copy Markdown
Contributor Author

My suggestion is to gate the USE_ED25519 to !CB_ONLY_ED25519

If you prefer to do that in a follow-up PR I'm OK also to merge as it is now

Excellent catch. I've pushed a commit to fix it and add a test case in CI.

For future reference, this was the problematic configure command:

./configure --enable-ed25519 --enable-cryptocb --disable-curve25519 CFLAGS="-O2 -DWOLF_CRYPTO_CB_ONLY_ED25519"

@padelsbach
padelsbach requested a review from rizlik July 14, 2026 16:05
@padelsbach
padelsbach force-pushed the ed25519-cryptocb-only branch from 614585f to a6383a3 Compare July 14, 2026 16:08
rizlik
rizlik previously approved these changes Jul 15, 2026
Comment thread wolfssl/wolfcrypt/fe_operations.h

@philljj philljj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good first pass, just two tiny questions.

Comment thread wolfssl/wolfcrypt/settings.h Outdated
Comment thread wolfssl/wolfcrypt/fe_operations.h
@philljj philljj assigned padelsbach and unassigned wolfSSL-Bot Jul 16, 2026
@rizlik

rizlik commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Does an extra comment need to be added, or is this resolved?

@philljj it can be addressed by the PR that adds CB_ONLY_CURVE25519, no need to block this one for this

@padelsbach padelsbach removed their assignment Jul 17, 2026
@padelsbach
padelsbach requested a review from philljj July 17, 2026 13:36
@philljj

philljj commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Retest this please.

(Connection to github.com closed by remote host.).

@philljj
philljj merged commit dc1c77e into wolfSSL:master Jul 17, 2026
365 of 366 checks passed
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.

6 participants