X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fgovpn%2Fhandshake.go;h=d9e86352dbde5e26b6a22d40e66859b8908d7e6d;hb=cb53249d78d1a4c175312fbe83bd3127e0067e4c;hp=8c7696728ab6e342a166713c5a7467f876ef445b;hpb=bea62b33bb6f217dcb05b7b6be0e6327abf60fc3;p=govpn.git diff --git a/src/govpn/handshake.go b/src/govpn/handshake.go index 8c76967..d9e8635 100644 --- a/src/govpn/handshake.go +++ b/src/govpn/handshake.go @@ -27,9 +27,9 @@ import ( "github.com/agl/ed25519" "github.com/agl/ed25519/extra25519" + "github.com/dchest/blake2b" "golang.org/x/crypto/curve25519" "golang.org/x/crypto/salsa20" - "golang.org/x/crypto/salsa20/salsa" "golang.org/x/crypto/xtea" ) @@ -61,11 +61,6 @@ func keyFromSecrets(server, client []byte) *[SSize]byte { return k } -// Apply HSalsa20 function for data. Used to hash public keys. -func HApply(data *[32]byte) { - salsa.HSalsa20(data, new([16]byte), data, &salsa.Sigma) -} - // Zero handshake's memory state func (h *Handshake) Zero() { if h.rNonce != nil { @@ -118,8 +113,8 @@ func dhKeypairGen() (*[32]byte, *[32]byte) { func dhKeyGen(priv, pub *[32]byte) *[32]byte { key := new([32]byte) curve25519.ScalarMult(key, priv, pub) - HApply(key) - return key + hashed := blake2b.Sum256(key[:]) + return &hashed } // Create new handshake state. @@ -132,7 +127,8 @@ func NewHandshake(addr string, conn io.Writer, conf *PeerConf) *Handshake { } state.dsaPubH = new([ed25519.PublicKeySize]byte) copy(state.dsaPubH[:], state.Conf.Verifier.Pub[:]) - HApply(state.dsaPubH) + hashed := blake2b.Sum256(state.dsaPubH[:]) + state.dsaPubH = &hashed return &state }