From 73b5a51529c7364b77b6f4af14de5528ba6a0e72 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 22 Jan 2017 20:43:01 +0100 Subject: [PATCH] true none encryption --- proxy/vmess/encoding/auth.go | 20 ++++++++++++++++++++ proxy/vmess/encoding/client.go | 2 +- proxy/vmess/encoding/server.go | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/proxy/vmess/encoding/auth.go b/proxy/vmess/encoding/auth.go index 0d676d65..610c2157 100644 --- a/proxy/vmess/encoding/auth.go +++ b/proxy/vmess/encoding/auth.go @@ -15,6 +15,26 @@ func Authenticate(b []byte) uint32 { return fnv1hash.Sum32() } +type NoOpAuthenticator struct{} + +func (NoOpAuthenticator) NonceSize() int { + return 0 +} + +func (NoOpAuthenticator) Overhead() int { + return 0 +} + +// Seal implements AEAD.Seal(). +func (NoOpAuthenticator) Seal(dst, nonce, plaintext, additionalData []byte) []byte { + return append(dst[:0], plaintext...) +} + +// Open implements AEAD.Open(). +func (NoOpAuthenticator) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { + return append(dst[:0], ciphertext...), nil +} + // FnvAuthenticator is an AEAD based on Fnv hash. type FnvAuthenticator struct { } diff --git a/proxy/vmess/encoding/client.go b/proxy/vmess/encoding/client.go index 6d85dac2..5e2da55e 100644 --- a/proxy/vmess/encoding/client.go +++ b/proxy/vmess/encoding/client.go @@ -122,7 +122,7 @@ func (v *ClientSession) EncodeRequestBody(request *protocol.RequestHeader, write if request.Security.Is(protocol.SecurityType_NONE) { if request.Option.Has(protocol.RequestOptionChunkStream) { auth := &crypto.AEADAuthenticator{ - AEAD: new(FnvAuthenticator), + AEAD: NoOpAuthenticator{}, NonceGenerator: crypto.NoOpBytesGenerator{}, AdditionalDataGenerator: crypto.NoOpBytesGenerator{}, } diff --git a/proxy/vmess/encoding/server.go b/proxy/vmess/encoding/server.go index 6e5edcb3..4d73b24a 100644 --- a/proxy/vmess/encoding/server.go +++ b/proxy/vmess/encoding/server.go @@ -155,7 +155,7 @@ func (v *ServerSession) DecodeRequestBody(request *protocol.RequestHeader, reade if request.Security.Is(protocol.SecurityType_NONE) { if request.Option.Has(protocol.RequestOptionChunkStream) { auth := &crypto.AEADAuthenticator{ - AEAD: new(FnvAuthenticator), + AEAD: NoOpAuthenticator{}, NonceGenerator: crypto.NoOpBytesGenerator{}, AdditionalDataGenerator: crypto.NoOpBytesGenerator{}, }