浏览代码

Missing guard for CTR

Marcin Krzyżanowski 10 年之前
父节点
当前提交
a845c89e28
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      CryptoSwift/CipherBlockMode.swift

+ 2 - 2
CryptoSwift/CipherBlockMode.swift

@@ -204,7 +204,7 @@ private struct CTRMode: BlockMode {
     }
     
     func decryptBlocks(blocks:[[UInt8]], iv:[UInt8]?, cipherOperation:CipherOperationOnBlock) throws -> [UInt8] {
-        guard iv != nil else {
+        guard let iv = iv else {
             throw BlockError.MissingInitializationVector
         }
         
@@ -212,7 +212,7 @@ private struct CTRMode: BlockMode {
         var out:[UInt8] = [UInt8]()
         out.reserveCapacity(blocks.count * blocks[0].count)
         for plaintext in blocks {
-            let nonce = buildNonce(iv!, counter: counter++)
+            let nonce = buildNonce(iv, counter: counter++)
             if let encrypted = cipherOperation(block: nonce) {
                 out.extend(xor(encrypted, b: plaintext))
             }