Skip to content

Commit

Permalink
Merge pull request #391 from ladeiko/master
Browse files Browse the repository at this point in the history
Fix PKCS7.add: removed unreachable code
  • Loading branch information
skreutzberger committed Apr 6, 2020
2 parents 4d8f9f0 + bed316c commit f0c36dd
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions Sources/AES256CBC.swift
Expand Up @@ -600,16 +600,9 @@ private struct PKCS7 {
func add(bytes: [UInt8], blockSize: Int) -> [UInt8] {
let padding = UInt8(blockSize - (bytes.count % blockSize))
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.append(contentsOf: [UInt8(blockSize)])
}
} else {
// The value of each added byte is the number of bytes that are added
for _ in 0..<padding {
withPadding.append(contentsOf: [UInt8(padding)])
}
// The value of each added byte is the number of bytes that are added
for _ in 0..<padding {
withPadding.append(contentsOf: [UInt8(padding)])
}
return withPadding
}
Expand Down

0 comments on commit f0c36dd

Please sign in to comment.