Browse Source

CipherType -> CipherProtocol

Marcin Krzyżanowski 9 years ago
parent
commit
ea286843ed

+ 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 /* 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 */; };
+		757BC9581C1CA5790093AAA9 /* CipherProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* CipherProtocol.swift */; };
+		757BC9591C1CA5790093AAA9 /* CipherProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* CipherProtocol.swift */; };
+		757BC95A1C1CA5790093AAA9 /* CipherProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* CipherProtocol.swift */; };
+		757BC95B1C1CA5790093AAA9 /* CipherProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757BC9211C1CA5790093AAA9 /* CipherProtocol.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 */; };
@@ -339,7 +339,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 /* CipherType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CipherType.swift; path = Sources/CryptoSwift/CipherType.swift; sourceTree = SOURCE_ROOT; };
+		757BC9211C1CA5790093AAA9 /* CipherProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CipherProtocol.swift; path = Sources/CryptoSwift/CipherProtocol.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; };
@@ -472,7 +472,7 @@
 				757F440D1CC1822A002B1F85 /* SecureBytes.swift */,
 				757BC91F1C1CA5790093AAA9 /* BytesSequence.swift */,
 				757BC9201C1CA5790093AAA9 /* ChaCha20.swift */,
-				757BC9211C1CA5790093AAA9 /* CipherType.swift */,
+				757BC9211C1CA5790093AAA9 /* CipherProtocol.swift */,
 				757F44081CC172B6002B1F85 /* BlockCipherType.swift */,
 				75CB93291C8F5EC60087740D /* BlockMode */,
 				757BC9231C1CA5790093AAA9 /* CRC.swift */,
@@ -843,7 +843,7 @@
 				757BC9951C1CA5790093AAA9 /* Padding.swift in Sources */,
 				80545D141CA9FECD00474A99 /* Bit.swift in Sources */,
 				757BC9A51C1CA5790093AAA9 /* Rabbit.swift in Sources */,
-				757BC9591C1CA5790093AAA9 /* CipherType.swift in Sources */,
+				757BC9591C1CA5790093AAA9 /* CipherProtocol.swift in Sources */,
 				757BC90B1C1CA56A0093AAA9 /* NSData+Extension.swift in Sources */,
 				757BC9791C1CA5790093AAA9 /* HMAC.swift in Sources */,
 				75482EAD1CB329DF001F66A5 /* PKCS5.swift in Sources */,
@@ -901,7 +901,7 @@
 				757BC9941C1CA5790093AAA9 /* Padding.swift in Sources */,
 				80545D131CA9FECD00474A99 /* Bit.swift in Sources */,
 				757BC9A41C1CA5790093AAA9 /* Rabbit.swift in Sources */,
-				757BC9581C1CA5790093AAA9 /* CipherType.swift in Sources */,
+				757BC9581C1CA5790093AAA9 /* CipherProtocol.swift in Sources */,
 				757BC9021C1CA56A0093AAA9 /* ArrayUInt8+Foundation.swift in Sources */,
 				757BC9781C1CA5790093AAA9 /* HMAC.swift in Sources */,
 				75482EAC1CB329DF001F66A5 /* PKCS5.swift in Sources */,
@@ -976,7 +976,7 @@
 				757BC9961C1CA5790093AAA9 /* Padding.swift in Sources */,
 				80545D161CA9FECD00474A99 /* Bit.swift in Sources */,
 				757BC9A61C1CA5790093AAA9 /* Rabbit.swift in Sources */,
-				757BC95A1C1CA5790093AAA9 /* CipherType.swift in Sources */,
+				757BC95A1C1CA5790093AAA9 /* CipherProtocol.swift in Sources */,
 				757BC9041C1CA56A0093AAA9 /* ArrayUInt8+Foundation.swift in Sources */,
 				757BC97A1C1CA5790093AAA9 /* HMAC.swift in Sources */,
 				75482EAF1CB329DF001F66A5 /* PKCS5.swift in Sources */,
@@ -1034,7 +1034,7 @@
 				757BC9971C1CA5790093AAA9 /* Padding.swift in Sources */,
 				80545D151CA9FECD00474A99 /* Bit.swift in Sources */,
 				757BC9A71C1CA5790093AAA9 /* Rabbit.swift in Sources */,
-				757BC95B1C1CA5790093AAA9 /* CipherType.swift in Sources */,
+				757BC95B1C1CA5790093AAA9 /* CipherProtocol.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

@@ -441,7 +441,7 @@ extension AES {
     }
 }
 
-extension AES: CipherType {
+extension AES: CipherProtocol {
     // 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: CipherType) throws -> [Generator.Element] {
+    public func encrypt(cipher: CipherProtocol) throws -> [Generator.Element] {
         return try cipher.cipherEncrypt(cs_arrayValue())
     }
 
-    public func decrypt(cipher: CipherType) throws -> [Generator.Element] {
+    public func decrypt(cipher: CipherProtocol) throws -> [Generator.Element] {
         return try cipher.cipherDecrypt(cs_arrayValue())
     }
     

+ 1 - 1
Sources/CryptoSwift/ChaCha20.swift

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

+ 3 - 3
Sources/CryptoSwift/CipherType.swift → Sources/CryptoSwift/CipherProtocol.swift

@@ -1,5 +1,5 @@
 //
-//  Cipher.swift
+//  CipherProtocol.swift
 //  CryptoSwift
 //
 //  Created by Marcin Krzyzanowski on 30/08/14.
@@ -17,14 +17,14 @@ public enum CipherError: ErrorType {
     case Decrypt
 }
 
-public protocol CipherType {
+public protocol CipherProtocol {
     func cipherEncrypt(bytes: [UInt8]) throws -> [UInt8]
     func cipherDecrypt(bytes: [UInt8]) throws -> [UInt8]
     
     static func randomIV(blockSize:Int) -> [UInt8]
 }
 
-extension CipherType {
+extension CipherProtocol {
     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: CipherType) throws -> NSData {
+    public func encrypt(cipher: CipherProtocol) throws -> NSData {
         let encrypted = try cipher.cipherEncrypt(self.arrayOfBytes())
         return NSData.withBytes(encrypted)
     }
 
-    public func decrypt(cipher: CipherType) throws -> NSData {
+    public func decrypt(cipher: CipherProtocol) 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: CipherType) throws -> String {
+    public func decryptBase64ToString(cipher: CipherProtocol) 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: CipherType) throws -> [UInt8] {
+    public func decryptBase64(cipher: CipherProtocol) throws -> [UInt8] {
         guard let decodedData = NSData(base64EncodedString: self, options: []) else {
             throw CipherError.Decrypt
         }

+ 1 - 1
Sources/CryptoSwift/Rabbit.swift

@@ -202,7 +202,7 @@ final public class Rabbit: BlockCipherType {
 
 // MARK: - CipherType
 
-extension Rabbit: CipherType {
+extension Rabbit: CipherProtocol {
     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: CipherType) throws -> [UInt8] {
+    public func encrypt(cipher: CipherProtocol) throws -> [UInt8] {
         return try self.utf8.lazy.map({ $0 as UInt8 }).encrypt(cipher)
     }
 
-    public func decrypt(cipher: CipherType) throws -> [UInt8] {
+    public func decrypt(cipher: CipherProtocol) throws -> [UInt8] {
         return try self.utf8.lazy.map({ $0 as UInt8 }).decrypt(cipher)
     }