org.bouncycastle.openpgp
Class PGPSecretKey
java.lang.Object
org.bouncycastle.openpgp.PGPSecretKey
public class PGPSecretKey
extends java.lang.Object
general class to handle a PGP secret key object.
PGPSecretKey(int certificationLevel, int algorithm, PublicKey pubKey, PrivateKey privKey, Date time, String id, int encAlgorithm, char[] passPhrase, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, SecureRandom rand, String provider)
|
PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, String id, int encAlgorithm, char[] passPhrase, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, SecureRandom rand, String provider)
|
static PGPSecretKey | copyWithNewPassword(PGPSecretKey key, char[] oldPassPhrase, char[] newPassPhrase, int newEncAlgorithm, SecureRandom rand, String provider) - Return a copy of the passed in secret key, encrypted using a new
password and the passed in algorithm.
|
void | encode(OutputStream outStream)
|
PGPPrivateKey | extractPrivateKey(char[] passPhrase, String provider) - 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.
|
Iterator | getUserAttributes() - Return any user attribute vectors associated with the key.
|
Iterator | getUserIDs() - Return any userIDs associated with the key.
|
boolean | isMasterKey() - Return true if this is a master key.
|
boolean | isSigningKey() - return true if this key is marked as suitable for signature generation.
|
PGPSecretKey
public PGPSecretKey(int certificationLevel,
int algorithm,
PublicKey pubKey,
PrivateKey privKey,
Date time,
String id,
int encAlgorithm,
char[] passPhrase,
PGPSignatureSubpacketVector hashedPcks,
PGPSignatureSubpacketVector unhashedPcks,
SecureRandom rand,
String provider)
throws PGPException,
NoSuchProviderException
copyWithNewPassword
public static PGPSecretKey copyWithNewPassword(PGPSecretKey key,
char[] oldPassPhrase,
char[] newPassPhrase,
int newEncAlgorithm,
SecureRandom rand,
String provider)
throws PGPException,
NoSuchProviderException
Return a copy of the passed in secret key, encrypted using a new
password and the passed in algorithm.
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 use
encode
public void encode(OutputStream outStream)
throws IOException
extractPrivateKey
public PGPPrivateKey extractPrivateKey(char[] passPhrase,
String provider)
throws PGPException,
NoSuchProviderException
Extract a PGPPrivate key from the SecretKey's encrypted contents.
passPhrase
- provider
-
- PGPPrivateKey
PGPException
-
getEncoded
public byte[] getEncoded()
throws IOException
getKeyEncryptionAlgorithm
public int getKeyEncryptionAlgorithm()
return the algorithm the key is encrypted with.
- the algorithm used to encrypt the secret key.
getKeyID
public long getKeyID()
Return the keyID of the public key associated with this key.
- the keyID associated with this key.
getPublicKey
public PGPPublicKey getPublicKey()
Return the public key associated with this key.
- the public key for this key.
getUserAttributes
public Iterator getUserAttributes()
Return any user attribute vectors associated with the key.
- an iterator of Strings.
getUserIDs
public Iterator getUserIDs()
Return any userIDs associated with the key.
- an iterator of Strings.
isMasterKey
public boolean isMasterKey()
Return true if this is a master key.
- true if a master key.
isSigningKey
public boolean isSigningKey()
return true if this key is marked as suitable for signature generation.