wolfSSL's Curve25519 scalar-multiply blinding (enabled by default) requires an RNG to be attached to the private-key struct via wc_curve25519_set_rng() before each scalar multiply. wc_curve25519_shared_secret_ex does not accept an RNG parameter inline.
This forces every DH operation to initialize a throwaway RNG, set it on the key, perform the multiply, and free the RNG — four extra steps per call, one of which (wc_InitRng) may touch the entropy source.
Current code required for every DH call:
WC_RNG rng;
wc_InitRng(&rng);
wc_curve25519_set_rng(&private_key, &rng);
wc_curve25519_shared_secret_ex(&private_key, &public_key, out, &outlen, EC25519_LITTLE_ENDIAN);
wc_FreeRng(&rng);
For high-throughput servers or entropy-constrained platforms (HSMs, TPMs, embedded), this is unnecessary overhead. Callers already have an RNG instance they would naturally reuse.
Requested fix: Accept an optional WC_RNG* parameter in wc_curve25519_shared_secret_ex so callers can pass an existing RNG rather than constructing a temporary one per operation. A NULL parameter could fall back to the current behavior for backward compatibility.
Migrated from internal tracking (ZD-21738).
wolfSSL's Curve25519 scalar-multiply blinding (enabled by default) requires an RNG to be attached to the private-key struct via
wc_curve25519_set_rng()before each scalar multiply.wc_curve25519_shared_secret_exdoes not accept an RNG parameter inline.This forces every DH operation to initialize a throwaway RNG, set it on the key, perform the multiply, and free the RNG — four extra steps per call, one of which (
wc_InitRng) may touch the entropy source.Current code required for every DH call:
For high-throughput servers or entropy-constrained platforms (HSMs, TPMs, embedded), this is unnecessary overhead. Callers already have an RNG instance they would naturally reuse.
Requested fix: Accept an optional
WC_RNG*parameter inwc_curve25519_shared_secret_exso callers can pass an existing RNG rather than constructing a temporary one per operation. ANULLparameter could fall back to the current behavior for backward compatibility.Migrated from internal tracking (ZD-21738).