Package org.pgpainless.key.protection
Class PasswordBasedSecretKeyRingProtector
- java.lang.Object
-
- org.pgpainless.key.protection.PasswordBasedSecretKeyRingProtector
-
- All Implemented Interfaces:
SecretKeyRingProtector
public class PasswordBasedSecretKeyRingProtector extends java.lang.Object implements SecretKeyRingProtector
ProvidesPBESecretKeyDecryptorandPBESecretKeyEncryptorobjects while getting the passphrases from aSecretKeyPassphraseProviderand using settings from anKeyRingProtectionSettings.
-
-
Field Summary
Fields Modifier and Type Field Description protected SecretKeyPassphraseProviderpassphraseProviderprotected KeyRingProtectionSettingsprotectionSettings
-
Constructor Summary
Constructors Constructor Description PasswordBasedSecretKeyRingProtector(KeyRingProtectionSettings settings, SecretKeyPassphraseProvider passphraseProvider)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PasswordBasedSecretKeyRingProtectorforKey(org.bouncycastle.openpgp.PGPKeyRing keyRing, Passphrase passphrase)static PasswordBasedSecretKeyRingProtectorforKey(org.bouncycastle.openpgp.PGPSecretKey key, Passphrase passphrase)org.bouncycastle.openpgp.operator.PBESecretKeyDecryptorgetDecryptor(java.lang.Long keyId)Return a decryptor for the key of idkeyId.org.bouncycastle.openpgp.operator.PBESecretKeyEncryptorgetEncryptor(java.lang.Long keyId)Return an encryptor for the key of idkeyId.
-
-
-
Field Detail
-
protectionSettings
protected final KeyRingProtectionSettings protectionSettings
-
passphraseProvider
protected final SecretKeyPassphraseProvider passphraseProvider
-
-
Constructor Detail
-
PasswordBasedSecretKeyRingProtector
public PasswordBasedSecretKeyRingProtector(@Nonnull KeyRingProtectionSettings settings, @Nonnull SecretKeyPassphraseProvider passphraseProvider)Constructor. Passphrases for keys are sourced from thepassphraseProviderand decryptors/encryptors are constructed following the settings given insettings.- Parameters:
settings- S2K settings etc.passphraseProvider- provider which provides passphrases.
-
-
Method Detail
-
forKey
public static PasswordBasedSecretKeyRingProtector forKey(org.bouncycastle.openpgp.PGPKeyRing keyRing, Passphrase passphrase)
-
forKey
public static PasswordBasedSecretKeyRingProtector forKey(org.bouncycastle.openpgp.PGPSecretKey key, Passphrase passphrase)
-
getDecryptor
@Nullable public org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor getDecryptor(java.lang.Long keyId) throws org.bouncycastle.openpgp.PGPExceptionDescription copied from interface:SecretKeyRingProtectorReturn a decryptor for the key of idkeyId. This method returns null if the key is unprotected.- Specified by:
getDecryptorin interfaceSecretKeyRingProtector- Parameters:
keyId- id of the key- Returns:
- decryptor for the key
- Throws:
org.bouncycastle.openpgp.PGPException
-
getEncryptor
@Nullable public org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor getEncryptor(java.lang.Long keyId) throws org.bouncycastle.openpgp.PGPExceptionDescription copied from interface:SecretKeyRingProtectorReturn an encryptor for the key of idkeyId. This method returns null if the key is unprotected.- Specified by:
getEncryptorin interfaceSecretKeyRingProtector- Parameters:
keyId- id of the key- Returns:
- encryptor for the key
- Throws:
org.bouncycastle.openpgp.PGPException- if the encryptor cannot be created for some reason
-
-