From 1916a8fd294686595998ad99cbfcfa157702e5a8 Mon Sep 17 00:00:00 2001 From: cR Date: Wed, 3 Apr 2019 19:03:22 -0500 Subject: [PATCH] Added default argument options: Int = kCCModeOptionCTR_BE in crypt to ensure proper CTR block-mode operation --- SwCrypt/SwCrypt.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SwCrypt/SwCrypt.swift b/SwCrypt/SwCrypt.swift index 40a7504..6a19078 100644 --- a/SwCrypt/SwCrypt.swift +++ b/SwCrypt/SwCrypt.swift @@ -1,4 +1,5 @@ import Foundation +import CommonCrypto open class SwKeyStore { @@ -724,7 +725,7 @@ open class CC { public static func crypt(_ opMode: OpMode, blockMode: BlockMode, algorithm: Algorithm, padding: Padding, - data: Data, key: Data, iv: Data) throws -> Data { + data: Data, key: Data, iv: Data, options: Int = kCCModeOptionCTR_BE) throws -> Data { if blockMode.needIV { guard iv.count == algorithm.blockSize else { throw CCError(.paramError) } } @@ -736,7 +737,7 @@ open class CC { algorithm.rawValue, padding.rawValue, ivBytes, keyBytes, key.count, nil, 0, 0, - CCModeOptions(), &cryptor) + CCModeOptions(options), &cryptor) }) guard status == noErr else { throw CCError(status) }