← ALL ADVISORIES

MEDIUM BYTERAY-2026-0405Disclosed

wolfSSL — Key-Dependent S-Box Table Lookups in Software DES and 3DES

The software DES/3DES core in wolfCrypt indexes its eight S-box tables with values that mix block data and round-key bits, and has no side-channel countermeasure. An attacker with power or electromagnetic measurement access can attempt to recover the key from traces of many encryptions.

Advisory
BYTERAY-2026-0405
CWE
CWE-1300
CVSS
4.2 (CVSS:3.1/AV:P/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), builds that compile the software DES/3DES core (NO_DES3 not defined)
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

The software DES and 3DES implementation in wolfcrypt/src/des3.c processes each block through eight fixed S-box tables. The index of every lookup is built from the block data XORed with bits of the secret round key, so the memory locations read during encryption depend on the key.

DesRawProcessBlock(), which performs the lookups, has no countermeasure. The AES code offers an option that touches all table lines; des3.c has nothing equivalent, and no masked or bitsliced variant.

On a microcontroller these accesses show in power draw and electromagnetic emissions. An attacker who can probe the device while it encrypts or decrypts chosen data can average many traces and attempt to recover the DES or 3DES key, then decrypt captured traffic. The shipped ESP-IDF template does not define NO_DES3, so it compiles this code. The barrier is physical measurement access and trace volume.

Affected Products and Versions

  • Component: wolfcrypt/src/des3.c, DesRawProcessBlock(), used by wc_Des_Cbc* and wc_Des3_Cbc*.
  • Required build: the software DES/3DES core compiled in, that is, NO_DES3 not defined. The shipped ESP-IDF template (IDE/Espressif/ESP-IDF/user_settings.h) has no NO_DES3 define.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A build that compiles 3DES adds the 3DES-EDE-CBC suites it defines to the TLS suite list in InitSuites (src/internal.c:4467-4478), with no further application configuration.
  • Other releases were not checked.

Technical Details

DesRawProcessBlock() (wolfcrypt/src/des3.c:1738) runs the 16 DES rounds. Each half-round mixes the round key into a working word and uses 6-bit slices of it as table indices (wolfcrypt/src/des3.c:1744-1748):

            word32 work = rotrFixed(r, 4U) ^ kptr[4*i+0];
            l ^= Spbox[6][(work) & 0x3f]
              ^  Spbox[4][(work >> 8) & 0x3f]
              ^  Spbox[2][(work >> 16) & 0x3f]
              ^  Spbox[0][(work >> 24) & 0x3f];

The same pattern repeats with kptr[4*i+1], kptr[4*i+2] and kptr[4*i+3] (wolfcrypt/src/des3.c:1749, wolfcrypt/src/des3.c:1755, wolfcrypt/src/des3.c:1760), for lookups through wolfcrypt/src/des3.c:1745-1764. The table is static const FLASH_QUALIFIER word32 Spbox[8][64] (wolfcrypt/src/des3.c:1428).

  1. DesSetKey derives the key schedule from the secret key (wolfcrypt/src/des3.c:1699-1736).
  2. DesProcessBlock passes des->key (wolfcrypt/src/des3.c:1782); Des3ProcessBlock passes des->key[0], des->key[1] and des->key[2] (wolfcrypt/src/des3.c:1805-1807).
  3. DesRawProcessBlock() XORs the round key into work and indexes Spbox with the result.
  4. The table lines read are a function of key bits and data, and show in the power and electromagnetic domain.

Nothing in des3.c alters this: no touch-all-lines mode like WOLFSSL_AES_TOUCH_LINES, no masking, no randomization.

Reachability and Preconditions

  • Build with the software DES/3DES core.
  • The device performs DES-CBC or 3DES-EDE-CBC operations. A TLS peer can negotiate a 3DES-EDE-CBC suite where the build offers one and then send chosen records; an application can also call wc_Des3_CbcEncrypt or wc_Des3_CbcDecrypt directly. The TLS path needs no client authentication.
  • The attacker has physical or near-field access to measure power or electromagnetic emissions, synchronized to the encryption.
  • Many operations under the same key are recorded for averaging.

Impact

Recovery of the DES or 3DES key in use, for a TLS session the session key, which allows decryption of captured traffic for that session. This is a confidentiality loss. First-round S-box analysis under chosen plaintext is a well established power analysis target, but it needs sustained physical access and thousands of traces.

ByteRay did not build a proof of concept for this issue. The analysis is from source review.

Remediation and Mitigation

ByteRay has not confirmed a fixed wolfSSL release for this issue as of 2026-12-03, and has not checked it against wolfSSL changes made after the tested commit.

The fix direction is a software core whose memory accesses do not depend on secret bits: a variant that touches all 64 entries of each S-box per lookup, or a masked or bitsliced DES. The cheaper and more complete change is to stop using the cipher: define NO_DES3 in the shipped templates and remove the 3DES-EDE-CBC suites from the default suite list. 3DES is deprecated in any case.

Workaround: define NO_DES3, or exclude 3DES suites from the cipher list. Where legacy interoperability requires 3DES, restrict it to a hardware DES accelerator where the platform has one, and keep keys per session.

Timeline

  • 2026-09-28 — Reported to wolfSSL.
  • 2026-12-03 — Public disclosure.

Credits

Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.

References