Skip to content

Add AES-XTS (AES-128-XTS, AES-256-XTS) - #510

Open
ColtonWilley wants to merge 2 commits into
wolfSSL:masterfrom
ColtonWilley:aes-xts
Open

ColtonWilley wants to merge 2 commits into
wolfSSL:masterfrom
ColtonWilley:aes-xts

Conversation

@ColtonWilley

Copy link
Copy Markdown
Contributor

Adds AES-XTS matching the OpenSSL default provider, built when wolfSSL 5.6.6+ has AES-XTS and the build is non-FIPS or FIPS v6+. One difference: wolfCrypt rejects equal key halves on decrypt (FIPS, and by default from 5.9.2), where OpenSSL accepts them. Covered by new unit tests and the IEEE 1619 evp_test vectors, and verified end to end with cryptsetup LUKS2 aes-xts-plain64.

Each update is one data unit through wolfCrypt's one-shot
wc_AesXtsEncrypt/Decrypt, matching the OpenSSL default provider.
Registered when wolfSSL 5.6.6+ is built with AES-XTS and the build is
non-FIPS or FIPS v6+; the FIPS v5 module has no XTS.

Equal key halves are rejected on encrypt, as in OpenSSL. On decrypt,
wolfCrypt decides: it rejects them under FIPS and, by default, from
wolfSSL 5.9.2, where OpenSSL's default provider accepts them.

A failed wolfCrypt set-key leaves the context without a key, since the
data key may already have been replaced. Context copy is refused when
wolfSSL's Aes owns resources (WC_AESFREE_IS_MANDATORY).
Known answers and byte-exact cross-checks against the default provider,
including ciphertext-stealing lengths; data-unit limits; equal key
halves; key-only, IV-only and per-unit IV re-init; live re-keys in both
directions; context copy; and params. The IEEE 1619 evp_test vectors
move to their own file, run only when wolfProvider offers AES-XTS.
Copilot AI balanced review requested due to automatic review settings October 7, 2026 19:27

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

Repeated updates reuse the initial XTS tweak instead of rejecting unsupported streaming.

1 open finding
What changed in this PR

Adds AES-128-XTS and AES-256-XTS support backed by wolfCrypt.

Changes:

  • Implements and registers AES-XTS with version/FIPS gating.
  • Adds unit and IEEE 1619 vector tests.
  • Updates build files and documentation.
File Description
src/​wp_aes_xts.c Implements AES-XTS provider operations.
src/​wp_wolfprov.c Registers AES-XTS ciphers.
src/​include.am Adds the implementation to builds.
include/​wolfprovider/​settings.h Gates AES-XTS availability.
include/​wolfprovider/​alg_funcs.h Declares names and dispatch tables.
IDE/​WINVS/​wolfprovider/​wolfprovider.vcxproj Adds Visual Studio compilation support.
test/​test_cipher.c Adds functional and compatibility tests.
test/​unit.c Registers new unit tests.
test/​unit.h Declares new unit tests.
scripts/​test-openssl.sh Conditionally runs XTS vectors.
scripts/​evp_test/​evpciph_aes_xts.txt Adds IEEE 1619 vectors.
README.md Documents AES-XTS support.
docs/​INTEGRATION_GUIDE.md Documents the wolfSSL build flag.

🧠 Review effort: Balanced


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

Comment thread src/wp_aes_xts.c
Comment on lines +463 to +466
if (ok) {
if (ctx->enc) {
rc = wc_AesXtsEncrypt(&ctx->xts, out, in, (word32)inLen, ctx->iv,
AES_BLOCK_SIZE);
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