Skip to content

Commit 6e13489

Browse files
committed
isPassphraseCorrect(): Return false if passphrase provided and key is not locked
1 parent 7e9d2cc commit 6e13489

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,11 @@ private void sanitizeProtectionMode()
367367

368368
public boolean isPassphraseCorrect(char[] passphrase)
369369
{
370+
if (passphrase != null && !isLocked())
371+
{
372+
return false;
373+
}
374+
370375
try
371376
{
372377
OpenPGPPrivateKey privateKey = unlock(passphrase);

0 commit comments

Comments
 (0)