From 7c316b9194317d950a55d56e0534eed6f986ff65 Mon Sep 17 00:00:00 2001 From: nsa Date: Thu, 30 Jan 2020 13:34:49 -0500 Subject: [PATCH] brontide: add SetCurveToNil function --- brontide/noise.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/brontide/noise.go b/brontide/noise.go index 7d5f42d4e..16263e5fa 100644 --- a/brontide/noise.go +++ b/brontide/noise.go @@ -871,3 +871,23 @@ func (b *Machine) ReadBody(r io.Reader, buf []byte) ([]byte, error) { // TODO(roasbeef): modify to let pass in slice return b.recvCipher.Decrypt(nil, nil, buf) } + +// SetCurveToNil sets the 'Curve' parameter to nil on the handshakeState keys. +// This allows us to log the Machine object without spammy log messages. +func (b *Machine) SetCurveToNil() { + if b.localStatic != nil { + b.localStatic.Curve = nil + } + + if b.localEphemeral != nil { + b.localEphemeral.Curve = nil + } + + if b.remoteStatic != nil { + b.remoteStatic.Curve = nil + } + + if b.remoteEphemeral != nil { + b.remoteEphemeral.Curve = nil + } +}