From 075423972b1e3f1017835672f311c32ed2d53b13 Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 23 Feb 2016 18:25:00 +0100 Subject: [PATCH] remove unnecessary function --- common/crypto/internal/chacha.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/common/crypto/internal/chacha.go b/common/crypto/internal/chacha.go index 7624248f..988ac984 100644 --- a/common/crypto/internal/chacha.go +++ b/common/crypto/internal/chacha.go @@ -44,7 +44,7 @@ func NewChaCha20Stream(key []byte, nonce []byte, rounds int) *ChaCha20Stream { } s.rounds = rounds - s.advance() + ChaCha20Block(&s.state, s.block[:], s.rounds) return s } @@ -72,14 +72,9 @@ func (s *ChaCha20Stream) XORKeyStream(dst, src []byte) { s.offset = o if o == blockSize { - s.advance() + s.offset = 0 + s.state[12]++ + ChaCha20Block(&s.state, s.block[:], s.rounds) } } } - -func (s *ChaCha20Stream) advance() { - ChaCha20Block(&s.state, s.block[:], s.rounds) - - s.offset = 0 - s.state[12]++ -}