Ver código fonte

Replaced while loop with an explicit array addition of the correct size.

Brandon Toms 3 anos atrás
pai
commit
b628b84927
1 arquivos alterados com 1 adições e 14 exclusões
  1. 1 14
      Sources/CryptoSwift/RSA/RSA+Cipher.swift

+ 1 - 14
Sources/CryptoSwift/RSA/RSA+Cipher.swift

@@ -106,20 +106,7 @@ extension RSA {
           return bytes
         case .raw, .pksc1v15:
           // Format the encrypted bytes before returning
-          //var bytes = bytes
-//          if bytes.isEmpty {
-//            // Instead of returning an empty byte array, we return an array of zero's of length keySize bytes
-//            // This functionality matches that of Apple's `Security` framework
-//            return Array<UInt8>(repeating: 0, count: blockSize)
-//          } else {
-//            while bytes.count % 4 != 0 { bytes.insert(0x00, at: 0) }
-//            return bytes
-//          }
-          var bytes = bytes
-          while bytes.count != blockSize {
-            bytes.insert(0x00, at: 0)
-          }
-          return bytes
+          return Array<UInt8>(repeating: 0x00, count: blockSize - bytes.count) + bytes
       }
     }