瀏覽代碼

Update tests

Marcin Krzyżanowski 8 年之前
父節點
當前提交
ea4d2355fe

+ 4 - 1
CryptoSwift.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

@@ -1,5 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
-<dict/>
+<dict>
+	<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
+	<false/>
+</dict>
 </plist>

+ 1 - 1
Sources/CryptoSwift/AES.swift

@@ -116,7 +116,7 @@ public final class AES: BlockCipher {
     /// - parameter key:       Key. Length of the key decides on AES variant.
     /// - parameter iv:        Initialization Vector (Optional for some blockMode values)
     /// - parameter blockMode: Cipher mode of operation
-    /// - parameter padding:   Padding method. PKCS7.Padding(), NoPadding(), ZeroPadding(), ...
+    /// - parameter padding:   Padding method. .pkcs7, .noPadding, .zeroPadding, ...
     ///
     /// - throws: AES.Error
     ///

+ 23 - 23
Tests/CryptoSwiftTests/AESTests.swift

@@ -17,7 +17,7 @@ final class AESTests: XCTestCase {
         let input: Array<UInt8> = [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]
         let expected: Array<UInt8> = [0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x4, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a]
 
-        let aes = try! AES(key: aesKey, blockMode: .ECB, padding: NoPadding())
+        let aes = try! AES(key: aesKey, blockMode: .ECB, padding: .noPadding)
         let encrypted = try! aes.encrypt(input)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -31,7 +31,7 @@ final class AESTests: XCTestCase {
 
         let expected: Array<UInt8> = [0xae, 0x8c, 0x59, 0x95, 0xb2, 0x6f, 0x8e, 0x3d, 0xb0, 0x6f, 0x0a, 0xa5, 0xfe, 0xc4, 0xf0, 0xc2]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .noPadding)
         let encrypted = try! aes.encrypt(input)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -44,7 +44,7 @@ final class AESTests: XCTestCase {
         let input: Array<UInt8> = [0x62, 0x72, 0x61, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
         let expected: Array<UInt8> = [0xae, 0x8c, 0x59, 0x95, 0xb2, 0x6f, 0x8e, 0x3d, 0xb0, 0x6f, 0x0a, 0xa5, 0xfe, 0xc4, 0xf0, 0xc2]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .noPadding)
         let encrypted = try! aes.encrypt(input)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -57,7 +57,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a]
         let expected: Array<UInt8> = [0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46, 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .noPadding)
         let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -70,7 +70,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a]
         let expected: Array<UInt8> = [0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46, 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d, 0x89, 0x64, 0xe0, 0xb1, 0x49, 0xc1, 0x0b, 0x7b, 0x68, 0x2e, 0x6e, 0x39, 0xaa, 0xeb, 0x73, 0x1c]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7)
         let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -82,7 +82,7 @@ final class AESTests: XCTestCase {
         let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7)
 
         var ciphertext = Array<UInt8>()
         var encryptor = aes.makeEncryptor()
@@ -113,7 +113,7 @@ final class AESTests: XCTestCase {
         let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
         let ciphertext: Array<UInt8> = [118, 73, 171, 172, 129, 25, 178, 70, 206, 233, 142, 155, 18, 233, 25, 125, 76, 187, 200, 88, 117, 107, 53, 129, 37, 82, 158, 150, 152, 163, 143, 68, 169, 105, 137, 234, 93, 98, 239, 215, 41, 45, 51, 254, 138, 92, 251, 17]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7)
         var plaintext = Array<UInt8>()
         var decryptor = aes.makeDecryptor()
         plaintext += try! decryptor.update(withBytes: ciphertext[0..<8])
@@ -129,7 +129,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a]
         let expected: Array<UInt8> = [0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CFB, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CFB, padding: .noPadding)
         let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -152,7 +152,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a]
         let expected: Array<UInt8> = [0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .OFB, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .OFB, padding: .noPadding)
         let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -165,7 +165,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a]
         let expected: Array<UInt8> = [0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b, 0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .OFB, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .OFB, padding: .noPadding)
         let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -178,7 +178,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a]
         let expected: Array<UInt8> = [0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba, 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .PCBC, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .PCBC, padding: .noPadding)
         let encrypted = try! aes.encrypt(plaintext)
         print(encrypted.toHexString())
         XCTAssertEqual(encrypted, expected, "encryption failed")
@@ -192,7 +192,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a]
         let expected: Array<UInt8> = [0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26, 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: .noPadding)
         let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted.count, plaintext.count)
         XCTAssertEqual(encrypted, expected, "encryption failed")
@@ -207,7 +207,7 @@ final class AESTests: XCTestCase {
         let iv: Array<UInt8> = [0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff]
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xfd]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: ZeroPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: .zeroPadding)
         let encrypted = try! aes.encrypt(plaintext)
 
         XCTAssertEqual(plaintext.count, 17)
@@ -220,7 +220,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0x01]
         let expected: Array<UInt8> = [0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26, 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce, 0x37]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: .noPadding)
         let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
         let decrypted = try! aes.decrypt(encrypted)
@@ -243,7 +243,7 @@ final class AESTests: XCTestCase {
             plaintext[i * 6 + 5] = "|".utf8.first!
         }
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: .noPadding)
         let encrypted = try! aes.encrypt(plaintext)
 
         var decryptor = aes.makeDecryptor()
@@ -275,7 +275,7 @@ final class AESTests: XCTestCase {
         let plaintext: Array<UInt8> = [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0x01, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0x01]
         let expected: Array<UInt8> = [0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26, 0x1b, 0xef, 0x68, 0x64, 0x99, 0xd, 0xb6, 0xce, 0x37, 0x40, 0xbd, 0x82, 0x85, 0x5d, 0x11, 0xfc, 0x8e, 0x49, 0x4a, 0xa9, 0xed, 0x23, 0xe0, 0xb9, 0x40, 0x2d]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: NoPadding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CTR, padding: .noPadding)
         var encryptor = aes.makeEncryptor()
         var encrypted = Array<UInt8>()
         encrypted += try! encryptor.update(withBytes: plaintext[0..<5])
@@ -299,8 +299,8 @@ final class AESTests: XCTestCase {
         let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
         let plaintext: Array<UInt8> = [49, 46, 50, 50, 50, 51, 51, 51, 51]
 
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding())
-        let aes2 = try! AES(key: key2, iv: iv, blockMode: .CBC, padding: PKCS7.Padding())
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7)
+        let aes2 = try! AES(key: key2, iv: iv, blockMode: .CBC, padding: .pkcs7)
         let encrypted = try! aes.encrypt(plaintext)
         let decrypted = try? aes2.decrypt(encrypted)
         XCTAssertTrue(decrypted! != plaintext, "failed")
@@ -314,7 +314,7 @@ final class AESTests: XCTestCase {
         let iv = "fedcba9876543210"
 
         do {
-            let aes = try AES(key: key, iv: iv, blockMode: .CBC, padding: NoPadding())
+            let aes = try AES(key: key, iv: iv, blockMode: .CBC, padding: .noPadding)
             let ciphertext = try aes.decrypt(Array<UInt8>(hex: encryptedValue))
             XCTAssertEqual(ciphertext, expected)
         } catch {
@@ -327,7 +327,7 @@ final class AESTests: XCTestCase {
         let plaintext = Array("Nullam quis risus eget urna mollis ornare vel eu leo.".utf8)
         let key = Array("passwordpassword".utf8).md5() // -md md5
         let iv = Array("drowssapdrowssap".utf8) // -iv 64726f777373617064726f7773736170
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding()) // -aes-128-cbc
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7) // -aes-128-cbc
         let ciphertext = try! aes.encrypt(plaintext) // enc
 
         // $ echo -n "Nullam quis risus eget urna mollis ornare vel eu leo." | openssl enc -aes-128-cbc -md md5 -nosalt -iv 64726f777373617064726f7773736170 -pass pass:passwordpassword -base64
@@ -341,7 +341,7 @@ final class AESTests: XCTestCase {
         let ciphertext: Array<UInt8> = [0x2a, 0x3a, 0x80, 0x05, 0xaf, 0x46, 0x58, 0x2d, 0x66, 0x52, 0x10, 0xae, 0x86, 0xd3, 0x8e, 0x8f] // test
         let key = Array("passwordpassword".utf8).md5() // -md md5
         let iv = Array("drowssapdrowssap".utf8) // -iv 64726f777373617064726f7773736170
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding()) // -aes-128-cbc
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7) // -aes-128-cbc
         let plaintext = try! ciphertext.decrypt(cipher: aes)
         XCTAssertEqual("74657374", plaintext.toHexString())
     }
@@ -355,7 +355,7 @@ final class AESTests: XCTestCase {
             let key: Array<UInt8> = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
             let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
             let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
-            let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding())
+            let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7)
             measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true, for: { () -> Void in
                 _ = try! aes.encrypt(message)
             })
@@ -365,7 +365,7 @@ final class AESTests: XCTestCase {
             let key: Array<UInt8> = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
             let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
             let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
-            let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding())
+            let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7)
             measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true, for: { () -> Void in
                 _ = try! aes.decrypt(message)
             })

+ 2 - 2
Tests/CryptoSwiftTests/Access.swift

@@ -194,7 +194,7 @@ class Access: XCTestCase {
             let enc = try cipher.encrypt([1, 2, 3])
             _ = try cipher.decrypt(enc)
 
-            _ = try AES(key: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6], iv: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6], blockMode: .CBC, padding: NoPadding())
+            _ = try AES(key: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6], iv: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6], blockMode: .CBC, padding: .noPadding)
 
             _ = AES.Variant.aes128
             _ = AES.blockSize
@@ -209,7 +209,7 @@ class Access: XCTestCase {
             let enc = try cipher.encrypt([1, 2, 3])
             _ = try cipher.decrypt(enc)
 
-            _ = try Blowfish(key: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6], iv: [1, 2, 3, 4, 5, 6, 7, 8], blockMode: .CBC, padding: NoPadding())
+            _ = try Blowfish(key: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6], iv: [1, 2, 3, 4, 5, 6, 7, 8], blockMode: .CBC, padding: .noPadding)
 
             _ = Blowfish.blockSize
         } catch {

+ 6 - 6
Tests/CryptoSwiftTests/BlowfishTests.swift

@@ -156,13 +156,13 @@ class BlowfishTests: XCTestCase {
 
     func testEncrypt() {
         for test in tests {
-            XCTAssertEqual(try Blowfish(key: test.key, blockMode: .ECB, padding: NoPadding()).encrypt(test.input), test.output)
+            XCTAssertEqual(try Blowfish(key: test.key, blockMode: .ECB, padding: .noPadding).encrypt(test.input), test.output)
         }
     }
 
     func testDecrypt() {
         for test in tests {
-            XCTAssertEqual(try Blowfish(key: test.key, blockMode: .ECB, padding: NoPadding()).decrypt(test.output), test.input)
+            XCTAssertEqual(try Blowfish(key: test.key, blockMode: .ECB, padding: .noPadding).decrypt(test.output), test.input)
         }
     }
 
@@ -170,7 +170,7 @@ class BlowfishTests: XCTestCase {
         let key = Array<UInt8>.init(hex: "0123456789ABCDEFF0E1D2C3B4A59687")
         let iv = Array<UInt8>.init(hex: "FEDCBA9876543210")
         let input = Array<UInt8>.init(hex: "37363534333231204E6F77206973207468652074696D6520666F722000")
-        XCTAssertEqual(try Blowfish(key: key, iv: iv, blockMode: .CBC, padding: ZeroPadding()).encrypt(input), Array<UInt8>(hex: "6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC"))
+        XCTAssertEqual(try Blowfish(key: key, iv: iv, blockMode: .CBC, padding: .zeroPadding).encrypt(input), Array<UInt8>(hex: "6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC"))
     }
 
     func testEncryptDecrypt() {
@@ -179,7 +179,7 @@ class BlowfishTests: XCTestCase {
         let input = Array<UInt8>.init(hex: "37363534333231204E6F77206973207468652074696D6520666F722000")
 
         do {
-            let cipher = try Blowfish(key: key, iv: iv, blockMode: .CBC, padding: PKCS7.Padding())
+            let cipher = try Blowfish(key: key, iv: iv, blockMode: .CBC, padding: .pkcs7)
             let ciphertext = try cipher.encrypt(input)
             let plaintext = try cipher.decrypt(ciphertext)
             XCTAssertEqual(plaintext, input)
@@ -192,8 +192,8 @@ class BlowfishTests: XCTestCase {
     func testDecryptCFB415() {
         do {
             let plaintext = Array("secret12".utf8)
-            let encrypted = try Blowfish(key: "passwordpassword", iv: "12345678", blockMode: .CFB, padding: NoPadding()).encrypt(plaintext)
-            let decrypted = try Blowfish(key: "passwordpassword", iv: "12345678", blockMode: .CFB, padding: NoPadding()).decrypt(encrypted)
+            let encrypted = try Blowfish(key: "passwordpassword", iv: "12345678", blockMode: .CFB, padding: .noPadding).encrypt(plaintext)
+            let decrypted = try Blowfish(key: "passwordpassword", iv: "12345678", blockMode: .CFB, padding: .noPadding).decrypt(encrypted)
             XCTAssertEqual(plaintext, decrypted)
         } catch {
             XCTFail(error.localizedDescription)