2
0
Эх сурвалжийг харах

Address possible timing issue. Reported by @blochberger

Marcin Krzyzanowski 5 жил өмнө
parent
commit
6d599042fd

+ 2 - 6
Sources/CryptoSwift/PKCS/PKCS7Padding.swift

@@ -30,14 +30,10 @@ struct PKCS7Padding: PaddingProtocol {
     var withPadding = bytes
     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 += Array<UInt8>(arrayLiteral: UInt8(blockSize))
-      }
+      withPadding += Array<UInt8>(repeating: UInt8(blockSize), count: Int(blockSize))
     } else {
       // The value of each added byte is the number of bytes that are added
-      for _ in 0..<padding {
-        withPadding += Array<UInt8>(arrayLiteral: UInt8(padding))
-      }
+      withPadding += Array<UInt8>(repeating: padding, count: Int(padding))
     }
     return withPadding
   }