Skip to content

Add AES-GCM DEM, CryptoCb support, and devId threading to ECIES#10883

Open
night1rider wants to merge 7 commits into
wolfSSL:masterfrom
night1rider:Extend-ECIES
Open

Add AES-GCM DEM, CryptoCb support, and devId threading to ECIES#10883
night1rider wants to merge 7 commits into
wolfSSL:masterfrom
night1rider:Extend-ECIES

Conversation

@night1rider

Copy link
Copy Markdown
Contributor

Add AES-GCM (128/256) as an ECIES DEM next to the AES-CBC/CTR+HMAC modes.

Only the encryption key comes from the KDF; the mac salt is bound as GCM AAD and the 16-byte tag replaces the HMAC.

The GCM DEM honors all three IV build modes, and default fixed-nonce GCM is gated behind the new WOLFSSL_ECIES_STATIC_GCM_NONCE opt-in. Adds ECIES CryptoCb encrypt/decrypt, the WOLF_CRYPTO_CB ctx getters, devId/heap threading into the DEM primitives, and test/benchmark/CI coverage.

@night1rider night1rider self-assigned this Jul 10, 2026

@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 #10883

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

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

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

@night1rider
night1rider marked this pull request as ready for review July 11, 2026 00:28
@github-actions

Copy link
Copy Markdown

retest this please

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown

@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 #10883

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

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

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

@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 #10883

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

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

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

@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 #10883

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

Findings: 1
1 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/src/ecc.c Outdated
@night1rider
night1rider requested review from wolfSSL-Fenrir-bot and removed request for wolfSSL-Fenrir-bot July 13, 2026 16:29

@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 #10883

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

No new issues found in the changed files. ✅

@night1rider

Copy link
Copy Markdown
Contributor Author

Rebased to fix merge conflict

@night1rider

Copy link
Copy Markdown
Contributor Author

Jenkins retest this please

Comment thread wolfcrypt/benchmark/benchmark.c Outdated
ecEncCtx* cliCtx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &gRng);
ecEncCtx* srvCtx = wc_ecc_ctx_new(REQ_RESP_SERVER, &gRng);
char encDesc[32];
char decDesc[32];

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.

Avoid magic numbers here (32), maybe WC_BENCH_MAX_LINE_LEN if it should fit on one line. Or another macro.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment thread wolfcrypt/src/ecc.c Outdated
if ((msgSz % blockSz) != 0)
return BAD_PADDING_E;

if (ecc_is_gcm(ctx->encAlgo)) {

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.

This section of code is identical to the section at line 15700, please consider a helper function for the checks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created a static function helper

Comment thread wolfcrypt/src/ecc.c Outdated
#else
ctx->encAlgo = ecAES_128_CTR;
#endif
#elif !defined(NO_AES) && defined(HAVE_AESGCM)

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.

In a GCM-only build with default IV mode, ecc_ctx_init defaults to AES-GCM but encrypt/decrypt then reject GCM with NOT_COMPILED_IN, making ECIES unusable without a manual wc_ecc_ctx_set_algo override.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good observation, added a compile time check.

Comment thread wolfssl/wolfcrypt/ecc.h Outdated
IV_SIZE_64 = 8,
IV_SIZE_128 = 16,
ECC_MAX_IV_SIZE = 16,
AES_GCM_NONCE_SZ = 12, /* GCM IV/nonce length for ECIES DEM */

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.

I think these enums are duplicates of existing AES ones available. Use GCM_NONCE_MID_SZ for nonce size and in other places we use WC_AES_BLOCK_SIZE for a 16 bit tag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed the duplicates

Add AES-GCM (128/256) as an ECIES DEM next to the AES-CBC/CTR+HMAC modes. Only the encryption key comes from the KDF; the mac salt is bound as GCM AAD and the 16-byte tag replaces the HMAC. The GCM DEM honors all three IV build modes, and default fixed-nonce GCM is gated behind the new WOLFSSL_ECIES_STATIC_GCM_NONCE opt-in. Adds ECIES CryptoCb encrypt/decrypt, the WOLF_CRYPTO_CB ctx getters, devId/heap threading into the DEM primitives, and test/benchmark/CI coverage.
…Id field by reading it into a guarded local (PLUTON_CRYPTO_ECC/WOLF_CRYPTO_CB) that defaults to INVALID_DEVID
…path so a device that services encrypt/decrypt without a software fallback cannot reuse the ctx.

Add a testwolfcrypt case that services ECIES entirely in the callback and checks a second op on the same ctx is rejected with BAD_STATE_E.
… output size into ecc_ecies_total_size helper,

gate the AES-GCM ctx default on a usable IV mode, and name the benchmark ECIES desc buffer size
@night1rider

Copy link
Copy Markdown
Contributor Author

Addressed comments, and rebased off current master.

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.

4 participants