Skip to content

Commit

Permalink
DeterministicKey: throw a KeyCrypterException instead of an IllegalSt…
Browse files Browse the repository at this point in the history
…ateException if the derivation check fails (as this can happen when the password is wrong)
  • Loading branch information
mikehearn committed Sep 2, 2015
1 parent 48b4df7 commit a73677e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/main/java/org/bitcoinj/crypto/DeterministicKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@ private BigInteger derivePrivateKeyDownwards(DeterministicKey cursor, byte[] par
downCursor = HDKeyDerivation.deriveChildKey(downCursor, num);
}
// downCursor is now the same key as us, but with private key bytes.
checkState(downCursor.pub.equals(pub));
// If it's not, it means we tried decrypting with an invalid password and earlier checks e.g. for padding didn't
// catch it.
if (!downCursor.pub.equals(pub))
throw new KeyCrypterException("Could not decrypt bytes");
return checkNotNull(downCursor.priv);
}

Expand Down

0 comments on commit a73677e

Please sign in to comment.