瀏覽代碼

remove unnecessary function

v2ray 9 年之前
父節點
當前提交
075423972b
共有 1 個文件被更改,包括 4 次插入9 次删除
  1. 4 9
      common/crypto/internal/chacha.go

+ 4 - 9
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]++
-}