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 theOpenPGPKeywhich thisOpenPGPKey.OpenPGPSecretKeybelongs to.Return the underlyingPGPSecretKey.Return the publicOpenPGPCertificate.OpenPGPCertificateComponentthat belongs to this component.Return the publicOpenPGPCertificate.OpenPGPComponentKeycorresponding to thisOpenPGPKey.OpenPGPSecretKey.booleanisLocked()If true, the secret key is not available in plain and likely needs to be decrypted by providing a key passphrase.booleanisPassphraseCorrect(char[] passphrase) Return true if the provided passphrase is correct.booleanReturn true, if thisOpenPGPCertificate.OpenPGPComponentKeyrepresents the primary key of anOpenPGPCertificate.Return a detailed String representation of this component.unlock()Unlock an unprotectedOpenPGPKey.OpenPGPSecretKey.unlock(char[] passphrase) Access thePGPKeyPairby 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, isSigningKeyMethods 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.OpenPGPCertificateComponentReturn the publicOpenPGPCertificate.OpenPGPCertificateComponentthat 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 inMapsthat usecomponentsas map keys.- Overrides:
getPublicComponentin classOpenPGPCertificate.OpenPGPCertificateComponent- Returns:
- public certificate component
-
isPrimaryKey
public boolean isPrimaryKey()Description copied from class:OpenPGPCertificate.OpenPGPComponentKeyReturn true, if thisOpenPGPCertificate.OpenPGPComponentKeyrepresents the primary key of anOpenPGPCertificate.- Specified by:
isPrimaryKeyin classOpenPGPCertificate.OpenPGPComponentKey- Returns:
- true if primary, false if subkey
-
getLatestSelfSignature
Description copied from class:OpenPGPCertificate.OpenPGPCertificateComponentReturn the (at evaluation time) latest self-signature on the component. That might either be a certification signature, or a revocation.- Overrides:
getLatestSelfSignaturein classOpenPGPCertificate.OpenPGPComponentKey- Parameters:
evaluationTime- reference time- Returns:
- latest self signature
-
getOpenPGPKey
Return theOpenPGPKeywhich thisOpenPGPKey.OpenPGPSecretKeybelongs to.- Returns:
- OpenPGPKey
-
toDetailString
Description copied from class:OpenPGPCertificate.OpenPGPCertificateComponentReturn a detailed String representation of this component.- Specified by:
toDetailStringin classOpenPGPCertificate.OpenPGPCertificateComponent- Returns:
- detailed String representation
-
getPGPSecretKey
Return the underlyingPGPSecretKey.- Returns:
- secret key
-
getPublicKey
Return the publicOpenPGPCertificate.OpenPGPComponentKeycorresponding 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 thePGPKeyPairby 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
-