Skip to content

Commit

Permalink
Replaced while loop with an explicit array addition of the correct size.
Browse files Browse the repository at this point in the history
  • Loading branch information
btoms20 committed Sep 1, 2022
1 parent d6f3449 commit b628b84
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions Sources/CryptoSwift/RSA/RSA+Cipher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit b628b84

Please sign in to comment.