Преглед на файлове

Adopt @inlinable attribute

Marcin Krzyzanowski преди 4 години
родител
ревизия
1adeed4bc5
променени са 38 файла, в които са добавени 277 реда и са изтрити 57 реда
  1. 2 0
      Sources/CryptoSwift/AES.Cryptors.swift
  2. 17 5
      Sources/CryptoSwift/AES.swift
  3. 2 0
      Sources/CryptoSwift/Array+Extension.swift
  4. 18 0
      Sources/CryptoSwift/BatchedCollection.swift
  5. 1 0
      Sources/CryptoSwift/Bit.swift
  6. 13 4
      Sources/CryptoSwift/BlockDecryptor.swift
  7. 4 0
      Sources/CryptoSwift/BlockEncryptor.swift
  8. 1 1
      Sources/CryptoSwift/BlockMode/BlockMode.swift
  9. 7 0
      Sources/CryptoSwift/BlockMode/BlockModeOptions.swift
  10. 5 0
      Sources/CryptoSwift/BlockMode/CBC.swift
  11. 4 0
      Sources/CryptoSwift/BlockMode/CCM.swift
  12. 2 0
      Sources/CryptoSwift/BlockMode/CFB.swift
  13. 3 0
      Sources/CryptoSwift/BlockMode/CTR.swift
  14. 3 0
      Sources/CryptoSwift/BlockMode/CipherModeWorker.swift
  15. 1 0
      Sources/CryptoSwift/BlockMode/ECB.swift
  16. 3 0
      Sources/CryptoSwift/BlockMode/GCM.swift
  17. 1 0
      Sources/CryptoSwift/BlockMode/OCB.swift
  18. 2 0
      Sources/CryptoSwift/BlockMode/OFB.swift
  19. 3 0
      Sources/CryptoSwift/BlockMode/PCBC.swift
  20. 18 3
      Sources/CryptoSwift/Checksum.swift
  21. 4 1
      Sources/CryptoSwift/Collection+Extension.swift
  22. 1 0
      Sources/CryptoSwift/CompactMap.swift
  23. 1 0
      Sources/CryptoSwift/Generics.swift
  24. 2 0
      Sources/CryptoSwift/ISO78164Padding.swift
  25. 1 1
      Sources/CryptoSwift/Int+Extension.swift
  26. 15 5
      Sources/CryptoSwift/PKCS/PBKDF1.swift
  27. 2 0
      Sources/CryptoSwift/PKCS/PKCS7Padding.swift
  28. 19 6
      Sources/CryptoSwift/SHA1.swift
  29. 37 9
      Sources/CryptoSwift/SHA2.swift
  30. 11 3
      Sources/CryptoSwift/SHA3.swift
  31. 18 5
      Sources/CryptoSwift/StreamDecryptor.swift
  32. 15 4
      Sources/CryptoSwift/StreamEncryptor.swift
  33. 15 0
      Sources/CryptoSwift/String+Extension.swift
  34. 1 0
      Sources/CryptoSwift/UInt32+Extension.swift
  35. 1 0
      Sources/CryptoSwift/UInt64+Extension.swift
  36. 10 0
      Sources/CryptoSwift/Updatable.swift
  37. 12 10
      Sources/CryptoSwift/Utils.swift
  38. 2 0
      Sources/CryptoSwift/ZeroPadding.swift

+ 2 - 0
Sources/CryptoSwift/AES.Cryptors.swift

@@ -16,6 +16,7 @@
 // MARK: Cryptors
 
 extension AES: Cryptors {
+  @inlinable
   public func makeEncryptor() throws -> Cryptor & Updatable {
     let blockSize = blockMode.customBlockSize ?? AES.blockSize
     let worker = try blockMode.worker(blockSize: blockSize, cipherOperation: encrypt, encryptionOperation: encrypt)
@@ -25,6 +26,7 @@ extension AES: Cryptors {
     return try BlockEncryptor(blockSize: blockSize, padding: padding, worker)
   }
 
+  @inlinable
   public func makeDecryptor() throws -> Cryptor & Updatable {
     let blockSize = blockMode.customBlockSize ?? AES.blockSize
     let cipherOperation: CipherOperationOnBlock = blockMode.options.contains(.useEncryptToDecrypt) == true ? encrypt : decrypt

Файловите разлики са ограничени, защото са твърде много
+ 17 - 5
Sources/CryptoSwift/AES.swift


+ 2 - 0
Sources/CryptoSwift/Array+Extension.swift

@@ -14,11 +14,13 @@
 //
 
 extension Array {
+  @inlinable
   init(reserveCapacity: Int) {
     self = Array<Element>()
     self.reserveCapacity(reserveCapacity)
   }
 
+  @inlinable
   var slice: ArraySlice<Element> {
     self[self.startIndex ..< self.endIndex]
   }

+ 18 - 0
Sources/CryptoSwift/BatchedCollection.swift

@@ -13,15 +13,18 @@
 //  - This notice may not be removed or altered from any source or binary distribution.
 //
 
+@usableFromInline
 struct BatchedCollectionIndex<Base: Collection> {
   let range: Range<Base.Index>
 }
 
 extension BatchedCollectionIndex: Comparable {
+  @usableFromInline
   static func == <Base>(lhs: BatchedCollectionIndex<Base>, rhs: BatchedCollectionIndex<Base>) -> Bool {
     lhs.range.lowerBound == rhs.range.lowerBound
   }
 
+  @usableFromInline
   static func < <Base>(lhs: BatchedCollectionIndex<Base>, rhs: BatchedCollectionIndex<Base>) -> Bool {
     lhs.range.lowerBound < rhs.range.lowerBound
   }
@@ -31,32 +34,47 @@ protocol BatchedCollectionType: Collection {
   associatedtype Base: Collection
 }
 
+@usableFromInline
 struct BatchedCollection<Base: Collection>: Collection {
   let base: Base
   let size: Int
+
+  @usableFromInline
+  init(base: Base, size: Int) {
+    self.base = base
+    self.size = size
+  }
+
+  @usableFromInline
   typealias Index = BatchedCollectionIndex<Base>
+
   private func nextBreak(after idx: Base.Index) -> Base.Index {
     self.base.index(idx, offsetBy: self.size, limitedBy: self.base.endIndex) ?? self.base.endIndex
   }
 
+  @usableFromInline
   var startIndex: Index {
     Index(range: self.base.startIndex..<self.nextBreak(after: self.base.startIndex))
   }
 
+  @usableFromInline
   var endIndex: Index {
     Index(range: self.base.endIndex..<self.base.endIndex)
   }
 
+  @usableFromInline
   func index(after idx: Index) -> Index {
     Index(range: idx.range.upperBound..<self.nextBreak(after: idx.range.upperBound))
   }
 
+  @usableFromInline
   subscript(idx: Index) -> Base.SubSequence {
     self.base[idx.range]
   }
 }
 
 extension Collection {
+  @inlinable
   func batched(by size: Int) -> BatchedCollection<Self> {
     BatchedCollection(base: self, size: size)
   }

+ 1 - 0
Sources/CryptoSwift/Bit.swift

@@ -19,6 +19,7 @@ public enum Bit: Int {
 }
 
 extension Bit {
+  @inlinable
   func inverted() -> Bit {
     self == .zero ? .one : .zero
   }

+ 13 - 4
Sources/CryptoSwift/BlockDecryptor.swift

@@ -13,17 +13,26 @@
 //
 
 public class BlockDecryptor: Cryptor, Updatable {
-  private let blockSize: Int
-  private let padding: Padding
-  private var worker: CipherModeWorker
-  private var accumulated = Array<UInt8>()
+  @usableFromInline
+  let blockSize: Int
 
+  @usableFromInline
+  let padding: Padding
+
+  @usableFromInline
+  var worker: CipherModeWorker
+
+  @usableFromInline
+  var accumulated = Array<UInt8>()
+
+  @usableFromInline
   init(blockSize: Int, padding: Padding, _ worker: CipherModeWorker) throws {
     self.blockSize = blockSize
     self.padding = padding
     self.worker = worker
   }
 
+  @inlinable
   public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
     self.accumulated += bytes
 

+ 4 - 0
Sources/CryptoSwift/BlockEncryptor.swift

@@ -11,6 +11,8 @@
 //  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
 //  - This notice may not be removed or altered from any source or binary distribution.
 //
+
+@usableFromInline
 final class BlockEncryptor: Cryptor, Updatable {
   private let blockSize: Int
   private var worker: CipherModeWorker
@@ -20,6 +22,7 @@ final class BlockEncryptor: Cryptor, Updatable {
 
   private var lastBlockRemainder = 0
 
+  @usableFromInline
   init(blockSize: Int, padding: Padding, _ worker: CipherModeWorker) throws {
     self.blockSize = blockSize
     self.padding = padding
@@ -52,6 +55,7 @@ final class BlockEncryptor: Cryptor, Updatable {
     return encrypted
   }
 
+  @usableFromInline
   func seek(to: Int) throws {
     fatalError("Not supported")
   }

+ 1 - 1
Sources/CryptoSwift/BlockMode/BlockMode.swift

@@ -18,7 +18,7 @@ public typealias CipherOperationOnBlock = (_ block: ArraySlice<UInt8>) -> Array<
 public protocol BlockMode {
   var options: BlockModeOption { get }
   //TODO: doesn't have to be public
-  func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock, encryptionOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker
+  @inlinable func worker(blockSize: Int, cipherOperation: @escaping CipherOperationOnBlock, encryptionOperation: @escaping CipherOperationOnBlock) throws -> CipherModeWorker
 
   var customBlockSize: Int? { get }
 }

+ 7 - 0
Sources/CryptoSwift/BlockMode/BlockModeOptions.swift

@@ -20,8 +20,15 @@ public struct BlockModeOption: OptionSet {
     self.rawValue = rawValue
   }
 
+  @usableFromInline
   static let none = BlockModeOption(rawValue: 1 << 0)
+
+  @usableFromInline
   static let initializationVectorRequired = BlockModeOption(rawValue: 1 << 1)
+
+  @usableFromInline
   static let paddingRequired = BlockModeOption(rawValue: 1 << 2)
+
+  @usableFromInline
   static let useEncryptToDecrypt = BlockModeOption(rawValue: 1 << 3)
 }

+ 5 - 0
Sources/CryptoSwift/BlockMode/CBC.swift

@@ -23,7 +23,9 @@ public struct CBC: BlockMode {
   }
 
   public let options: BlockModeOption = [.initializationVectorRequired, .paddingRequired]
+  
   private let iv: Array<UInt8>
+
   public let customBlockSize: Int? = nil
 
   public init(iv: Array<UInt8>) {
@@ -46,12 +48,14 @@ struct CBCModeWorker: BlockModeWorker {
   private let iv: ArraySlice<UInt8>
   private var prev: ArraySlice<UInt8>?
 
+  @inlinable
   init(blockSize: Int, iv: ArraySlice<UInt8>, cipherOperation: @escaping CipherOperationOnBlock) {
     self.blockSize = blockSize
     self.iv = iv
     self.cipherOperation = cipherOperation
   }
 
+  @inlinable
   mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
     guard let ciphertext = cipherOperation(xor(prev ?? iv, plaintext)) else {
       return Array(plaintext)
@@ -60,6 +64,7 @@ struct CBCModeWorker: BlockModeWorker {
     return ciphertext
   }
 
+  @inlinable
   mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
     guard let plaintext = cipherOperation(ciphertext) else {
       return Array(ciphertext)

+ 4 - 0
Sources/CryptoSwift/BlockMode/CCM.swift

@@ -142,6 +142,7 @@ class CCMModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker, Fi
     return self.cipherOperation(ctr.slice)!
   }
 
+  @inlinable
   func seek(to position: Int) throws {
     self.counter = position
     self.keystream = try self.S(i: position)
@@ -175,6 +176,7 @@ class CCMModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker, Fi
     return result
   }
 
+  @inlinable
   func finalize(encrypt ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
     // concatenate T at the end
     guard let S0 = try? S(i: 0) else { return ciphertext }
@@ -220,6 +222,7 @@ class CCMModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker, Fi
     return output
   }
 
+  @inlinable
   func finalize(decrypt plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
     // concatenate T at the end
     let computedTag = Array(last_y.prefix(self.tagLength))
@@ -240,6 +243,7 @@ class CCMModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker, Fi
     return ciphertext[ciphertext.startIndex..<ciphertext.endIndex.advanced(by: -Swift.min(tagLength, ciphertext.count))]
   }
 
+  @inlinable
   func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
 
     // Calculate Tag, from the last CBC block, for accumulated plaintext.

+ 2 - 0
Sources/CryptoSwift/BlockMode/CFB.swift

@@ -62,6 +62,7 @@ struct CFBModeWorker: BlockModeWorker {
     self.cipherOperation = cipherOperation
   }
 
+  @inlinable
   mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
     switch segmentSize {
     case .cfb128:
@@ -80,6 +81,7 @@ struct CFBModeWorker: BlockModeWorker {
     }
   }
 
+  @inlinable
   mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
     switch segmentSize {
     case .cfb128:

+ 3 - 0
Sources/CryptoSwift/BlockMode/CTR.swift

@@ -53,6 +53,7 @@ struct CTRModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker {
       self.constPrefix + self.value.bytes()
     }
 
+    @inlinable
     init(_ initialValue: Array<UInt8>) {
       let halfIndex = initialValue.startIndex.advanced(by: initialValue.count / 2)
       self.constPrefix = Array(initialValue[initialValue.startIndex..<halfIndex])
@@ -92,6 +93,7 @@ struct CTRModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker {
     self.keystream = Array(cipherOperation(self.counter.bytes.slice)!)
   }
 
+  @inlinable
   mutating func seek(to position: Int) throws {
     let offset = position % self.blockSize
     self.counter = CTRCounter(nonce: self.iv, startAt: position / self.blockSize)
@@ -100,6 +102,7 @@ struct CTRModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker {
   }
 
   // plaintext is at most blockSize long
+  @inlinable
   mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
     var result = Array<UInt8>(reserveCapacity: plaintext.count)
 

+ 3 - 0
Sources/CryptoSwift/BlockMode/CipherModeWorker.swift

@@ -20,7 +20,10 @@ public protocol CipherModeWorker {
   // eg. for GCM combined mode
   var additionalBufferSize: Int { get }
 
+  @inlinable
   mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8>
+
+  @inlinable
   mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8>
 }
 

+ 1 - 0
Sources/CryptoSwift/BlockMode/ECB.swift

@@ -39,6 +39,7 @@ struct ECBModeWorker: BlockModeWorker {
     self.cipherOperation = cipherOperation
   }
 
+  @inlinable
   mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
     guard let ciphertext = cipherOperation(plaintext) else {
       return Array(plaintext)

+ 3 - 0
Sources/CryptoSwift/BlockMode/GCM.swift

@@ -156,6 +156,7 @@ final class GCMModeWorker: BlockModeWorker, FinalizingEncryptModeWorker, Finaliz
     return Array(ciphertext)
   }
 
+  @inlinable
   func finalize(encrypt ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
     // Calculate MAC tag.
     let ghash = self.gf.ghashFinish()
@@ -172,6 +173,7 @@ final class GCMModeWorker: BlockModeWorker, FinalizingEncryptModeWorker, Finaliz
     }
   }
 
+  @inlinable
   func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
     self.counter = incrementCounter(self.counter)
 
@@ -203,6 +205,7 @@ final class GCMModeWorker: BlockModeWorker, FinalizingEncryptModeWorker, Finaliz
     }
   }
 
+  @inlinable
   func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
     // Calculate MAC tag.
     let ghash = self.gf.ghashFinish()

+ 1 - 0
Sources/CryptoSwift/BlockMode/OCB.swift

@@ -57,6 +57,7 @@ public final class OCB: BlockMode {
   }
 
   // decrypt
+  @inlinable
   public convenience init(nonce N: Array<UInt8>, authenticationTag: Array<UInt8>, additionalAuthenticatedData: Array<UInt8>? = nil, mode: Mode = .detached) {
     self.init(nonce: N, additionalAuthenticatedData: additionalAuthenticatedData, tagLength: authenticationTag.count, mode: mode)
     self.authenticationTag = authenticationTag

+ 2 - 0
Sources/CryptoSwift/BlockMode/OFB.swift

@@ -52,6 +52,7 @@ struct OFBModeWorker: BlockModeWorker {
     self.cipherOperation = cipherOperation
   }
 
+  @inlinable
   mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
     guard let ciphertext = cipherOperation(prev ?? iv) else {
       return Array(plaintext)
@@ -60,6 +61,7 @@ struct OFBModeWorker: BlockModeWorker {
     return xor(plaintext, ciphertext)
   }
 
+  @inlinable
   mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
     guard let decrypted = cipherOperation(prev ?? iv) else {
       return Array(ciphertext)

+ 3 - 0
Sources/CryptoSwift/BlockMode/PCBC.swift

@@ -46,12 +46,14 @@ struct PCBCModeWorker: BlockModeWorker {
   private let iv: ArraySlice<UInt8>
   private var prev: ArraySlice<UInt8>?
 
+  @inlinable
   init(blockSize: Int, iv: ArraySlice<UInt8>, cipherOperation: @escaping CipherOperationOnBlock) {
     self.blockSize = blockSize
     self.iv = iv
     self.cipherOperation = cipherOperation
   }
 
+  @inlinable
   mutating func encrypt(block plaintext: ArraySlice<UInt8>) -> Array<UInt8> {
     guard let ciphertext = cipherOperation(xor(prev ?? iv, plaintext)) else {
       return Array(plaintext)
@@ -60,6 +62,7 @@ struct PCBCModeWorker: BlockModeWorker {
     return ciphertext
   }
 
+  @inlinable
   mutating func decrypt(block ciphertext: ArraySlice<UInt8>) -> Array<UInt8> {
     guard let plaintext = cipherOperation(ciphertext) else {
       return Array(ciphertext)

+ 18 - 3
Sources/CryptoSwift/Checksum.swift

@@ -15,7 +15,9 @@
 
 /// CRC - cyclic redundancy check code.
 public final class Checksum {
-  private static let table32: Array<UInt32> = [
+
+  @usableFromInline
+  static let table32: Array<UInt32> = [
     0x0000_0000, 0x7707_3096, 0xEE0E_612C, 0x9909_51BA, 0x076D_C419, 0x706A_F48F, 0xE963_A535, 0x9E64_95A3,
     0x0EDB_8832, 0x79DC_B8A4, 0xE0D5_E91E, 0x97D2_D988, 0x09B6_4C2B, 0x7EB1_7CBD, 0xE7B8_2D07, 0x90BF_1D91,
     0x1DB7_1064, 0x6AB0_20F2, 0xF3B9_7148, 0x84BE_41DE, 0x1ADA_D47D, 0x6DDD_E4EB, 0xF4D4_B551, 0x83D3_85C7,
@@ -50,7 +52,8 @@ public final class Checksum {
     0xB366_7A2E, 0xC461_4AB8, 0x5D68_1B02, 0x2A6F_2B94, 0xB40B_BE37, 0xC30C_8EA1, 0x5A05_DF1B, 0x2D02_EF8D
   ]
 
-  private static let table32c: Array<UInt32> = [
+  @usableFromInline
+  static let table32c: Array<UInt32> = [
     0x0000_0000, 0xF26B_8303, 0xE13B_70F7, 0x1350_F3F4, 0xC79A_971F, 0x35F1_141C, 0x26A1_E7E8, 0xD4CA_64EB,
     0x8AD9_58CF, 0x78B2_DBCC, 0x6BE2_2838, 0x9989_AB3B, 0x4D43_CFD0, 0xBF28_4CD3, 0xAC78_BF27, 0x5E13_3C24,
     0x105E_C76F, 0xE235_446C, 0xF165_B798, 0x030E_349B, 0xD7C4_5070, 0x25AF_D373, 0x36FF_2087, 0xC494_A384,
@@ -85,7 +88,8 @@ public final class Checksum {
     0x79B7_37BA, 0x8BDC_B4B9, 0x988C_474D, 0x6AE7_C44E, 0xBE2D_A0A5, 0x4C46_23A6, 0x5F16_D052, 0xAD7D_5351
   ]
 
-  private static let table16: Array<UInt16> = [
+  @usableFromInline
+  static let table16: Array<UInt16> = [
     0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
     0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
     0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
@@ -120,7 +124,13 @@ public final class Checksum {
     0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
   ]
 
+  @usableFromInline
+  init() {
+    //
+  }
+
   /// Polynomial: 0xEDB88320 (Reversed) - IEEE
+  @inlinable
   func crc32(_ message: Array<UInt8>, seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
     var crc: UInt32 = seed != nil ? seed! : 0xFFFF_FFFF
     for chunk in message.batched(by: 256) {
@@ -133,6 +143,7 @@ public final class Checksum {
   }
 
   /// Polynomial: 0x82F63B78 (Reversed) - Castagnoli
+  @inlinable
   func crc32c(_ message: Array<UInt8>, seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
     var crc: UInt32 = seed != nil ? seed! : 0xFFFF_FFFF
     for chunk in message.batched(by: 256) {
@@ -145,6 +156,7 @@ public final class Checksum {
   }
 
   /// Polynomial: 0xA001 (Reversed) - IBM
+  @inlinable
   func crc16(_ message: Array<UInt8>, seed: UInt16? = nil) -> UInt16 {
     var crc: UInt16 = seed != nil ? seed! : 0x0000
     for chunk in message.batched(by: 256) {
@@ -166,6 +178,7 @@ public extension Checksum {
   /// - parameter reflect: is reflect (default true)
   ///
   /// - returns: Calculated code
+  @inlinable
   static func crc32(_ message: Array<UInt8>, seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
     Checksum().crc32(message, seed: seed, reflect: reflect)
   }
@@ -177,6 +190,7 @@ public extension Checksum {
   /// - parameter reflect: is reflect (default true)
   ///
   /// - returns: Calculated code
+  @inlinable
   static func crc32c(_ message: Array<UInt8>, seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
     Checksum().crc32c(message, seed: seed, reflect: reflect)
   }
@@ -187,6 +201,7 @@ public extension Checksum {
   /// - parameter seed:    Seed value (Optional)
   ///
   /// - returns: Calculated code
+  @inlinable
   static func crc16(_ message: Array<UInt8>, seed: UInt16? = nil) -> UInt16 {
     Checksum().crc16(message, seed: seed)
   }

+ 4 - 1
Sources/CryptoSwift/Collection+Extension.swift

@@ -14,6 +14,7 @@
 //
 extension Collection where Self.Element == UInt8, Self.Index == Int {
   // Big endian order
+  @inlinable
   func toUInt32Array() -> Array<UInt32> {
     guard !isEmpty else {
       return []
@@ -33,6 +34,7 @@ extension Collection where Self.Element == UInt8, Self.Index == Int {
   }
 
   // Big endian order
+  @inlinable
   func toUInt64Array() -> Array<UInt64> {
     guard !isEmpty else {
       return []
@@ -52,7 +54,8 @@ extension Collection where Self.Element == UInt8, Self.Index == Int {
   }
 }
 
-private func strideCount(from: Int, to: Int, by: Int) -> Int {
+@usableFromInline
+func strideCount(from: Int, to: Int, by: Int) -> Int {
     let count = to - from
     return count / by + (count % by > 0 ? 1 : 0)
 }

+ 1 - 0
Sources/CryptoSwift/CompactMap.swift

@@ -16,6 +16,7 @@
 // TODO: remove this file when Xcode 9.2 is no longer used
 #else
   extension Sequence {
+    @inlinable
     public func compactMap<ElementOfResult>(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
       try flatMap(transform)
     }

+ 1 - 0
Sources/CryptoSwift/Generics.swift

@@ -25,6 +25,7 @@
 @_specialize(where T == UInt16)
 @_specialize(where T == UInt32)
 @_specialize(where T == UInt64)
+@inlinable
 func arrayOfBytes<T: FixedWidthInteger>(value: T, length totalBytes: Int = MemoryLayout<T>.size) -> Array<UInt8> {
   let valuePointer = UnsafeMutablePointer<T>.allocate(capacity: 1)
   valuePointer.pointee = value

+ 2 - 0
Sources/CryptoSwift/ISO78164Padding.swift

@@ -22,6 +22,7 @@ struct ISO78164Padding: PaddingProtocol {
   init() {
   }
 
+  @inlinable
   func add(to bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
     var padded = Array(bytes)
     padded.append(0x80)
@@ -32,6 +33,7 @@ struct ISO78164Padding: PaddingProtocol {
     return padded
   }
 
+  @inlinable
   func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
     if let idx = bytes.lastIndex(of: 0x80) {
       return Array(bytes[..<idx])

+ 1 - 1
Sources/CryptoSwift/Int+Extension.swift

@@ -23,7 +23,7 @@ import ucrt
 #endif
 
 extension FixedWidthInteger {
-  @_transparent
+  @inlinable
   func bytes(totalBytes: Int = MemoryLayout<Self>.size) -> Array<UInt8> {
     arrayOfBytes(value: self.littleEndian, length: totalBytes)
     // TODO: adjust bytes order

+ 15 - 5
Sources/CryptoSwift/PKCS/PBKDF1.swift

@@ -28,6 +28,7 @@ public extension PKCS5 {
     public enum Variant {
       case md5, sha1
 
+      @usableFromInline
       var size: Int {
         switch self {
           case .md5:
@@ -37,7 +38,8 @@ public extension PKCS5 {
         }
       }
 
-      fileprivate func calculateHash(_ bytes: Array<UInt8>) -> Array<UInt8> {
+      @usableFromInline
+      func calculateHash(_ bytes: Array<UInt8>) -> Array<UInt8> {
         switch self {
           case .sha1:
             return Digest.sha1(bytes)
@@ -47,10 +49,17 @@ public extension PKCS5 {
       }
     }
 
-    private let iterations: Int // c
-    private let variant: Variant
-    private let keyLength: Int
-    private let t1: Array<UInt8>
+    @usableFromInline
+    let iterations: Int // c
+
+    @usableFromInline
+    let variant: Variant
+
+    @usableFromInline
+    let keyLength: Int
+
+    @usableFromInline
+    let t1: Array<UInt8>
 
     /// - parameters:
     ///   - salt: salt, an eight-bytes
@@ -76,6 +85,7 @@ public extension PKCS5 {
     }
 
     /// Apply the underlying hash function Hash for c iterations
+    @inlinable
     public func calculate() -> Array<UInt8> {
       var t = self.t1
       for _ in 2...self.iterations {

+ 2 - 0
Sources/CryptoSwift/PKCS/PKCS7Padding.swift

@@ -25,6 +25,7 @@ struct PKCS7Padding: PaddingProtocol {
   init() {
   }
 
+  @inlinable
   func add(to bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
     let padding = UInt8(blockSize - (bytes.count % blockSize))
     var withPadding = bytes
@@ -38,6 +39,7 @@ struct PKCS7Padding: PaddingProtocol {
     return withPadding
   }
 
+  @inlinable
   func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
     guard !bytes.isEmpty, let lastByte = bytes.last else {
       return bytes

+ 19 - 6
Sources/CryptoSwift/SHA1.swift

@@ -14,17 +14,29 @@
 //
 
 public final class SHA1: DigestType {
+
+  @usableFromInline
   static let digestLength: Int = 20 // 160 / 8
+
+  @usableFromInline
   static let blockSize: Int = 64
-  fileprivate static let hashInitialValue: ContiguousArray<UInt32> = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]
 
-  fileprivate var accumulated = Array<UInt8>()
-  fileprivate var processedBytesTotalCount: Int = 0
-  fileprivate var accumulatedHash: ContiguousArray<UInt32> = SHA1.hashInitialValue
+  @usableFromInline
+  static let hashInitialValue: ContiguousArray<UInt32> = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]
+
+  @usableFromInline
+  var accumulated = Array<UInt8>()
+
+  @usableFromInline
+  var processedBytesTotalCount: Int = 0
+
+  @usableFromInline
+  var accumulatedHash: ContiguousArray<UInt32> = SHA1.hashInitialValue
 
   public init() {
   }
 
+  @inlinable
   public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
     do {
       return try update(withBytes: bytes.slice, isLast: true)
@@ -33,7 +45,8 @@ public final class SHA1: DigestType {
     }
   }
 
-  fileprivate func process(block chunk: ArraySlice<UInt8>, currentHash hh: inout ContiguousArray<UInt32>) {
+  @usableFromInline
+  func process(block chunk: ArraySlice<UInt8>, currentHash hh: inout ContiguousArray<UInt32>) {
     // break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15, big-endian
     // Extend the sixteen 32-bit words into eighty 32-bit words:
     let M = UnsafeMutablePointer<UInt32>.allocate(capacity: 80)
@@ -98,7 +111,7 @@ public final class SHA1: DigestType {
 }
 
 extension SHA1: Updatable {
-  @discardableResult
+  @discardableResult @inlinable
   public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
     self.accumulated += bytes
 

+ 37 - 9
Sources/CryptoSwift/SHA2.swift

@@ -17,16 +17,31 @@
 //
 
 public final class SHA2: DigestType {
+  @usableFromInline
   let variant: Variant
+
+  @usableFromInline
   let size: Int
+
+  @usableFromInline
   let blockSize: Int
+
+  @usableFromInline
   let digestLength: Int
+
   private let k: Array<UInt64>
 
-  fileprivate var accumulated = Array<UInt8>()
-  fileprivate var processedBytesTotalCount: Int = 0
-  fileprivate var accumulatedHash32 = Array<UInt32>()
-  fileprivate var accumulatedHash64 = Array<UInt64>()
+  @usableFromInline
+  var accumulated = Array<UInt8>()
+
+  @usableFromInline
+  var processedBytesTotalCount: Int = 0
+
+  @usableFromInline
+  var accumulatedHash32 = Array<UInt32>()
+
+  @usableFromInline
+  var accumulatedHash64 = Array<UInt64>()
 
   public enum Variant: RawRepresentable {
     case sha224, sha256, sha384, sha512
@@ -73,7 +88,8 @@ public final class SHA2: DigestType {
       }
     }
 
-    fileprivate var h: Array<UInt64> {
+    @usableFromInline
+    var h: Array<UInt64> {
       switch self {
         case .sha224:
           return [0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4]
@@ -86,7 +102,8 @@ public final class SHA2: DigestType {
       }
     }
 
-    fileprivate var finalLength: Int {
+    @usableFromInline
+    var finalLength: Int {
       switch self {
         case .sha224:
           return 7
@@ -142,6 +159,7 @@ public final class SHA2: DigestType {
     }
   }
 
+  @inlinable
   public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
     do {
       return try update(withBytes: bytes.slice, isLast: true)
@@ -150,7 +168,8 @@ public final class SHA2: DigestType {
     }
   }
 
-  fileprivate func process64(block chunk: ArraySlice<UInt8>, currentHash hh: inout Array<UInt64>) {
+  @usableFromInline
+  func process64(block chunk: ArraySlice<UInt8>, currentHash hh: inout Array<UInt64>) {
     // break chunk into sixteen 64-bit words M[j], 0 ≤ j ≤ 15, big-endian
     // Extend the sixteen 64-bit words into eighty 64-bit words:
     let M = UnsafeMutablePointer<UInt64>.allocate(capacity: self.k.count)
@@ -210,7 +229,8 @@ public final class SHA2: DigestType {
   }
 
   // mutating currentHash in place is way faster than returning new result
-  fileprivate func process32(block chunk: ArraySlice<UInt8>, currentHash hh: inout Array<UInt32>) {
+  @usableFromInline
+  func process32(block chunk: ArraySlice<UInt8>, currentHash hh: inout Array<UInt32>) {
     // break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15, big-endian
     // Extend the sixteen 32-bit words into sixty-four 32-bit words:
     let M = UnsafeMutablePointer<UInt32>.allocate(capacity: self.k.count)
@@ -272,6 +292,8 @@ public final class SHA2: DigestType {
 }
 
 extension SHA2: Updatable {
+
+  @inlinable
   public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
     self.accumulated += bytes
 
@@ -294,7 +316,9 @@ extension SHA2: Updatable {
             self.process32(block: chunk, currentHash: &self.accumulatedHash32)
           case .sha384, .sha512:
             self.process64(block: chunk, currentHash: &self.accumulatedHash64)
-        }
+          @unknown default:
+            preconditionFailure()
+          }
         processedBytes += chunk.count
       }
     }
@@ -328,6 +352,8 @@ extension SHA2: Updatable {
           result[pos + 7] = UInt8(h & 0xff)
           pos += 8
         }
+      @unknown default:
+          preconditionFailure()
     }
 
     // reset hash value for instance
@@ -337,6 +363,8 @@ extension SHA2: Updatable {
           self.accumulatedHash32 = self.variant.h.lazy.map { UInt32($0) } // FIXME: UInt64 for process64
         case .sha384, .sha512:
           self.accumulatedHash64 = self.variant.h
+        @unknown default:
+          preconditionFailure()
       }
     }
 

+ 11 - 3
Sources/CryptoSwift/SHA3.swift

@@ -39,8 +39,12 @@ public final class SHA3: DigestType {
   public let digestLength: Int
   public let markByte: UInt8
 
-  fileprivate var accumulated = Array<UInt8>()
-  fileprivate var accumulatedHash: Array<UInt64>
+  @usableFromInline
+  var accumulated = Array<UInt8>()
+
+
+  @usableFromInline
+  var accumulatedHash: Array<UInt64>
 
   public enum Variant {
     case sha224, sha256, sha384, sha512, keccak224, keccak256, keccak384, keccak512
@@ -83,6 +87,7 @@ public final class SHA3: DigestType {
     self.accumulatedHash = Array<UInt64>(repeating: 0, count: self.digestLength)
   }
 
+  @inlinable
   public func calculate(for bytes: Array<UInt8>) -> Array<UInt8> {
     do {
       return try update(withBytes: bytes.slice, isLast: true)
@@ -177,7 +182,8 @@ public final class SHA3: DigestType {
     a[0] ^= self.round_constants[round]
   }
 
-  fileprivate func process(block chunk: ArraySlice<UInt64>, currentHash hh: inout Array<UInt64>) {
+  @usableFromInline
+  func process(block chunk: ArraySlice<UInt64>, currentHash hh: inout Array<UInt64>) {
     // expand
     hh[0] ^= chunk[0].littleEndian
     hh[1] ^= chunk[1].littleEndian
@@ -251,6 +257,8 @@ public final class SHA3: DigestType {
 }
 
 extension SHA3: Updatable {
+
+  @inlinable
   public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
     self.accumulated += bytes
 

+ 18 - 5
Sources/CryptoSwift/StreamDecryptor.swift

@@ -12,14 +12,25 @@
 //  - This notice may not be removed or altered from any source or binary distribution.
 //
 
+@usableFromInline
 final class StreamDecryptor: Cryptor, Updatable {
-  private let blockSize: Int
-  private var worker: CipherModeWorker
-  private let padding: Padding
-  private var accumulated = Array<UInt8>()
 
-  private var lastBlockRemainder = 0
+  @usableFromInline
+  internal let blockSize: Int
 
+  @usableFromInline
+  internal var worker: CipherModeWorker
+
+  @usableFromInline
+  internal let padding: Padding
+
+  @usableFromInline
+  internal var accumulated = Array<UInt8>()
+
+  @usableFromInline
+  internal var lastBlockRemainder = 0
+
+  @usableFromInline
   init(blockSize: Int, padding: Padding, _ worker: CipherModeWorker) throws {
     self.blockSize = blockSize
     self.padding = padding
@@ -28,6 +39,7 @@ final class StreamDecryptor: Cryptor, Updatable {
 
   // MARK: Updatable
 
+  @inlinable
   public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool) throws -> Array<UInt8> {
     self.accumulated += bytes
 
@@ -68,6 +80,7 @@ final class StreamDecryptor: Cryptor, Updatable {
     return plaintext
   }
 
+  @inlinable
   public func seek(to position: Int) throws {
     guard var worker = self.worker as? SeekableModeWorker else {
       fatalError("Not supported")

+ 15 - 4
Sources/CryptoSwift/StreamEncryptor.swift

@@ -12,13 +12,22 @@
 //  - This notice may not be removed or altered from any source or binary distribution.
 //
 
+@usableFromInline
 final class StreamEncryptor: Cryptor, Updatable {
-  private let blockSize: Int
-  private var worker: CipherModeWorker
-  private let padding: Padding
 
-  private var lastBlockRemainder = 0
+  @usableFromInline
+  internal let blockSize: Int
 
+  @usableFromInline
+  internal var worker: CipherModeWorker
+
+  @usableFromInline
+  internal let padding: Padding
+
+  @usableFromInline
+  internal var lastBlockRemainder = 0
+
+  @usableFromInline
   init(blockSize: Int, padding: Padding, _ worker: CipherModeWorker) throws {
     self.blockSize = blockSize
     self.padding = padding
@@ -27,6 +36,7 @@ final class StreamEncryptor: Cryptor, Updatable {
 
   // MARK: Updatable
 
+  @inlinable
   public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool) throws -> Array<UInt8> {
     var accumulated = Array(bytes)
     if isLast {
@@ -51,6 +61,7 @@ final class StreamEncryptor: Cryptor, Updatable {
     return encrypted
   }
 
+  @usableFromInline
   func seek(to: Int) throws {
     fatalError("Not supported")
   }

+ 15 - 0
Sources/CryptoSwift/String+Extension.swift

@@ -15,58 +15,72 @@
 
 /** String extension */
 extension String {
+
+  @inlinable
   public var bytes: Array<UInt8> {
     data(using: String.Encoding.utf8, allowLossyConversion: true)?.bytes ?? Array(utf8)
   }
 
+  @inlinable
   public func md5() -> String {
     self.bytes.md5().toHexString()
   }
 
+  @inlinable
   public func sha1() -> String {
     self.bytes.sha1().toHexString()
   }
 
+  @inlinable
   public func sha224() -> String {
     self.bytes.sha224().toHexString()
   }
 
+  @inlinable
   public func sha256() -> String {
     self.bytes.sha256().toHexString()
   }
 
+  @inlinable
   public func sha384() -> String {
     self.bytes.sha384().toHexString()
   }
 
+  @inlinable
   public func sha512() -> String {
     self.bytes.sha512().toHexString()
   }
 
+  @inlinable
   public func sha3(_ variant: SHA3.Variant) -> String {
     self.bytes.sha3(variant).toHexString()
   }
 
+  @inlinable
   public func crc32(seed: UInt32? = nil, reflect: Bool = true) -> String {
     self.bytes.crc32(seed: seed, reflect: reflect).bytes().toHexString()
   }
 
+  @inlinable
   public func crc32c(seed: UInt32? = nil, reflect: Bool = true) -> String {
     self.bytes.crc32c(seed: seed, reflect: reflect).bytes().toHexString()
   }
 
+  @inlinable
   public func crc16(seed: UInt16? = nil) -> String {
     self.bytes.crc16(seed: seed).bytes().toHexString()
   }
 
   /// - parameter cipher: Instance of `Cipher`
   /// - returns: hex string of bytes
+  @inlinable
   public func encrypt(cipher: Cipher) throws -> String {
     try self.bytes.encrypt(cipher: cipher).toHexString()
   }
 
   /// - parameter cipher: Instance of `Cipher`
   /// - returns: base64 encoded string of encrypted bytes
+  @inlinable
   public func encryptToBase64(cipher: Cipher) throws -> String? {
     try self.bytes.encrypt(cipher: cipher).toBase64()
   }
@@ -75,6 +89,7 @@ extension String {
 
   /// - parameter authenticator: Instance of `Authenticator`
   /// - returns: hex string of string
+  @inlinable
   public func authenticate<A: Authenticator>(with authenticator: A) throws -> String {
     try self.bytes.authenticate(with: authenticator).toHexString()
   }

+ 1 - 0
Sources/CryptoSwift/UInt32+Extension.swift

@@ -32,6 +32,7 @@ extension UInt32 {
   }
 
   @_specialize(where T == ArraySlice<UInt8>)
+  @inlinable
   init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Element == UInt8, T.Index == Int {
     if bytes.isEmpty {
       self = 0

+ 1 - 0
Sources/CryptoSwift/UInt64+Extension.swift

@@ -21,6 +21,7 @@ extension UInt64 {
   }
 
   @_specialize(where T == ArraySlice<UInt8>)
+  @inlinable
   init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Element == UInt8, T.Index == Int {
     if bytes.isEmpty {
       self = 0

+ 10 - 0
Sources/CryptoSwift/Updatable.swift

@@ -34,6 +34,7 @@ public protocol Updatable {
 }
 
 extension Updatable {
+  @inlinable
   public mutating func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false, output: (_ bytes: Array<UInt8>) -> Void) throws {
     let processed = try update(withBytes: bytes, isLast: isLast)
     if !processed.isEmpty {
@@ -41,14 +42,17 @@ extension Updatable {
     }
   }
 
+  @inlinable
   public mutating func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
     try self.update(withBytes: bytes, isLast: isLast)
   }
 
+  @inlinable
   public mutating func update(withBytes bytes: Array<UInt8>, isLast: Bool = false) throws -> Array<UInt8> {
     try self.update(withBytes: bytes.slice, isLast: isLast)
   }
 
+  @inlinable
   public mutating func update(withBytes bytes: Array<UInt8>, isLast: Bool = false, output: (_ bytes: Array<UInt8>) -> Void) throws {
     try self.update(withBytes: bytes.slice, isLast: isLast, output: output)
   }
@@ -56,10 +60,12 @@ extension Updatable {
   /// Finish updates. This may apply padding.
   /// - parameter bytes: Bytes to process
   /// - returns: Processed data.
+  @inlinable
   public mutating func finish(withBytes bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
     try self.update(withBytes: bytes, isLast: true)
   }
 
+  @inlinable
   public mutating func finish(withBytes bytes: Array<UInt8>) throws -> Array<UInt8> {
     try self.finish(withBytes: bytes.slice)
   }
@@ -68,6 +74,7 @@ extension Updatable {
   ///
   /// - Returns: Processed data
   /// - Throws: Error
+  @inlinable
   public mutating func finish() throws -> Array<UInt8> {
     try self.update(withBytes: [], isLast: true)
   }
@@ -76,6 +83,7 @@ extension Updatable {
   /// - parameter bytes: Bytes to process
   /// - parameter output: Resulting data
   /// - returns: Processed data.
+  @inlinable
   public mutating func finish(withBytes bytes: ArraySlice<UInt8>, output: (_ bytes: Array<UInt8>) -> Void) throws {
     let processed = try update(withBytes: bytes, isLast: true)
     if !processed.isEmpty {
@@ -83,6 +91,7 @@ extension Updatable {
     }
   }
 
+  @inlinable
   public mutating func finish(withBytes bytes: Array<UInt8>, output: (_ bytes: Array<UInt8>) -> Void) throws {
     try self.finish(withBytes: bytes.slice, output: output)
   }
@@ -91,6 +100,7 @@ extension Updatable {
   ///
   /// - Parameter output: Processed data
   /// - Throws: Error
+  @inlinable
   public mutating func finish(output: (Array<UInt8>) -> Void) throws {
     try self.finish(withBytes: [], output: output)
   }

+ 12 - 10
Sources/CryptoSwift/Utils.swift

@@ -13,42 +13,42 @@
 //  - This notice may not be removed or altered from any source or binary distribution.
 //
 
-@_transparent
+@inlinable
 func rotateLeft(_ value: UInt8, by: UInt8) -> UInt8 {
   ((value << by) & 0xff) | (value >> (8 - by))
 }
 
-@_transparent
+@inlinable
 func rotateLeft(_ value: UInt16, by: UInt16) -> UInt16 {
   ((value << by) & 0xffff) | (value >> (16 - by))
 }
 
-@_transparent
+@inlinable
 func rotateLeft(_ value: UInt32, by: UInt32) -> UInt32 {
   ((value << by) & 0xffffffff) | (value >> (32 - by))
 }
 
-@_transparent
+@inlinable
 func rotateLeft(_ value: UInt64, by: UInt64) -> UInt64 {
   (value << by) | (value >> (64 - by))
 }
 
-@_transparent
+@inlinable
 func rotateRight(_ value: UInt16, by: UInt16) -> UInt16 {
   (value >> by) | (value << (16 - by))
 }
 
-@_transparent
+@inlinable
 func rotateRight(_ value: UInt32, by: UInt32) -> UInt32 {
   (value >> by) | (value << (32 - by))
 }
 
-@_transparent
+@inlinable
 func rotateRight(_ value: UInt64, by: UInt64) -> UInt64 {
   ((value >> by) | (value << (64 - by)))
 }
 
-@_transparent
+@inlinable
 func reversed(_ uint8: UInt8) -> UInt8 {
   var v = uint8
   v = (v & 0xf0) >> 4 | (v & 0x0f) << 4
@@ -57,7 +57,7 @@ func reversed(_ uint8: UInt8) -> UInt8 {
   return v
 }
 
-@_transparent
+@inlinable
 func reversed(_ uint32: UInt32) -> UInt32 {
   var v = uint32
   v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1)
@@ -68,10 +68,12 @@ func reversed(_ uint32: UInt32) -> UInt32 {
   return v
 }
 
+@inlinable
 func xor<T, V>(_ left: T, _ right: V) -> ArraySlice<UInt8> where T: RandomAccessCollection, V: RandomAccessCollection, T.Element == UInt8, T.Index == Int, V.Element == UInt8, V.Index == Int {
   return xor(left, right).slice
 }
 
+@inlinable
 func xor<T, V>(_ left: T, _ right: V) -> Array<UInt8> where T: RandomAccessCollection, V: RandomAccessCollection, T.Element == UInt8, T.Index == Int, V.Element == UInt8, V.Index == Int {
   let length = Swift.min(left.count, right.count)
 
@@ -98,7 +100,7 @@ func xor<T, V>(_ left: T, _ right: V) -> Array<UInt8> where T: RandomAccessColle
  - blockSize: Padding size in bytes.
  - allowance: Excluded trailing number of bytes.
  */
-@inline(__always)
+@inline(__always) @inlinable
 func bitPadding(to data: inout Array<UInt8>, blockSize: Int, allowance: Int = 0) {
   let msgLength = data.count
   // Step 1. Append Padding Bits

+ 2 - 0
Sources/CryptoSwift/ZeroPadding.swift

@@ -19,6 +19,7 @@ struct ZeroPadding: PaddingProtocol {
   init() {
   }
 
+  @inlinable
   func add(to bytes: Array<UInt8>, blockSize: Int) -> Array<UInt8> {
     let paddingCount = blockSize - (bytes.count % blockSize)
     if paddingCount > 0 {
@@ -27,6 +28,7 @@ struct ZeroPadding: PaddingProtocol {
     return bytes
   }
 
+  @inlinable
   func remove(from bytes: Array<UInt8>, blockSize _: Int?) -> Array<UInt8> {
     for (idx, value) in bytes.reversed().enumerated() {
       if value != 0 {

Някои файлове не бяха показани, защото твърде много файлове са промени