Skip to content

Commit a80a201

Browse files
committed
github #76 fixed so cost of 31 correct.
1 parent d25f85f commit a80a201

File tree

1 file changed

+2
-1
lines changed
  • core/src/main/java/org/bouncycastle/crypto/generators

1 file changed

+2
-1
lines changed

core/src/main/java/org/bouncycastle/crypto/generators/BCrypt.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ private final byte[] deriveRawKey(
586586
Arrays.fill(salt32Bit2, 0);
587587

588588
int rounds = 1 << cost;
589-
for (int i = 0; i < rounds; i++)
589+
for (int i = 0; i != rounds; i++) // rounds may be negative if cost is 31
590590
{
591591
// state <- ExpandKey(state, 0, key);
592592
cyclicXorKey(psw);
@@ -598,6 +598,7 @@ private final byte[] deriveRawKey(
598598
processTable(0, 0, P);
599599
processTable(P[P_SZ - 2], P[P_SZ - 1], S);
600600
}
601+
601602
// encrypt magicString 64 times
602603
return encryptMagicString();
603604
}

0 commit comments

Comments
 (0)