Skip to content

API tests: more cipher tests#10226

Merged
dgarske merged 1 commit intowolfSSL:masterfrom
SparkiDev:api_test_cipher_algs_3
Apr 15, 2026
Merged

API tests: more cipher tests#10226
dgarske merged 1 commit intowolfSSL:masterfrom
SparkiDev:api_test_cipher_algs_3

Conversation

@SparkiDev
Copy link
Copy Markdown
Contributor

Description

  1. Unaligned Buffer Tests Verify correct output when input/output buffers are byte-offset by 1, 2, and 3 bytes.
  • AES-CBC, AES-CTS, AES-CTR, AES-GCM, AES-CCM, AES-XTS
  • ChaCha20, ChaCha20-Poly1305
  1. In-Place (Overlapping) Buffer Tests Verify correct output when out == in (same pointer for input and output).
  • AES-CTS, AES-GCM, AES-CCM, AES-XTS
  • ChaCha20, ChaCha20-Poly1305
  1. Cross-Cipher Verification Tests Verify that a higher-level mode produces identical output when manually reconstructed from a lower-level primitive (typically AES-ECB + XOR).
  • AES-CBC (= ECB + XOR chaining)
  • AES-CFB (= ECB(ciphertext feedback) + XOR)
    • AES-OFB (= ECB(output feedback) + XOR)
  • AES-CTR (= ECB(counter) + XOR with big-endian increment)
    • AES-GCM (ciphertext portion = CTR starting at counter J0+1)
  • ChaCha20-Poly1305 (ciphertext = raw ChaCha20 keystream XOR; tag = independent Poly1305)
  1. Counter Overflow Tests Verify correct carry propagation when the internal block counter wraps around.
  • AES-CTR (32-bit big-endian carry across 4 bytes: 0xFFFFFFFE → wrap)
  • ChaCha20 (32-bit counter: 0xFFFFFFFF → 0x00000000)
  1. AEAD Edge Case Tests Verify correct behavior for empty inputs, empty AAD, and invalid auth tag rejection.
  • Ascon-AEAD128
  • AES-CCM
  • ChaCha20-Poly1305
  1. Non-Standard Parameter Tests Verify behavior outside the common fast path.
  • AES-GCM: non-96-bit nonce lengths (1-byte, 60-byte, variable-length loop, zero-length rejection)
  1. Streaming API State Tests Verify mid-stream state behavior and re-initialization after a final call.
  • AES-GCM stream, AES-XTS stream
  • ChaCha20-Poly1305 stream

Testing

./configure --disable-shared --enable-all --enable-experimental --enable-rc2 --enable-aesofb --enable-aescts --enable-ascon

@SparkiDev SparkiDev self-assigned this Apr 15, 2026
@SparkiDev SparkiDev force-pushed the api_test_cipher_algs_3 branch from 3afd5af to ce27509 Compare April 15, 2026 03:43
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

MemBrowse Memory Report

No memory changes detected for:

@SparkiDev SparkiDev force-pushed the api_test_cipher_algs_3 branch 4 times, most recently from 8461d97 to 23f39ed Compare April 15, 2026 06:15
1. Unaligned Buffer Tests
Verify correct output when input/output buffers are byte-offset by 1,
2, and 3 bytes.
  - AES-CBC, AES-CTS, AES-CTR, AES-GCM, AES-CCM, AES-XTS
- ChaCha20, ChaCha20-Poly1305

2. In-Place (Overlapping) Buffer Tests
Verify correct output when out == in (same pointer for input and
output).
  - AES-CTS, AES-GCM, AES-CCM, AES-XTS
- ChaCha20, ChaCha20-Poly1305

3. Cross-Cipher Verification Tests
Verify that a higher-level mode produces identical output when
manually reconstructed from a lower-level primitive (typically AES-ECB +
XOR).
- AES-CBC (= ECB + XOR chaining)
- AES-CFB (= ECB(ciphertext feedback) + XOR)
  - AES-OFB (= ECB(output feedback) + XOR)
- AES-CTR (= ECB(counter) + XOR with big-endian increment)
  - AES-GCM (ciphertext portion = CTR starting at counter J0+1)
- ChaCha20-Poly1305 (ciphertext = raw ChaCha20 keystream XOR; tag =
independent Poly1305)

4. Counter Overflow Tests
Verify correct carry propagation when the internal block counter wraps
around.
  - AES-CTR (32-bit big-endian carry across 4 bytes: 0xFFFFFFFE → wrap)
- ChaCha20 (32-bit counter: 0xFFFFFFFF → 0x00000000)

5. AEAD Edge Case Tests
Verify correct behavior for empty inputs, empty AAD, and invalid auth
tag rejection.
  - Ascon-AEAD128
  - AES-CCM
  - ChaCha20-Poly1305

6. Non-Standard Parameter Tests
  Verify behavior outside the common fast path.
- AES-GCM: non-96-bit nonce lengths (1-byte, 60-byte, variable-length
loop, zero-length rejection)

7. Streaming API State Tests
Verify mid-stream state behavior and re-initialization after a final
call.
  - AES-GCM stream, AES-XTS stream
  - ChaCha20-Poly1305 stream
Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10226

No scan targets match the changed files in this PR. Review skipped.

Copy link
Copy Markdown
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

Why are we putting all these into our unit tests and not in the portable wolfcrypt/test/test.c?

@SparkiDev
Copy link
Copy Markdown
Contributor Author

SparkiDev commented Apr 15, 2026

test.c is made to be run on embedded platforms.
I don't want to fill it up to the point where it is too big to fit.
These are lower importance tests for embedded - except for, maybe, the unaligned test.

@SparkiDev SparkiDev assigned dgarske and unassigned SparkiDev Apr 15, 2026
@dgarske dgarske merged commit faa6e98 into wolfSSL:master Apr 15, 2026
392 of 393 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