1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-09-29 21:54:10 -04:00

implementation for Shadowsocks AEAD

This commit is contained in:
Darien Raymond
2017-11-26 00:51:54 +01:00
parent 41961dbd60
commit 713ebfb203
5 changed files with 173 additions and 49 deletions

View File

@@ -29,6 +29,26 @@ func (v StaticBytesGenerator) Next() []byte {
return v.Content
}
type IncreasingAEADNonceGenerator struct {
nonce []byte
}
func NewIncreasingAEADNonceGenerator() *IncreasingAEADNonceGenerator {
return &IncreasingAEADNonceGenerator{
nonce: []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
}
}
func (g *IncreasingAEADNonceGenerator) Next() []byte {
for i := range g.nonce {
g.nonce[i]++
if g.nonce[i] != 0 {
break
}
}
return g.nonce
}
type Authenticator interface {
NonceSize() int
Overhead() int