This commit is contained in:
parent
c79c3c83cb
commit
e3d00878b3
|
@ -2,7 +2,6 @@ package handshake
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
@ -51,11 +50,7 @@ func (c C2S2) Write(w io.Writer) error {
|
|||
buf[6] = byte(c.Time2 >> 8)
|
||||
buf[7] = byte(c.Time2)
|
||||
|
||||
if c.Random == nil {
|
||||
rand.Read(buf[8:])
|
||||
} else {
|
||||
copy(buf[8:], c.Random)
|
||||
}
|
||||
copy(buf[8:], c.Random)
|
||||
|
||||
// signature
|
||||
if c.Digest != nil {
|
||||
|
|
|
@ -29,12 +29,18 @@ func DoClient(rw io.ReadWriter, validateSignature bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err = (&C2S2{Digest: c1.Digest}).Read(rw, validateSignature)
|
||||
err = (&C2S2{
|
||||
Digest: c1.Digest,
|
||||
}).Read(rw, validateSignature)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = C2S2{Digest: s1.Digest}.Write(rw)
|
||||
err = C2S2{
|
||||
Time: s1.Time,
|
||||
Random: s1.Random,
|
||||
Digest: s1.Digest,
|
||||
}.Write(rw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -66,7 +72,11 @@ func DoServer(rw io.ReadWriter, validateSignature bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err = C2S2{Digest: c1.Digest}.Write(rw)
|
||||
err = C2S2{
|
||||
Time: c1.Time,
|
||||
Random: c1.Random,
|
||||
Digest: c1.Digest,
|
||||
}.Write(rw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue