Răsfoiți Sursa

UpdatableCryptor -> Updatable

Marcin Krzyżanowski 9 ani în urmă
părinte
comite
cb7ff5a669

+ 10 - 10
CryptoSwift.xcodeproj/project.pbxproj

@@ -243,10 +243,10 @@
 		75DB81A41CDBFDC700ED181A /* BlockModeWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A21CDBFDC700ED181A /* BlockModeWorker.swift */; };
 		75DB81A41CDBFDC700ED181A /* BlockModeWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A21CDBFDC700ED181A /* BlockModeWorker.swift */; };
 		75DB81A51CDBFDC700ED181A /* BlockModeWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A21CDBFDC700ED181A /* BlockModeWorker.swift */; };
 		75DB81A51CDBFDC700ED181A /* BlockModeWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A21CDBFDC700ED181A /* BlockModeWorker.swift */; };
 		75DB81A61CDBFDC700ED181A /* BlockModeWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A21CDBFDC700ED181A /* BlockModeWorker.swift */; };
 		75DB81A61CDBFDC700ED181A /* BlockModeWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A21CDBFDC700ED181A /* BlockModeWorker.swift */; };
-		75DB81A81CDC06B100ED181A /* UpdatableCryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A71CDC06B100ED181A /* UpdatableCryptor.swift */; };
-		75DB81A91CDC06B100ED181A /* UpdatableCryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A71CDC06B100ED181A /* UpdatableCryptor.swift */; };
-		75DB81AA1CDC06B100ED181A /* UpdatableCryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A71CDC06B100ED181A /* UpdatableCryptor.swift */; };
-		75DB81AB1CDC06B100ED181A /* UpdatableCryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A71CDC06B100ED181A /* UpdatableCryptor.swift */; };
+		75DB81A81CDC06B100ED181A /* Updatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A71CDC06B100ED181A /* Updatable.swift */; };
+		75DB81A91CDC06B100ED181A /* Updatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A71CDC06B100ED181A /* Updatable.swift */; };
+		75DB81AA1CDC06B100ED181A /* Updatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A71CDC06B100ED181A /* Updatable.swift */; };
+		75DB81AB1CDC06B100ED181A /* Updatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DB81A71CDC06B100ED181A /* Updatable.swift */; };
 		80545D131CA9FECD00474A99 /* Bit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80545D121CA9FECD00474A99 /* Bit.swift */; };
 		80545D131CA9FECD00474A99 /* Bit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80545D121CA9FECD00474A99 /* Bit.swift */; };
 		80545D141CA9FECD00474A99 /* Bit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80545D121CA9FECD00474A99 /* Bit.swift */; };
 		80545D141CA9FECD00474A99 /* Bit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80545D121CA9FECD00474A99 /* Bit.swift */; };
 		80545D151CA9FECD00474A99 /* Bit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80545D121CA9FECD00474A99 /* Bit.swift */; };
 		80545D151CA9FECD00474A99 /* Bit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80545D121CA9FECD00474A99 /* Bit.swift */; };
@@ -410,7 +410,7 @@
 		75D1F1F31D06B98B005A87A2 /* PBKDF1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PBKDF1.swift; path = Sources/CryptoSwift/PKCS5/PBKDF1.swift; sourceTree = SOURCE_ROOT; };
 		75D1F1F31D06B98B005A87A2 /* PBKDF1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PBKDF1.swift; path = Sources/CryptoSwift/PKCS5/PBKDF1.swift; sourceTree = SOURCE_ROOT; };
 		75D614BF1BD844F2001358B2 /* CryptoSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CryptoSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		75D614BF1BD844F2001358B2 /* CryptoSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CryptoSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		75DB81A21CDBFDC700ED181A /* BlockModeWorker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BlockModeWorker.swift; path = Sources/CryptoSwift/BlockMode/BlockModeWorker.swift; sourceTree = SOURCE_ROOT; };
 		75DB81A21CDBFDC700ED181A /* BlockModeWorker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BlockModeWorker.swift; path = Sources/CryptoSwift/BlockMode/BlockModeWorker.swift; sourceTree = SOURCE_ROOT; };
-		75DB81A71CDC06B100ED181A /* UpdatableCryptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UpdatableCryptor.swift; path = Sources/CryptoSwift/UpdatableCryptor.swift; sourceTree = SOURCE_ROOT; };
+		75DB81A71CDC06B100ED181A /* Updatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Updatable.swift; path = Sources/CryptoSwift/Updatable.swift; sourceTree = SOURCE_ROOT; };
 		75DF77721BC8EB59006E9520 /* CryptoSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CryptoSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		75DF77721BC8EB59006E9520 /* CryptoSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CryptoSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		80545D121CA9FECD00474A99 /* Bit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Bit.swift; path = Sources/CryptoSwift/Bit.swift; sourceTree = SOURCE_ROOT; };
 		80545D121CA9FECD00474A99 /* Bit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Bit.swift; path = Sources/CryptoSwift/Bit.swift; sourceTree = SOURCE_ROOT; };
 /* End PBXFileReference section */
 /* End PBXFileReference section */
@@ -505,7 +505,7 @@
 				757F440D1CC1822A002B1F85 /* SecureBytes.swift */,
 				757F440D1CC1822A002B1F85 /* SecureBytes.swift */,
 				757BC91F1C1CA5790093AAA9 /* BytesSequence.swift */,
 				757BC91F1C1CA5790093AAA9 /* BytesSequence.swift */,
 				755655C61D080E3F00F004E7 /* Cryptors.swift */,
 				755655C61D080E3F00F004E7 /* Cryptors.swift */,
-				75DB81A71CDC06B100ED181A /* UpdatableCryptor.swift */,
+				75DB81A71CDC06B100ED181A /* Updatable.swift */,
 				75558FCB1D4BA93C00CF6C18 /* RandomAccessCryptor.swift */,
 				75558FCB1D4BA93C00CF6C18 /* RandomAccessCryptor.swift */,
 				75CB93291C8F5EC60087740D /* BlockMode */,
 				75CB93291C8F5EC60087740D /* BlockMode */,
 				757BC9231C1CA5790093AAA9 /* CRC.swift */,
 				757BC9231C1CA5790093AAA9 /* CRC.swift */,
@@ -885,7 +885,7 @@
 				757BC9811C1CA5790093AAA9 /* IntegerConvertible.swift in Sources */,
 				757BC9811C1CA5790093AAA9 /* IntegerConvertible.swift in Sources */,
 				757BC9511C1CA5790093AAA9 /* BytesSequence.swift in Sources */,
 				757BC9511C1CA5790093AAA9 /* BytesSequence.swift in Sources */,
 				757BC9891C1CA5790093AAA9 /* MD5.swift in Sources */,
 				757BC9891C1CA5790093AAA9 /* MD5.swift in Sources */,
-				75DB81A91CDC06B100ED181A /* UpdatableCryptor.swift in Sources */,
+				75DB81A91CDC06B100ED181A /* Updatable.swift in Sources */,
 				757BC9A91C1CA5790093AAA9 /* SHA1.swift in Sources */,
 				757BC9A91C1CA5790093AAA9 /* SHA1.swift in Sources */,
 				75D1F1F51D06B98B005A87A2 /* PBKDF1.swift in Sources */,
 				75D1F1F51D06B98B005A87A2 /* PBKDF1.swift in Sources */,
 				755655C81D080E3F00F004E7 /* Cryptors.swift in Sources */,
 				755655C81D080E3F00F004E7 /* Cryptors.swift in Sources */,
@@ -950,7 +950,7 @@
 				757BC9501C1CA5790093AAA9 /* BytesSequence.swift in Sources */,
 				757BC9501C1CA5790093AAA9 /* BytesSequence.swift in Sources */,
 				757BC9881C1CA5790093AAA9 /* MD5.swift in Sources */,
 				757BC9881C1CA5790093AAA9 /* MD5.swift in Sources */,
 				757BC9A81C1CA5790093AAA9 /* SHA1.swift in Sources */,
 				757BC9A81C1CA5790093AAA9 /* SHA1.swift in Sources */,
-				75DB81A81CDC06B100ED181A /* UpdatableCryptor.swift in Sources */,
+				75DB81A81CDC06B100ED181A /* Updatable.swift in Sources */,
 				75D1F1F41D06B98B005A87A2 /* PBKDF1.swift in Sources */,
 				75D1F1F41D06B98B005A87A2 /* PBKDF1.swift in Sources */,
 				755655C71D080E3F00F004E7 /* Cryptors.swift in Sources */,
 				755655C71D080E3F00F004E7 /* Cryptors.swift in Sources */,
 				757BC9901C1CA5790093AAA9 /* Operators.swift in Sources */,
 				757BC9901C1CA5790093AAA9 /* Operators.swift in Sources */,
@@ -1030,7 +1030,7 @@
 				757BC9821C1CA5790093AAA9 /* IntegerConvertible.swift in Sources */,
 				757BC9821C1CA5790093AAA9 /* IntegerConvertible.swift in Sources */,
 				757BC9521C1CA5790093AAA9 /* BytesSequence.swift in Sources */,
 				757BC9521C1CA5790093AAA9 /* BytesSequence.swift in Sources */,
 				757BC98A1C1CA5790093AAA9 /* MD5.swift in Sources */,
 				757BC98A1C1CA5790093AAA9 /* MD5.swift in Sources */,
-				75DB81AB1CDC06B100ED181A /* UpdatableCryptor.swift in Sources */,
+				75DB81AB1CDC06B100ED181A /* Updatable.swift in Sources */,
 				757BC9AA1C1CA5790093AAA9 /* SHA1.swift in Sources */,
 				757BC9AA1C1CA5790093AAA9 /* SHA1.swift in Sources */,
 				75D1F1F71D06B98B005A87A2 /* PBKDF1.swift in Sources */,
 				75D1F1F71D06B98B005A87A2 /* PBKDF1.swift in Sources */,
 				755655CA1D080E3F00F004E7 /* Cryptors.swift in Sources */,
 				755655CA1D080E3F00F004E7 /* Cryptors.swift in Sources */,
@@ -1094,7 +1094,7 @@
 				757BC9831C1CA5790093AAA9 /* IntegerConvertible.swift in Sources */,
 				757BC9831C1CA5790093AAA9 /* IntegerConvertible.swift in Sources */,
 				757BC9531C1CA5790093AAA9 /* BytesSequence.swift in Sources */,
 				757BC9531C1CA5790093AAA9 /* BytesSequence.swift in Sources */,
 				757BC98B1C1CA5790093AAA9 /* MD5.swift in Sources */,
 				757BC98B1C1CA5790093AAA9 /* MD5.swift in Sources */,
-				75DB81AA1CDC06B100ED181A /* UpdatableCryptor.swift in Sources */,
+				75DB81AA1CDC06B100ED181A /* Updatable.swift in Sources */,
 				757BC9AB1C1CA5790093AAA9 /* SHA1.swift in Sources */,
 				757BC9AB1C1CA5790093AAA9 /* SHA1.swift in Sources */,
 				75D1F1F61D06B98B005A87A2 /* PBKDF1.swift in Sources */,
 				75D1F1F61D06B98B005A87A2 /* PBKDF1.swift in Sources */,
 				755655C91D080E3F00F004E7 /* Cryptors.swift in Sources */,
 				755655C91D080E3F00F004E7 /* Cryptors.swift in Sources */,

+ 1 - 1
Sources/CryptoSwift/AES.swift

@@ -391,7 +391,7 @@ extension AES {
 
 
 // MARK: Encryptor
 // MARK: Encryptor
 extension AES {
 extension AES {
-    public struct Encryptor: UpdatableCryptor {
+    public struct Encryptor: Updatable {
         private var worker: BlockModeWorker
         private var worker: BlockModeWorker
         private let padding: Padding
         private let padding: Padding
         private var accumulated = Array<UInt8>()
         private var accumulated = Array<UInt8>()

+ 2 - 2
Sources/CryptoSwift/ChaCha20.swift

@@ -142,7 +142,7 @@ final public class ChaCha20: BlockCipher {
 
 
 // MARK: Encryptor
 // MARK: Encryptor
 extension ChaCha20 {
 extension ChaCha20 {
-    public struct Encryptor: UpdatableCryptor {
+    public struct Encryptor: Updatable {
         private var accumulated = Array<UInt8>()
         private var accumulated = Array<UInt8>()
         private let chacha: ChaCha20
         private let chacha: ChaCha20
 
 
@@ -168,7 +168,7 @@ extension ChaCha20 {
 
 
 // MARK: Decryptor
 // MARK: Decryptor
 extension ChaCha20 {
 extension ChaCha20 {
-    public struct Decryptor: UpdatableCryptor {
+    public struct Decryptor: Updatable {
         private var accumulated = Array<UInt8>()
         private var accumulated = Array<UInt8>()
 
 
         private var offset: Int = 0
         private var offset: Int = 0

+ 2 - 2
Sources/CryptoSwift/Cryptors.swift

@@ -13,8 +13,8 @@
 #endif
 #endif
 
 
 public protocol Cryptors: class {
 public protocol Cryptors: class {
-    associatedtype EncryptorType: UpdatableCryptor
-    associatedtype DecryptorType: UpdatableCryptor
+    associatedtype EncryptorType: Updatable
+    associatedtype DecryptorType: Updatable
 
 
     /// Cryptor suitable for encryption
     /// Cryptor suitable for encryption
     func makeEncryptor() -> EncryptorType
     func makeEncryptor() -> EncryptorType

+ 1 - 1
Sources/CryptoSwift/RandomAccessCryptor.swift

@@ -6,7 +6,7 @@
 //  Copyright © 2016 Marcin Krzyzanowski. All rights reserved.
 //  Copyright © 2016 Marcin Krzyzanowski. All rights reserved.
 //
 //
 
 
-public protocol RandomAccessCryptor: UpdatableCryptor {
+public protocol RandomAccessCryptor: Updatable {
     /// Seek to position in file. Usable if block mode allows random access.
     /// Seek to position in file. Usable if block mode allows random access.
     @discardableResult mutating func seek(to: Int) -> Bool
     @discardableResult mutating func seek(to: Int) -> Bool
 }
 }

+ 7 - 7
Sources/CryptoSwift/UpdatableCryptor.swift → Sources/CryptoSwift/Updatable.swift

@@ -1,20 +1,20 @@
 //
 //
-//  UpdatableCryptor.swift
+//  Updatable.swift
 //  CryptoSwift
 //  CryptoSwift
 //
 //
 //  Created by Marcin Krzyzanowski on 06/05/16.
 //  Created by Marcin Krzyzanowski on 06/05/16.
 //  Copyright © 2016 Marcin Krzyzanowski. All rights reserved.
 //  Copyright © 2016 Marcin Krzyzanowski. All rights reserved.
 //
 //
 
 
-public protocol UpdatableCryptor {
-    /// Encrypt/Decrypt given bytes in chunks.
+public protocol Updatable {
+    /// Update given bytes in chunks.
     ///
     ///
     /// - parameter bytes: Bytes to process
     /// - parameter bytes: Bytes to process
     /// - parameter isLast: (Optional) Given chunk is the last one. No more updates after this call.
     /// - parameter isLast: (Optional) Given chunk is the last one. No more updates after this call.
     /// - returns: Processed data or empty array.
     /// - returns: Processed data or empty array.
     mutating func update(withBytes bytes:Array<UInt8>, isLast: Bool) throws -> Array<UInt8>
     mutating func update(withBytes bytes:Array<UInt8>, isLast: Bool) throws -> Array<UInt8>
 
 
-    /// Encrypt/Decrypt given bytes in chunks.
+    /// Update given bytes in chunks.
     ///
     ///
     /// - parameter bytes: Bytes to process
     /// - parameter bytes: Bytes to process
     /// - parameter isLast: (Optional) Given chunk is the last one. No more updates after this call.
     /// - parameter isLast: (Optional) Given chunk is the last one. No more updates after this call.
@@ -22,19 +22,19 @@ public protocol UpdatableCryptor {
     /// - returns: Processed data or empty array.
     /// - returns: Processed data or empty array.
     mutating func update(withBytes bytes:Array<UInt8>, isLast: Bool, output: (Array<UInt8>) -> Void) throws
     mutating func update(withBytes bytes:Array<UInt8>, isLast: Bool, output: (Array<UInt8>) -> Void) throws
 
 
-    /// Finish encryption/decryption. This may apply padding.
+    /// Finish updates. This may apply padding.
     /// - parameter bytes: Bytes to process
     /// - parameter bytes: Bytes to process
     /// - returns: Processed data.
     /// - returns: Processed data.
     mutating func finish(withBytes bytes:Array<UInt8>) throws -> Array<UInt8>
     mutating func finish(withBytes bytes:Array<UInt8>) throws -> Array<UInt8>
 
 
-    /// Finish encryption/decryption. This may apply padding.
+    /// Finish updates. This may apply padding.
     /// - parameter bytes: Bytes to process
     /// - parameter bytes: Bytes to process
     /// - parameter output: Resulting data
     /// - parameter output: Resulting data
     /// - returns: Processed data.
     /// - returns: Processed data.
     mutating func finish(withBytes bytes:Array<UInt8>, output: (Array<UInt8>) -> Void) throws
     mutating func finish(withBytes bytes:Array<UInt8>, output: (Array<UInt8>) -> Void) throws
 }
 }
 
 
-extension UpdatableCryptor {
+extension Updatable {
     mutating public func update(withBytes bytes:Array<UInt8>, isLast: Bool = false, output: (Array<UInt8>) -> Void) throws {
     mutating public func update(withBytes bytes:Array<UInt8>, isLast: Bool = false, output: (Array<UInt8>) -> Void) throws {
         let processed = try self.update(withBytes: bytes, isLast: isLast)
         let processed = try self.update(withBytes: bytes, isLast: isLast)
         if (!processed.isEmpty) {
         if (!processed.isEmpty) {