Skip to content

Commit b1065da

Browse files
committed
Merge pull request #349 from mbrubeck/bcrypt-cost-overflow
bcrypt: Fix overflow when cost == 31.
2 parents 1fefe9d + 2f34dbd commit b1065da

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bcrypt.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ use cryptoutil::{write_u32_be};
99
use step_by::RangeExt;
1010

1111
fn setup(cost: u32, salt: &[u8], key: &[u8]) -> Blowfish {
12+
assert!(cost < 32);
1213
let mut state = Blowfish::init_state();
1314

1415
state.salted_expand_key(salt, key);
15-
for _ in 0..1 << cost {
16+
for _ in 0..1u32 << cost {
1617
state.expand_key(key);
1718
state.expand_key(salt);
1819
}

0 commit comments

Comments
 (0)