Browse Source

rename protocol Cipher -> CipherType

Marcin Krzyżanowski 9 years ago
parent
commit
a1c3335843

+ 10 - 10
CryptoSwift.xcodeproj/project.pbxproj

@@ -80,10 +80,10 @@
 		757BC9551C1CA5790093AAA9 /* ChaCha20.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9201C1CA5790093AAA9 /* ChaCha20.swift */; };
 		757BC9561C1CA5790093AAA9 /* ChaCha20.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9201C1CA5790093AAA9 /* ChaCha20.swift */; };
 		757BC9571C1CA5790093AAA9 /* ChaCha20.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9201C1CA5790093AAA9 /* ChaCha20.swift */; };
-		757BC9581C1CA5790093AAA9 /* Cipher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* Cipher.swift */; };
-		757BC9591C1CA5790093AAA9 /* Cipher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* Cipher.swift */; };
-		757BC95A1C1CA5790093AAA9 /* Cipher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* Cipher.swift */; };
-		757BC95B1C1CA5790093AAA9 /* Cipher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* Cipher.swift */; };
+		757BC9581C1CA5790093AAA9 /* CipherType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* CipherType.swift */; };
+		757BC9591C1CA5790093AAA9 /* CipherType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* CipherType.swift */; };
+		757BC95A1C1CA5790093AAA9 /* CipherType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* CipherType.swift */; };
+		757BC95B1C1CA5790093AAA9 /* CipherType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* CipherType.swift */; };
 		757BC9601C1CA5790093AAA9 /* CRC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9231C1CA5790093AAA9 /* CRC.swift */; };
 		757BC9611C1CA5790093AAA9 /* CRC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9231C1CA5790093AAA9 /* CRC.swift */; };
 		757BC9621C1CA5790093AAA9 /* CRC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9231C1CA5790093AAA9 /* CRC.swift */; };
@@ -331,7 +331,7 @@
 		757BC91D1C1CA5790093AAA9 /* Authenticator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Authenticator.swift; path = Sources/CryptoSwift/Authenticator.swift; sourceTree = SOURCE_ROOT; };
 		757BC91F1C1CA5790093AAA9 /* BytesSequence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BytesSequence.swift; path = Sources/CryptoSwift/BytesSequence.swift; sourceTree = SOURCE_ROOT; };
 		757BC9201C1CA5790093AAA9 /* ChaCha20.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChaCha20.swift; path = Sources/CryptoSwift/ChaCha20.swift; sourceTree = SOURCE_ROOT; };
-		757BC9211C1CA5790093AAA9 /* Cipher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Cipher.swift; path = Sources/CryptoSwift/Cipher.swift; sourceTree = SOURCE_ROOT; };
+		757BC9211C1CA5790093AAA9 /* CipherType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CipherType.swift; path = Sources/CryptoSwift/CipherType.swift; sourceTree = SOURCE_ROOT; };
 		757BC9231C1CA5790093AAA9 /* CRC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CRC.swift; path = Sources/CryptoSwift/CRC.swift; sourceTree = SOURCE_ROOT; };
 		757BC9251C1CA5790093AAA9 /* CSArrayType+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "CSArrayType+Extensions.swift"; path = "Sources/CryptoSwift/CSArrayType+Extensions.swift"; sourceTree = SOURCE_ROOT; };
 		757BC9261C1CA5790093AAA9 /* Generics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Generics.swift; path = Sources/CryptoSwift/Generics.swift; sourceTree = SOURCE_ROOT; };
@@ -461,7 +461,7 @@
 				80545D121CA9FECD00474A99 /* Bit.swift */,
 				757BC91F1C1CA5790093AAA9 /* BytesSequence.swift */,
 				757BC9201C1CA5790093AAA9 /* ChaCha20.swift */,
-				757BC9211C1CA5790093AAA9 /* Cipher.swift */,
+				757BC9211C1CA5790093AAA9 /* CipherType.swift */,
 				75CB93291C8F5EC60087740D /* BlockMode */,
 				757BC9231C1CA5790093AAA9 /* CRC.swift */,
 				757BC9251C1CA5790093AAA9 /* CSArrayType+Extensions.swift */,
@@ -829,7 +829,7 @@
 				757BC9951C1CA5790093AAA9 /* Padding.swift in Sources */,
 				80545D141CA9FECD00474A99 /* Bit.swift in Sources */,
 				757BC9A51C1CA5790093AAA9 /* Rabbit.swift in Sources */,
-				757BC9591C1CA5790093AAA9 /* Cipher.swift in Sources */,
+				757BC9591C1CA5790093AAA9 /* CipherType.swift in Sources */,
 				757BC90B1C1CA56A0093AAA9 /* NSData+Extension.swift in Sources */,
 				757BC9791C1CA5790093AAA9 /* HMAC.swift in Sources */,
 				75482EAD1CB329DF001F66A5 /* PKCS5.swift in Sources */,
@@ -885,7 +885,7 @@
 				757BC9941C1CA5790093AAA9 /* Padding.swift in Sources */,
 				80545D131CA9FECD00474A99 /* Bit.swift in Sources */,
 				757BC9A41C1CA5790093AAA9 /* Rabbit.swift in Sources */,
-				757BC9581C1CA5790093AAA9 /* Cipher.swift in Sources */,
+				757BC9581C1CA5790093AAA9 /* CipherType.swift in Sources */,
 				757BC9021C1CA56A0093AAA9 /* ArrayUInt8+Foundation.swift in Sources */,
 				757BC9781C1CA5790093AAA9 /* HMAC.swift in Sources */,
 				75482EAC1CB329DF001F66A5 /* PKCS5.swift in Sources */,
@@ -958,7 +958,7 @@
 				757BC9961C1CA5790093AAA9 /* Padding.swift in Sources */,
 				80545D161CA9FECD00474A99 /* Bit.swift in Sources */,
 				757BC9A61C1CA5790093AAA9 /* Rabbit.swift in Sources */,
-				757BC95A1C1CA5790093AAA9 /* Cipher.swift in Sources */,
+				757BC95A1C1CA5790093AAA9 /* CipherType.swift in Sources */,
 				757BC9041C1CA56A0093AAA9 /* ArrayUInt8+Foundation.swift in Sources */,
 				757BC97A1C1CA5790093AAA9 /* HMAC.swift in Sources */,
 				75482EAF1CB329DF001F66A5 /* PKCS5.swift in Sources */,
@@ -1014,7 +1014,7 @@
 				757BC9971C1CA5790093AAA9 /* Padding.swift in Sources */,
 				80545D151CA9FECD00474A99 /* Bit.swift in Sources */,
 				757BC9A71C1CA5790093AAA9 /* Rabbit.swift in Sources */,
-				757BC95B1C1CA5790093AAA9 /* Cipher.swift in Sources */,
+				757BC95B1C1CA5790093AAA9 /* CipherType.swift in Sources */,
 				757BC90D1C1CA56A0093AAA9 /* NSData+Extension.swift in Sources */,
 				757BC97B1C1CA5790093AAA9 /* HMAC.swift in Sources */,
 				75482EAE1CB329DF001F66A5 /* PKCS5.swift in Sources */,

+ 1 - 1
Sources/CryptoSwift/AES.swift

@@ -440,7 +440,7 @@ extension AES {
     }
 }
 
-extension AES: Cipher {
+extension AES: CipherType {
     // MARK: - Cipher
     
     public func cipherEncrypt(bytes:[UInt8]) throws -> [UInt8] {

+ 2 - 2
Sources/CryptoSwift/CSArrayType+Extensions.swift

@@ -73,11 +73,11 @@ public extension CSArrayType where Generator.Element == UInt8 {
         return Hash.crc16(cs_arrayValue(), seed: seed).calculate()
     }
     
-    public func encrypt(cipher: Cipher) throws -> [Generator.Element] {
+    public func encrypt(cipher: CipherType) throws -> [Generator.Element] {
         return try cipher.cipherEncrypt(cs_arrayValue())
     }
 
-    public func decrypt(cipher: Cipher) throws -> [Generator.Element] {
+    public func decrypt(cipher: CipherType) throws -> [Generator.Element] {
         return try cipher.cipherDecrypt(cs_arrayValue())
     }
     

+ 1 - 1
Sources/CryptoSwift/ChaCha20.swift

@@ -176,7 +176,7 @@ final public class ChaCha20 {
 
 // MARK: - Cipher
 
-extension ChaCha20: Cipher {
+extension ChaCha20: CipherType {
     public func cipherEncrypt(bytes:[UInt8]) throws -> [UInt8] {
         return try self.encrypt(bytes)
     }

+ 2 - 2
Sources/CryptoSwift/Cipher.swift → Sources/CryptoSwift/CipherType.swift

@@ -17,14 +17,14 @@ public enum CipherError: ErrorType {
     case Decrypt
 }
 
-public protocol Cipher {
+public protocol CipherType {
     func cipherEncrypt(bytes: [UInt8]) throws -> [UInt8]
     func cipherDecrypt(bytes: [UInt8]) throws -> [UInt8]
     
     static func randomIV(blockSize:Int) -> [UInt8]
 }
 
-extension Cipher {
+extension CipherType {
     static public func randomIV(blockSize:Int) -> [UInt8] {
         var randomIV:[UInt8] = [UInt8]();
         for _ in 0..<blockSize {

+ 2 - 2
Sources/CryptoSwift/Foundation/NSData+Extension.swift

@@ -70,12 +70,12 @@ extension NSData {
         return NSData.withBytes(result)
     }
 
-    public func encrypt(cipher: Cipher) throws -> NSData {
+    public func encrypt(cipher: CipherType) throws -> NSData {
         let encrypted = try cipher.cipherEncrypt(self.arrayOfBytes())
         return NSData.withBytes(encrypted)
     }
 
-    public func decrypt(cipher: Cipher) throws -> NSData {
+    public func decrypt(cipher: CipherType) throws -> NSData {
         let decrypted = try cipher.cipherDecrypt(self.arrayOfBytes())
         return NSData.withBytes(decrypted)
     }

+ 2 - 2
Sources/CryptoSwift/Foundation/String+FoundationExtension.swift

@@ -11,7 +11,7 @@ import Foundation
 extension String {
 
     /// Return Base64 back to String
-    public func decryptBase64ToString(cipher: Cipher) throws -> String {
+    public func decryptBase64ToString(cipher: CipherType) throws -> String {
         guard let decodedData = NSData(base64EncodedString: self, options: []) else {
             throw CipherError.Decrypt
         }
@@ -25,7 +25,7 @@ extension String {
         throw CipherError.Decrypt
     }
 
-    public func decryptBase64(cipher: Cipher) throws -> [UInt8] {
+    public func decryptBase64(cipher: CipherType) throws -> [UInt8] {
         guard let decodedData = NSData(base64EncodedString: self, options: []) else {
             throw CipherError.Decrypt
         }

+ 2 - 2
Sources/CryptoSwift/Rabbit.swift

@@ -198,9 +198,9 @@ final public class Rabbit {
 }
 
 
-// MARK: - Cipher
+// MARK: - CipherType
 
-extension Rabbit: Cipher {
+extension Rabbit: CipherType {
     public func cipherEncrypt(bytes:[UInt8]) -> [UInt8] {
         return self.encrypt(bytes)
     }

+ 2 - 2
Sources/CryptoSwift/String+Extension.swift

@@ -41,11 +41,11 @@ extension String {
         return self.utf8.lazy.map({ $0 as UInt8 }).crc16(seed).toHexString()
     }
 
-    public func encrypt(cipher: Cipher) throws -> [UInt8] {
+    public func encrypt(cipher: CipherType) throws -> [UInt8] {
         return try self.utf8.lazy.map({ $0 as UInt8 }).encrypt(cipher)
     }
 
-    public func decrypt(cipher: Cipher) throws -> [UInt8] {
+    public func decrypt(cipher: CipherType) throws -> [UInt8] {
         return try self.utf8.lazy.map({ $0 as UInt8 }).decrypt(cipher)
     }