Эх сурвалжийг харах

Just Padding enum is public

Marcin Krzyżanowski 8 жил өмнө
parent
commit
47768a13fb

+ 4 - 4
Sources/CryptoSwift/NoPadding.swift

@@ -14,16 +14,16 @@
 //  - This notice may not be removed or altered from any source or binary distribution.
 //
 
-public struct NoPadding: PaddingProtocol {
+struct NoPadding: PaddingProtocol {
 
-    public init() {
+    init() {
     }
 
-    public func add(to data: Array<UInt8>, blockSize _: Int) -> Array<UInt8> {
+    func add(to data: Array<UInt8>, blockSize _: Int) -> Array<UInt8> {
         return data
     }
 
-    public func remove(from data: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
+    func remove(from data: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
         return data
     }
 }

+ 1 - 1
Sources/CryptoSwift/PKCS/PKCS5.swift

@@ -19,5 +19,5 @@
 //
 
 public enum PKCS5 {
-    public typealias Padding = PKCS7Padding
+    typealias Padding = PKCS7Padding
 }

+ 1 - 1
Sources/CryptoSwift/PKCS/PKCS7.swift

@@ -15,5 +15,5 @@
 //
 
 public enum PKCS7 {
-    public typealias Padding = PKCS7Padding
+    typealias Padding = PKCS7Padding
 }

+ 5 - 5
Sources/CryptoSwift/PKCS/PKCS7Padding.swift

@@ -18,16 +18,16 @@
 //  and published by RSA Security Inc, starting in the early 1990s.
 //
 
-public struct PKCS7Padding: PaddingProtocol {
+struct PKCS7Padding: PaddingProtocol {
 
-    public enum Error: Swift.Error {
+    enum Error: Swift.Error {
         case invalidPaddingValue
     }
 
-    public init() {
+    init() {
     }
 
-    public func add(to bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
+    func add(to bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
         let padding = UInt8(blockSize - (bytes.count % blockSize))
         var withPadding = bytes
         if padding == 0 {
@@ -44,7 +44,7 @@ public struct PKCS7Padding: PaddingProtocol {
         return withPadding
     }
 
-    public func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
+    func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
         guard !bytes.isEmpty, let lastByte = bytes.last else {
             return bytes
         }

+ 4 - 4
Sources/CryptoSwift/ZeroPadding.swift

@@ -16,12 +16,12 @@
 
 /// All the bytes that are required to be padded are padded with zero.
 /// Zero padding may not be reversible if the original file ends with one or more zero bytes.
-public struct ZeroPadding: PaddingProtocol {
+struct ZeroPadding: PaddingProtocol {
 
-    public init() {
+    init() {
     }
 
-    public func add(to bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
+    func add(to bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
         let paddingCount = blockSize - (bytes.count % blockSize)
         if paddingCount > 0 {
             return bytes + Array<UInt8>(repeating: 0, count: paddingCount)
@@ -29,7 +29,7 @@ public struct ZeroPadding: PaddingProtocol {
         return bytes
     }
 
-    public func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
+    func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
         for (idx, value) in bytes.reversed().enumerated() {
             if value != 0 {
                 return Array(bytes[0..<bytes.count - idx])

+ 8 - 8
Tests/CryptoSwiftTests/Access.swift

@@ -145,20 +145,20 @@ class Access: XCTestCase {
 
     func testPadding() {
         // PKCS7
-        _ = PKCS7.Padding().add(to: [1, 2, 3], blockSize: 16)
-        _ = PKCS7.Padding().remove(from: [1, 2, 3], blockSize: 16)
+        _ = Padding.pkcs7.add(to: [1, 2, 3], blockSize: 16)
+        _ = Padding.pkcs7.remove(from: [1, 2, 3], blockSize: 16)
 
         // PKCS5
-        _ = PKCS5.Padding().add(to: [1, 2, 3], blockSize: 16)
-        _ = PKCS5.Padding().remove(from: [1, 2, 3], blockSize: 16)
+        _ = Padding.pkcs5.add(to: [1, 2, 3], blockSize: 16)
+        _ = Padding.pkcs5.remove(from: [1, 2, 3], blockSize: 16)
 
         // NoPadding
-        _ = NoPadding().add(to: [1, 2, 3], blockSize: 16)
-        _ = NoPadding().remove(from: [1, 2, 3], blockSize: 16)
+        _ = Padding.noPadding.add(to: [1, 2, 3], blockSize: 16)
+        _ = Padding.noPadding.remove(from: [1, 2, 3], blockSize: 16)
 
         // ZeroPadding
-        _ = ZeroPadding().add(to: [1, 2, 3], blockSize: 16)
-        _ = ZeroPadding().remove(from: [1, 2, 3], blockSize: 16)
+        _ = Padding.zeroPadding.add(to: [1, 2, 3], blockSize: 16)
+        _ = Padding.zeroPadding.remove(from: [1, 2, 3], blockSize: 16)
     }
 
     func testPBKDF() {