mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-01-09 11:48:00 +01:00
return null-cryptors for unprotected keys
This commit is contained in:
parent
4b61745c46
commit
9c1f6fc812
1 changed files with 9 additions and 7 deletions
|
@ -55,18 +55,20 @@ public class PasswordBasedSecretKeyRingProtector implements SecretKeyRingProtect
|
||||||
@Nullable
|
@Nullable
|
||||||
public PBESecretKeyDecryptor getDecryptor(Long keyId) {
|
public PBESecretKeyDecryptor getDecryptor(Long keyId) {
|
||||||
Passphrase passphrase = passphraseProvider.getPassphraseFor(keyId);
|
Passphrase passphrase = passphraseProvider.getPassphraseFor(keyId);
|
||||||
return new BcPBESecretKeyDecryptorBuilder(calculatorProvider)
|
return passphrase == null ? null :
|
||||||
.build(passphrase != null ? passphrase.getChars() : null);
|
new BcPBESecretKeyDecryptorBuilder(calculatorProvider)
|
||||||
|
.build(passphrase.getChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@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 new BcPBESecretKeyEncryptorBuilder(
|
return passphrase == null ? null :
|
||||||
protectionSettings.getEncryptionAlgorithm().getAlgorithmId(),
|
new BcPBESecretKeyEncryptorBuilder(
|
||||||
calculatorProvider.get(protectionSettings.getHashAlgorithm().getAlgorithmId()),
|
protectionSettings.getEncryptionAlgorithm().getAlgorithmId(),
|
||||||
protectionSettings.getS2kCount())
|
calculatorProvider.get(protectionSettings.getHashAlgorithm().getAlgorithmId()),
|
||||||
.build(passphrase != null ? passphrase.getChars() : null);
|
protectionSettings.getS2kCount())
|
||||||
|
.build(passphrase.getChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue