Skip to content

wp_aes_block: strip the explicit IV only for TLS 1.1+ and DTLS - #500

Merged
ColtonWilley merged 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/f-14604
Oct 8, 2026
Merged

ColtonWilley merged 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/f-14604

Conversation

@yosuke-wolfssl

@yosuke-wolfssl yosuke-wolfssl commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

wp_aes_block_tls_dec_record() always removed a 16-byte explicit IV from a decrypted AES-CBC TLS record, whatever the TLS version. TLS 1.0 records have no explicit IV; their first block is payload, and OpenSSL's record layer does not skip it. The length handed back was 16 bytes short, so any TLS 1.0 + AES-CBC connection where wolfProvider decrypts fails during the handshake:

  • Encrypt-then-MAC (OpenSSL's default): the Finished record comes back short and the handshake fails.
  • MAC-then-Encrypt: every record fails with bad_record_mac.

Reaching this takes TLS 1.0 enabled (MinProtocol=TLSv1, @SECLEVEL=0) with wolfProvider supplying AES-CBC.

Fix (src/wp_aes_block.c)

The explicit IV length now comes from tls_version, as in OpenSSL's ossl_cipher_tlsunpadblock():

tls_version IV length
TLS1_1_VERSION, TLS1_2_VERSION, DTLS1_VERSION, DTLS1_2_VERSION, DTLS1_BAD_VER AES_BLOCK_SIZE
TLS1_VERSION 0
anything else decrypt fails

The minimum record length check and both the ETM and MtE paths use that length. Closes f-14604.

Tests (test/test_tls_cbc.c)

  • The record helpers take the TLS version and build the record with or without an explicit IV.
  • test_tls10_cbc: AES128-SHA records, MtE and ETM, decrypted across OpenSSL and wolfProvider in both directions. Without the fix it fails with got 22, expected 38.
  • test_dtls12_cbc: the same records at DTLS1_2_VERSION. It guards the new version list: dropping the DTLS1_2_VERSION case makes it fail.

CI (.github/workflows/qt5network5.yml)

The QSslSocket check expects an exact pass count. With this fix, tst_QSslSocket::pskServer(WithoutProxy) passes on non-FIPS: it runs TLS 1.0 with PSK-AES256-CBC-SHA, and the handshake used to fail. That is the only test that changed result. Non-FIPS now expects 522 passed (was 521); FIPS stays at 521. The check matches the Totals: line.

Verification

  • Unit suite: 237 passed on OpenSSL 3.0.7 and 3.6.5.
  • End to end, s_server with wolfProvider against stock s_client on TLS 1.0 / AES128-SHA: the handshake failed before the fix (ETM and -no_etm) and exchanges data after it.
  • ASan + UBSan clean on the TLS CBC tests.

@yosuke-wolfssl yosuke-wolfssl self-assigned this Oct 5, 2026
Copilot AI balanced review requested due to automatic review settings October 5, 2026 06:10

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.

Copilot review overview

🟢 Approval recommended

The implementation consistently applies the version-specific record layout and includes coverage for both affected paths.

Review effort: Balanced
Findings: None

What changed in this PR

Corrects AES-CBC record post-processing across TLS/DTLS versions.

Changes:

  • Preserves TLS 1.0 payloads by not stripping an explicit IV.
  • Handles explicit IVs for TLS 1.1+ and DTLS.
  • Adds TLS 1.0 and DTLS 1.2 interoperability tests.
File Description
src/​wp_aes_block.c Applies version-specific explicit-IV handling.
test/​test_tls_cbc.c Adds version-aware record tests.
test/​unit.c Registers the new tests.
test/​unit.h Declares the new tests.

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

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot 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.

Fenrir Automated Review — PR #500

Scan targets checked: wolfprovider-src, wolfprovider-bugs
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: test/unit.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@yosuke-wolfssl yosuke-wolfssl added the ci:all PR OSP toggle: run all label Oct 7, 2026
- wp_aes_block_tls_dec_record() takes the explicit IV length from
  tls_version: AES_BLOCK_SIZE for TLS 1.1, TLS 1.2 and DTLS, none
  for TLS 1.0. Any other version fails.
- The minimum record length check and both the ETM and MtE paths
  use that IV length in place of AES_BLOCK_SIZE.
- test_tls_cbc.c helpers take the TLS version and lay out the
  record with or without an explicit IV. The MAC check is skipped
  when there is no MAC.
- test_tls_cbc_ver() runs a table of records through OpenSSL alone
  or across OpenSSL and wolfProvider; test_tls12_cbc and
  test_tls12_cbc_ossl use it.
- Add test_tls10_cbc and test_dtls12_cbc: AES128-SHA records with
  MtE and with ETM at TLS1_VERSION and DTLS1_2_VERSION, across
  OpenSSL and wolfProvider.
- qt5network5 expects 521 passed QSslSocket tests for FIPS and 522
  for non-FIPS, where tst_QSslSocket::pskServer(WithoutProxy) now
  passes. The check matches the Totals: line of the test log.

Issue: F-14604
@yosuke-wolfssl yosuke-wolfssl added ci:all PR OSP toggle: run all and removed ci:all PR OSP toggle: run all labels Oct 7, 2026
@yosuke-wolfssl

Copy link
Copy Markdown
Contributor Author

Jenkins retest this please

1 similar comment
@yosuke-wolfssl

Copy link
Copy Markdown
Contributor Author

Jenkins retest this please

@ColtonWilley
ColtonWilley merged commit 6862338 into wolfSSL:master Oct 8, 2026
2490 of 2492 checks passed
@yosuke-wolfssl
yosuke-wolfssl deleted the fix/f-14604 branch October 8, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:all PR OSP toggle: run all

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants