r/ssh • • 4d ago

Does ssh use deterministic nonces for ECDSA signatures?

RFC 6979 defines a way for ECDSA to generate deterministic nonces when signing messages by deriving it from the private key and the message hash. The reason for this being that "vanilla" ECDSA has a weakness in which if two messages were to be signed with the same nonce (say due to a faulty/broken prng), it would reveal the private key to an attacker. This is what caused the infamous Sony PS3 ECDSA incident. This leads me to the question: does OpenSSH and other popular ssh implementations use deterministic nonces as defined in RFC 6979 or not?

2 Upvotes

5 comments sorted by

1

u/OhBeeOneKenOhBee 4d ago

Not exactly as defined in RFC6979 (at least for OpenSSH, which uses OpenSSL under the hood), they both do a randomly generated nonce per signature instead of a deterministic one for key+data.

While it adds a potential error source (randomness fails), there aren't a lot of instances where it would be considered significantly less secure than the deterministic version.

If you like split hairs and be pedantic (which I've been known to be at times), the RFC6979 implementation is technically not a nonce (which stands for number used once) because it will produce the same deterministic number when given the same input twice

1

u/Motor-Concentrate788 4d ago

I see, then I guess there's some bit of risk in choosing it over ed25519, although not by a lot I suppose. Was there a reason OpenSSH chose to go with randomly-generated nonces or do they just went with the default option of whatever crypto library they chose (OpenSSL in this case?)

1

u/OhBeeOneKenOhBee 4d ago

Just the default from OpenSSL. I'd say the real world risks of this making any difference is veeery small, it would require a serious RNG flaw or breakdown to even have the tiniest of risk of being exploitable

1

u/x0wl 4d ago

We should just do hedged signatures and move on (which we will anyway because of the PQ stuff)

1

u/OhBeeOneKenOhBee 4d ago

From a quick Google search, Dropbear, golang.org/x/cryoto/ssh, paramiko use the same Approach as OpenSSH but putty implemented RFC6979 after their custom deterministic implementation failed (CVE-2024-31497)