Package org.bouncycastle.openpgp.api
Class OpenPGPKey.OpenPGPSecretKey
java.lang.Object
org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPCertificateComponent
org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey
org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPSecretKey
- Enclosing class:
OpenPGPKey
Secret key component of a
OpenPGPCertificate.OpenPGPPrimaryKey
or
OpenPGPCertificate.OpenPGPSubkey
.-
Field Summary
Fields inherited from class org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey
rawPubkey
-
Constructor Summary
ConstructorsConstructorDescriptionOpenPGPSecretKey
(OpenPGPCertificate.OpenPGPComponentKey pubKey, PGPSecretKey secKey, PBESecretKeyDecryptorBuilderProvider decryptorBuilderProvider) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetLatestSelfSignature
(Date evaluationTime) Return the (at evaluation time) latest self-signature on the component.Return theOpenPGPKey
which thisOpenPGPKey.OpenPGPSecretKey
belongs to.Return the underlyingPGPSecretKey
.Return the publicOpenPGPCertificate.OpenPGPCertificateComponent
that belongs to this component.Return the publicOpenPGPCertificate.OpenPGPComponentKey
corresponding to thisOpenPGPKey.OpenPGPSecretKey
.boolean
isLocked()
If true, the secret key is not available in plain and likely needs to be decrypted by providing a key passphrase.boolean
isPassphraseCorrect
(char[] passphrase) Return true if the provided passphrase is correct.boolean
Return true, if thisOpenPGPCertificate.OpenPGPComponentKey
represents the primary key of anOpenPGPCertificate
.Return a detailed String representation of this component.unlock()
Unlock an unprotectedOpenPGPKey.OpenPGPSecretKey
.unlock
(char[] passphrase) Access thePGPKeyPair
by unlocking the potentially locked secret key using the provided passphrase.unlock
(KeyPassphraseProvider passphraseProvider) Unlock a protectedOpenPGPKey.OpenPGPSecretKey
.Methods inherited from class org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey
equals, getAlgorithm, getCreationTime, getKeyComponent, getKeyIdentifier, getPGPPublicKey, getVersion, hashCode, isCertificationKey, isCertificationKey, isEncryptionKey, isEncryptionKey, isSigningKey, isSigningKey
Methods inherited from class org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPCertificateComponent
getAEADCipherSuitePreferences, getAEADCipherSuitePreferences, getApplyingSubpacket, getCertificate, getCertification, getCompressionAlgorithmPreferences, getCompressionAlgorithmPreferences, getFeatures, getFeatures, getHashAlgorithmPreferences, getHashAlgorithmPreferences, getKeyExpirationDate, getKeyExpirationDateAt, getKeyFlags, getKeyFlags, getLatestSelfSignature, getMergedDanglingExternalSignatureChainEndsFrom, getRevocation, getSignatureChains, getSymmetricCipherPreferences, getSymmetricCipherPreferences, hasKeyFlags, isBound, isBoundAt
-
Constructor Details
-
OpenPGPSecretKey
public OpenPGPSecretKey(OpenPGPCertificate.OpenPGPComponentKey pubKey, PGPSecretKey secKey, PBESecretKeyDecryptorBuilderProvider decryptorBuilderProvider) Constructor.- Parameters:
pubKey
- corresponding public key componentsecKey
- secret keydecryptorBuilderProvider
- for unlocking private keys
-
-
Method Details
-
getPublicComponent
Description copied from class:OpenPGPCertificate.OpenPGPCertificateComponent
Return the publicOpenPGPCertificate.OpenPGPCertificateComponent
that belongs to this component. For public components (pubkeys, identities...), that's simply this, while secret components return their corresponding public component. This is used to properly map secret key and public key components inMaps
that usecomponents
as map keys.- Overrides:
getPublicComponent
in classOpenPGPCertificate.OpenPGPCertificateComponent
- Returns:
- public certificate component
-
isPrimaryKey
public boolean isPrimaryKey()Description copied from class:OpenPGPCertificate.OpenPGPComponentKey
Return true, if thisOpenPGPCertificate.OpenPGPComponentKey
represents the primary key of anOpenPGPCertificate
.- Specified by:
isPrimaryKey
in classOpenPGPCertificate.OpenPGPComponentKey
- Returns:
- true if primary, false if subkey
-
getLatestSelfSignature
Description copied from class:OpenPGPCertificate.OpenPGPCertificateComponent
Return the (at evaluation time) latest self-signature on the component. That might either be a certification signature, or a revocation.- Overrides:
getLatestSelfSignature
in classOpenPGPCertificate.OpenPGPComponentKey
- Parameters:
evaluationTime
- reference time- Returns:
- latest self signature
-
getOpenPGPKey
Return theOpenPGPKey
which thisOpenPGPKey.OpenPGPSecretKey
belongs to.- Returns:
- OpenPGPKey
-
toDetailString
Description copied from class:OpenPGPCertificate.OpenPGPCertificateComponent
Return a detailed String representation of this component.- Specified by:
toDetailString
in classOpenPGPCertificate.OpenPGPCertificateComponent
- Returns:
- detailed String representation
-
getPGPSecretKey
Return the underlyingPGPSecretKey
.- Returns:
- secret key
-
getPublicKey
Return the publicOpenPGPCertificate.OpenPGPComponentKey
corresponding to thisOpenPGPKey.OpenPGPSecretKey
.- Returns:
- public component key
-
isLocked
public boolean isLocked()If true, the secret key is not available in plain and likely needs to be decrypted by providing a key passphrase.- Returns:
- true if the key is locked
-
unlock
Unlock an unprotectedOpenPGPKey.OpenPGPSecretKey
.- Returns:
- unlocked private key
- Throws:
PGPException
- if the key cannot be unlocked
-
unlock
public OpenPGPKey.OpenPGPPrivateKey unlock(KeyPassphraseProvider passphraseProvider) throws PGPException Unlock a protectedOpenPGPKey.OpenPGPSecretKey
.- Parameters:
passphraseProvider
- provider for key passphrases- Returns:
- unlocked private key
- Throws:
PGPException
- if the key cannot be unlocked
-
unlock
Access thePGPKeyPair
by unlocking the potentially locked secret key using the provided passphrase. Note: If the key is not locked, it is sufficient to pass null as passphrase.- Parameters:
passphrase
- passphrase or null- Returns:
- keypair containing unlocked private key
- Throws:
PGPException
- if the key cannot be unlocked
-
isPassphraseCorrect
public boolean isPassphraseCorrect(char[] passphrase) Return true if the provided passphrase is correct.- Parameters:
passphrase
- passphrase- Returns:
- true if the passphrase is correct
-