瀏覽代碼

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

Marcin Krzyżanowski 9 年之前
父節點
當前提交
868458f800
共有 1 個文件被更改,包括 2 次插入8 次删除
  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
             }
 
-            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)
-            if keyLength > Int(((pow(2,32) as Double) - 1) * hLen) {
+            if keyLengthFinal > (pow(2,32) - 1) * hLen {
                 throw Error.InvalidInput
             }