Marcin Krzyzanowski пре 6 година
родитељ
комит
db430a2370

+ 1 - 1
Sources/CryptoSwift/BlockDecryptor.swift

@@ -56,7 +56,7 @@ public class BlockDecryptor: Cryptor, Updatable {
                 }
 
                 if var finalizingWorker = worker as? FinalizingDecryptModeWorker, isLast == true {
-                    plaintext = Array(try finalizingWorker.didDecryptLast(block: plaintext.slice))
+                    plaintext = Array(try finalizingWorker.didDecryptLast(bytes: plaintext.slice))
                 }
 
                 processedBytesCount += chunk.count

+ 3 - 3
Sources/CryptoSwift/BlockMode/CCM.swift

@@ -162,15 +162,15 @@ class CCMModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker, Fi
         return result
     }
 
-    func finalize(decrypt ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
-        return ciphertext
+    func finalize(decrypt plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
+        return plaintext
     }
 
     func willDecryptLast(bytes ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
         return ciphertext
     }
 
-    func didDecryptLast(block plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
+    func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
         return plaintext
     }
 }

+ 4 - 4
Sources/CryptoSwift/BlockMode/CipherModeWorker.swift

@@ -49,12 +49,12 @@ public protocol FinalizingEncryptModeWorker: CipherModeWorker {
 }
 
 public protocol FinalizingDecryptModeWorker: CipherModeWorker {
-    // Any final calculations, eg. calculate tag
-    // Called after the last block is encrypted
-    mutating func finalize(decrypt plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
     // Called before decryption, hence input is ciphertext.
     // ciphertext is either a last block, or a tag (for stream workers)
     mutating func willDecryptLast(bytes ciphertext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
     // Called after decryption, hence input is ciphertext
-    mutating func didDecryptLast(block plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
+    mutating func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
+    // Any final calculations, eg. calculate tag
+    // Called after the last block is encrypted
+    mutating func finalize(decrypt plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8>
 }

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

@@ -203,7 +203,7 @@ final class GCMModeWorker: BlockModeWorker, FinalizingEncryptModeWorker, Finaliz
         }
     }
 
-    func didDecryptLast(block plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
+    func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
         // Calculate MAC tag.
         let ghash = gf.ghashFinish()
         let computedTag = Array((ghash ^ eky0).bytes.prefix(GCMModeWorker.tagLength))