Sfoglia il codice sorgente

Tired of array slice bugs...

Nathan Fallet 4 anni fa
parent
commit
5ecda3852d
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 3 3
      Sources/CryptoSwift/BlockMode/CFB.swift

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

@@ -76,7 +76,7 @@ struct CFBModeWorker: BlockModeWorker {
       guard let ciphertext = cipherOperation(prev ?? iv) else {
         return Array(plaintext)
       }
-      let result = [plaintext[0] ^ ciphertext[0]]
+      let result = [Array(plaintext)[0] ^ Array(ciphertext)[0]]
       self.prev = Array((prev ?? iv).dropFirst()) + [result[0]]
       return result
     }
@@ -98,8 +98,8 @@ struct CFBModeWorker: BlockModeWorker {
       guard let plaintext = cipherOperation(prev ?? iv) else {
         return Array(ciphertext)
       }
-      self.prev = Array((prev ?? iv).dropFirst()) + [ciphertext[0]]
-      return [ciphertext[0] ^ plaintext[0]]
+      self.prev = Array((prev ?? iv).dropFirst()) + [Array(ciphertext)[0]]
+      return [Array(ciphertext)[0] ^ Array(plaintext)[0]]
     }
     return Array(ciphertext) // Unsupported segment size
   }