|
|
|
@ -367,11 +367,11 @@ func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoarey |
|
|
|
|
// key is part of the ID nonce signature.
|
|
|
|
|
var remotePubkey = new(ecdsa.PublicKey) |
|
|
|
|
if err := challenge.Node.Load((*enode.Secp256k1)(remotePubkey)); err != nil { |
|
|
|
|
return nil, nil, fmt.Errorf("can't find secp256k1 key for recipient") |
|
|
|
|
return nil, nil, errors.New("can't find secp256k1 key for recipient") |
|
|
|
|
} |
|
|
|
|
ephkey, err := c.sc.ephemeralKeyGen() |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, nil, fmt.Errorf("can't generate ephemeral key") |
|
|
|
|
return nil, nil, errors.New("can't generate ephemeral key") |
|
|
|
|
} |
|
|
|
|
ephpubkey := EncodePubkey(&ephkey.PublicKey) |
|
|
|
|
auth.pubkey = ephpubkey[:] |
|
|
|
@ -395,7 +395,7 @@ func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoarey |
|
|
|
|
// Create session keys.
|
|
|
|
|
sec := deriveKeys(sha256.New, ephkey, remotePubkey, c.localnode.ID(), challenge.Node.ID(), cdata) |
|
|
|
|
if sec == nil { |
|
|
|
|
return nil, nil, fmt.Errorf("key derivation failed") |
|
|
|
|
return nil, nil, errors.New("key derivation failed") |
|
|
|
|
} |
|
|
|
|
return auth, sec, err |
|
|
|
|
} |
|
|
|
|