Bläddra i källkod

Move padding parameter to AES constructor.
Add NoPadding to imitate no padding operation.

Marcin Krzyżanowski 9 år sedan
förälder
incheckning
88412d595f

+ 10 - 0
CryptoSwift.xcodeproj/project.pbxproj

@@ -13,6 +13,10 @@
 		54EE1C661C2199C8008DD2E5 /* CryptoSwift.h in Headers */ = {isa = PBXBuildFile; fileRef = 54EE1C621C2199B2008DD2E5 /* CryptoSwift.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		674A736F1BF5D85B00866C5B /* RabbitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 674A736E1BF5D85B00866C5B /* RabbitTests.swift */; };
 		75100F8F19B0BC890005C5F5 /* Poly1305Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75100F8E19B0BC890005C5F5 /* Poly1305Tests.swift */; };
+		753881EB1CB06E390089101D /* NoPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753881EA1CB06E390089101D /* NoPadding.swift */; };
+		753881EC1CB06E390089101D /* NoPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753881EA1CB06E390089101D /* NoPadding.swift */; };
+		753881ED1CB06E390089101D /* NoPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753881EA1CB06E390089101D /* NoPadding.swift */; };
+		753881EE1CB06E390089101D /* NoPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753881EA1CB06E390089101D /* NoPadding.swift */; };
 		754BE46819693E190098E6F3 /* HashTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754BE46719693E190098E6F3 /* HashTests.swift */; };
 		754C9D1B1C30800A0003D5FE /* String+LinuxFoundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754C9D1A1C30800A0003D5FE /* String+LinuxFoundation.swift */; };
 		754C9D1C1C30800A0003D5FE /* String+LinuxFoundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754C9D1A1C30800A0003D5FE /* String+LinuxFoundation.swift */; };
@@ -303,6 +307,7 @@
 		5596BDBB1BC8F220007E38D5 /* CryptoSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CryptoSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		674A736E1BF5D85B00866C5B /* RabbitTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RabbitTests.swift; sourceTree = "<group>"; };
 		75100F8E19B0BC890005C5F5 /* Poly1305Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Poly1305Tests.swift; sourceTree = "<group>"; };
+		753881EA1CB06E390089101D /* NoPadding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NoPadding.swift; path = Sources/CryptoSwift/NoPadding.swift; sourceTree = SOURCE_ROOT; };
 		754BE45519693E190098E6F3 /* CryptoSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CryptoSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		754BE46019693E190098E6F3 /* CryptoSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CryptoSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
 		754BE46619693E190098E6F3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -462,6 +467,7 @@
 				757BC9301C1CA5790093AAA9 /* Padding.swift */,
 				757BC9311C1CA5790093AAA9 /* PKCS5.swift */,
 				757BC9321C1CA5790093AAA9 /* PKCS7.swift */,
+				753881EA1CB06E390089101D /* NoPadding.swift */,
 				757BC9331C1CA5790093AAA9 /* Poly1305.swift */,
 				757BC9341C1CA5790093AAA9 /* Rabbit.swift */,
 				757BC9351C1CA5790093AAA9 /* SHA1.swift */,
@@ -794,6 +800,7 @@
 				757BC9A11C1CA5790093AAA9 /* Poly1305.swift in Sources */,
 				75CB93451C8F603C0087740D /* CTR.swift in Sources */,
 				757BC9451C1CA5790093AAA9 /* ArraySliceUInt8+Bytes.swift in Sources */,
+				753881EC1CB06E390089101D /* NoPadding.swift in Sources */,
 				758F58F21C8FB6E20054C377 /* OFB.swift in Sources */,
 				757BC9BD1C1CA5790093AAA9 /* UInt64Extension.swift in Sources */,
 				757BC9991C1CA5790093AAA9 /* PKCS5.swift in Sources */,
@@ -849,6 +856,7 @@
 				75CB93441C8F603C0087740D /* CTR.swift in Sources */,
 				757BC9441C1CA5790093AAA9 /* ArraySliceUInt8+Bytes.swift in Sources */,
 				757BC9BC1C1CA5790093AAA9 /* UInt64Extension.swift in Sources */,
+				753881EB1CB06E390089101D /* NoPadding.swift in Sources */,
 				758F58F11C8FB6E20054C377 /* OFB.swift in Sources */,
 				757BC9981C1CA5790093AAA9 /* PKCS5.swift in Sources */,
 				75CB934E1C8F609D0087740D /* BlockModeOptions.swift in Sources */,
@@ -920,6 +928,7 @@
 				757BC9A21C1CA5790093AAA9 /* Poly1305.swift in Sources */,
 				75CB93461C8F603C0087740D /* CTR.swift in Sources */,
 				757BC9461C1CA5790093AAA9 /* ArraySliceUInt8+Bytes.swift in Sources */,
+				753881EE1CB06E390089101D /* NoPadding.swift in Sources */,
 				758F58F31C8FB6E20054C377 /* OFB.swift in Sources */,
 				757BC9BE1C1CA5790093AAA9 /* UInt64Extension.swift in Sources */,
 				757BC99A1C1CA5790093AAA9 /* PKCS5.swift in Sources */,
@@ -975,6 +984,7 @@
 				757BC9A31C1CA5790093AAA9 /* Poly1305.swift in Sources */,
 				75CB93471C8F603C0087740D /* CTR.swift in Sources */,
 				757BC9471C1CA5790093AAA9 /* ArraySliceUInt8+Bytes.swift in Sources */,
+				753881ED1CB06E390089101D /* NoPadding.swift in Sources */,
 				758F58F41C8FB6E20054C377 /* OFB.swift in Sources */,
 				757BC9BF1C1CA5790093AAA9 /* UInt64Extension.swift in Sources */,
 				757BC99B1C1CA5790093AAA9 /* PKCS5.swift in Sources */,

+ 41 - 41
CryptoSwiftTests/AESTests.swift

@@ -19,10 +19,10 @@ final class AESTests: XCTestCase {
         
         let expected:[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)
-        let encrypted = try! aes.encrypt(input, padding: nil)
+        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, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, input, "decryption failed")
     }
 
@@ -33,10 +33,10 @@ final class AESTests: XCTestCase {
         
         let expected:[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)
-        let encrypted = try! aes.encrypt(input, padding: nil)
+        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, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, input, "decryption failed")
     }
     
@@ -51,10 +51,10 @@ final class AESTests: XCTestCase {
             0xd8, 0xcd, 0xb7, 0x80,
             0x70, 0xb4, 0xc5, 0x5a];
         
-        let aes = try! AES(key: aesKey, blockMode: .ECB)
-        let encrypted = try! aes.encrypt(input, padding: nil)
+        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, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, input, "decryption failed")
     }
 
@@ -64,11 +64,11 @@ final class AESTests: XCTestCase {
         let plaintext:[UInt8] = [0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a]
         let expected:[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)
+        let aes = try! AES(key: key, iv:iv, blockMode: .CBC, padding: NoPadding())
         XCTAssertTrue(aes.blockMode == .CBC, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: nil)
+        let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
-        let decrypted = try! aes.decrypt(encrypted, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, plaintext, "decryption failed")
     }
 
@@ -78,11 +78,11 @@ final class AESTests: XCTestCase {
         let plaintext:[UInt8] = [0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a]
         let expected:[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)
+        let aes = try! AES(key: key, iv:iv, blockMode: .CBC, padding: PKCS7())
         XCTAssertTrue(aes.blockMode == .CBC, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: PKCS7())
+        let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
-        let decrypted = try! aes.decrypt(encrypted, padding: PKCS7())
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, plaintext, "decryption failed")
     }
     
@@ -92,11 +92,11 @@ final class AESTests: XCTestCase {
         let plaintext:[UInt8] = [0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a]
         let expected:[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)
+        let aes = try! AES(key: key, iv:iv, blockMode: .CFB, padding: NoPadding())
         XCTAssertTrue(aes.blockMode == .CFB, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: nil)
+        let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
-        let decrypted = try! aes.decrypt(encrypted, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, plaintext, "decryption failed")
     }
 
@@ -116,11 +116,11 @@ final class AESTests: XCTestCase {
         let plaintext:[UInt8] = [0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a]
         let expected:[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)
+        let aes = try! AES(key: key, iv:iv, blockMode: .OFB, padding: NoPadding())
         XCTAssertTrue(aes.blockMode == .OFB, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: nil)
+        let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
-        let decrypted = try! aes.decrypt(encrypted, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, plaintext, "decryption failed")
     }
 
@@ -130,11 +130,11 @@ final class AESTests: XCTestCase {
         let plaintext: [UInt8] = [0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a]
         let expected:[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)
+        let aes = try! AES(key: key, iv:iv, blockMode: .OFB, padding: NoPadding())
         XCTAssertTrue(aes.blockMode == .OFB, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: nil)
+        let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
-        let decrypted = try! aes.decrypt(encrypted, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, plaintext, "decryption failed")
     }
 
@@ -144,12 +144,12 @@ final class AESTests: XCTestCase {
         let plaintext: [UInt8] = [0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a]
         let expected:[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)
+        let aes = try! AES(key: key, iv:iv, blockMode: .PCBC, padding: NoPadding())
         XCTAssertTrue(aes.blockMode == .PCBC, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: nil)
+        let encrypted = try! aes.encrypt(plaintext)
         print(encrypted.toHexString())
         XCTAssertEqual(encrypted, expected, "encryption failed")
-        let decrypted = try! aes.decrypt(encrypted, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, plaintext, "decryption failed")
     }
 
@@ -159,11 +159,11 @@ final class AESTests: XCTestCase {
         let plaintext:[UInt8] = [0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a]
         let expected:[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)
+        let aes = try! AES(key: key, iv:iv, blockMode: .CTR, padding: NoPadding())
         XCTAssertTrue(aes.blockMode == .CTR, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: nil)
+        let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
-        let decrypted = try! aes.decrypt(encrypted, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, plaintext, "decryption failed")
     }
 
@@ -173,11 +173,11 @@ final class AESTests: XCTestCase {
         let plaintext:[UInt8] = [0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,0x01]
         let expected:[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)
+        let aes = try! AES(key: key, iv:iv, blockMode: .CTR, padding: NoPadding())
         XCTAssertTrue(aes.blockMode == .CTR, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: nil)
+        let encrypted = try! aes.encrypt(plaintext)
         XCTAssertEqual(encrypted, expected, "encryption failed")
-        let decrypted = try! aes.decrypt(encrypted, padding: nil)
+        let decrypted = try! aes.decrypt(encrypted)
         XCTAssertEqual(decrypted, plaintext, "decryption failed")
     }
 
@@ -185,9 +185,9 @@ final class AESTests: XCTestCase {
         let key:[UInt8] = [0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c];
         let iv:[UInt8] = [0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F]
         let message = [UInt8](count: 1024 * 1024, repeatedValue: 7)
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC)
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7())
         measureMetrics([XCTPerformanceMetric_WallClockTime], automaticallyStartMeasuring: true, forBlock: { () -> Void in
-            try! aes.encrypt(message, padding: PKCS7())
+            try! aes.encrypt(message)
         })
     }
 
@@ -195,9 +195,9 @@ final class AESTests: XCTestCase {
         let key:[UInt8] = [0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c];
         let iv:[UInt8] = [0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F]
         let message = [UInt8](count: 1024 * 1024, repeatedValue: 7)
-        let aes = try! AES(key: key, iv: iv, blockMode: .CBC)
+        let aes = try! AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7())
         measureMetrics([XCTPerformanceMetric_WallClockTime], automaticallyStartMeasuring: true, forBlock: { () -> Void in
-            try! aes.decrypt(message, padding: PKCS7())
+            try! aes.decrypt(message)
         })
     }
 
@@ -246,11 +246,11 @@ final class AESTests: XCTestCase {
         let iv:[UInt8] = [0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F]
         let plaintext:[UInt8] = [49, 46, 50, 50, 50, 51, 51, 51, 51]
 
-        let aes = try! AES(key: key, iv:iv, blockMode: .CBC)
-        let aes2 = try! AES(key: key2, iv:iv, blockMode: .CBC)
+        let aes = try! AES(key: key, iv:iv, blockMode: .CBC, padding: PKCS7())
+        let aes2 = try! AES(key: key2, iv:iv, blockMode: .CBC, padding: PKCS7())
         XCTAssertTrue(aes.blockMode == .CBC, "Invalid block mode")
-        let encrypted = try! aes.encrypt(plaintext, padding: PKCS7())
-        let decrypted = try? aes2.decrypt(encrypted, padding: PKCS7())
+        let encrypted = try! aes.encrypt(plaintext)
+        let decrypted = try? aes2.decrypt(encrypted)
         XCTAssertTrue(decrypted! != plaintext, "failed")
     }
 

+ 3 - 3
README.md

@@ -235,8 +235,8 @@ let key: [UInt8] = [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 let iv: [UInt8] = AES.randomIV(AES.blockSize)
 
 do {
-    let encrypted: [UInt8] = try AES(key: key, iv: iv, blockMode: .CBC).encrypt(input, padding: PKCS7())
-    let decrypted: [UInt8] = try AES(key: key, iv: iv, blockMode: .CBC).decrypt(encrypted, padding: PKCS7())
+    let encrypted: [UInt8] = try AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7()).encrypt(input)
+    let decrypted: [UInt8] = try AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7()).decrypt(encrypted)
 } catch AES.Error.BlockSizeExceeded {
     // block size exceeded
 } catch {
@@ -248,7 +248,7 @@ AES without data padding
 
 ```swift
 let input: [UInt8] = [0,1,2,3,4,5,6,7,8,9]
-let encrypted: [UInt8] = try! AES(key: "secret0key000000", iv:"0123456789012345", blockMode: .CBC).encrypt(input, padding: nil)
+let encrypted: [UInt8] = try! AES(key: "secret0key000000", iv:"0123456789012345", blockMode: .CBC, padding: NoPadding()).encrypt(input)
 ```
 
 Using extensions

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 1
Sources/CryptoSwift/AES.swift


+ 2 - 2
Sources/CryptoSwift/Foundation/AES+Foundation.swift

@@ -9,11 +9,11 @@
 import Foundation
 
 extension AES {
-    convenience public init(key:String, iv:String, blockMode:CipherBlockMode = .CBC) throws {
+    convenience public init(key:String, iv:String, blockMode:CipherBlockMode = .CBC, padding: Padding = PKCS7()) throws {
         guard let kkey = key.bridge().dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)?.arrayOfBytes(), let iiv = iv.bridge().dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)?.arrayOfBytes() else {
             throw Error.InvalidKeyOrInitializationVector
         }
         
-        try self.init(key: kkey, iv: iiv, blockMode: blockMode)
+        try self.init(key: kkey, iv: iiv, blockMode: blockMode, padding: padding)
     }
 }

+ 17 - 0
Sources/CryptoSwift/NoPadding.swift

@@ -0,0 +1,17 @@
+//
+//  NoPadding.swift
+//  CryptoSwift
+//
+//  Created by Marcin Krzyzanowski on 02/04/16.
+//  Copyright © 2016 Marcin Krzyzanowski. All rights reserved.
+//
+
+public struct NoPadding: Padding {
+    public func add(data: [UInt8], blockSize:Int) -> [UInt8] {
+        return data;
+    }
+
+    public func remove(data: [UInt8], blockSize:Int?) -> [UInt8] {
+        return data;
+    }
+}

Vissa filer visades inte eftersom för många filer har ändrats