Browse Source

Prevent overflow

Marcin Krzyżanowski 7 năm trước cách đây
mục cha
commit
38343e69a5
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      Sources/CryptoSwift/ChaCha20.swift

+ 1 - 1
Sources/CryptoSwift/ChaCha20.swift

@@ -223,7 +223,7 @@ public final class ChaCha20: BlockCipher {
             var u: UInt32 = 1
             for i in 0..<4 {
                 u += UInt32(counter[i])
-                counter[i] = UInt8(u)
+                counter[i] = UInt8(u & 0xFF)
                 u >>= 8
             }
             bytes = Array(bytes[ChaCha20.blockSize..<bytes.endIndex])