* Fix `@escaping` compile error * Resolve complexity compile error
@@ -11,7 +11,7 @@ typealias CipherOperationOnBlock = (_ block: Array<UInt8>) -> Array<UInt8>?
public enum BlockMode {
case ECB, CBC, PCBC, CFB, OFB, CTR
- func worker(_ iv: Array<UInt8>?, cipherOperation: CipherOperationOnBlock) -> BlockModeWorker {
+ func worker(_ iv: Array<UInt8>?, cipherOperation: @escaping CipherOperationOnBlock) -> BlockModeWorker {
switch (self) {
case .ECB:
return ECBModeWorker(iv: iv ?? [], cipherOperation: cipherOperation)
@@ -15,7 +15,7 @@ struct CBCModeWorker: BlockModeWorker {
private let iv: Element
private var prev: Element?
- init(iv: Array<UInt8>, cipherOperation: CipherOperationOnBlock) {
+ init(iv: Array<UInt8>, cipherOperation: @escaping CipherOperationOnBlock) {
self.iv = iv
self.cipherOperation = cipherOperation
}
@@ -15,7 +15,7 @@ struct CFBModeWorker: BlockModeWorker {
@@ -15,7 +15,7 @@ struct CTRModeWorker: RandomAccessBlockModeWorker {
var counter: UInt = 0
@@ -12,7 +12,7 @@ struct ECBModeWorker: BlockModeWorker {
typealias Element = Array<UInt8>
let cipherOperation: CipherOperationOnBlock
@@ -15,7 +15,7 @@ struct OFBModeWorker: BlockModeWorker {
@@ -15,7 +15,7 @@ struct PCBCModeWorker: BlockModeWorker {
@@ -60,7 +60,9 @@ final class ExtensionsTest: XCTestCase {
let ii:Int = 21
XCTAssert(ii &<< 1 == ii << 1, "shift left failed")
XCTAssert(ii &<< 8 == ii << 8, "shift left failed")
- XCTAssert(ii &<< ((MemoryLayout<Int>.size * 8) - 1) == ii << ((MemoryLayout<Int>.size * 8) - 1), "shift left failed")
+ let shiftLeft1 = ii &<< ((MemoryLayout<Int>.size * 8) - 1)
+ let shiftLeft2 = ii << ((MemoryLayout<Int>.size * 8) - 1)
+ XCTAssert(shiftLeft1 == shiftLeft2, "shift left failed")
XCTAssert(ii &<< ((MemoryLayout<Int>.size * 8)) == 0, "shift left failed")
let iii:UInt32 = 21