Package org.pgpainless.key.protection
Interface SecretKeyRingProtector
-
- All Known Implementing Classes:
CachingSecretKeyRingProtector,PasswordBasedSecretKeyRingProtector,UnprotectedKeysProtector
public interface SecretKeyRingProtectorInterface that is used to provide secret key ring encryptors and decryptors.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static CachingSecretKeyRingProtectordefaultSecretKeyRingProtector(SecretKeyPassphraseProvider missingPassphraseCallback)Return a protector for secret keys.static SecretKeyRingProtectorfromPassphraseMap(java.util.Map<java.lang.Long,Passphrase> passphraseMap)Use the provided map of key-ids and passphrases to unlock keys.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.static SecretKeyRingProtectorunlockAllKeysWith(Passphrase passphrase, org.bouncycastle.openpgp.PGPSecretKeyRing keys)Use the provided passphrase to lock/unlock all subkeys in the provided key ring.static SecretKeyRingProtectorunlockSingleKeyWith(Passphrase passphrase, org.bouncycastle.openpgp.PGPSecretKey key)Use the provided passphrase to lock/unlock only the provided (sub-)key.static SecretKeyRingProtectorunprotectedKeys()Protector for unprotected keys.
-
-
-
Method Detail
-
getDecryptor
@Nullable org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor getDecryptor(java.lang.Long keyId) throws org.bouncycastle.openpgp.PGPExceptionReturn a decryptor for the key of idkeyId. This method returns null if the key is unprotected.- Parameters:
keyId- id of the key- Returns:
- decryptor for the key
- Throws:
org.bouncycastle.openpgp.PGPException
-
getEncryptor
@Nullable org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor getEncryptor(java.lang.Long keyId) throws org.bouncycastle.openpgp.PGPExceptionReturn an encryptor for the key of idkeyId. This method returns null if the key is unprotected.- 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
-
defaultSecretKeyRingProtector
static CachingSecretKeyRingProtector defaultSecretKeyRingProtector(SecretKeyPassphraseProvider missingPassphraseCallback)
Return a protector for secret keys. The protector maintains an in-memory cache of passphrases and can be extended with new passphrases at runtime.- Parameters:
missingPassphraseCallback- callback that is used to provide missing passphrases.- Returns:
- caching secret key protector
-
unlockAllKeysWith
static SecretKeyRingProtector unlockAllKeysWith(Passphrase passphrase, org.bouncycastle.openpgp.PGPSecretKeyRing keys)
Use the provided passphrase to lock/unlock all subkeys in the provided key ring.- Parameters:
passphrase- passphrasekeys- key ring- Returns:
- protector
-
unlockSingleKeyWith
static SecretKeyRingProtector unlockSingleKeyWith(Passphrase passphrase, org.bouncycastle.openpgp.PGPSecretKey key)
Use the provided passphrase to lock/unlock only the provided (sub-)key.- Parameters:
passphrase- passphrasekey- key to lock/unlock- Returns:
- protector
-
unprotectedKeys
static SecretKeyRingProtector unprotectedKeys()
Protector for unprotected keys.- Returns:
- protector
-
fromPassphraseMap
static SecretKeyRingProtector fromPassphraseMap(java.util.Map<java.lang.Long,Passphrase> passphraseMap)
Use the provided map of key-ids and passphrases to unlock keys.- Parameters:
passphraseMap- map of key ids and their respective passphrases- Returns:
- protector
-
-