Table of Contents

Class PgpSecretKeyRingBundle

Namespace
Org.BouncyCastle.Bcpg.OpenPgp
Assembly
BouncyCastle.Cryptography.dll
public class PgpSecretKeyRingBundle
Inheritance
PgpSecretKeyRingBundle
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 secret key file in one hit this is the class for you.

Constructors

PgpSecretKeyRingBundle(byte[])

public PgpSecretKeyRingBundle(byte[] encoding)

Parameters

encoding byte[]

PgpSecretKeyRingBundle(IEnumerable<PgpObject>)

public PgpSecretKeyRingBundle(IEnumerable<PgpObject> e)

Parameters

e IEnumerable<PgpObject>

PgpSecretKeyRingBundle(Stream)

Build a PgpSecretKeyRingBundle from the passed in input stream.

public PgpSecretKeyRingBundle(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 PgpSecretKeyRing.

Properties

Count

Return the number of rings in this collection.

public int Count { get; }

Property Value

int

Methods

AddSecretKeyRing(PgpSecretKeyRingBundle, PgpSecretKeyRing)

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

public static PgpSecretKeyRingBundle AddSecretKeyRing(PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing)

Parameters

bundle PgpSecretKeyRingBundle

The PgpSecretKeyRingBundle the key ring is to be added to.

secretKeyRing PgpSecretKeyRing

The key ring to be added.

Returns

PgpSecretKeyRingBundle

A new PgpSecretKeyRingBundle 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 secret key rings making up this collection.

public IEnumerable<PgpSecretKeyRing> GetKeyRings()

Returns

IEnumerable<PgpSecretKeyRing>

GetKeyRings(string)

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

public IEnumerable<PgpSecretKeyRing> GetKeyRings(string userId)

Parameters

userId string

The user ID to be matched.

Returns

IEnumerable<PgpSecretKeyRing>

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<PgpSecretKeyRing> 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<PgpSecretKeyRing>

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<PgpSecretKeyRing> 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<PgpSecretKeyRing>

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

GetSecretKey(long)

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

public PgpSecretKey GetSecretKey(long keyId)

Parameters

keyId long

The ID of the secret key to return.

Returns

PgpSecretKey

GetSecretKeyRing(long)

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

public PgpSecretKeyRing GetSecretKeyRing(long keyId)

Parameters

keyId long

The ID of the secret key

Returns

PgpSecretKeyRing

RemoveSecretKeyRing(PgpSecretKeyRingBundle, PgpSecretKeyRing)

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

public static PgpSecretKeyRingBundle RemoveSecretKeyRing(PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing)

Parameters

bundle PgpSecretKeyRingBundle

The PgpSecretKeyRingBundle the key ring is to be removed from.

secretKeyRing PgpSecretKeyRing

The key ring to be removed.

Returns

PgpSecretKeyRingBundle

A new PgpSecretKeyRingBundle not containing the passed in key ring.

Exceptions

ArgumentException

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