@@ -179,23 +179,28 @@ func (s *State) verifyClientAuth(data []byte) bool {
179179 secHasher .Write (s .aBob [:])
180180 copy (s .secret2 [:], secHasher .Sum (nil ))
181181
182- s .hello = make ([]byte , 0 , len (data )- 16 )
182+ s .hello = make ([]byte , len (data )- 16 )
183183
184184 var (
185185 nonce [24 ]byte // always 0?
186186 openOk bool
187187 sig [ed25519 .SignatureSize ]byte
188188 public [ed25519 .PublicKeySize ]byte
189+ hello = make ([]byte , 0 , len (data )- 16 )
189190 )
190191
191- s . hello , openOk = box .OpenAfterPrecomputation (s . hello , data , & nonce , & s .secret2 )
192- if ! openOk && s . hello == nil {
192+ hello , openOk = box .OpenAfterPrecomputation (hello , data , & nonce , & s .secret2 )
193+ if ! openOk && hello == nil {
193194 fmt .Println ("warning: nil hello" )
194195 }
196+
195197 // subtle API requires an int containing 0 or 1, we only have bool.
196198 // we can't branch because openOk is secret.
197199 okInt := int (* ((* byte )(unsafe .Pointer (& openOk ))))
198200
201+ // this is not super secret data like keys, so we can copy it around
202+ copy (s .hello , hello )
203+
199204 subtle .ConstantTimeCopy (okInt , sig [:], s .hello [:ed25519 .SignatureSize ])
200205 subtle .ConstantTimeCopy (okInt , public [:], s .hello [ed25519 .SignatureSize :ed25519 .SignatureSize + ed25519 .PublicKeySize ])
201206
0 commit comments