maxep 6 жил өмнө
parent
commit
6311e974ad

+ 84 - 0
Tests/CryptoTests/Chacha20Tests.swift

@@ -0,0 +1,84 @@
+// Chacha20Tests.swift
+// This file is part of KeePassKit.
+//
+// Copyright © 2019 Maxime Epain. All rights reserved.
+//
+// KeePassKit is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// KeePassKit is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with KeePassKit. If not, see <https://www.gnu.org/licenses/>.
+
+import XCTest
+import Binary
+
+@testable import Crypto
+
+class Chacha20Tests: XCTestCase {
+
+    override func setUp() {
+        // Put setup code here. This method is called before the invocation of each test method in the class.
+    }
+
+    override func tearDown() {
+        // Put teardown code here. This method is called after the invocation of each test method in the class.
+    }
+
+    func testChaCha20() {
+        let keys: [Array<UInt8>] = [
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f],
+        ]
+
+        let ivs: [Array<UInt8>] = [
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00],
+            [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00],
+        ]
+
+        let messages = [
+            "76B8E0ADA0F13D90405D6AE55386BD28BDD219B8A08DED1AA836EFCC8B770DC7DA41597C5157488D7724E03FB8D84A376A43B8F41518A11CC387B669B2EE6586",
+
+            "4540F05A9F1FB296D7736E7B208E3C96EB4FE1834688D2604F450952ED432D41BBE2A0B6EA7566D2A5D1E7E20D42AF2C53D792B1C43FEA817E9AD275AE546963",
+            "DE9CBA7BF3D69EF5E786DC63973F653A0B49E015ADBFF7134FCB7DF137821031E85A050278A7084527214F73EFC7FA5B5277062EB7A0433E445F41E3",
+            "EF3FDFD6C61578FBF5CF35BD3DD33B8009631634D21E42AC33960BD138E50D32111E4CAF237EE53CA8AD6426194A88545DDC497A0B466E7D6BBDB0041B2F586B",
+            "F798A189F195E66982105FFB640BB7757F579DA31602FC93EC01AC56F85AC3C134A4547B733B46413042C9440049176905D3BE59EA1C53F15916155C2BE8241A38008B9A26BC35941E2444177C8ADE6689DE95264986D95889FB60E84629C9BD9A5ACB1CC118BE563EB9B3A4A472F82E09A7E778492B562EF7130E88DFE031C79DB9D4F7C7A899151B9A475032B63FC385245FE054E3DD5A97A5F576FE064025D3CE042C566AB2C507B138DB853E3D6959660996546CC9C4A6EAFDC777C040D70EAF46F76DAD3979E5C5360C3317166A1C894C94A371876A94DF7628FE4EAAF2CCB27D5AAAE0AD7AD0F9D4B6AD3B54098746D4524D38407A6DEB3AB78FAB78C9",
+        ]
+
+        for index in 0..<keys.count {
+
+            let key = Bytes(rawValue: keys[index])
+            let iv = Bytes(rawValue: ivs[index])
+
+            let data = Bytes(string: messages[index], using: .utf8)!
+
+            do {
+                let encrypted = try ChaCha20(key: key, iv: iv).encrypt(data: data)
+                let decrypted = try ChaCha20(key: key, iv: iv).decrypt(data: encrypted)
+
+                let message = String(bytes: decrypted, encoding: .utf8)
+                XCTAssertEqual(message, messages[index], "ChaCha20 decryption failed")
+
+            } catch {
+                XCTAssert(false, "Failed")
+            }
+        }
+    }
+
+    static var allTests = [
+        ("testChaCha20", testChaCha20),
+    ]
+
+}

+ 0 - 13
Tests/CryptoTests/CryptoTests.swift

@@ -1,13 +0,0 @@
-import XCTest
-@testable import Crypto
-
-final class CryptoTests: XCTestCase {
-
-    func testExample() {
-        
-    }
-
-    static var allTests = [
-        ("testExample", testExample),
-    ]
-}

+ 83 - 0
Tests/CryptoTests/Salsa20Tests.swift

@@ -0,0 +1,83 @@
+// Salsa20Tests.swift
+// This file is part of KeePassKit.
+//
+// Copyright © 2019 Maxime Epain. All rights reserved.
+//
+// KeePassKit is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// KeePassKit is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with KeePassKit. If not, see <https://www.gnu.org/licenses/>.
+
+import XCTest
+import Binary
+
+@testable import Crypto
+
+class Salsa20Tests: XCTestCase {
+
+    override func setUp() {
+        // Put setup code here. This method is called before the invocation of each test method in the class.
+    }
+
+    override func tearDown() {
+        // Put teardown code here. This method is called after the invocation of each test method in the class.
+    }
+
+    func testSalsa20() {
+        let keys: [Array<UInt8>] = [
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f],
+        ]
+
+        let ivs: [Array<UInt8>] = [
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01],
+            [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+            [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07],
+        ]
+
+        let messages = [
+            "76B8E0ADA0F13D90405D6AE55386BD28BDD219B8A08DED1AA836EFCC8B770DC7DA41597C5157488D7724E03FB8D84A376A43B8F41518A11CC387B669B2EE6586",
+            "4540F05A9F1FB296D7736E7B208E3C96EB4FE1834688D2604F450952ED432D41BBE2A0B6EA7566D2A5D1E7E20D42AF2C53D792B1C43FEA817E9AD275AE546963",
+            "DE9CBA7BF3D69EF5E786DC63973F653A0B49E015ADBFF7134FCB7DF137821031E85A050278A7084527214F73EFC7FA5B5277062EB7A0433E445F41E3",
+            "EF3FDFD6C61578FBF5CF35BD3DD33B8009631634D21E42AC33960BD138E50D32111E4CAF237EE53CA8AD6426194A88545DDC497A0B466E7D6BBDB0041B2F586B",
+            "F798A189F195E66982105FFB640BB7757F579DA31602FC93EC01AC56F85AC3C134A4547B733B46413042C9440049176905D3BE59EA1C53F15916155C2BE8241A38008B9A26BC35941E2444177C8ADE6689DE95264986D95889FB60E84629C9BD9A5ACB1CC118BE563EB9B3A4A472F82E09A7E778492B562EF7130E88DFE031C79DB9D4F7C7A899151B9A475032B63FC385245FE054E3DD5A97A5F576FE064025D3CE042C566AB2C507B138DB853E3D6959660996546CC9C4A6EAFDC777C040D70EAF46F76DAD3979E5C5360C3317166A1C894C94A371876A94DF7628FE4EAAF2CCB27D5AAAE0AD7AD0F9D4B6AD3B54098746D4524D38407A6DEB3AB78FAB78C9",
+        ]
+
+        for index in 0..<keys.count {
+
+            let key = Bytes(rawValue: keys[index])
+            let iv = Bytes(rawValue: ivs[index])
+
+            let data = Bytes(string: messages[index], using: .utf8)!
+
+            do {
+                let encrypted = try Salsa20(key: key, iv: iv).encrypt(data: data)
+                let decrypted = try Salsa20(key: key, iv: iv).decrypt(data: encrypted)
+
+                let message = String(bytes: decrypted, encoding: .utf8)
+                XCTAssertEqual(message, messages[index], "Salsa20 decryption failed")
+
+            } catch {
+                XCTAssert(false, "Failed")
+            }
+        }
+    }
+
+    static var allTests = [
+        ("testSalsa20", testSalsa20),
+    ]
+
+}

+ 338 - 0
Tests/CryptoTests/TwofishTests.swift

@@ -0,0 +1,338 @@
+// TwofishTests.swift
+// This file is part of KeePassKit.
+//
+// Copyright © 2019 Maxime Epain. All rights reserved.
+//
+// KeePassKit is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// KeePassKit is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with KeePassKit. If not, see <https://www.gnu.org/licenses/>.
+
+import XCTest
+import Binary
+
+@testable import Crypto
+
+class TwofishTests: XCTestCase {
+
+    override func setUp() {
+        // Put setup code here. This method is called before the invocation of each test method in the class.
+    }
+
+    override func tearDown() {
+        // Put teardown code here. This method is called after the invocation of each test method in the class.
+    }
+
+//    func testKey128_1() throws {
+//        let key = Bytes(hex: "00000000000000000000000000000000")!
+//        var pt = Bytes(hex: "00000000000000000000000000000000")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "9F589F5CF6122C32B6BFEC2F2AE8C35A", "Twofish: Encrypt Keysize=128 I=1 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "00000000000000000000000000000000", "Twofish: Decrypt Keysize=128 I=1 failed")
+//    }
+//
+//    func testKey128_2() throws {
+//        let key = Bytes(hex: "00000000000000000000000000000000")!
+//        var pt = Bytes(hex: "9F589F5CF6122C32B6BFEC2F2AE8C35A")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "D491DB16E7B1C39E86CB086B789F5419", "Twofish: Encrypt Keysize=128 I=2 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "9F589F5CF6122C32B6BFEC2F2AE8C35A", "Twofish: Decrypt Keysize=128 I=2 failed")
+//    }
+//
+//    func testKey128_3() throws {
+//        let key = Bytes(hex: "9F589F5CF6122C32B6BFEC2F2AE8C35A")!
+//        var pt = Bytes(hex: "D491DB16E7B1C39E86CB086B789F5419")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "019F9809DE1711858FAAC3A3BA20FBC3", "Twofish: Encrypt Keysize=128 I=3 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "D491DB16E7B1C39E86CB086B789F5419", "Twofish: Decrypt Keysize=128 I=3 failed")
+//    }
+//
+//    func testKey128_4() throws {
+//        let key = Bytes(hex: "D491DB16E7B1C39E86CB086B789F5419")!
+//        var pt = Bytes(hex: "019F9809DE1711858FAAC3A3BA20FBC3")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "6363977DE839486297E661C6C9D668EB", "Twofish: Encrypt Keysize=128 I=4 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "019F9809DE1711858FAAC3A3BA20FBC3", "Twofish: Decrypt Keysize=128 I=4 failed")
+//    }
+//
+//    func testKey128_5() throws {
+//        let key = Bytes(hex: "019F9809DE1711858FAAC3A3BA20FBC3")!
+//        var pt = Bytes(hex: "6363977DE839486297E661C6C9D668EB")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "816D5BD0FAE35342BF2A7412C246F752", "Twofish: Encrypt Keysize=128 I=5 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "6363977DE839486297E661C6C9D668EB", "Twofish: Decrypt Keysize=128 I=5 failed")
+//    }
+//
+//    func testKey128_6() throws {
+//        let key = Bytes(hex: "6363977DE839486297E661C6C9D668EB")!
+//        var pt = Bytes(hex: "816D5BD0FAE35342BF2A7412C246F752")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "5449ECA008FF5921155F598AF4CED4D0", "Twofish: Encrypt Keysize=128 I=6 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "816D5BD0FAE35342BF2A7412C246F752", "Twofish: Decrypt Keysize=128 I=6 failed")
+//    }
+//
+//    func testKey128_7() throws {
+//        let key = Bytes(hex: "816D5BD0FAE35342BF2A7412C246F752")!
+//        var pt = Bytes(hex: "5449ECA008FF5921155F598AF4CED4D0")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "6600522E97AEB3094ED5F92AFCBCDD10", "Twofish: Encrypt Keysize=128 I=7 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "5449ECA008FF5921155F598AF4CED4D0", "Twofish: Decrypt Keysize=128 I=7 failed")
+//    }
+//
+//    func testKey128_8() throws {
+//        let key = Bytes(hex: "5449ECA008FF5921155F598AF4CED4D0")!
+//        var pt = Bytes(hex: "6600522E97AEB3094ED5F92AFCBCDD10")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "34C8A5FB2D3D08A170D120AC6D26DBFA", "Twofish: Encrypt Keysize=128 I=8 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "6600522E97AEB3094ED5F92AFCBCDD10", "Twofish: Decrypt Keysize=128 I=8 failed")
+//    }
+//
+//    func testKey128_9() throws {
+//        let key = Bytes(hex: "6600522E97AEB3094ED5F92AFCBCDD10")!
+//        var pt = Bytes(hex: "34C8A5FB2D3D08A170D120AC6D26DBFA")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "28530B358C1B42EF277DE6D4407FC591", "Twofish: Encrypt Keysize=128 I=9 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "34C8A5FB2D3D08A170D120AC6D26DBFA", "Twofish: Decrypt Keysize=128 I=9 failed")
+//    }
+//
+//    func testKey128_10() throws {
+//        let key = Bytes(hex: "34C8A5FB2D3D08A170D120AC6D26DBFA")!
+//        var pt = Bytes(hex: "28530B358C1B42EF277DE6D4407FC591")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "8A8AB983310ED78C8C0ECDE030B8DCA4", "Twofish: Encrypt Keysize=128 I=10 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "28530B358C1B42EF277DE6D4407FC591", "Twofish: Decrypt Keysize=128 I=10 failed")
+//    }
+//
+//    func testKey192_1() throws {
+//        let key = Bytes(hex: "000000000000000000000000000000000000000000000000")!
+//        var pt = Bytes(hex: "00000000000000000000000000000000")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "EFA71F788965BD4453F860178FC19101", "Twofish: Encrypt Keysize=192 I=1 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "00000000000000000000000000000000", "Twofish: Decrypt Keysize=192 I=1 failed")
+//    }
+//
+//    func testKey192_2() throws {
+//        let key = Bytes(hex: "000000000000000000000000000000000000000000000000")!
+//        var pt = Bytes(hex: "EFA71F788965BD4453F860178FC19101")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "88B2B2706B105E36B446BB6D731A1E88", "Twofish: Encrypt Keysize=192 I=2 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "EFA71F788965BD4453F860178FC19101", "Twofish: Decrypt Keysize=192 I=2 failed")
+//    }
+//
+//    func testKey192_3() throws {
+//        let key = Bytes(hex: "EFA71F788965BD4453F860178FC191010000000000000000")!
+//        var pt = Bytes(hex: "88B2B2706B105E36B446BB6D731A1E88")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "39DA69D6BA4997D585B6DC073CA341B2", "Twofish: Encrypt Keysize=192 I=3 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "88B2B2706B105E36B446BB6D731A1E88", "Twofish: Decrypt Keysize=192 I=3 failed")
+//    }
+//
+//    func testKey192_4() throws {
+//        let key = Bytes(hex: "88B2B2706B105E36B446BB6D731A1E88EFA71F788965BD44")!
+//        var pt = Bytes(hex: "39DA69D6BA4997D585B6DC073CA341B2")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "182B02D81497EA45F9DAACDC29193A65", "Twofish: Encrypt Keysize=192 I=4 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "39DA69D6BA4997D585B6DC073CA341B2", "Twofish: Decrypt Keysize=192 I=4 failed")
+//    }
+//
+//    func testKey192_5() throws {
+//        let key = Bytes(hex: "39DA69D6BA4997D585B6DC073CA341B288B2B2706B105E36")!
+//        var pt = Bytes(hex: "182B02D81497EA45F9DAACDC29193A65")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "7AFF7A70CA2FF28AC31DD8AE5DAAAB63", "Twofish: Encrypt Keysize=192 I=5 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "182B02D81497EA45F9DAACDC29193A65", "Twofish: Decrypt Keysize=192 I=5 failed")
+//    }
+//
+//    func testKey192_6() throws {
+//        let key = Bytes(hex: "182B02D81497EA45F9DAACDC29193A6539DA69D6BA4997D5")!
+//        var pt = Bytes(hex: "7AFF7A70CA2FF28AC31DD8AE5DAAAB63")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "D1079B789F666649B6BD7D1629F1F77E", "Twofish: Encrypt Keysize=192 I=6 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "7AFF7A70CA2FF28AC31DD8AE5DAAAB63", "Twofish: Decrypt Keysize=192 I=6 failed")
+//    }
+//
+//    func testKey192_7() throws {
+//        let key = Bytes(hex: "7AFF7A70CA2FF28AC31DD8AE5DAAAB63182B02D81497EA45")!
+//        var pt = Bytes(hex: "D1079B789F666649B6BD7D1629F1F77E")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "3AF6F7CE5BD35EF18BEC6FA787AB506B", "Twofish: Encrypt Keysize=192 I=7 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "D1079B789F666649B6BD7D1629F1F77E", "Twofish: Decrypt Keysize=192 I=7 failed")
+//    }
+//
+//    func testKey192_8() throws {
+//        let key = Bytes(hex: "D1079B789F666649B6BD7D1629F1F77E7AFF7A70CA2FF28A")!
+//        var pt = Bytes(hex: "3AF6F7CE5BD35EF18BEC6FA787AB506B")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "AE8109BFDA85C1F2C5038B34ED691BFF", "Twofish: Encrypt Keysize=192 I=8 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "3AF6F7CE5BD35EF18BEC6FA787AB506B", "Twofish: Decrypt Keysize=192 I=8 failed")
+//    }
+//
+//    func testKey192_9() throws {
+//        let key = Bytes(hex: "3AF6F7CE5BD35EF18BEC6FA787AB506BD1079B789F666649")!
+//        var pt = Bytes(hex: "AE8109BFDA85C1F2C5038B34ED691BFF")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "893FD67B98C550073571BD631263FC78", "Twofish: Encrypt Keysize=192 I=9 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "AE8109BFDA85C1F2C5038B34ED691BFF", "Twofish: Decrypt Keysize=192 I=9 failed")
+//    }
+//
+//    func testKey192_10() throws {
+//        let key = Bytes(hex: "AE8109BFDA85C1F2C5038B34ED691BFF3AF6F7CE5BD35EF1")!
+//        var pt = Bytes(hex: "893FD67B98C550073571BD631263FC78")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "16434FC9C8841A63D58700B5578E8F67", "Twofish: Encrypt Keysize=192 I=10 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "893FD67B98C550073571BD631263FC78", "Twofish: Decrypt Keysize=192 I=10 failed")
+//    }
+//
+//    func testKey256_1() throws {
+//        let key = Bytes(hex: "0000000000000000000000000000000000000000000000000000000000000000")!
+//        var pt = Bytes(hex: "00000000000000000000000000000000")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "57FF739D4DC92C1BD7FC01700CC8216F", "Twofish: Encrypt Keysize=256 I=1 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "00000000000000000000000000000000", "Twofish: Decrypt Keysize=256 I=1 failed")
+//    }
+//
+//    func testKey256_2() throws {
+//        let key = Bytes(hex: "0000000000000000000000000000000000000000000000000000000000000000")!
+//        var pt = Bytes(hex: "57FF739D4DC92C1BD7FC01700CC8216F")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "D43BB7556EA32E46F2A282B7D45B4E0D", "Twofish: Encrypt Keysize=256 I=2 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "57FF739D4DC92C1BD7FC01700CC8216F", "Twofish: Decrypt Keysize=256 I=2 failed")
+//    }
+//
+//    func testKey256_3() throws {
+//        let key = Bytes(hex: "57FF739D4DC92C1BD7FC01700CC8216F00000000000000000000000000000000")!
+//        var pt = Bytes(hex: "D43BB7556EA32E46F2A282B7D45B4E0D")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "90AFE91BB288544F2C32DC239B2635E6", "Twofish: Encrypt Keysize=256 I=3 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "D43BB7556EA32E46F2A282B7D45B4E0D", "Twofish: Decrypt Keysize=256 I=3 failed")
+//    }
+//
+//    func testKey256_4() throws {
+//        let key = Bytes(hex: "D43BB7556EA32E46F2A282B7D45B4E0D57FF739D4DC92C1BD7FC01700CC8216F")!
+//        var pt = Bytes(hex: "90AFE91BB288544F2C32DC239B2635E6")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "6CB4561C40BF0A9705931CB6D408E7FA", "Twofish: Encrypt Keysize=256 I=4 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "90AFE91BB288544F2C32DC239B2635E6", "Twofish: Decrypt Keysize=256 I=4 failed")
+//    }
+//
+//    func testKey256_5() throws {
+//        let key = Bytes(hex: "90AFE91BB288544F2C32DC239B2635E6D43BB7556EA32E46F2A282B7D45B4E0D")!
+//        var pt = Bytes(hex: "6CB4561C40BF0A9705931CB6D408E7FA")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "3059D6D61753B958D92F4781C8640E58", "Twofish: Encrypt Keysize=256 I=5 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "6CB4561C40BF0A9705931CB6D408E7FA", "Twofish: Decrypt Keysize=256 I=5 failed")
+//    }
+//
+//    func testKey256_6() throws {
+//        let key = Bytes(hex: "6CB4561C40BF0A9705931CB6D408E7FA90AFE91BB288544F2C32DC239B2635E6")!
+//        var pt = Bytes(hex: "3059D6D61753B958D92F4781C8640E58")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "E69465770505D7F80EF68CA38AB3A3D6", "Twofish: Encrypt Keysize=256 I=6 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "3059D6D61753B958D92F4781C8640E58", "Twofish: Decrypt Keysize=256 I=6 failed")
+//    }
+//
+//    func testKey256_7() throws {
+//        let key = Bytes(hex: "3059D6D61753B958D92F4781C8640E586CB4561C40BF0A9705931CB6D408E7FA")!
+//        var pt = Bytes(hex: "E69465770505D7F80EF68CA38AB3A3D6")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "5AB67A5F8539A4A5FD9F0373BA463466", "Twofish: Encrypt Keysize=256 I=7 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "E69465770505D7F80EF68CA38AB3A3D6", "Twofish: Decrypt Keysize=256 I=7 failed")
+//    }
+//
+//    func testKey256_8() throws {
+//        let key = Bytes(hex: "E69465770505D7F80EF68CA38AB3A3D63059D6D61753B958D92F4781C8640E58")!
+//        var pt = Bytes(hex: "5AB67A5F8539A4A5FD9F0373BA463466")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "DC096BCD99FC72F79936D4C748E75AF7", "Twofish: Encrypt Keysize=256 I=8 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "5AB67A5F8539A4A5FD9F0373BA463466", "Twofish: Decrypt Keysize=256 I=8 failed")
+//    }
+//
+//    func testKey256_9() throws {
+//        let key = Bytes(hex: "5AB67A5F8539A4A5FD9F0373BA463466E69465770505D7F80EF68CA38AB3A3D6")!
+//        var pt = Bytes(hex: "DC096BCD99FC72F79936D4C748E75AF7")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "C5A3E7CEE0F1B7260528A68FB4EA05F2", "Twofish: Encrypt Keysize=256 I=9 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "DC096BCD99FC72F79936D4C748E75AF7", "Twofish: Decrypt Keysize=256 I=9 failed")
+//    }
+//
+//    func testKey256_10() throws {
+//        let key = Bytes(hex: "DC096BCD99FC72F79936D4C748E75AF75AB67A5F8539A4A5FD9F0373BA463466")!
+//        var pt = Bytes(hex: "C5A3E7CEE0F1B7260528A68FB4EA05F2")!
+//        let ct = try Twofish(key: key).encrypt(data: pt)
+//        XCTAssertEqual(ct.hexa.uppercased(), "43D5CEC327B24AB90AD34A79D0469151", "Twofish: Encrypt Keysize=256 I=10 failed")
+//
+//        pt = try Twofish(key: key).decrypt(data: ct)
+//        XCTAssertEqual(pt.hexa.uppercased(), "C5A3E7CEE0F1B7260528A68FB4EA05F2", "Twofish: Decrypt Keysize=256 I=10 failed")
+//    }
+
+    // static var allTests = [
+    //     ("testSalsa20", testSalsa20),
+    // ]
+
+}

+ 2 - 1
Tests/CryptoTests/XCTestManifests.swift

@@ -3,7 +3,8 @@ import XCTest
 #if !canImport(ObjectiveC)
 public func allTests() -> [XCTestCaseEntry] {
     return [
-        testCase(CryptoTests.allTests),
+        testCase(Chacha20Tests.allTests),
+        testCase(Salsa20Tests.allTests),
     ]
 }
 #endif