Table of Contents

Class PgpPublicKeyRingBundle

Namespace
Org.BouncyCastle.Bcpg.OpenPgp
Assembly
BouncyCastle.Cryptography.dll
public class PgpPublicKeyRingBundle
Inheritance
PgpPublicKeyRingBundle
Inherited Members

Remarks

Often a PGP key ring file is made up of a succession of master/sub-key key rings. If you want to read an entire public key file in one hit this is the class for you.

Constructors

PgpPublicKeyRingBundle(byte[])

public PgpPublicKeyRingBundle(byte[] encoding)

Parameters

encoding byte[]

PgpPublicKeyRingBundle(IEnumerable<PgpObject>)

public PgpPublicKeyRingBundle(IEnumerable<PgpObject> e)

Parameters

e IEnumerable<PgpObject>

PgpPublicKeyRingBundle(Stream)

Build a PgpPublicKeyRingBundle from the passed in input stream.

public PgpPublicKeyRingBundle(Stream inputStream)

Parameters

inputStream Stream

Input stream containing data.

Exceptions

IOException

If a problem parsing the stream occurs.

PgpException

If an object is encountered which isn't a PgpPublicKeyRing.

Properties

Count

Return the number of key rings in this collection.

public int Count { get; }

Property Value

int

Methods

AddPublicKeyRing(PgpPublicKeyRingBundle, PgpPublicKeyRing)

Return a new bundle containing the contents of the passed in bundle and the passed in public key ring.

public static PgpPublicKeyRingBundle AddPublicKeyRing(PgpPublicKeyRingBundle bundle, PgpPublicKeyRing publicKeyRing)

Parameters

bundle PgpPublicKeyRingBundle

The PgpPublicKeyRingBundle the key ring is to be added to.

publicKeyRing PgpPublicKeyRing

The key ring to be added.

Returns

PgpPublicKeyRingBundle

A new PgpPublicKeyRingBundle merging the current one with the passed in key ring.

Exceptions

ArgumentException

If the keyId for the passed in key ring is already present.

Contains(long)

Return true if a key matching the passed in key ID is present, false otherwise.

public bool Contains(long keyID)

Parameters

keyID long

key ID to look for.

Returns

bool

Encode(Stream)

public void Encode(Stream outStr)

Parameters

outStr Stream

GetEncoded()

public byte[] GetEncoded()

Returns

byte[]

GetKeyRings()

Allow enumeration of the public key rings making up this collection.

public IEnumerable<PgpPublicKeyRing> GetKeyRings()

Returns

IEnumerable<PgpPublicKeyRing>

GetKeyRings(string)

Allow enumeration of the key rings associated with the passed in userId.

public IEnumerable<PgpPublicKeyRing> GetKeyRings(string userId)

Parameters

userId string

The user ID to be matched.

Returns

IEnumerable<PgpPublicKeyRing>

An IEnumerable of key rings which matched (possibly none).

GetKeyRings(string, bool)

Allow enumeration of the key rings associated with the passed in userId.

public IEnumerable<PgpPublicKeyRing> GetKeyRings(string userId, bool matchPartial)

Parameters

userId string

The user ID to be matched.

matchPartial bool

If true, userId need only be a substring of an actual ID string to match.

Returns

IEnumerable<PgpPublicKeyRing>

An IEnumerable of key rings which matched (possibly none).

GetKeyRings(string, bool, bool)

Allow enumeration of the key rings associated with the passed in userId.

public IEnumerable<PgpPublicKeyRing> GetKeyRings(string userID, bool matchPartial, bool ignoreCase)

Parameters

userID string

The user ID to be matched.

matchPartial bool

If true, userId need only be a substring of an actual ID string to match.

ignoreCase bool

If true, case is ignored in user ID comparisons.

Returns

IEnumerable<PgpPublicKeyRing>

An IEnumerable of key rings which matched (possibly none).

GetPublicKey(byte[])

Return the PGP public key associated with the given key fingerprint.

public PgpPublicKey GetPublicKey(byte[] fingerprint)

Parameters

fingerprint byte[]

the public key fingerprint to match against.

Returns

PgpPublicKey

GetPublicKey(long)

Return the PGP public key associated with the given key id.

public PgpPublicKey GetPublicKey(long keyId)

Parameters

keyId long

The ID of the public key to return.

Returns

PgpPublicKey

GetPublicKeyRing(byte[])

Return the public key ring which contains the key associated with the given key fingerprint.

public PgpPublicKeyRing GetPublicKeyRing(byte[] fingerprint)

Parameters

fingerprint byte[]

the public key fingerprint to match against.

Returns

PgpPublicKeyRing

GetPublicKeyRing(long)

Return the public key ring which contains the key referred to by keyId

public PgpPublicKeyRing GetPublicKeyRing(long keyId)

Parameters

keyId long

key ID to match against

Returns

PgpPublicKeyRing

RemovePublicKeyRing(PgpPublicKeyRingBundle, PgpPublicKeyRing)

Return a new bundle containing the contents of the passed in bundle with the passed in public key ring removed.

public static PgpPublicKeyRingBundle RemovePublicKeyRing(PgpPublicKeyRingBundle bundle, PgpPublicKeyRing publicKeyRing)

Parameters

bundle PgpPublicKeyRingBundle

The PgpPublicKeyRingBundle the key ring is to be removed from.

publicKeyRing PgpPublicKeyRing

The key ring to be removed.

Returns

PgpPublicKeyRingBundle

A new PgpPublicKeyRingBundle not containing the passed in key ring.

Exceptions

ArgumentException

If the keyId for the passed in key ring is not present.