Table of Contents

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

certificationLevel int

The certification level for keys on this ring.

masterKey PgpKeyPair

The master key pair.

id string

The id to be associated with the ring.

encAlgorithm SymmetricKeyAlgorithmTag

The algorithm to be used to protect secret keys.

hashAlgorithm HashAlgorithmTag

The hash algorithm.

utf8PassPhrase bool

If 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).

passPhrase char[]

The passPhrase to be used to protect secret keys.

useSha1 bool

Checksum the secret keys with SHA1 rather than the older 16 bit checksum.

hashedPackets PgpSignatureSubpacketVector

Packets to be included in the certification hash.

unhashedPackets PgpSignatureSubpacketVector

Packets to be attached unhashed to the certification.

rand SecureRandom

input 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

certificationLevel int

The certification level for keys on this ring.

masterKey PgpKeyPair

The master key pair.

id string

The id to be associated with the ring.

encAlgorithm SymmetricKeyAlgorithmTag

The algorithm to be used to protect secret keys.

hashAlgorithm HashAlgorithmTag

The hash algorithm.

rawPassPhrase byte[]

The passPhrase to be used to protect secret keys.

useSha1 bool

Checksum the secret keys with SHA1 rather than the older 16 bit checksum.

hashedPackets PgpSignatureSubpacketVector

Packets to be included in the certification hash.

unhashedPackets PgpSignatureSubpacketVector

Packets to be attached unhashed to the certification.

rand SecureRandom

input 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

certificationLevel int

The certification level for keys on this ring.

masterKey PgpKeyPair

The master key pair.

id string

The id to be associated with the ring.

encAlgorithm SymmetricKeyAlgorithmTag

The algorithm to be used to protect secret keys.

hashAlgorithm HashAlgorithmTag

The hash algorithm.

passPhrase char[]

The passPhrase to be used to protect secret keys.

useSha1 bool

Checksum the secret keys with SHA1 rather than the older 16 bit checksum.

hashedPackets PgpSignatureSubpacketVector

Packets to be included in the certification hash.

unhashedPackets PgpSignatureSubpacketVector

Packets to be attached unhashed to the certification.

rand SecureRandom

input 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

certificationLevel int

The certification level for keys on this ring.

masterKey PgpKeyPair

The master key pair.

id string

The id to be associated with the ring.

encAlgorithm SymmetricKeyAlgorithmTag

The algorithm to be used to protect secret keys.

utf8PassPhrase bool

If 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).

passPhrase char[]

The passPhrase to be used to protect secret keys.

useSha1 bool

Checksum the secret keys with SHA1 rather than the older 16 bit checksum.

hashedPackets PgpSignatureSubpacketVector

Packets to be included in the certification hash.

unhashedPackets PgpSignatureSubpacketVector

Packets to be attached unhashed to the certification.

rand SecureRandom

input 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

certificationLevel int

The certification level for keys on this ring.

masterKey PgpKeyPair

The master key pair.

id string

The id to be associated with the ring.

encAlgorithm SymmetricKeyAlgorithmTag

The algorithm to be used to protect secret keys.

rawPassPhrase byte[]

The passPhrase to be used to protect secret keys.

useSha1 bool

Checksum the secret keys with SHA1 rather than the older 16 bit checksum.

hashedPackets PgpSignatureSubpacketVector

Packets to be included in the certification hash.

unhashedPackets PgpSignatureSubpacketVector

Packets to be attached unhashed to the certification.

rand SecureRandom

input 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

certificationLevel int

The certification level for keys on this ring.

masterKey PgpKeyPair

The master key pair.

id string

The id to be associated with the ring.

encAlgorithm SymmetricKeyAlgorithmTag

The algorithm to be used to protect secret keys.

passPhrase char[]

The passPhrase to be used to protect secret keys.

useSha1 bool

Checksum the secret keys with SHA1 rather than the older 16 bit checksum.

hashedPackets PgpSignatureSubpacketVector

Packets to be included in the certification hash.

unhashedPackets PgpSignatureSubpacketVector

Packets to be attached unhashed to the certification.

rand SecureRandom

input 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

keyPair PgpKeyPair

AddSubKey(PgpKeyPair, HashAlgorithmTag)

Add a subkey to the key ring to be generated with default certification.

public void AddSubKey(PgpKeyPair keyPair, HashAlgorithmTag hashAlgorithm)

Parameters

keyPair PgpKeyPair

The key pair.

hashAlgorithm HashAlgorithmTag

The 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

keyPair PgpKeyPair

The key pair.

hashAlgorithm HashAlgorithmTag

The hash algorithm.

primaryKeyBindingHashAlgorithm HashAlgorithmTag

The 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

keyPair PgpKeyPair

Public/private key pair.

hashedPackets PgpSignatureSubpacketVector

Hashed packet values to be included in certification.

unhashedPackets PgpSignatureSubpacketVector

Unhashed packets values to be included in certification.

Exceptions

PgpException

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

keyPair PgpKeyPair

Public/private key pair.

hashedPackets PgpSignatureSubpacketVector

Hashed packet values to be included in certification.

unhashedPackets PgpSignatureSubpacketVector

Unhashed packets values to be included in certification.

hashAlgorithm HashAlgorithmTag

The 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

keyPair PgpKeyPair

Public/private key pair.

hashedPackets PgpSignatureSubpacketVector

Hashed packet values to be included in certification.

unhashedPackets PgpSignatureSubpacketVector

Unhashed packets values to be included in certification.

hashAlgorithm HashAlgorithmTag

The hash algorithm.

primaryKeyBindingHashAlgorithm HashAlgorithmTag

The 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

PgpPublicKeyRing

GenerateSecretKeyRing()

Return the secret key ring.

public PgpSecretKeyRing GenerateSecretKeyRing()

Returns

PgpSecretKeyRing