Jelajahi Sumber

fix spacing after comma

Nicholas Maccharoli 5 tahun lalu
induk
melakukan
d4a89da456

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

@@ -102,7 +102,7 @@ class CCMModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker, Fi
         case invalidParameter
         case invalidParameter
     }
     }
 
 
-    init(blockSize: Int, nonce: ArraySlice<UInt8>, messageLength: Int,  additionalAuthenticatedData: [UInt8]?, expectedTag: Array<UInt8>? = nil, tagLength: Int, cipherOperation: @escaping CipherOperationOnBlock) {
+    init(blockSize: Int, nonce: ArraySlice<UInt8>, messageLength: Int, additionalAuthenticatedData: [UInt8]?, expectedTag: Array<UInt8>? = nil, tagLength: Int, cipherOperation: @escaping CipherOperationOnBlock) {
         self.blockSize = 16 // CCM is defined for 128 block size
         self.blockSize = 16 // CCM is defined for 128 block size
         self.tagLength = tagLength
         self.tagLength = tagLength
         self.additionalBufferSize = tagLength
         self.additionalBufferSize = tagLength
@@ -236,7 +236,7 @@ class CCMModeWorker: StreamModeWorker, SeekableModeWorker, CounterModeWorker, Fi
         // overwrite expectedTag property used later for verification
         // overwrite expectedTag property used later for verification
         guard let S0 = try? S(i: 0) else { return ciphertext }
         guard let S0 = try? S(i: 0) else { return ciphertext }
         self.expectedTag = xor(ciphertext.suffix(tagLength), S0) as [UInt8]
         self.expectedTag = xor(ciphertext.suffix(tagLength), S0) as [UInt8]
-        return ciphertext[ciphertext.startIndex..<ciphertext.endIndex.advanced(by: -Swift.min(tagLength,ciphertext.count))]
+        return ciphertext[ciphertext.startIndex..<ciphertext.endIndex.advanced(by: -Swift.min(tagLength, ciphertext.count))]
     }
     }
 
 
     func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
     func didDecryptLast(bytes plaintext: ArraySlice<UInt8>) throws -> ArraySlice<UInt8> {
@@ -330,7 +330,7 @@ private func format(aad: [UInt8]) -> [UInt8] {
     case 65280..<4_294_967_296: // 2^32
     case 65280..<4_294_967_296: // 2^32
         // [a]32
         // [a]32
         return addPadding([0xFF, 0xFE] + a.bytes(totalBytes: 4) + aad, blockSize: 16)
         return addPadding([0xFF, 0xFE] + a.bytes(totalBytes: 4) + aad, blockSize: 16)
-    case 4_294_967_296..<pow(2,64): // 2^64
+    case 4_294_967_296..<pow(2, 64): // 2^64
         // [a]64
         // [a]64
         return addPadding([0xFF, 0xFF] + a.bytes(totalBytes: 8) + aad, blockSize: 16)
         return addPadding([0xFF, 0xFF] + a.bytes(totalBytes: 8) + aad, blockSize: 16)
     default:
     default:

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

@@ -196,7 +196,7 @@ final class GCMModeWorker: BlockModeWorker, FinalizingEncryptModeWorker, Finaliz
         case .combined:
         case .combined:
             // overwrite expectedTag property used later for verification
             // overwrite expectedTag property used later for verification
             self.expectedTag = Array(ciphertext.suffix(tagLength))
             self.expectedTag = Array(ciphertext.suffix(tagLength))
-            return ciphertext[ciphertext.startIndex..<ciphertext.endIndex.advanced(by: -Swift.min(tagLength,ciphertext.count))]
+            return ciphertext[ciphertext.startIndex..<ciphertext.endIndex.advanced(by: -Swift.min(tagLength, ciphertext.count))]
         case .detached:
         case .detached:
             return ciphertext
             return ciphertext
         }
         }

+ 3 - 3
Tests/CryptoSwiftTests/AESCCMTests.swift

@@ -26,7 +26,7 @@ final class AESCCMTests: XCTestCase {
         let plaintext: Array<UInt8>
         let plaintext: Array<UInt8>
         let expected: Array<UInt8>
         let expected: Array<UInt8>
 
 
-        init(_ tagLength: Int, _ key: String, _ nonce: String,  _ plaintext: String, _ expected: String, _ aad: String) {
+        init(_ tagLength: Int, _ key: String, _ nonce: String, _ plaintext: String, _ expected: String, _ aad: String) {
             self.tagLength = tagLength
             self.tagLength = tagLength
             self.key = Array<UInt8>(hex: key)
             self.key = Array<UInt8>(hex: key)
             self.nonce = Array<UInt8>(hex: nonce)
             self.nonce = Array<UInt8>(hex: nonce)
@@ -55,7 +55,7 @@ final class AESCCMTests: XCTestCase {
             TestFixture(4, "e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8", "0545fd9ecbc73ccdbbbd4244fd", "", "5c349fb2", ""),
             TestFixture(4, "e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8", "0545fd9ecbc73ccdbbbd4244fd", "", "5c349fb2", ""),
             TestFixture(4, "e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8", "0a37f2e7c66490e97285f1b09e", "", "c59bf14c", ""),
             TestFixture(4, "e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8", "0a37f2e7c66490e97285f1b09e", "", "c59bf14c", ""),
             TestFixture(4, "e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8", "c1ad812bf2bbb2cdaee4636ee7", "", "5b96f41d", ""),
             TestFixture(4, "e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8", "c1ad812bf2bbb2cdaee4636ee7", "", "5b96f41d", ""),
-            TestFixture(16, "af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569", "a544218dadd3c10583db49cf39", "","97e1a8dd4259ccd2e431e057b0397fcf", ""),
+            TestFixture(16, "af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569", "a544218dadd3c10583db49cf39", "", "97e1a8dd4259ccd2e431e057b0397fcf", ""),
             TestFixture(16, "af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569", "79ac204a26b9fee1132370c20f", "", "5c8c9a5b97be8c7bc01ca8d693b809f9", ""),
             TestFixture(16, "af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569", "79ac204a26b9fee1132370c20f", "", "5c8c9a5b97be8c7bc01ca8d693b809f9", ""),
             TestFixture(16, "af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569", "0545fd9ecbc73ccdbbbd4244fd", "", "84201662b213c7a1ff0c1b3c25e4ec45", ""),
             TestFixture(16, "af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569", "0545fd9ecbc73ccdbbbd4244fd", "", "84201662b213c7a1ff0c1b3c25e4ec45", ""),
             TestFixture(16, "af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569", "0a37f2e7c66490e97285f1b09e", "", "586e728193ce6db9a926b03b2d77dd6e", ""),
             TestFixture(16, "af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569", "0a37f2e7c66490e97285f1b09e", "", "586e728193ce6db9a926b03b2d77dd6e", ""),
@@ -390,7 +390,7 @@ final class AESCCMTests: XCTestCase {
             return true
             return true
         }
         }
 
 
-        for (i,fixture) in fixtures.enumerated() {
+        for (i, fixture) in fixtures.enumerated() {
             XCTAssertTrue(testEncrypt(fixture: fixture), "Encryption failed")
             XCTAssertTrue(testEncrypt(fixture: fixture), "Encryption failed")
             XCTAssertTrue(testDecrypt(fixture: fixture), "(\(i) - Decryption failed.")
             XCTAssertTrue(testDecrypt(fixture: fixture), "(\(i) - Decryption failed.")
         }
         }