Skip to content

Take AES-GCM TLS and IV-gen IVs from the wolfCrypt module counter - #531

Open
kaleb-himes wants to merge 3 commits into
wolfSSL:masterfrom
kaleb-himes:gcm-module-iv-counter
Open

kaleb-himes wants to merge 3 commits into
wolfSSL:masterfrom
kaleb-himes:gcm-module-iv-counter

Conversation

@kaleb-himes

Copy link
Copy Markdown
Contributor

Take AES-GCM IVs from the wolfCrypt module counter

FIPS v7 locks the AES-GCM IV once wolfCrypt generates it (wolfSSL/wolfssl#12170,
FIPS 140-3 IG C.H). After wc_AesGcmSetIV(), a caller IV passed to
wc_AesGcmInit() or wc_AesGcmSetExtIV() returns BAD_STATE_E until the next
key is set. wolfProvider incremented the IV itself and passed it back as a
caller IV, so TLS 1.2 GCM records and EVP IV-gen failed against v7.

Changes in src/wp_aes_aead.c:

  • A context flag records that wolfCrypt generated the IV (encrypt with
    SET_IV_FIXED). A new key, a caller IV, the -1 restore of a full IV, and
    every decrypt init clear it.
  • TLS 1.2 records encrypt with wc_AesGcmEncrypt_ex(). The 8-byte explicit
    nonce is copied from the IV the module used, so the wire format is
    unchanged (RFC 5288 section 3).
  • IV_GEN and streaming init use wc_AesGcmEncryptInit_ex() to take the
    module's next IV, instead of incrementing it in the provider.
  • Decrypt, and plain EVP use with a caller IV, are unchanged.

Test: test_aes_gcm_iv_gen_multi runs SET_IV_FIXED once, then IV_GEN for 8
messages on one context. It checks that each IV keeps the fixed field, is
unique, and decrypts with OpenSSL. It fails on the current code against v7.

Tested: unit tests against FIPS v7 (only the known ECDSA failures), non-FIPS
wolfSSL master 250/250, FIPS v6.0.0 223/223, FIPS v5.2.1 208/208. TLS 1.2
ECDHE-RSA-AES128-GCM-SHA256 with EMS against OpenSSL 3.5.4, with the provider
as client and as server, completes and exchanges application data.

Copilot AI balanced review requested due to automatic review settings November 20, 2026 21:01
@kaleb-himes kaleb-himes self-assigned this Nov 20, 2026

This comment was marked as resolved.

This comment was marked as resolved.

wolfSSL-Fenrir-bot

This comment was marked as resolved.

This comment was marked as outdated.

wolfSSL-Fenrir-bot

This comment was marked as duplicate.

wolfSSL-Fenrir-bot

This comment was marked as outdated.

@kaleb-himes
kaleb-himes requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot November 20, 2026 22: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 #531

Scan targets checked: none
Unchanged since last review (not re-run): wolfprovider-src, wolfprovider-bugs
Not reviewed (no scan target covers them): ChangeLog.md, test/unit.h

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 20, 2026 22:29

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

Copilot AI 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.

🔵 Needs a closer look

Human assessment is needed because the added tests leave consecutive IV generation and module-generated IV lazy initialization unverified in streaming builds.

No open issues 🎉

Review effort: Balanced

@kaleb-himes
kaleb-himes marked this pull request as ready for review November 20, 2026 22:52
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