org.bouncycastle.openpgp

Class PGPSecretKey

public class PGPSecretKey extends Object

general class to handle a PGP secret key object.
Constructor Summary
PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, 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, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, SecureRandom rand, String provider)
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, int algorithm, PublicKey pubKey, PrivateKey privKey, Date time, String id, int encAlgorithm, char[] passPhrase, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, SecureRandom rand, String provider)
Method Summary
static PGPSecretKeycopyWithNewPassword(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.
voidencode(OutputStream outStream)
PGPPrivateKeyextractPrivateKey(char[] passPhrase, String provider)
Extract a PGPPrivate key from the SecretKey's encrypted contents.
byte[]getEncoded()
intgetKeyEncryptionAlgorithm()
return the algorithm the key is encrypted with.
longgetKeyID()
Return the keyID of the public key associated with this key.
PGPPublicKeygetPublicKey()
Return the public key associated with this key.
IteratorgetUserAttributes()
Return any user attribute vectors associated with the key.
IteratorgetUserIDs()
Return any userIDs associated with the key.
booleanisMasterKey()
Return true if this is a master key.
booleanisSigningKey()
return true if this key is marked as suitable for signature generation.

Constructor Detail

PGPSecretKey

public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, String id, int encAlgorithm, char[] passPhrase, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, SecureRandom rand, String provider)

PGPSecretKey

public PGPSecretKey(int certificationLevel, PGPKeyPair keyPair, String id, int encAlgorithm, char[] passPhrase, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, SecureRandom rand, String provider)

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)

PGPSecretKey

public PGPSecretKey(int certificationLevel, int algorithm, PublicKey pubKey, PrivateKey privKey, Date time, String id, int encAlgorithm, char[] passPhrase, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, SecureRandom rand, String provider)

Method Detail

copyWithNewPassword

public 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.

Parameters: 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)

extractPrivateKey

public PGPPrivateKey extractPrivateKey(char[] passPhrase, String provider)
Extract a PGPPrivate key from the SecretKey's encrypted contents.

Parameters: passPhrase provider

Returns: PGPPrivateKey

Throws: PGPException NoSuchProviderException

getEncoded

public byte[] getEncoded()

getKeyEncryptionAlgorithm

public int getKeyEncryptionAlgorithm()
return the algorithm the key is encrypted with.

Returns: the algorithm used to encrypt the secret key.

getKeyID

public long getKeyID()
Return the keyID of the public key associated with this key.

Returns: the keyID associated with this key.

getPublicKey

public PGPPublicKey getPublicKey()
Return the public key associated with this key.

Returns: the public key for this key.

getUserAttributes

public Iterator getUserAttributes()
Return any user attribute vectors associated with the key.

Returns: an iterator of Strings.

getUserIDs

public Iterator getUserIDs()
Return any userIDs associated with the key.

Returns: an iterator of Strings.

isMasterKey

public boolean isMasterKey()
Return true if this is a master key.

Returns: true if a master key.

isSigningKey

public boolean isSigningKey()
return true if this key is marked as suitable for signature generation.