소스 검색

Support Xcode 7 beta 6

Matias Cudich 10 년 전
부모
커밋
bbc2961138
3개의 변경된 파일10개의 추가작업 그리고 10개의 파일을 삭제
  1. 2 2
      CryptoSwift/ChaCha20.swift
  2. 6 6
      CryptoSwift/CipherBlockMode.swift
  3. 2 2
      CryptoSwift/PKCS7.swift

+ 2 - 2
CryptoSwift/ChaCha20.swift

@@ -81,7 +81,7 @@ final public class ChaCha20 {
 
         for i in 0..<16 {
             x[i] = x[i] &+ input[i]            
-            output.extend([UInt8((x[i] & 0xFFFFFFFF) >> 24),
+            output.appendContentsOf([UInt8((x[i] & 0xFFFFFFFF) >> 24),
                        UInt8((x[i] & 0xFFFFFF) >> 16),
                        UInt8((x[i] & 0xFFFF) >> 8),
                        UInt8((x[i] & 0xFF) >> 0)])
@@ -194,7 +194,7 @@ final public class ChaCha20 {
 /// Change array to number. It's here because arrayOfBytes is too slow
 private func wordNumber(bytes:ArraySlice<UInt8>) -> UInt32 {
     var value:UInt32 = 0
-    for (var i:UInt32 = 0, j = 0; i < 4; i++, j++) {
+    for (var i:UInt32 = 0, j = bytes.startIndex; i < 4; i++, j++) {
         value = value | UInt32(bytes[j]) << (8 * i)
     }
     return value

+ 6 - 6
CryptoSwift/CipherBlockMode.swift

@@ -89,7 +89,7 @@ private struct CBCMode: BlockMode {
         var prevCiphertext = iv // for the first time prevCiphertext = iv
         for plaintext in blocks {
             if let encrypted = cipherOperation(block: xor(prevCiphertext, b: plaintext)) {
-                out.extend(encrypted)
+                out.appendContentsOf(encrypted)
                 prevCiphertext = encrypted
             }
         }
@@ -107,7 +107,7 @@ private struct CBCMode: BlockMode {
         var prevCiphertext = iv // for the first time prevCiphertext = iv
         for ciphertext in blocks {
             if let decrypted = cipherOperation(block: ciphertext) { // decrypt
-                out.extend(xor(prevCiphertext, b: decrypted)) //FIXME: b:
+                out.appendContentsOf(xor(prevCiphertext, b: decrypted)) //FIXME: b:
             }
             prevCiphertext = ciphertext
         }
@@ -134,7 +134,7 @@ private struct CFBMode: BlockMode {
         for plaintext in blocks {
             if let encrypted = cipherOperation(block: lastCiphertext) {
                 lastCiphertext = xor(plaintext,b: encrypted)
-                out.extend(lastCiphertext)
+                out.appendContentsOf(lastCiphertext)
             }
         }
         return out
@@ -157,7 +157,7 @@ private struct ECBMode: BlockMode {
         out.reserveCapacity(blocks.count * blocks[0].count)
         for plaintext in blocks {
             if let encrypted = cipherOperation(block: plaintext) {
-                out.extend(encrypted)
+                out.appendContentsOf(encrypted)
             }
         }
         return out
@@ -197,7 +197,7 @@ private struct CTRMode: BlockMode {
         for plaintext in blocks {
             let nonce = buildNonce(iv, counter: counter++)
             if let encrypted = cipherOperation(block: nonce) {
-                out.extend(xor(plaintext, b: encrypted))
+                out.appendContentsOf(xor(plaintext, b: encrypted))
             }
         }
         return out
@@ -214,7 +214,7 @@ private struct CTRMode: BlockMode {
         for plaintext in blocks {
             let nonce = buildNonce(iv, counter: counter++)
             if let encrypted = cipherOperation(block: nonce) {
-                out.extend(xor(encrypted, b: plaintext))
+                out.appendContentsOf(xor(encrypted, b: plaintext))
             }
         }
         return out

+ 2 - 2
CryptoSwift/PKCS7.swift

@@ -23,12 +23,12 @@ public struct PKCS7: Padding {
         if (padding == 0) {
             // If the original data is a multiple of N bytes, then an extra block of bytes with value N is added.
             for _ in 0..<blockSize {
-                withPadding.extend([UInt8(blockSize)])
+                withPadding.appendContentsOf([UInt8(blockSize)])
             }
         } else {
             // The value of each added byte is the number of bytes that are added
             for _ in 0..<padding {
-                withPadding.extend([UInt8(padding)])
+                withPadding.appendContentsOf([UInt8(padding)])
             }
         }
         return withPadding