Skip to content

Commit

Permalink
Address possible timing issue. Reported by @blochberger
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyzanowskim committed Apr 2, 2020
1 parent f639517 commit 6d59904
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Sources/CryptoSwift/PKCS/PKCS7Padding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 6d59904

Please sign in to comment.