mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
LibCrypto: Tweak ::prune_padding() to be more intuitive with loop bounds
This commit is contained in:
parent
b394543d3c
commit
4d932ce701
1 changed files with 4 additions and 4 deletions
|
@ -68,8 +68,8 @@ protected:
|
|||
// cannot be padding (the entire block cannot be padding)
|
||||
return;
|
||||
}
|
||||
for (auto i = maybe_padding_length; i > 0; --i) {
|
||||
if (data[size - i] != maybe_padding_length) {
|
||||
for (auto i = size - maybe_padding_length; i < size; ++i) {
|
||||
if (data[i] != maybe_padding_length) {
|
||||
// not padding, part of data
|
||||
return;
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ protected:
|
|||
return;
|
||||
}
|
||||
// FIXME: If we want to constant-time operations, this loop should not stop
|
||||
for (auto i = maybe_padding_length; i > 0; --i) {
|
||||
if (data[size - i - 1] != maybe_padding_length) {
|
||||
for (auto i = size - maybe_padding_length - 1; i < size; ++i) {
|
||||
if (data[i] != maybe_padding_length) {
|
||||
// note that this is likely invalid padding
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue