public class PGPSecretKey
extends java.lang.Object
Constructor and Description |
---|
PGPSecretKey(int certificationLevel,
int algorithm,
java.security.PublicKey pubKey,
java.security.PrivateKey privKey,
java.util.Date time,
java.lang.String id,
int encAlgorithm,
char[] passPhrase,
boolean useSHA1,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
java.security.SecureRandom rand,
java.lang.String provider)
Deprecated.
use method taking PBESecretKeyEncryptor
|
PGPSecretKey(int certificationLevel,
int algorithm,
java.security.PublicKey pubKey,
java.security.PrivateKey privKey,
java.util.Date time,
java.lang.String id,
int encAlgorithm,
char[] passPhrase,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
java.security.SecureRandom rand,
java.lang.String provider)
Deprecated.
use method taking PBESecretKeyEncryptor
|
PGPSecretKey(int certificationLevel,
int algorithm,
java.security.PublicKey pubKey,
java.security.PrivateKey privKey,
java.util.Date time,
java.lang.String id,
PGPDigestCalculator checksumCalculator,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
PGPContentSignerBuilder certificationSignerBuilder,
PBESecretKeyEncryptor keyEncryptor)
Deprecated.
use method taking PGPKeyPair
|
PGPSecretKey(int certificationLevel,
int algorithm,
java.security.PublicKey pubKey,
java.security.PrivateKey privKey,
java.util.Date time,
java.lang.String id,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
PGPContentSignerBuilder certificationSignerBuilder,
PBESecretKeyEncryptor keyEncryptor)
Deprecated.
use method taking PGPKeyPair
|
PGPSecretKey(int certificationLevel,
PGPKeyPair keyPair,
java.lang.String id,
int encAlgorithm,
char[] passPhrase,
boolean useSHA1,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
java.security.SecureRandom rand,
java.security.Provider provider)
Deprecated.
use method taking PBESecretKeyEncryptor
|
PGPSecretKey(int certificationLevel,
PGPKeyPair keyPair,
java.lang.String id,
int encAlgorithm,
char[] passPhrase,
boolean useSHA1,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
java.security.SecureRandom rand,
java.lang.String provider)
Deprecated.
use method taking PBESecretKeyEncryptor
|
PGPSecretKey(int certificationLevel,
PGPKeyPair keyPair,
java.lang.String id,
int encAlgorithm,
char[] passPhrase,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
java.security.SecureRandom rand,
java.lang.String provider)
Deprecated.
use method taking PBESecretKeyEncryptor
|
PGPSecretKey(int certificationLevel,
PGPKeyPair keyPair,
java.lang.String id,
PGPDigestCalculator checksumCalculator,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
PGPContentSignerBuilder certificationSignerBuilder,
PBESecretKeyEncryptor keyEncryptor) |
PGPSecretKey(int certificationLevel,
PGPKeyPair keyPair,
java.lang.String id,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
PGPContentSignerBuilder certificationSignerBuilder,
PBESecretKeyEncryptor keyEncryptor) |
Modifier and Type | Method and Description |
---|---|
static PGPSecretKey |
copyWithNewPassword(PGPSecretKey key,
char[] oldPassPhrase,
char[] newPassPhrase,
int newEncAlgorithm,
java.security.SecureRandom rand,
java.security.Provider provider)
Deprecated.
use method taking PBESecretKeyDecryptor and PBESecretKeyEncryptor
|
static PGPSecretKey |
copyWithNewPassword(PGPSecretKey key,
char[] oldPassPhrase,
char[] newPassPhrase,
int newEncAlgorithm,
java.security.SecureRandom rand,
java.lang.String provider)
Deprecated.
use method taking PBESecretKeyDecryptor and PBESecretKeyEncryptor
|
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.
|
void |
encode(java.io.OutputStream outStream) |
PGPPrivateKey |
extractPrivateKey(char[] passPhrase,
java.security.Provider provider)
Deprecated.
use method that takes a PBESecretKeyDecryptor
|
PGPPrivateKey |
extractPrivateKey(char[] passPhrase,
java.lang.String provider)
Deprecated.
use method that takes a PBESecretKeyDecryptor
|
PGPPrivateKey |
extractPrivateKey(PBESecretKeyDecryptor decryptorFactory)
Extract a PGPPrivate key from the SecretKey's encrypted contents.
|
byte[] |
getEncoded() |
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.
|
java.util.Iterator |
getUserAttributes()
Return any user attribute vectors associated with the key.
|
java.util.Iterator |
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 |
replacePublicKey(PGPSecretKey secretKey,
PGPPublicKey publicKey)
Replace the passed the public key on the passed in secret key.
|
public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, java.lang.String id, int encAlgorithm, char[] passPhrase, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, java.security.SecureRandom rand, java.lang.String provider) throws PGPException, java.security.NoSuchProviderException
PGPException
java.security.NoSuchProviderException
public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, java.lang.String id, int encAlgorithm, char[] passPhrase, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, java.security.SecureRandom rand, java.lang.String provider) throws PGPException, java.security.NoSuchProviderException
PGPException
java.security.NoSuchProviderException
public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, java.lang.String id, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder certificationSignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException
PGPException
public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, java.lang.String id, int encAlgorithm, char[] passPhrase, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, java.security.SecureRandom rand, java.security.Provider provider) throws PGPException
PGPException
public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, java.lang.String id, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder certificationSignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException
PGPException
public PGPSecretKey(int certificationLevel, int algorithm, java.security.PublicKey pubKey, java.security.PrivateKey privKey, java.util.Date time, java.lang.String id, int encAlgorithm, char[] passPhrase, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, java.security.SecureRandom rand, java.lang.String provider) throws PGPException, java.security.NoSuchProviderException
PGPException
java.security.NoSuchProviderException
public PGPSecretKey(int certificationLevel, int algorithm, java.security.PublicKey pubKey, java.security.PrivateKey privKey, java.util.Date time, java.lang.String id, int encAlgorithm, char[] passPhrase, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, java.security.SecureRandom rand, java.lang.String provider) throws PGPException, java.security.NoSuchProviderException
PGPException
java.security.NoSuchProviderException
public PGPSecretKey(int certificationLevel, int algorithm, java.security.PublicKey pubKey, java.security.PrivateKey privKey, java.util.Date time, java.lang.String id, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder certificationSignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException
PGPException
public PGPSecretKey(int certificationLevel, int algorithm, java.security.PublicKey pubKey, java.security.PrivateKey privKey, java.util.Date time, java.lang.String id, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder certificationSignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException, java.security.NoSuchProviderException
PGPException
java.security.NoSuchProviderException
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 PGPPublicKey getPublicKey()
public java.util.Iterator getUserIDs()
public java.util.Iterator getUserAttributes()
public PGPPrivateKey extractPrivateKey(char[] passPhrase, java.lang.String provider) throws PGPException, java.security.NoSuchProviderException
passPhrase
- provider
- PGPException
java.security.NoSuchProviderException
public PGPPrivateKey extractPrivateKey(char[] passPhrase, java.security.Provider provider) throws PGPException
passPhrase
- provider
- PGPException
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, char[] oldPassPhrase, char[] newPassPhrase, int newEncAlgorithm, java.security.SecureRandom rand, java.lang.String provider) throws PGPException, java.security.NoSuchProviderException
key
- the PGPSecretKey to be copied.oldPassPhrase
- the current password for key.newPassPhrase
- the new password for the key.newEncAlgorithm
- the algorithm to be used for the encryption.rand
- source of randomness.provider
- name of the provider to usePGPException
java.security.NoSuchProviderException
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, char[] oldPassPhrase, char[] newPassPhrase, int newEncAlgorithm, java.security.SecureRandom rand, java.security.Provider provider) throws PGPException
key
- the PGPSecretKey to be copied.oldPassPhrase
- the current password for key.newPassPhrase
- the new password for the key.newEncAlgorithm
- the algorithm to be used for the encryption.rand
- source of randomness.provider
- the provider to usePGPException
public static PGPSecretKey replacePublicKey(PGPSecretKey secretKey, PGPPublicKey publicKey)
secretKey
- secret key to changepublicKey
- new public key.java.lang.IllegalArgumentException
- if keyIDs do not match.