mirror of https://github.com/schollz/croc.git
use random salt
This commit is contained in:
parent
e72795985b
commit
9952da9f6d
|
@ -3,6 +3,7 @@ package croc
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
|
"crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -396,14 +397,13 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if c.Pake.IsVerified() {
|
if c.Pake.IsVerified() {
|
||||||
log.Debug("session key is verified, generating encryption")
|
if c.Options.IsSender {
|
||||||
key, err := c.Pake.SessionKey()
|
salt := make([]byte, 8)
|
||||||
if err != nil {
|
rand.Read(salt)
|
||||||
return true, err
|
err = message.Send(c.conn[0], c.Key, message.Message{
|
||||||
}
|
Type: "salt",
|
||||||
c.Key, err = crypt.New(key, []byte(c.Options.SharedSecret))
|
Bytes: salt,
|
||||||
if err != nil {
|
})
|
||||||
return true, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// connects to the other ports of the server for transfer
|
// connects to the other ports of the server for transfer
|
||||||
|
@ -425,8 +425,24 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
c.Step1ChannelSecured = true
|
|
||||||
}
|
}
|
||||||
|
case "salt":
|
||||||
|
if !c.Options.IsSender {
|
||||||
|
err = message.Send(c.conn[0], c.Key, message.Message{
|
||||||
|
Type: "salt",
|
||||||
|
Bytes: m.Bytes,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
log.Debugf("session key is verified, generating encryption with salt: %x", m.Bytes)
|
||||||
|
key, err := c.Pake.SessionKey()
|
||||||
|
if err != nil {
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
c.Key, err = crypt.New(key, m.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
c.Step1ChannelSecured = true
|
||||||
case "error":
|
case "error":
|
||||||
// c.spinner.Stop()
|
// c.spinner.Stop()
|
||||||
fmt.Print("\r")
|
fmt.Print("\r")
|
||||||
|
|
Loading…
Reference in New Issue