Class PgpSecretKeyRing
- Namespace
- Org.BouncyCastle.Bcpg.OpenPgp
- Assembly
- BouncyCastle.Cryptography.dll
public class PgpSecretKeyRing : PgpKeyRing
- Inheritance
-
PgpSecretKeyRing
- Inherited Members
Remarks
Class to hold a single master secret key and its subkeys.
Often PGP keyring files consist of multiple master keys, if you are trying to process
or construct one of these you should use the PgpSecretKeyRingBundle class.
Constructors
PgpSecretKeyRing(byte[])
public PgpSecretKeyRing(byte[] encoding)
Parameters
encodingbyte[]
PgpSecretKeyRing(Stream)
public PgpSecretKeyRing(Stream inputStream)
Parameters
inputStreamStream
Methods
CopyWithNewPassword(PgpSecretKeyRing, char[], char[], SymmetricKeyAlgorithmTag, SecureRandom)
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.
public static PgpSecretKeyRing CopyWithNewPassword(PgpSecretKeyRing ring, char[] oldPassPhrase, char[] newPassPhrase, SymmetricKeyAlgorithmTag newEncAlgorithm, SecureRandom rand)
Parameters
ringPgpSecretKeyRingThe
PgpSecretKeyRingto be copied.oldPassPhrasechar[]The current password for key.
newPassPhrasechar[]The new password for the key.
newEncAlgorithmSymmetricKeyAlgorithmTagThe algorithm to be used for the encryption.
randSecureRandomSource of randomness.
Returns
Encode(Stream)
public void Encode(Stream outStr)
Parameters
outStrStream
GetEncoded()
public byte[] GetEncoded()
Returns
- byte[]
GetExtraPublicKeys()
Return an iterator of the public keys in the secret key ring that have no matching private key. At the moment only personal certificate data appears in this fashion.
public IEnumerable<PgpPublicKey> GetExtraPublicKeys()
Returns
- IEnumerable<PgpPublicKey>
An
IEnumerableof unattached, or extra, public keys.
GetKeysWithSignaturesBy(long)
public IEnumerable<PgpPublicKey> GetKeysWithSignaturesBy(long keyID)
Parameters
keyIDlong
Returns
GetPublicKey()
Return the public key for the master key.
public PgpPublicKey GetPublicKey()
Returns
GetPublicKey(byte[])
Return the public key with the passed in fingerprint if it is present.
public PgpPublicKey GetPublicKey(byte[] fingerprint)
Parameters
fingerprintbyte[]
Returns
GetPublicKey(long)
Return the public key referred to by the passed in keyID if it is present.
public PgpPublicKey GetPublicKey(long keyID)
Parameters
keyIDlong
Returns
GetPublicKeys()
public IEnumerable<PgpPublicKey> GetPublicKeys()
Returns
GetSecretKey()
Return the master private key.
public PgpSecretKey GetSecretKey()
Returns
GetSecretKey(byte[])
Return the secret key associated with the passed in fingerprint if it is present.
public PgpSecretKey GetSecretKey(byte[] fingerprint)
Parameters
fingerprintbyte[]
Returns
GetSecretKey(long)
Return the secret key referred to by the passed in keyID if it is present.
public PgpSecretKey GetSecretKey(long keyId)
Parameters
keyIdlong
Returns
GetSecretKeys()
Allows enumeration of the secret keys.
public IEnumerable<PgpSecretKey> GetSecretKeys()
Returns
- IEnumerable<PgpSecretKey>
An
IEnumerableofPgpSecretKeyobjects.
InsertSecretKey(PgpSecretKeyRing, PgpSecretKey)
Returns a new key ring with the secret key passed in either added or replacing an existing one with the same key ID.
public static PgpSecretKeyRing InsertSecretKey(PgpSecretKeyRing secRing, PgpSecretKey secKey)
Parameters
secRingPgpSecretKeyRingThe secret key ring to be modified.
secKeyPgpSecretKeyThe secret key to be inserted.
Returns
- PgpSecretKeyRing
A new
PgpSecretKeyRing
RemoveSecretKey(PgpSecretKeyRing, PgpSecretKey)
Returns a new key ring with the secret key passed in removed from the key ring.
public static PgpSecretKeyRing RemoveSecretKey(PgpSecretKeyRing secRing, PgpSecretKey secKey)
Parameters
secRingPgpSecretKeyRingThe secret key ring to be modified.
secKeyPgpSecretKeyThe secret key to be removed.
Returns
- PgpSecretKeyRing
A new
PgpSecretKeyRing, or null if secKey is not found.
ReplacePublicKeys(PgpSecretKeyRing, PgpPublicKeyRing)
Replace the public key set on the secret ring with the corresponding key off the public ring.
public static PgpSecretKeyRing ReplacePublicKeys(PgpSecretKeyRing secretRing, PgpPublicKeyRing publicRing)
Parameters
secretRingPgpSecretKeyRingSecret ring to be changed.
publicRingPgpPublicKeyRingPublic ring containing the new public key set.