Skip to content

Commit

Permalink
lazy init of authenticator
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Nov 29, 2017
1 parent f6bb214 commit 3aa5102
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions proxy/shadowsocks/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.Reques
account := rawAccount.(*MemoryAccount)

var iv []byte
var authenticator *Authenticator
if !account.Cipher.IsAEAD() && account.Cipher.IVSize() > 0 {
// Keep track of IV as it gets removed from payload in DecodePacket.
iv = make([]byte, account.Cipher.IVSize())
Expand Down Expand Up @@ -333,7 +332,7 @@ func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.Reques
payloadLen := payload.Len() - AuthSize
authBytes := payload.BytesFrom(payloadLen)

authenticator = NewAuthenticator(HeaderKeyGenerator(account.Key, iv))
authenticator := NewAuthenticator(HeaderKeyGenerator(account.Key, iv))
actualAuth := make([]byte, AuthSize)
authenticator.Authenticate(payload.BytesTo(payloadLen))(actualAuth)
if !bytes.Equal(actualAuth, authBytes) {
Expand Down

0 comments on commit 3aa5102

Please sign in to comment.