1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-10-13 12:34:10 -04:00

common.Must2

This commit is contained in:
Darien Raymond
2017-09-19 23:27:49 +02:00
parent 190adf1872
commit 8971e699d9
13 changed files with 103 additions and 74 deletions

View File

@@ -4,15 +4,16 @@ import (
"crypto/md5"
"hash/fnv"
"golang.org/x/crypto/sha3"
"v2ray.com/core/common"
"v2ray.com/core/common/serial"
"golang.org/x/crypto/sha3"
)
// Authenticate authenticates a byte array using Fnv hash.
func Authenticate(b []byte) uint32 {
fnv1hash := fnv.New32a()
fnv1hash.Write(b)
common.Must2(fnv1hash.Write(b))
return fnv1hash.Sum32()
}
@@ -81,7 +82,7 @@ type ShakeSizeParser struct {
func NewShakeSizeParser(nonce []byte) *ShakeSizeParser {
shake := sha3.NewShake128()
shake.Write(nonce)
common.Must2(shake.Write(nonce))
return &ShakeSizeParser{
shake: shake,
}
@@ -92,7 +93,7 @@ func (*ShakeSizeParser) SizeBytes() int {
}
func (s *ShakeSizeParser) next() uint16 {
s.shake.Read(s.buffer[:])
common.Must2(s.shake.Read(s.buffer[:]))
return serial.BytesToUint16(s.buffer[:])
}