/*
-govpn -- high-performance secure virtual private network daemon
+govpn -- Simple secure virtual private network daemon
Copyright (C) 2014 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
package main
import (
"net"
"time"
- "code.google.com/p/go.crypto/curve25519"
- "code.google.com/p/go.crypto/poly1305"
- "code.google.com/p/go.crypto/salsa20"
- "code.google.com/p/go.crypto/salsa20/salsa"
+ "golang.org/x/crypto/curve25519"
+ "golang.org/x/crypto/poly1305"
+ "golang.org/x/crypto/salsa20"
+ "golang.org/x/crypto/salsa20/salsa"
)
type Handshake struct {
return &state
}
-func (h *Handshake) Server(conn *net.UDPConn, key *[32]byte, data []byte) *Peer {
+func (h *Handshake) Server(noncediff uint64, conn *net.UDPConn, key *[32]byte, data []byte) *Peer {
switch len(data) {
case 56: // R + ENC(PSK, dh_client_pub) + NULLs
fmt.Print("[HS1]")
}
// Switch peer
- peer := Peer{addr: h.addr, nonceOur: 0, nonceRecv: 0}
+ peer := Peer{
+ addr: h.addr,
+ nonceOur: noncediff + 0,
+ nonceRecv: noncediff + 0,
+ }
peer.key = KeyFromSecrets(h.sServer[:], decRs[8+8:])
fmt.Print("[OK]")
return &peer
return nil
}
-func (h *Handshake) Client(conn *net.UDPConn, key *[32]byte, data []byte) *Peer {
+func (h *Handshake) Client(noncediff uint64, conn *net.UDPConn, key *[32]byte, data []byte) *Peer {
switch len(data) {
case 88: // ENC(PSK, dh_server_pub) + ENC(K, RS + SS) + NULLs
fmt.Print("[HS2]")
}
// Switch peer
- peer := Peer{addr: h.addr, nonceOur: 1, nonceRecv: 0}
+ peer := Peer{
+ addr: h.addr,
+ nonceOur: noncediff + 1,
+ nonceRecv: noncediff + 0,
+ }
peer.key = KeyFromSecrets(h.sServer[:], h.sClient[:])
fmt.Print("[OK]")
return &peer