Skip to content

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Nov 13, 2025

This PR adds AES-CTS support for one block (16-byte) input, and fixes buffering behavior.

  • Support exactly 16-byte inputs per RFC 3962/8009 (reduces to plain CBC)
  • Change CTS to buffer all data until doFinal() instead of streaming
    • CTS requires the entire message for ciphertext stealing
    • Groups CTS with GCM/CCM as non-streaming modes
  • Add tests for 16-byte edge case (byte array and ByteBuffer)
  • Update existing tests to reflect correct buffering behavior

This fixes SunJCE KerberosAesSha2 test failures when using AES-CTS encryption with exactly one block of input.

@cconlon cconlon self-assigned this Nov 13, 2025
@cconlon cconlon requested a review from Copilot November 13, 2025 21:35
Copilot finished reviewing on behalf of cconlon November 13, 2025 21:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds AES-CTS support for exactly 16-byte (single block) inputs and corrects the buffering behavior to ensure CTS processes the entire message at finalization rather than streaming incrementally.

  • Updates minimum input length requirement from > 16 bytes to >= 16 bytes per RFC 3962/8009
  • Changes CTS buffering to match GCM/CCM: buffer all data until doFinal() call
  • Implements single-block edge case in JNI using plain CBC encryption/decryption
  • Adds comprehensive test coverage for 16-byte inputs using both byte arrays and ByteBuffers

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/java/com/wolfssl/wolfcrypt/AesCts.java Updated validation logic from <= BLOCK_SIZE to < BLOCK_SIZE and revised documentation to reflect that CTS now accepts exactly 16 bytes
src/main/java/com/wolfssl/provider/jce/WolfCryptCipher.java Added CTS to non-streaming modes (with GCM/CCM) in isNoOpUpdate(), removed CTS from streaming cipher list, updated minimum length validation, and added explanatory comments
src/test/java/com/wolfssl/wolfcrypt/test/AesCtsTest.java Updated test to verify 15-byte rejection and 16-byte acceptance, replaced hard-coded values with Aes.BLOCK_SIZE constant
src/test/java/com/wolfssl/provider/jce/test/WolfCryptCipherTest.java Added 16 to test data sizes, updated minimum length test to verify 15-byte rejection and 16-byte acceptance, added two new comprehensive tests for single-block edge case (byte array and ByteBuffer paths)
jni/jni_aescts.c Updated validation from <= AES_BLOCK_SIZE to < AES_BLOCK_SIZE, added special case handling for exactly 16 bytes using plain CBC (applies to both byte array and ByteBuffer JNI methods)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cconlon cconlon assigned rlm2002 and unassigned cconlon Nov 13, 2025
@rlm2002 rlm2002 merged commit 194f675 into wolfSSL:master Nov 14, 2025
52 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.

2 participants