Skip to content

Add AES-XTS support - #268

Open
cconlon wants to merge 1 commit into
wolfSSL:masterfrom
cconlon:aesXts
Open

Add AES-XTS support#268
cconlon wants to merge 1 commit into
wolfSSL:masterfrom
cconlon:aesXts

Conversation

@cconlon

@cconlon cconlon commented Aug 27, 2026

Copy link
Copy Markdown
Member

This PR adds AES-XTS (IEEE 1619 / NIST SP 800-38E) at both JNI/JCE layers.

  • New com.wolfssl.wolfcrypt.AesXts class with one-shot, sector-number, and streaming APIs, in byte[] and direct ByteBuffer variants.
  • Cipher.AES/XTS/NoPadding (aliases AES_128/XTS/NoPadding, AES_256/XTS/NoPadding):
    • Key is the two concatenated AES keys (32/64 bytes, 48 on non-FIPS builds), tweak passed as IvParameterSpec.
    • Ciphertext stealing for partial blocks, output length equals input length.
    • update() streams when native streaming is compiled in, otherwise buffers until doFinal().
  • New AesXtsTest and WolfCryptCipherTest cases using vectors from wolfSSL wolfcrypt/test/test.c and IEEE 1619
    Annex B.
  • Expand GitHub workflow --enable-all with --disable-aesxts-stream to cover the non-streaming fallback.
  • Simple example: examples/provider/AesXtsExample

Requires wolfSSL built with --enable-aesxts (enabled by default with --enable-all).

@cconlon cconlon self-assigned this Aug 27, 2026
Copilot AI lite review requested due to automatic review settings August 27, 2026 21:37

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.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds AES-XTS (IEEE 1619 / NIST SP 800-38E) support across the JNI wolfcrypt wrapper and the wolfJCE provider, plus tests, examples, and build/workflow wiring to cover both native streaming and non-streaming fallback behavior.

Changes:

  • Introduces com.wolfssl.wolfcrypt.AesXts JNI wrapper and native JNI implementation (jni_aesxts.c) plus feature-detection hooks.
  • Registers Cipher.AES/XTS/NoPadding (and aliases) in the JCE provider and updates WolfCryptCipher to handle XTS streaming vs buffer-until-doFinal() behavior.
  • Adds extensive JNI and JCE test coverage and an example, plus build/project/workflow updates to compile and exercise AES-XTS.

Reviewed changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/test/java/com/wolfssl/wolfcrypt/test/WolfCryptTestSuite.java Adds AesXtsTest to the overall wolfcrypt JNI test suite.
src/test/java/com/wolfssl/wolfcrypt/test/AesXtsTest.java Adds comprehensive JNI wrapper tests for one-shot, sector, and streaming APIs.
src/test/java/com/wolfssl/provider/jce/test/WolfCryptCipherTest.java Adds JCE-level AES-XTS tests (vectors, streaming/off fallback, ByteBuffer, interop) and an additional CBC update/output-size regression test.
src/main/java/com/wolfssl/wolfcrypt/FeatureDetect.java Adds native feature-detect methods for AES-XTS and AES-XTS streaming.
src/main/java/com/wolfssl/wolfcrypt/AesXts.java New Java JNI wrapper for AES-XTS with one-shot, sector, and streaming APIs.
src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java Registers AES/XTS/NoPadding and aliases when AES-XTS is available.
src/main/java/com/wolfssl/provider/jce/WolfCryptCipher.java Implements XTS mode support including output sizing, buffering/streaming decisions, and reset behavior.
spotbugs-exclude.xml Excludes SpotBugs CT_CONSTRUCTOR_THROW for AesXts (constructor can throw if not compiled in).
scripts/infer.sh Adds AesXts.java to Infer static analysis compilation list.
makefile.macosx Adds jni_aesxts.o to macOS build object list.
makefile.linux Adds jni_aesxts.o to Linux build object list.
jni/jni_feature_detect.c Implements JNI feature-detect for AesXtsEnabled and AesXtsStreamEnabled.
jni/jni_aesxts.c New JNI bridge implementing AES-XTS one-shot, sector, and streaming operations.
examples/provider/AesXtsExample.sh Adds a runnable shell script for the AES-XTS provider example.
examples/provider/AesXtsExample.java Adds a wolfJCE AES-XTS example demonstrating sector tweaks and partial-block data units.
README_JCE.md Documents AES/XTS/NoPadding and aliases as supported algorithms.
IDE/WIN/wolfcryptjni.vcxproj.filters Adds jni_aesxts.c to the Windows filters file.
IDE/WIN/wolfcryptjni.vcxproj Adds jni_aesxts.c and generated header to the Windows project.
IDE/Android/app/src/main/cpp/CMakeLists.txt Adds jni_aesxts.c to Android build inputs.
.github/workflows/main.yml Adds a CI permutation to run --disable-aesxts-stream for the non-streaming fallback path.
Files not reviewed (2)
  • jni/include/com_wolfssl_wolfcrypt_AesXts.h: Generated file
  • jni/include/com_wolfssl_wolfcrypt_FeatureDetect.h: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main/java/com/wolfssl/provider/jce/WolfCryptCipher.java Outdated
Comment thread src/main/java/com/wolfssl/provider/jce/WolfCryptCipher.java Outdated
Comment thread src/main/java/com/wolfssl/provider/jce/WolfCryptCipher.java Outdated
Comment thread src/test/java/com/wolfssl/wolfcrypt/test/AesXtsTest.java Outdated
@cconlon
cconlon force-pushed the aesXts branch 2 times, most recently from 616ed98 to 07b3add Compare August 27, 2026 23:42
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.

2 participants