Skip to content

Add AES/GCM-SIV/NoPadding cipher support (RFC 8452)#533

Open
jmcrawford45 wants to merge 4 commits intocorretto:mainfrom
jmcrawford45:jcrawford/issue-323-aes-gcm-siv
Open

Add AES/GCM-SIV/NoPadding cipher support (RFC 8452)#533
jmcrawford45 wants to merge 4 commits intocorretto:mainfrom
jmcrawford45:jcrawford/issue-323-aes-gcm-siv

Conversation

@jmcrawford45
Copy link
Copy Markdown

Issue #, if available: #323

Description of changes:

Implements AES-GCM-SIV (AES/GCM-SIV/NoPadding, AES_128/GCM-SIV/NoPadding, AES_256/GCM-SIV/NoPadding) backed by the AWS-LC EVP_AEAD API (EVP_aead_aes_128_gcm_siv / EVP_aead_aes_256_gcm_siv).

AES-GCM-SIV is a nonce-misuse-resistant AEAD cipher defined in
[RFC 8452](https://www.rfc-editor.org/rfc/rfc8452). Unlike AES-GCM, reusing a key+nonce pair does not compromise authenticity, only (some) confidentiality.


New files

  • csrc/aes_gcm_siv.cpp
    JNI implementation using EVP_AEAD_CTX_seal / EVP_AEAD_CTX_open. Context caching
    avoids redundant key schedule computation across calls with the same key.

  • src/.../AesGcmSivSpi.java
    CipherSpi implementation. Supports one-shot (doFinal) and streaming
    (update + doFinal) modes, heap and direct ByteBuffer, and AAD via updateAAD.

  • src/.../NativeEvpAeadCtx.java
    NativeResource wrapper for safe GC cleanup of native EVP_AEAD_CTX pointers.

  • benchmarks/.../AesGcmSivOneShot.java
    JMH benchmark for 1 MiB encrypt and decrypt with 128-bit and 256-bit keys.


Modified files

  • AmazonCorrettoCryptoProvider.java
    Registers the three algorithm aliases.

  • Utils.java / csrc/util.cpp
    Adds releaseEvpAeadCtx JNI teardown.

  • CMakeLists.txt
    Adds aes_gcm_siv.cpp to the native source list.

  • tst/.../AesGcmSivTest.java
    Full test suite:

    • All 28 RFC 8452 Appendix C KAT vectors (encrypt + decrypt)
    • Behavioral tests (ByteBuffer heap/direct, getOutputSize, 1 MiB round-trip, rekey,
      nonce-reuse tolerance, AAD ordering, tag authentication, algorithm name variants,
      16-thread concurrency)
  • README.md / DIFFERENCES.md
    Documents the new algorithm and its behavioral differences from AES/GCM/NoPadding
    (no IvParameterSpec, fixed 12-byte nonce, 128-bit tag only, 128/256-bit keys only,
    nonce reuse does not throw).


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute
this contribution, under the terms of your choice.

jmcrawford45 and others added 4 commits April 15, 2026 17:12
Implements GitHub issue corretto#323. Registers three algorithm names:
  - AES/GCM-SIV/NoPadding
  - AES_128/GCM-SIV/NoPadding
  - AES_256/GCM-SIV/NoPadding

New files:
  - csrc/aes_gcm_siv.cpp: JNI implementation using EVP_AEAD_CTX_seal/open
  - src/.../AesGcmSivSpi.java: CipherSpi — one-shot AEAD, 12-byte nonce,
    128-bit tag, 128/256-bit keys only; nonce reuse does not throw
  - src/.../NativeEvpAeadCtx.java: NativeResource wrapper for EVP_AEAD_CTX

Modified files:
  - csrc/util.cpp: add releaseEvpAeadCtx JNI function
  - src/.../Utils.java: declare releaseEvpAeadCtx native method
  - src/.../AmazonCorrettoCryptoProvider.java: register the three aliases
  - CMakeLists.txt: add csrc/aes_gcm_siv.cpp to the build

Tests: 40 cases covering RFC 8452 Appendix C KAT vectors, round-trips,
streaming buffering, auth failure (AEADBadTagException), parameter
validation, nonce-reuse tolerance, and algorithm name variants.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add AES/GCM-SIV/NoPadding and AES_<n>/GCM-SIV/NoPadding to README
  supported algorithms list
- Document GCM-SIV behavioral differences in DIFFERENCES.md: rejects
  IvParameterSpec, enforces fixed nonce/tag length, tolerates nonce reuse
- Add AesGcmSivOneShot JMH benchmark (128/256-bit, 1 MiB, encrypt+decrypt)
- Expand AesGcmSivTest with 8 behavioral tests: ByteBuffer (heap+direct),
  getOutputSize (encrypt+decrypt), large 1 MiB round-trip, rekey changes
  output, AAD-after-update throws IllegalStateException, concurrent 16-thread
  encrypt/decrypt correctness

Closes corretto#323

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirrors AesGcmOneShot structure: extends AesBase, uses provider @param
with ACCP and BouncyCastle (both support AES/GCM-SIV/NoPadding). SunJCE
is excluded because JDK-8256530 (add GCM-SIV to SunJCE) is still open.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jmcrawford45 jmcrawford45 requested a review from a team as a code owner April 15, 2026 22:12
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.

1 participant