org.bouncycastle.openpgp
public class PGPSecretKeyRing extends PGPKeyRing
Often PGP keyring files consist of multiple master keys, if you are trying to process or construct one of these you should use the PGPSecretKeyRingCollection class.
| Constructor and Description |
|---|
PGPSecretKeyRing(byte[] encoding) |
PGPSecretKeyRing(java.io.InputStream in) |
| Modifier and Type | Method and Description |
|---|---|
static PGPSecretKeyRing |
copyWithNewPassword(PGPSecretKeyRing ring,
char[] oldPassPhrase,
char[] newPassPhrase,
int newEncAlgorithm,
java.security.SecureRandom rand,
java.security.Provider provider)
Return a copy of the passed in secret key ring, with the master key and sub keys encrypted
using a new password and the passed in algorithm.
|
static PGPSecretKeyRing |
copyWithNewPassword(PGPSecretKeyRing ring,
char[] oldPassPhrase,
char[] newPassPhrase,
int newEncAlgorithm,
java.security.SecureRandom rand,
java.lang.String provider)
Return a copy of the passed in secret key ring, with the master key and sub keys encrypted
using a new password and the passed in algorithm.
|
void |
encode(java.io.OutputStream outStream) |
byte[] |
getEncoded() |
java.util.Iterator |
getExtraPublicKeys()
Return an iterator of the public keys in the secret key ring that
have no matching private key.
|
PGPPublicKey |
getPublicKey()
Return the public key for the master key.
|
PGPSecretKey |
getSecretKey()
Return the master private key.
|
PGPSecretKey |
getSecretKey(long keyId) |
java.util.Iterator |
getSecretKeys()
Return an iterator containing all the secret keys.
|
static PGPSecretKeyRing |
insertSecretKey(PGPSecretKeyRing secRing,
PGPSecretKey secKey)
Returns a new key ring with the secret key passed in either added or
replacing an existing one with the same key ID.
|
static PGPSecretKeyRing |
removeSecretKey(PGPSecretKeyRing secRing,
PGPSecretKey secKey)
Returns a new key ring with the secret key passed in removed from the
key ring.
|
static PGPSecretKeyRing |
replacePublicKeys(PGPSecretKeyRing secretRing,
PGPPublicKeyRing publicRing)
Replace the public key set on the secret ring with the corresponding key off the public ring.
|
public PGPSecretKeyRing(byte[] encoding)
throws java.io.IOException,
PGPException
java.io.IOExceptionPGPExceptionpublic PGPSecretKeyRing(java.io.InputStream in)
throws java.io.IOException,
PGPException
java.io.IOExceptionPGPExceptionpublic PGPPublicKey getPublicKey()
public PGPSecretKey getSecretKey()
public java.util.Iterator getSecretKeys()
public PGPSecretKey getSecretKey(long keyId)
public java.util.Iterator getExtraPublicKeys()
public byte[] getEncoded()
throws java.io.IOException
java.io.IOExceptionpublic void encode(java.io.OutputStream outStream)
throws java.io.IOException
java.io.IOExceptionpublic static PGPSecretKeyRing replacePublicKeys(PGPSecretKeyRing secretRing, PGPPublicKeyRing publicRing)
secretRing - secret ring to be changed.publicRing - public ring containing the new public key set.public static PGPSecretKeyRing copyWithNewPassword(PGPSecretKeyRing ring, char[] oldPassPhrase, char[] newPassPhrase, int newEncAlgorithm, java.security.SecureRandom rand, java.lang.String provider) throws PGPException, java.security.NoSuchProviderException
ring - the PGPSecretKeyRing 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 usePGPExceptionjava.security.NoSuchProviderExceptionpublic static PGPSecretKeyRing copyWithNewPassword(PGPSecretKeyRing ring, char[] oldPassPhrase, char[] newPassPhrase, int newEncAlgorithm, java.security.SecureRandom rand, java.security.Provider provider) throws PGPException
ring - the PGPSecretKeyRing 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 - provider to usePGPExceptionpublic static PGPSecretKeyRing insertSecretKey(PGPSecretKeyRing secRing, PGPSecretKey secKey)
secRing - the secret key ring to be modified.secKey - the secret key to be added.public static PGPSecretKeyRing removeSecretKey(PGPSecretKeyRing secRing, PGPSecretKey secKey)
secRing - the secret key ring to be modified.secKey - the secret key to be removed.