public class PGPSecretKey
extends java.lang.Object
Constructor and Description |
---|
PGPSecretKey(int certificationLevel,
PGPKeyPair keyPair,
java.lang.String id,
PGPDigestCalculator checksumCalculator,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
PGPContentSignerBuilder certificationSignerBuilder,
PBESecretKeyEncryptor keyEncryptor)
Construct a PGPSecretKey using the passed in private/public key pair and binding it to the passed in id
using a generated certification of certificationLevel.
|
PGPSecretKey(int certificationLevel,
PGPKeyPair keyPair,
java.lang.String id,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
PGPContentSignerBuilder certificationSignerBuilder,
PBESecretKeyEncryptor keyEncryptor)
Construct a PGPSecretKey using the passed in private/public key pair and binding it to the passed in id
using a generated certification of certificationLevel.The secret key checksum is calculated using the original
non-digest based checksum.
|
PGPSecretKey(PGPKeyPair masterKeyPair,
PGPKeyPair keyPair,
PGPDigestCalculator checksumCalculator,
PGPContentSignerBuilder certificationSignerBuilder,
PBESecretKeyEncryptor keyEncryptor)
Construct a PGPSecretKey sub-key using the passed in private/public key pair and binding it to the master key pair.
|
PGPSecretKey(PGPKeyPair masterKeyPair,
PGPKeyPair keyPair,
PGPDigestCalculator checksumCalculator,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
PGPContentSignerBuilder certificationSignerBuilder,
PBESecretKeyEncryptor keyEncryptor)
Construct a PGPSecretKey sub-key using the passed in private/public key pair and binding it to the master key pair.
|
PGPSecretKey(PGPPrivateKey privKey,
PGPPublicKey pubKey,
PGPDigestCalculator checksumCalculator,
boolean isMasterKey,
PBESecretKeyEncryptor keyEncryptor)
Construct a PGPSecretKey using the passed in private key and public key.
|
PGPSecretKey(SecretKeyPacket secret,
PGPPublicKey pub) |
Modifier and Type | Method and Description |
---|---|
static PGPSecretKey |
copyWithNewPassword(PGPSecretKey key,
PBESecretKeyDecryptor oldKeyDecryptor,
PBESecretKeyEncryptor newKeyEncryptor)
Return a copy of the passed in secret key, encrypted using a new
password and the passed in algorithm.
|
static PGPSecretKey |
copyWithNewPassword(PGPSecretKey key,
PBESecretKeyDecryptor oldKeyDecryptor,
PBESecretKeyEncryptor newKeyEncryptor,
PGPDigestCalculator checksumCalculator)
Return a copy of the passed in secret key, encrypted using a new
password and the passed in algorithm.
|
void |
encode(java.io.OutputStream outStream) |
PGPKeyPair |
extractKeyPair(PBESecretKeyDecryptor decryptorFactory)
Extract a PGPPrivate key from the SecretKey's encrypted contents.
|
PGPPrivateKey |
extractPrivateKey(PBESecretKeyDecryptor decryptorFactory)
Extract a PGPPrivate key from the SecretKey's encrypted contents.
|
byte[] |
getEncoded() |
byte[] |
getFingerprint()
Return the fingerprint of the public key associated with this key.
|
int |
getKeyEncryptionAlgorithm()
return the algorithm the key is encrypted with.
|
long |
getKeyID()
Return the keyID of the public key associated with this key.
|
PGPPublicKey |
getPublicKey()
Return the public key associated with this key.
|
S2K |
getS2K()
Return the S2K used to process this key
|
int |
getS2KUsage()
Return the S2K usage associated with this key.
|
java.util.Iterator<PGPUserAttributeSubpacketVector> |
getUserAttributes()
Return any user attribute vectors associated with the key.
|
java.util.Iterator<java.lang.String> |
getUserIDs()
Return any userIDs associated with the key.
|
boolean |
isMasterKey()
Return true if this is a master key.
|
boolean |
isPrivateKeyEmpty()
Detect if the Secret Key's Private Key is empty or not
|
boolean |
isSigningKey()
Return true if this key has an algorithm type that makes it suitable to use for signing.
|
static PGPSecretKey |
parseSecretKeyFromSExpr(java.io.InputStream inputStream,
PBEProtectionRemoverFactory keyProtectionRemoverFactory,
KeyFingerPrintCalculator fingerPrintCalculator)
Deprecated.
use org.bouncycastle.gpg.SExprParser - it will also allow you to verify the protection checksum if it is available.
|
static PGPSecretKey |
parseSecretKeyFromSExpr(java.io.InputStream inputStream,
PBEProtectionRemoverFactory keyProtectionRemoverFactory,
PGPPublicKey pubKey)
Deprecated.
use org.bouncycastle.gpg.SExprParser - it will also allow you to verify the protection checksum if it is available.
|
static PGPSecretKey |
replacePublicKey(PGPSecretKey secretKey,
PGPPublicKey publicKey)
Replace the passed the public key on the passed in secret key.
|
public PGPSecretKey(SecretKeyPacket secret, PGPPublicKey pub)
public PGPSecretKey(PGPPrivateKey privKey, PGPPublicKey pubKey, PGPDigestCalculator checksumCalculator, boolean isMasterKey, PBESecretKeyEncryptor keyEncryptor) throws PGPException
privKey
- the private key component.pubKey
- the public key component.checksumCalculator
- a calculator for the private key checksumisMasterKey
- true if the key is a master key, false otherwise.keyEncryptor
- an encryptor for the key if required (null otherwise).PGPException
- if there is an issue creating the secret key packet.public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, java.lang.String id, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder certificationSignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException
certificationLevel
- the type of certification to be added.keyPair
- the public/private keys to use.id
- the id to bind to the key.hashedPcks
- the hashed packets to be added to the certification.unhashedPcks
- the unhashed packets to be added to the certification.certificationSignerBuilder
- the builder for generating the certification.keyEncryptor
- an encryptor for the key if required (null otherwise).PGPException
- if there is an issue creating the secret key packet or the certification.public PGPSecretKey(PGPKeyPair masterKeyPair, PGPKeyPair keyPair, PGPDigestCalculator checksumCalculator, PGPContentSignerBuilder certificationSignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException
masterKeyPair
- the master public/private keys for the new subkey.keyPair
- the public/private keys to use.checksumCalculator
- a calculator for the private key checksumcertificationSignerBuilder
- the builder for generating the certification.keyEncryptor
- an encryptor for the key if required (null otherwise).PGPException
- if there is an issue creating the secret key packet or the certification.public PGPSecretKey(PGPKeyPair masterKeyPair, PGPKeyPair keyPair, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder certificationSignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException
masterKeyPair
- the master public/private keys for the new subkey.keyPair
- the public/private keys to use.checksumCalculator
- calculator for PGP key checksums.hashedPcks
- the hashed packets to be added to the certification.unhashedPcks
- the unhashed packets to be added to the certification.certificationSignerBuilder
- the builder for generating the certification.keyEncryptor
- an encryptor for the key if required (null otherwise).PGPException
- if there is an issue creating the secret key packet or the certification.public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, java.lang.String id, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder certificationSignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException
certificationLevel
- the type of certification to be added.keyPair
- the public/private keys to use.id
- the id to bind to the key.checksumCalculator
- a calculator for the private key checksum.hashedPcks
- the hashed packets to be added to the certification.unhashedPcks
- the unhashed packets to be added to the certification.certificationSignerBuilder
- the builder for generating the certification.keyEncryptor
- an encryptor for the key if required (null otherwise).PGPException
- if there is an issue creating the secret key packet or the certification.public boolean isSigningKey()
Note: with version 4 keys KeyFlags subpackets should also be considered when present for determining the preferred use of the key.
public boolean isMasterKey()
public boolean isPrivateKeyEmpty()
public int getKeyEncryptionAlgorithm()
public long getKeyID()
public byte[] getFingerprint()
public int getS2KUsage()
public S2K getS2K()
public PGPPublicKey getPublicKey()
public java.util.Iterator<java.lang.String> getUserIDs()
public java.util.Iterator<PGPUserAttributeSubpacketVector> getUserAttributes()
public PGPKeyPair extractKeyPair(PBESecretKeyDecryptor decryptorFactory) throws PGPException
decryptorFactory
- factory to use to generate a decryptor for the passed in secretKey.PGPException
- on failure.public PGPPrivateKey extractPrivateKey(PBESecretKeyDecryptor decryptorFactory) throws PGPException
decryptorFactory
- factory to use to generate a decryptor for the passed in secretKey.PGPException
- on failure.public byte[] getEncoded() throws java.io.IOException
java.io.IOException
public void encode(java.io.OutputStream outStream) throws java.io.IOException
java.io.IOException
public static PGPSecretKey copyWithNewPassword(PGPSecretKey key, PBESecretKeyDecryptor oldKeyDecryptor, PBESecretKeyEncryptor newKeyEncryptor) throws PGPException
key
- the PGPSecretKey to be copied.oldKeyDecryptor
- the current decryptor based on the current password for key.newKeyEncryptor
- a new encryptor based on a new password for encrypting the secret key material.PGPException
public static PGPSecretKey copyWithNewPassword(PGPSecretKey key, PBESecretKeyDecryptor oldKeyDecryptor, PBESecretKeyEncryptor newKeyEncryptor, PGPDigestCalculator checksumCalculator) throws PGPException
key
- the PGPSecretKey to be copied.oldKeyDecryptor
- the current decryptor based on the current password for key.newKeyEncryptor
- a new encryptor based on a new password for encrypting the secret key material.checksumCalculator
- digest based checksum calculator for private key data.PGPException
public static PGPSecretKey replacePublicKey(PGPSecretKey secretKey, PGPPublicKey publicKey)
secretKey
- secret key to changepublicKey
- new public key.java.lang.IllegalArgumentException
- if keyIDs do not match.public static PGPSecretKey parseSecretKeyFromSExpr(java.io.InputStream inputStream, PBEProtectionRemoverFactory keyProtectionRemoverFactory, PGPPublicKey pubKey) throws java.io.IOException, PGPException
java.io.IOException
PGPException
public static PGPSecretKey parseSecretKeyFromSExpr(java.io.InputStream inputStream, PBEProtectionRemoverFactory keyProtectionRemoverFactory, KeyFingerPrintCalculator fingerPrintCalculator) throws java.io.IOException, PGPException
java.io.IOException
PGPException