← ALL ADVISORIES

LOW BYTERAY-2026-0543Disclosed

wolfSSL — Missing Scalar Blinding in Small-Build X25519 Scalar Multiplication

wolfSSL enables X25519 scalar blinding only for the default non-small C build. The small implementation rejects blinding at compile time, and the shipped ESP-IDF template selects that implementation, so X25519 on such builds runs an unblinded Montgomery ladder on the private scalar.

Advisory
BYTERAY-2026-0543
CWE
CWE-1300
CVSS
2.0 (CVSS:3.1/AV:P/AC:H/PR:N/UI:N/S:U/C:L/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 with HAVE_CURVE25519 and CURVE25519_SMALL, as in the shipped ESP-IDF template
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL can blind the X25519 private scalar, re-randomizing it on every operation, as a defence against power and electromagnetic analysis. The option is WOLFSSL_CURVE25519_BLINDING. It is switched on automatically only for the default, non-small C implementation.

The size-optimized implementation, selected with CURVE25519_SMALL, does not support blinding and stops the build with #error if it is requested. The ESP-IDF template shipped in the repository defines CURVE25519_SMALL. On those builds every X25519 key generation and shared-secret computation runs the plain ladder on the private scalar.

X25519 is the default TLS 1.3 key-exchange group, so a remote peer can trigger the operation at will. An attacker with a probe near the device can record traces and attempt to recover the scalar. The small-build ladder is constant-time in structure and TLS scalars are ephemeral, so this requires demanding single-trace analysis. The default non-small C build is not affected.

Affected Products and Versions

  • Component: wolfcrypt/src/curve25519.c, wc_curve25519_generic() and curve25519_key_make_pub().
  • Required build: HAVE_CURVE25519 with CURVE25519_SMALL. The shipped ESP-IDF template defines both (IDE/Espressif/ESP-IDF/user_settings.h:98-99). The blinding default is also given up with WOLFSSL_ARMASM, USE_INTEL_SPEEDUP or WC_NO_RNG (wolfssl/wolfcrypt/settings.h:4792-4798).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The default C, non-small build defines WOLFSSL_CURVE25519_BLINDING and uses the blinded path.
  • Other releases were not checked.

Technical Details

The default is set in wolfssl/wolfcrypt/settings.h:4792-4798: blinding is defined only when CURVE25519_SMALL, WOLFSSL_ARMASM, USE_INTEL_SPEEDUP and WC_NO_RNG are all absent. The small implementation refuses it (wolfcrypt/src/curve25519.c:64-66):

#if defined(WOLFSSL_CURVE25519_BLINDING)
    #if defined(CURVE25519_SMALL)
        #error "Blinding not needed nor available for small implementation"

Without the macro, wc_curve25519_generic() compiles the #elif !defined(WOLFSSL_CURVE25519_BLINDING) branch and calls curve25519(pub, priv, basepoint) directly (wolfcrypt/src/curve25519.c:546-555). curve25519_key_make_pub() selects the unblinded variant in the same way (wolfcrypt/src/curve25519.c:492-499). The TLS call sites skip the RNG setup that blinding would use (src/internal.c:6892-6899, src/tls.c:9861-9865).

The small-build ladder (wolfcrypt/src/fe_low_mem.c:143-185) is constant-time in structure. The secret bit (wolfcrypt/src/fe_low_mem.c:159) drives only the mask-based fe_select (wolfcrypt/src/fe_low_mem.c:598-607). Addresses, control flow and iteration count do not depend on the scalar. What is missing is per-call randomization of the scalar.

  1. A TLS 1.3 peer sends an x25519 key share.
  2. The key-share handling (src/tls.c:9861, src/internal.c:6892) calls wc_curve25519_shared_secret_ex, which calls wc_curve25519_generic() with the device's private scalar.
  3. With CURVE25519_SMALL, the unblinded branch runs curve25519(pub, priv, basepoint) (wolfcrypt/src/curve25519.c:551).
  4. The arithmetic of the ladder is correlated with the scalar bits in the device's power and electromagnetic emissions.

Reachability and Preconditions

  • Build with CURVE25519_SMALL, for example from the shipped ESP-IDF template.
  • The device performs X25519 key agreement. A remote TLS 1.3 peer can start handshakes without authentication and chooses the base point.
  • The attacker has physical or near-field access to measure power or electromagnetic emissions.
  • TLS session scalars are ephemeral, which rules out averaging traces of one key across handshakes. A long-lived X25519 key would make averaging possible.

Impact

Recovery of an X25519 private scalar by physical side-channel analysis. For a TLS handshake this compromises that session's keys. For a long-lived identity key it allows impersonation. The constant-time ladder and ephemeral scalars raise the bar to research-grade single-trace analysis with high-end equipment.

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 longer-term fix direction is per-call scalar randomization for the small implementation, replacing the #error with a blinded ladder path, so the countermeasure exists in size-optimized configurations.

Workaround: build physically exposed devices with the default non-small C implementation, so that WOLFSSL_CURVE25519_BLINDING is enabled, and keep an RNG available. That means not defining CURVE25519_SMALL in the ESP-IDF template, at a cost in code size. Avoid long-lived X25519 keys on small or assembly builds.

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