Class PgpKeyRingGenerator
- Namespace
- Org.BouncyCastle.Bcpg.OpenPgp
- Assembly
- BouncyCastle.Cryptography.dll
public class PgpKeyRingGenerator
- Inheritance
-
PgpKeyRingGenerator
- Inherited Members
Remarks
Generator for a PGP master and subkey ring. This class will generate both the secret and public key rings
Constructors
PgpKeyRingGenerator(int, PgpKeyPair, string, SymmetricKeyAlgorithmTag, HashAlgorithmTag, bool, char[], bool, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector, SecureRandom)
Create a new key ring generator.
public PgpKeyRingGenerator(int certificationLevel, PgpKeyPair masterKey, string id, SymmetricKeyAlgorithmTag encAlgorithm, HashAlgorithmTag hashAlgorithm, bool utf8PassPhrase, char[] passPhrase, bool useSha1, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, SecureRandom rand)
Parameters
certificationLevelintThe certification level for keys on this ring.
masterKeyPgpKeyPairThe master key pair.
idstringThe id to be associated with the ring.
encAlgorithmSymmetricKeyAlgorithmTagThe algorithm to be used to protect secret keys.
hashAlgorithmHashAlgorithmTagThe hash algorithm.
utf8PassPhraseboolIf true, conversion of the passphrase to bytes uses Encoding.UTF8.GetBytes(), otherwise the conversion is performed using Convert.ToByte(), which is the historical behaviour of the library (1.7 and earlier).
passPhrasechar[]The passPhrase to be used to protect secret keys.
useSha1boolChecksum the secret keys with SHA1 rather than the older 16 bit checksum.
hashedPacketsPgpSignatureSubpacketVectorPackets to be included in the certification hash.
unhashedPacketsPgpSignatureSubpacketVectorPackets to be attached unhashed to the certification.
randSecureRandominput secured random.
PgpKeyRingGenerator(int, PgpKeyPair, string, SymmetricKeyAlgorithmTag, HashAlgorithmTag, byte[], bool, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector, SecureRandom)
Create a new key ring generator.
public PgpKeyRingGenerator(int certificationLevel, PgpKeyPair masterKey, string id, SymmetricKeyAlgorithmTag encAlgorithm, HashAlgorithmTag hashAlgorithm, byte[] rawPassPhrase, bool useSha1, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, SecureRandom rand)
Parameters
certificationLevelintThe certification level for keys on this ring.
masterKeyPgpKeyPairThe master key pair.
idstringThe id to be associated with the ring.
encAlgorithmSymmetricKeyAlgorithmTagThe algorithm to be used to protect secret keys.
hashAlgorithmHashAlgorithmTagThe hash algorithm.
rawPassPhrasebyte[]The passPhrase to be used to protect secret keys.
useSha1boolChecksum the secret keys with SHA1 rather than the older 16 bit checksum.
hashedPacketsPgpSignatureSubpacketVectorPackets to be included in the certification hash.
unhashedPacketsPgpSignatureSubpacketVectorPackets to be attached unhashed to the certification.
randSecureRandominput secured random.
Remarks
Allows the caller to handle the encoding of the passphrase to bytes.
PgpKeyRingGenerator(int, PgpKeyPair, string, SymmetricKeyAlgorithmTag, HashAlgorithmTag, char[], bool, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector, SecureRandom)
Create a new key ring generator.
public PgpKeyRingGenerator(int certificationLevel, PgpKeyPair masterKey, string id, SymmetricKeyAlgorithmTag encAlgorithm, HashAlgorithmTag hashAlgorithm, char[] passPhrase, bool useSha1, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, SecureRandom rand)
Parameters
certificationLevelintThe certification level for keys on this ring.
masterKeyPgpKeyPairThe master key pair.
idstringThe id to be associated with the ring.
encAlgorithmSymmetricKeyAlgorithmTagThe algorithm to be used to protect secret keys.
hashAlgorithmHashAlgorithmTagThe hash algorithm.
passPhrasechar[]The passPhrase to be used to protect secret keys.
useSha1boolChecksum the secret keys with SHA1 rather than the older 16 bit checksum.
hashedPacketsPgpSignatureSubpacketVectorPackets to be included in the certification hash.
unhashedPacketsPgpSignatureSubpacketVectorPackets to be attached unhashed to the certification.
randSecureRandominput secured random.
Remarks
Conversion of the passphrase characters to bytes is performed using Convert.ToByte(), which is the historical behaviour of the library (1.7 and earlier).
PgpKeyRingGenerator(int, PgpKeyPair, string, SymmetricKeyAlgorithmTag, bool, char[], bool, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector, SecureRandom)
Create a new key ring generator.
public PgpKeyRingGenerator(int certificationLevel, PgpKeyPair masterKey, string id, SymmetricKeyAlgorithmTag encAlgorithm, bool utf8PassPhrase, char[] passPhrase, bool useSha1, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, SecureRandom rand)
Parameters
certificationLevelintThe certification level for keys on this ring.
masterKeyPgpKeyPairThe master key pair.
idstringThe id to be associated with the ring.
encAlgorithmSymmetricKeyAlgorithmTagThe algorithm to be used to protect secret keys.
utf8PassPhraseboolIf true, conversion of the passphrase to bytes uses Encoding.UTF8.GetBytes(), otherwise the conversion is performed using Convert.ToByte(), which is the historical behaviour of the library (1.7 and earlier).
passPhrasechar[]The passPhrase to be used to protect secret keys.
useSha1boolChecksum the secret keys with SHA1 rather than the older 16 bit checksum.
hashedPacketsPgpSignatureSubpacketVectorPackets to be included in the certification hash.
unhashedPacketsPgpSignatureSubpacketVectorPackets to be attached unhashed to the certification.
randSecureRandominput secured random.
PgpKeyRingGenerator(int, PgpKeyPair, string, SymmetricKeyAlgorithmTag, byte[], bool, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector, SecureRandom)
Create a new key ring generator.
public PgpKeyRingGenerator(int certificationLevel, PgpKeyPair masterKey, string id, SymmetricKeyAlgorithmTag encAlgorithm, byte[] rawPassPhrase, bool useSha1, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, SecureRandom rand)
Parameters
certificationLevelintThe certification level for keys on this ring.
masterKeyPgpKeyPairThe master key pair.
idstringThe id to be associated with the ring.
encAlgorithmSymmetricKeyAlgorithmTagThe algorithm to be used to protect secret keys.
rawPassPhrasebyte[]The passPhrase to be used to protect secret keys.
useSha1boolChecksum the secret keys with SHA1 rather than the older 16 bit checksum.
hashedPacketsPgpSignatureSubpacketVectorPackets to be included in the certification hash.
unhashedPacketsPgpSignatureSubpacketVectorPackets to be attached unhashed to the certification.
randSecureRandominput secured random.
PgpKeyRingGenerator(int, PgpKeyPair, string, SymmetricKeyAlgorithmTag, char[], bool, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector, SecureRandom)
Create a new key ring generator.
public PgpKeyRingGenerator(int certificationLevel, PgpKeyPair masterKey, string id, SymmetricKeyAlgorithmTag encAlgorithm, char[] passPhrase, bool useSha1, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, SecureRandom rand)
Parameters
certificationLevelintThe certification level for keys on this ring.
masterKeyPgpKeyPairThe master key pair.
idstringThe id to be associated with the ring.
encAlgorithmSymmetricKeyAlgorithmTagThe algorithm to be used to protect secret keys.
passPhrasechar[]The passPhrase to be used to protect secret keys.
useSha1boolChecksum the secret keys with SHA1 rather than the older 16 bit checksum.
hashedPacketsPgpSignatureSubpacketVectorPackets to be included in the certification hash.
unhashedPacketsPgpSignatureSubpacketVectorPackets to be attached unhashed to the certification.
randSecureRandominput secured random.
Remarks
Conversion of the passphrase characters to bytes is performed using Convert.ToByte(), which is the historical behaviour of the library (1.7 and earlier).
Methods
AddSubKey(PgpKeyPair)
Add a subkey to the key ring to be generated with default certification.
public void AddSubKey(PgpKeyPair keyPair)
Parameters
keyPairPgpKeyPair
AddSubKey(PgpKeyPair, HashAlgorithmTag)
Add a subkey to the key ring to be generated with default certification.
public void AddSubKey(PgpKeyPair keyPair, HashAlgorithmTag hashAlgorithm)
Parameters
keyPairPgpKeyPairThe key pair.
hashAlgorithmHashAlgorithmTagThe hash algorithm.
AddSubKey(PgpKeyPair, HashAlgorithmTag, HashAlgorithmTag)
Add a signing subkey to the key ring to be generated with default certification and a primary key binding signature.
public void AddSubKey(PgpKeyPair keyPair, HashAlgorithmTag hashAlgorithm, HashAlgorithmTag primaryKeyBindingHashAlgorithm)
Parameters
keyPairPgpKeyPairThe key pair.
hashAlgorithmHashAlgorithmTagThe hash algorithm.
primaryKeyBindingHashAlgorithmHashAlgorithmTagThe primary-key binding hash algorithm.
AddSubKey(PgpKeyPair, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector)
Add a subkey with specific hashed and unhashed packets associated with it and default certification using SHA-1.
public void AddSubKey(PgpKeyPair keyPair, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets)
Parameters
keyPairPgpKeyPairPublic/private key pair.
hashedPacketsPgpSignatureSubpacketVectorHashed packet values to be included in certification.
unhashedPacketsPgpSignatureSubpacketVectorUnhashed packets values to be included in certification.
Exceptions
AddSubKey(PgpKeyPair, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector, HashAlgorithmTag)
Add a subkey with specific hashed and unhashed packets associated with it and default certification.
public void AddSubKey(PgpKeyPair keyPair, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, HashAlgorithmTag hashAlgorithm)
Parameters
keyPairPgpKeyPairPublic/private key pair.
hashedPacketsPgpSignatureSubpacketVectorHashed packet values to be included in certification.
unhashedPacketsPgpSignatureSubpacketVectorUnhashed packets values to be included in certification.
hashAlgorithmHashAlgorithmTagThe hash algorithm.
Exceptions
- PgpException
exception adding subkey:
- PgpException
AddSubKey(PgpKeyPair, PgpSignatureSubpacketVector, PgpSignatureSubpacketVector, HashAlgorithmTag, HashAlgorithmTag)
Add a signing subkey with specific hashed and unhashed packets associated with it and default certifications, including the primary-key binding signature.
public void AddSubKey(PgpKeyPair keyPair, PgpSignatureSubpacketVector hashedPackets, PgpSignatureSubpacketVector unhashedPackets, HashAlgorithmTag hashAlgorithm, HashAlgorithmTag primaryKeyBindingHashAlgorithm)
Parameters
keyPairPgpKeyPairPublic/private key pair.
hashedPacketsPgpSignatureSubpacketVectorHashed packet values to be included in certification.
unhashedPacketsPgpSignatureSubpacketVectorUnhashed packets values to be included in certification.
hashAlgorithmHashAlgorithmTagThe hash algorithm.
primaryKeyBindingHashAlgorithmHashAlgorithmTagThe primary-key binding hash algorithm.
Exceptions
- PgpException
exception adding subkey:
- PgpException
GeneratePublicKeyRing()
Return the public key ring that corresponds to the secret key ring.
public PgpPublicKeyRing GeneratePublicKeyRing()
Returns
GenerateSecretKeyRing()
Return the secret key ring.
public PgpSecretKeyRing GenerateSecretKeyRing()