1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-29 13:35:20 -05:00

update frame header masking strategy

This commit is contained in:
Darien Raymond
2017-02-14 14:16:43 +01:00
parent 104446afdf
commit 3c032f0d53
6 changed files with 100 additions and 43 deletions

View File

@@ -10,15 +10,12 @@ import (
"v2ray.com/core/common/buf"
. "v2ray.com/core/common/crypto"
"v2ray.com/core/common/dice"
"v2ray.com/core/testing/assert"
)
func TestAuthenticationReaderWriter(t *testing.T) {
assert := assert.On(t)
sizeMask := uint16(dice.Roll(65536))
key := make([]byte, 16)
rand.Read(key)
block, err := aes.NewCipher(key)
@@ -40,7 +37,7 @@ func TestAuthenticationReaderWriter(t *testing.T) {
Content: iv,
},
AdditionalDataGenerator: &NoOpBytesGenerator{},
}, cache, sizeMask)
}, cache, NewShakeUint16Generator([]byte{'a'}))
nBytes, err := writer.Write(payload)
assert.Error(err).IsNil()
@@ -55,7 +52,7 @@ func TestAuthenticationReaderWriter(t *testing.T) {
Content: iv,
},
AdditionalDataGenerator: &NoOpBytesGenerator{},
}, cache, sizeMask)
}, cache, NewShakeUint16Generator([]byte{'a'}))
actualPayload := make([]byte, 16*1024)
nBytes, err = reader.Read(actualPayload)
@@ -70,8 +67,6 @@ func TestAuthenticationReaderWriter(t *testing.T) {
func TestAuthenticationReaderWriterPartial(t *testing.T) {
assert := assert.On(t)
sizeMask := uint16(dice.Roll(65536))
key := make([]byte, 16)
rand.Read(key)
block, err := aes.NewCipher(key)
@@ -93,7 +88,7 @@ func TestAuthenticationReaderWriterPartial(t *testing.T) {
Content: iv,
},
AdditionalDataGenerator: &NoOpBytesGenerator{},
}, cache, sizeMask)
}, cache, NewShakeUint16Generator([]byte{'a', 'b'}))
writer.Write([]byte{'a', 'b', 'c', 'd'})
@@ -123,7 +118,7 @@ func TestAuthenticationReaderWriterPartial(t *testing.T) {
Content: iv,
},
AdditionalDataGenerator: &NoOpBytesGenerator{},
}, pr, sizeMask)
}, pr, NewShakeUint16Generator([]byte{'a', 'b'}))
actualPayload := make([]byte, 7*1024)
nBytes, err = reader.Read(actualPayload)