"expvar"
"fmt"
"io"
- "io/ioutil"
"math"
"math/big"
"strconv"
return h.Sum(nil)
}
-func newEncrypt(initer bool, s []byte, skey []byte) (c *rc4.Cipher) {
+func newEncrypt(initer bool, s, skey []byte) (c *rc4.Cipher) {
c, err := rc4.NewCipher(hash([]byte(func() string {
if initer {
return "keyA"
return ret
}
}()
- cr.c.XORKeyStream(be[:], b)
+ cr.c.XORKeyStream(be, b)
n, err = cr.w.Write(be[:len(b)])
if n != len(b) {
// The cipher will have advanced beyond the callers stream position.
var b [96]byte
_, err := io.ReadFull(h.conn, b[:])
if err != nil {
- return fmt.Errorf("error reading Y: %s", err)
+ return fmt.Errorf("error reading Y: %w", err)
}
var Y, S big.Int
Y.SetBytes(b[:])
if err != nil {
return
}
- _, err = io.CopyN(ioutil.Discard, r, int64(padLen))
+ _, err = io.CopyN(io.Discard, r, int64(padLen))
if err != nil {
return
}
}
cryptoProvidesCount.Add(strconv.FormatUint(uint64(provides), 16), 1)
chosen = h.chooseMethod(provides)
- _, err = io.CopyN(ioutil.Discard, r, int64(padLen))
+ _, err = io.CopyN(io.Discard, r, int64(padLen))
if err != nil {
return
}
}()
err = h.establishS()
if err != nil {
- err = fmt.Errorf("error while establishing secret: %s", err)
+ err = fmt.Errorf("error while establishing secret: %w", err)
return
}
pad := make([]byte, newPadLen())
return
}
-func InitiateHandshake(rw io.ReadWriter, skey []byte, initialPayload []byte, cryptoProvides CryptoMethod) (ret io.ReadWriter, method CryptoMethod, err error) {
+func InitiateHandshake(
+ rw io.ReadWriter, skey, initialPayload []byte, cryptoProvides CryptoMethod,
+) (
+ ret io.ReadWriter, method CryptoMethod, err error,
+) {
h := handshake{
conn: rw,
initer: true,