Ver Fonte

Use Double in place of Int where at least 32 bits are needed. Fixes #257

Marcin Krzyżanowski há 9 anos atrás
pai
commit
868458f800
1 ficheiros alterados com 2 adições e 8 exclusões
  1. 2 8
      Sources/CryptoSwift/PKCS5/PBKDF2.swift

+ 2 - 8
Sources/CryptoSwift/PKCS5/PBKDF2.swift

@@ -25,15 +25,9 @@ public extension PKCS5 {
                 throw Error.InvalidInput
                 throw Error.InvalidInput
             }
             }
 
 
-            let keyLengthFinal: Int
-            if let kl = keyLength {
-                keyLengthFinal = kl
-            } else {
-                keyLengthFinal = hashVariant.size
-            }
-
+            let keyLengthFinal = Double(keyLength ?? hashVariant.size)
             let hLen = Double(prf.variant.size)
             let hLen = Double(prf.variant.size)
-            if keyLength > Int(((pow(2,32) as Double) - 1) * hLen) {
+            if keyLengthFinal > (pow(2,32) - 1) * hLen {
                 throw Error.InvalidInput
                 throw Error.InvalidInput
             }
             }