Marcin Krzyżanowski před 9 roky
rodič
revize
a292060fcd
1 změnil soubory, kde provedl 4 přidání a 1 odebrání
  1. 4 1
      Sources/CryptoSwift/ChaCha20.swift

+ 4 - 1
Sources/CryptoSwift/ChaCha20.swift

@@ -19,6 +19,8 @@ final public class ChaCha20: BlockCipher {
         var input = Array<UInt32>(repeating: 0, count: 16)
 
         init(key:Array<UInt8>, iv:Array<UInt8>) throws {
+            precondition(iv.count >= 8)
+
             let kbits = key.count * 8
 
             if (kbits != 128 && kbits != 256) {
@@ -69,7 +71,8 @@ final public class ChaCha20: BlockCipher {
     }
     
     private final func wordToByte(_ input:Array<UInt32> /* 64 */) -> Array<UInt8>? /* 16 */ {
-        assert(input.count == 16)
+        precondition(input.count == 16)
+
         var x = input
 
         for _ in 0..<10 {