소스 검색

Update testScrypt_2 test parameter

Marcin Krzyzanowski 6 년 전
부모
커밋
410fff85e8
4개의 변경된 파일28개의 추가작업 그리고 17개의 파일을 삭제
  1. 4 0
      CHANGELOG
  2. 4 1
      CryptoSwift.xcodeproj/project.pbxproj
  3. 5 1
      Sources/CryptoSwift/Scrypt.swift
  4. 15 15
      Tests/Tests/ScryptTests.swift

+ 4 - 0
CHANGELOG

@@ -1,3 +1,7 @@
+0.15.0
+- Adds The scrypt Password-Based Key Derivation Function (https://tools.ietf.org/html/rfc7914)
+- Minor improvements
+
 0.14.0
 - Fixed decryption of AES-GCM ciphertexts with custom tag length
 

+ 4 - 1
CryptoSwift.xcodeproj/project.pbxproj

@@ -819,7 +819,7 @@
 			};
 			buildConfigurationList = 754BE44F19693E190098E6F3 /* Build configuration list for PBXProject "CryptoSwift" */;
 			compatibilityVersion = "Xcode 8.0";
-			developmentRegion = English;
+			developmentRegion = en;
 			hasScannedForEncodings = 0;
 			knownRegions = (
 				en,
@@ -1121,6 +1121,7 @@
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = 75211FB020724A10004E41F8 /* Project-Debug.xcconfig */;
 			buildSettings = {
+				CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
 			};
 			name = Debug;
 		};
@@ -1128,6 +1129,7 @@
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = 75211FAA20724A0F004E41F8 /* Project-Release.xcconfig */;
 			buildSettings = {
+				CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
 			};
 			name = Release;
 		};
@@ -1196,6 +1198,7 @@
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = 75211FA620724A0F004E41F8 /* Project-Test.xcconfig */;
 			buildSettings = {
+				CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
 			};
 			name = Test;
 		};

+ 5 - 1
Sources/CryptoSwift/Scrypt.swift

@@ -135,7 +135,11 @@ private extension Scrypt {
 
         /* 6: for i = 0 to N - 1 do */
         for _ in stride(from: 0, to: N, by: 2) {
-            /* 7: j <-- Integerify(X) mod N */
+            /*
+             7: j <-- Integerify (X) mod N
+             where Integerify (B[0] ... B[2 * r - 1]) is defined
+             as the result of interpreting B[2 * r - 1] as a little-endian integer.
+             */
             var j = Int(integerify(X) & UInt64(N - 1))
 
             /* 8: X <-- H(X \xor V_j) */

+ 15 - 15
Tests/Tests/ScryptTests.swift

@@ -47,21 +47,21 @@ class Scrypt: XCTestCase {
     }
     
 //          Takes too long to run in debug mode!
-        func testScrypt_2() {
-            #if !DEBUG
-            let password = Array("pleaseletmein".data(using: .ascii)!)
-            let salt = Array("SodiumChloride".data(using: .ascii)!)
-            let deriver = try! CryptoSwift.Scrypt(password: password, salt: salt, dkLen: 64, N: 1048576, r: 8, p: 16)
-            let derived = try! deriver.calculate()
-            let expected: [UInt8] = Array<UInt8>.init(hex: """
-                    21 01 cb 9b 6a 51 1a ae ad db be 09 cf 70 f8 81
-                    ec 56 8d 57 4a 2f fd 4d ab e5 ee 98 20 ad aa 47
-                    8e 56 fd 8f 4b a5 d0 9f fa 1c 6d 92 7c 40 f4 c3
-                    37 30 40 49 e8 a9 52 fb cb f4 5c 6f a7 7a 41 a4
-    """.replacingOccurrences(of: " ", with: "").replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: "\t", with: ""))
-            XCTAssertEqual(derived, expected)
-            #endif
-        }
+    func testScrypt_2() {
+        #if !DEBUG
+        let password = Array("pleaseletmein".data(using: .ascii)!)
+        let salt = Array("SodiumChloride".data(using: .ascii)!)
+        let deriver = try! CryptoSwift.Scrypt(password: password, salt: salt, dkLen: 64, N: 1048576, r: 8, p: 1)
+        let derived = try! deriver.calculate()
+        let expected: [UInt8] = Array<UInt8>.init(hex: """
+                21 01 cb 9b 6a 51 1a ae ad db be 09 cf 70 f8 81
+                ec 56 8d 57 4a 2f fd 4d ab e5 ee 98 20 ad aa 47
+                8e 56 fd 8f 4b a5 d0 9f fa 1c 6d 92 7c 40 f4 c3
+                37 30 40 49 e8 a9 52 fb cb f4 5c 6f a7 7a 41 a4
+""".replacingOccurrences(of: " ", with: "").replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: "\t", with: ""))
+        XCTAssertEqual(derived, expected)
+        #endif
+    }
     
     static let allTests = [
         ("testScrypt_0", testScrypt_0),