|
|
@@ -25,14 +25,14 @@ var emptyIP = [4]byte{0x00, 0x00, 0x00, 0x00}
|
|
25
|
25
|
func NewMiddleProxyCipherRWC(conn wrappers.ReadWriteCloserWithAddr, req *rpc.RPCNonceRequest,
|
|
26
|
26
|
resp *rpc.RPCNonceResponse, client *net.TCPAddr, secret []byte) wrappers.ReadWriteCloserWithAddr {
|
|
27
|
27
|
remote := conn.Addr()
|
|
28
|
|
- encryptor := newCBCCipher(CipherPurposeClient, req, resp, client, remote, secret)
|
|
29
|
|
- decryptor := newCBCCipher(CipherPurposeServer, req, resp, client, remote, secret)
|
|
|
28
|
+ encryptor, _ := newCBCCipher(CipherPurposeClient, req, resp, client, remote, secret)
|
|
|
29
|
+ _, decryptor := newCBCCipher(CipherPurposeServer, req, resp, client, remote, secret)
|
|
30
|
30
|
|
|
31
|
31
|
return wrappers.NewBlockCipherRWC(conn, encryptor, decryptor)
|
|
32
|
32
|
}
|
|
33
|
33
|
|
|
34
|
34
|
func newCBCCipher(purpose CipherPurpose, req *rpc.RPCNonceRequest, resp *rpc.RPCNonceResponse,
|
|
35
|
|
- client *net.TCPAddr, remote *net.TCPAddr, secret []byte) cipher.BlockMode {
|
|
|
35
|
+ client *net.TCPAddr, remote *net.TCPAddr, secret []byte) (cipher.BlockMode, cipher.BlockMode) {
|
|
36
|
36
|
message := bytes.Buffer{}
|
|
37
|
37
|
message.Write(resp.Nonce[:])
|
|
38
|
38
|
message.Write(req.Nonce[:])
|
|
|
@@ -74,7 +74,7 @@ func newCBCCipher(purpose CipherPurpose, req *rpc.RPCNonceRequest, resp *rpc.RPC
|
|
74
|
74
|
return makeCipher(message.Bytes())
|
|
75
|
75
|
}
|
|
76
|
76
|
|
|
77
|
|
-func makeCipher(message []byte) cipher.BlockMode {
|
|
|
77
|
+func makeCipher(message []byte) (cipher.BlockMode, cipher.BlockMode) {
|
|
78
|
78
|
md5sum := md5.Sum(message[1:])
|
|
79
|
79
|
sha1sum := sha1.Sum(message)
|
|
80
|
80
|
|
|
|
@@ -86,7 +86,7 @@ func makeCipher(message []byte) cipher.BlockMode {
|
|
86
|
86
|
panic("Cannot create cipher from the given key")
|
|
87
|
87
|
}
|
|
88
|
88
|
|
|
89
|
|
- return cipher.NewCBCEncrypter(block, iv[:])
|
|
|
89
|
+ return cipher.NewCBCEncrypter(block, iv[:]), cipher.NewCBCDecrypter(block, iv[:])
|
|
90
|
90
|
}
|
|
91
|
91
|
|
|
92
|
92
|
func reverseBytes(data []byte) []byte {
|