Browse Source

Fix decrypt for CBC in case IV is longer than block size. #32

Marcin Krzyżanowski 11 years ago
parent
commit
3d7ce7933b
1 changed files with 1 additions and 1 deletions
  1. 1 1
      CryptoSwift/CipherBlockMode.swift

+ 1 - 1
CryptoSwift/CipherBlockMode.swift

@@ -111,7 +111,7 @@ private struct CBCMode {
         for (idx,ciphertext) in enumerate(blocks) {
         for (idx,ciphertext) in enumerate(blocks) {
             if let decrypted = cipher(block: ciphertext) { // decrypt
             if let decrypted = cipher(block: ciphertext) { // decrypt
                 
                 
-                var xored:[UInt8] = [UInt8](count: lastCiphertext.count, repeatedValue: 0)
+                var xored:[UInt8] = [UInt8](count: ciphertext.count, repeatedValue: 0)
                 for i in 0..<ciphertext.count {
                 for i in 0..<ciphertext.count {
                     xored[i] = lastCiphertext[i] ^ decrypted[i]
                     xored[i] = lastCiphertext[i] ^ decrypted[i]
                 }
                 }