mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-04 09:17:32 -05:00
lazy init of authenticator
This commit is contained in:
parent
f6bb214d30
commit
3aa5102036
@ -299,7 +299,6 @@ func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.Reques
|
|||||||
account := rawAccount.(*MemoryAccount)
|
account := rawAccount.(*MemoryAccount)
|
||||||
|
|
||||||
var iv []byte
|
var iv []byte
|
||||||
var authenticator *Authenticator
|
|
||||||
if !account.Cipher.IsAEAD() && account.Cipher.IVSize() > 0 {
|
if !account.Cipher.IsAEAD() && account.Cipher.IVSize() > 0 {
|
||||||
// Keep track of IV as it gets removed from payload in DecodePacket.
|
// Keep track of IV as it gets removed from payload in DecodePacket.
|
||||||
iv = make([]byte, account.Cipher.IVSize())
|
iv = make([]byte, account.Cipher.IVSize())
|
||||||
@ -333,7 +332,7 @@ func DecodeUDPPacket(user *protocol.User, payload *buf.Buffer) (*protocol.Reques
|
|||||||
payloadLen := payload.Len() - AuthSize
|
payloadLen := payload.Len() - AuthSize
|
||||||
authBytes := payload.BytesFrom(payloadLen)
|
authBytes := payload.BytesFrom(payloadLen)
|
||||||
|
|
||||||
authenticator = NewAuthenticator(HeaderKeyGenerator(account.Key, iv))
|
authenticator := NewAuthenticator(HeaderKeyGenerator(account.Key, iv))
|
||||||
actualAuth := make([]byte, AuthSize)
|
actualAuth := make([]byte, AuthSize)
|
||||||
authenticator.Authenticate(payload.BytesTo(payloadLen))(actualAuth)
|
authenticator.Authenticate(payload.BytesTo(payloadLen))(actualAuth)
|
||||||
if !bytes.Equal(actualAuth, authBytes) {
|
if !bytes.Equal(actualAuth, authBytes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user