Skip to content

Commit

Permalink
Replace upper_bound with lower_bound in pgp_s2k
Browse files Browse the repository at this point in the history
Fix: RFC4880_encode_count doesn't return consistent results when
processing exact iterations. It returns RFC4880 code + 1.
  • Loading branch information
evpo committed Mar 10, 2019
1 parent 2920510 commit 4e240e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ uint8_t RFC4880_encode_count(size_t desired_iterations)
if(desired_iterations >= OPENPGP_S2K_ITERS[255])
return 255;

auto i = std::upper_bound(OPENPGP_S2K_ITERS, OPENPGP_S2K_ITERS + 256, desired_iterations);
auto i = std::lower_bound(OPENPGP_S2K_ITERS, OPENPGP_S2K_ITERS + 256, desired_iterations);

return static_cast<uint8_t>(i - OPENPGP_S2K_ITERS);
}
Expand Down

0 comments on commit 4e240e8

Please sign in to comment.