mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-01-08 19:27:57 +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
|
||||
public PBESecretKeyDecryptor getDecryptor(Long keyId) {
|
||||
Passphrase passphrase = passphraseProvider.getPassphraseFor(keyId);
|
||||
return new BcPBESecretKeyDecryptorBuilder(calculatorProvider)
|
||||
.build(passphrase != null ? passphrase.getChars() : null);
|
||||
return passphrase == null ? null :
|
||||
new BcPBESecretKeyDecryptorBuilder(calculatorProvider)
|
||||
.build(passphrase.getChars());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PBESecretKeyEncryptor getEncryptor(Long keyId) throws PGPException {
|
||||
Passphrase passphrase = passphraseProvider.getPassphraseFor(keyId);
|
||||
return new BcPBESecretKeyEncryptorBuilder(
|
||||
protectionSettings.getEncryptionAlgorithm().getAlgorithmId(),
|
||||
calculatorProvider.get(protectionSettings.getHashAlgorithm().getAlgorithmId()),
|
||||
protectionSettings.getS2kCount())
|
||||
.build(passphrase != null ? passphrase.getChars() : null);
|
||||
return passphrase == null ? null :
|
||||
new BcPBESecretKeyEncryptorBuilder(
|
||||
protectionSettings.getEncryptionAlgorithm().getAlgorithmId(),
|
||||
calculatorProvider.get(protectionSettings.getHashAlgorithm().getAlgorithmId()),
|
||||
protectionSettings.getS2kCount())
|
||||
.build(passphrase.getChars());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue