Development discussion of WireGuard
 help / color / mirror / Atom feed
* Noise Protocol Question
@ 2023-02-11 15:39 z
  2023-02-16 15:39 ` Jason A. Donenfeld
  0 siblings, 1 reply; 2+ messages in thread
From: z @ 2023-02-11 15:39 UTC (permalink / raw)
  To: wireguard


I was reading over the source code for wireguard-go, and I noticed something in the device/noise-protocol.go file that I didn't understand.

There are six invocations of the sharedSecret() function, which performs the X25519 operation on a local private key and a remote public key as part of an ECDH key agreement. 

The first two invocations check for an all zero ECDH result.
ss := pk.sharedSecret(pubkey)
if isZero(ss) {
    return nil, errZeroECDHResult

If the result is zero, the operation is aborted.  The subsequent 4 invocations, however, don't check for zero on the output of sharedSecret(), and continue processing regardless.

In two of the 4 cases, I think I get why it isn't necessary, because the sharedSecret is used as input into an aead.Open, which would simply fail if the ECDH got zero'd out somehow.

However the remaining two calls are associated with an aead.Seal, which would succeed, no matter what the shared secret is.

TL;DR  Why is wireguard go not calling isZero() on the output of the ECDH key agreement every time?



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-16 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-11 15:39 Noise Protocol Question z
2023-02-16 15:39 ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).