瀏覽代碼

Fix CTR nonce calculation on 32bit arch.

Marcin Krzyżanowski 10 年之前
父節點
當前提交
e302748b6d
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      CryptoSwift/CipherBlockMode.swift

+ 1 - 1
CryptoSwift/CipherBlockMode.swift

@@ -177,7 +177,7 @@ private struct CTRMode: BlockMode {
     private func buildNonce(iv: [UInt8], counter: UInt) -> [UInt8] {
     private func buildNonce(iv: [UInt8], counter: UInt) -> [UInt8] {
         let noncePartLen = AES.blockSize / 2
         let noncePartLen = AES.blockSize / 2
         let noncePrefix = Array(iv[0..<noncePartLen])
         let noncePrefix = Array(iv[0..<noncePartLen])
-        let nonceSuffix = arrayOfBytes(counter)
+        let nonceSuffix = arrayOfBytes(counter, length: noncePartLen)
         
         
         var nonce = noncePrefix
         var nonce = noncePrefix
         nonce += nonceSuffix
         nonce += nonceSuffix