1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-30 00:02:06 +01:00

Fix BaseSecretKeyRingProtector misinterpreting empty passphrases

This commit is contained in:
Paul Schaub 2021-12-02 14:44:03 +01:00
parent 14c1cf013e
commit e7d0cf9c00
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -36,7 +36,7 @@ public class BaseSecretKeyRingProtector implements SecretKeyRingProtector {
@Nullable @Nullable
public PBESecretKeyDecryptor getDecryptor(Long keyId) throws PGPException { public PBESecretKeyDecryptor getDecryptor(Long keyId) throws PGPException {
Passphrase passphrase = passphraseProvider.getPassphraseFor(keyId); Passphrase passphrase = passphraseProvider.getPassphraseFor(keyId);
return passphrase == null ? null : return passphrase == null || passphrase.isEmpty() ? null :
ImplementationFactory.getInstance().getPBESecretKeyDecryptor(passphrase); ImplementationFactory.getInstance().getPBESecretKeyDecryptor(passphrase);
} }
@ -44,7 +44,7 @@ public class BaseSecretKeyRingProtector implements SecretKeyRingProtector {
@Nullable @Nullable
public PBESecretKeyEncryptor getEncryptor(Long keyId) throws PGPException { public PBESecretKeyEncryptor getEncryptor(Long keyId) throws PGPException {
Passphrase passphrase = passphraseProvider.getPassphraseFor(keyId); Passphrase passphrase = passphraseProvider.getPassphraseFor(keyId);
return passphrase == null ? null : return passphrase == null || passphrase.isEmpty() ? null :
ImplementationFactory.getInstance().getPBESecretKeyEncryptor( ImplementationFactory.getInstance().getPBESecretKeyEncryptor(
protectionSettings.getEncryptionAlgorithm(), protectionSettings.getEncryptionAlgorithm(),
protectionSettings.getHashAlgorithm(), protectionSettings.getHashAlgorithm(),