Skip to content

Reject AES-GCM/GMAC IVs under 96 bits on FIPS modules that mark them not approved - #293

Merged
rlm2002 merged 1 commit into
wolfSSL:masterfrom
cconlon:gcmShortIvFips
Oct 14, 2026
Merged

rlm2002 merged 1 commit into
wolfSSL:masterfrom
cconlon:gcmShortIvFips

Conversation

@cconlon

@cconlon cconlon commented Oct 7, 2026

Copy link
Copy Markdown
Member

This PR handles the FIPS 140-3 approved-service indicator (WC_FIPS_NOT_APPROVED, 1) that wolfCrypt FIPS v5.2.4 and v7+ return for AES-GCM/GMAC with IVs under 96 bits. Previously this was thrown at doFinal() as an unchecked WolfCryptException with an unmapped error code.

  • Add AesGcm.shortIvAllowed() and AesGcm.GCM_NONCE_MID_SZ.
  • wolfJCE AES-GCM Cipher and AES-GMAC Mac throw InvalidAlgorithmParameterException at init() for IVs under 96 bits on those modules.
  • Add WolfCryptError.WC_FIPS_NOT_APPROVED
  • Tests: testAesGcmShortIv, testAesGmacShortIv, testFipsNotApprovedError.

Fixes OpenJDK GCMParameterSpecTest and TestKATForGCM short-IV failures on wolfCrypt FIPS Ready (v7).

@cconlon cconlon self-assigned this Oct 7, 2026
@cconlon
cconlon requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot October 7, 2026 22:03

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

Scan targets checked: wolfcrypt-jni-src, wolfcrypt-jni-bugs
Coverage: 4 of 9 in-scope changed file(s) opened by the reviewer; not opened: jni/include/com_wolfssl_wolfcrypt_AesGcm.h, src/main/java/com/wolfssl/wolfcrypt/AesGcm.java, src/test/java/com/wolfssl/provider/jce/test/WolfCryptCipherTest.java, src/test/java/com/wolfssl/provider/jce/test/WolfCryptMacTest.java, src/test/java/com/wolfssl/wolfcrypt/test/WolfCryptTest.java

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

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.

🟡 Changes recommended

The allowed AES-GMAC test path does not execute the MAC operation where the original failure occurred.

3 open findings
What changed in this PR

Adds FIPS-aware short-IV validation for AES-GCM and AES-GMAC.

Changes:

  • Detects FIPS modules where short IVs are not approved.
  • Rejects affected IVs during JCE initialization.
  • Maps WC_FIPS_NOT_APPROVED and adds regression tests.
File Description
jni/​jni_aesgcm.c Implements native FIPS-version detection.
jni/​include/​com_wolfssl_wolfcrypt_AesGcm.h Declares the new JNI capability method.
src/​main/​java/​com/​wolfssl/​wolfcrypt/​AesGcm.java Exposes nonce size and short-IV capability.
src/​main/​java/​com/​wolfssl/​wolfcrypt/​WolfCryptError.java Maps the FIPS indicator error.
src/​main/​java/​com/​wolfssl/​provider/​jce/​WolfCryptCipher.java Rejects unapproved AES-GCM IVs at initialization.
src/​main/​java/​com/​wolfssl/​provider/​jce/​WolfCryptMac.java Rejects unapproved AES-GMAC IVs at initialization.
src/​test/​java/​com/​wolfssl/​wolfcrypt/​test/​WolfCryptTest.java Tests error mapping.
src/​test/​java/​com/​wolfssl/​provider/​jce/​test/​WolfCryptCipherTest.java Tests AES-GCM short-IV behavior.
src/​test/​java/​com/​wolfssl/​provider/​jce/​test/​WolfCryptMacTest.java Tests AES-GMAC short-IV behavior.
Files not reviewed (1)
  • jni/include/com_wolfssl_wolfcrypt_AesGcm.h: Generated file

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread src/test/java/com/wolfssl/provider/jce/test/WolfCryptMacTest.java
Comment thread jni/jni_aesgcm.c
Comment thread src/test/java/com/wolfssl/provider/jce/test/WolfCryptCipherTest.java Outdated
…les that mark them not approved, map WC_FIPS_NOT_APPROVED
@cconlon cconlon assigned rlm2002 and unassigned cconlon Oct 7, 2026
@rlm2002
rlm2002 merged commit 056ef7f into wolfSSL:master Oct 14, 2026
189 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.

4 participants