C# Class Org.BouncyCastle.Bcpg.OpenPgp.PgpPublicKey

General class to handle a PGP public key object.
Inheritance: IPgpPublicKey
Show file Open project: red-gate/iTextSharp-4.1.6 Class Usage Examples

Public Methods

Method Description
AddCertification ( PgpPublicKey key, PgpSignature certification ) : PgpPublicKey

Add a revocation or some other key certification to a key.

AddCertification ( PgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes, PgpSignature certification ) : PgpPublicKey

Add a certification for the given UserAttributeSubpackets to the given public key.

AddCertification ( PgpPublicKey key, string id, PgpSignature certification ) : PgpPublicKey

Add a certification for an id to the given public key.

Encode ( Stream outStr ) : void
GetEncoded ( ) : byte[]
GetFingerprint ( ) : byte[]

The fingerprint of the key

GetKey ( ) : AsymmetricKeyParameter

The public key contained in the object.

GetSignatures ( ) : IEnumerable

Allows enumeration of all signatures/certifications associated with this key.

GetSignaturesForId ( string id ) : IEnumerable

Allows enumeration of any signatures associated with the passed in id.

GetSignaturesForUserAttribute ( PgpUserAttributeSubpacketVector userAttributes ) : IEnumerable

Allows enumeration of signatures associated with the passed in user attributes.

GetSignaturesOfType ( int signatureType ) : IEnumerable

Allows enumeration of signatures of the passed in type that are on this key.

GetTrustData ( ) : byte[]

Return the trust data associated with the public key, if present.

GetUserAttributes ( ) : IEnumerable

Allows enumeration of any user attribute vectors associated with the key.

GetUserIds ( ) : IEnumerable

Allows enumeration of any user IDs associated with the key.

GetValidSeconds ( ) : long

The number of valid seconds from creation time - zero means no expiry.

IsRevoked ( ) : bool

Check whether this (sub)key has a revocation signature on it.

PgpPublicKey ( PublicKeyAlgorithmTag algorithm, AsymmetricKeyParameter pubKey, System.DateTime time ) : System

Create a PgpPublicKey from the passed in lightweight one.

Note: the time passed in affects the value of the key's keyId, so you probably only want to do this once for a lightweight key, or make sure you keep track of the time you used.

RemoveCertification ( PgpPublicKey key, PgpSignature certification ) : PgpPublicKey

Remove a certification from the key.

RemoveCertification ( PgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes ) : PgpPublicKey

Remove any certifications associated with a user attribute subpacket on a key.

RemoveCertification ( PgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes, PgpSignature certification ) : PgpPublicKey

Remove a certification associated with a given user attributes on a key.

RemoveCertification ( PgpPublicKey key, string id ) : PgpPublicKey

Remove any certifications associated with a given ID on a key.

RemoveCertification ( PgpPublicKey key, string id, PgpSignature certification ) : PgpPublicKey

Remove a certification associated with a given ID on a key.

Private Methods

Method Description
AddCert ( PgpPublicKey key, object id, PgpSignature certification ) : PgpPublicKey
GetExpirationTimeFromSig ( bool selfSigned, int signatureType ) : long
Init ( ) : void
PgpPublicKey ( PgpPublicKey pubKey ) : System

Copy constructor.

PgpPublicKey ( PgpPublicKey key, TrustPacket trust, ArrayList subSigs ) : System
PgpPublicKey ( PublicKeyPacket publicPk, ArrayList ids, ArrayList idSigs ) : System
PgpPublicKey ( PublicKeyPacket publicPk, TrustPacket trustPk, ArrayList sigs ) : System

Constructor for a sub-key.

PgpPublicKey ( PublicKeyPacket publicPk, TrustPacket trustPk, ArrayList keySigs, ArrayList ids, ArrayList idTrusts, ArrayList idSigs ) : System
RemoveCert ( PgpPublicKey key, object id ) : PgpPublicKey
RemoveCert ( PgpPublicKey key, object id, PgpSignature certification ) : PgpPublicKey

Method Details

AddCertification() public static method

Add a revocation or some other key certification to a key.
public static AddCertification ( PgpPublicKey key, PgpSignature certification ) : PgpPublicKey
key PgpPublicKey The key the revocation is to be added to.
certification PgpSignature The key signature to be added.
return PgpPublicKey

AddCertification() public static method

Add a certification for the given UserAttributeSubpackets to the given public key.
public static AddCertification ( PgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes, PgpSignature certification ) : PgpPublicKey
key PgpPublicKey The key the certification is to be added to.
userAttributes PgpUserAttributeSubpacketVector The attributes the certification is associated with.
certification PgpSignature The new certification.
return PgpPublicKey

AddCertification() public static method

Add a certification for an id to the given public key.
public static AddCertification ( PgpPublicKey key, string id, PgpSignature certification ) : PgpPublicKey
key PgpPublicKey The key the certification is to be added to.
id string The ID the certification is associated with.
certification PgpSignature The new certification.
return PgpPublicKey

Encode() public method

public Encode ( Stream outStr ) : void
outStr Stream
return void

GetEncoded() public method

public GetEncoded ( ) : byte[]
return byte[]

GetFingerprint() public method

The fingerprint of the key
public GetFingerprint ( ) : byte[]
return byte[]

GetKey() public method

The public key contained in the object.
If the key algorithm is not recognised.
public GetKey ( ) : AsymmetricKeyParameter
return Org.BouncyCastle.Crypto.AsymmetricKeyParameter

GetSignatures() public method

Allows enumeration of all signatures/certifications associated with this key.
public GetSignatures ( ) : IEnumerable
return IEnumerable

GetSignaturesForId() public method

Allows enumeration of any signatures associated with the passed in id.
public GetSignaturesForId ( string id ) : IEnumerable
id string The ID to be matched.
return IEnumerable

GetSignaturesForUserAttribute() public method

Allows enumeration of signatures associated with the passed in user attributes.
public GetSignaturesForUserAttribute ( PgpUserAttributeSubpacketVector userAttributes ) : IEnumerable
userAttributes PgpUserAttributeSubpacketVector The vector of user attributes to be matched.
return IEnumerable

GetSignaturesOfType() public method

Allows enumeration of signatures of the passed in type that are on this key.
public GetSignaturesOfType ( int signatureType ) : IEnumerable
signatureType int The type of the signature to be returned.
return IEnumerable

GetTrustData() public method

Return the trust data associated with the public key, if present.
public GetTrustData ( ) : byte[]
return byte[]

GetUserAttributes() public method

Allows enumeration of any user attribute vectors associated with the key.
public GetUserAttributes ( ) : IEnumerable
return IEnumerable

GetUserIds() public method

Allows enumeration of any user IDs associated with the key.
public GetUserIds ( ) : IEnumerable
return IEnumerable

GetValidSeconds() public method

The number of valid seconds from creation time - zero means no expiry.
public GetValidSeconds ( ) : long
return long

IsRevoked() public method

Check whether this (sub)key has a revocation signature on it.
public IsRevoked ( ) : bool
return bool

PgpPublicKey() public method

Create a PgpPublicKey from the passed in lightweight one.
Note: the time passed in affects the value of the key's keyId, so you probably only want to do this once for a lightweight key, or make sure you keep track of the time you used.
If pubKey is not public. On key creation problem.
public PgpPublicKey ( PublicKeyAlgorithmTag algorithm, AsymmetricKeyParameter pubKey, System.DateTime time ) : System
algorithm PublicKeyAlgorithmTag Asymmetric algorithm type representing the public key.
pubKey Org.BouncyCastle.Crypto.AsymmetricKeyParameter Actual public key to associate.
time System.DateTime Date of creation.
return System

RemoveCertification() public static method

Remove a certification from the key.
public static RemoveCertification ( PgpPublicKey key, PgpSignature certification ) : PgpPublicKey
key PgpPublicKey The key the certifications are to be removed from.
certification PgpSignature The certfication to be removed.
return PgpPublicKey

RemoveCertification() public static method

Remove any certifications associated with a user attribute subpacket on a key.
public static RemoveCertification ( PgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes ) : PgpPublicKey
key PgpPublicKey The key the certifications are to be removed from.
userAttributes PgpUserAttributeSubpacketVector The attributes to be removed.
return PgpPublicKey

RemoveCertification() public static method

Remove a certification associated with a given user attributes on a key.
public static RemoveCertification ( PgpPublicKey key, PgpUserAttributeSubpacketVector userAttributes, PgpSignature certification ) : PgpPublicKey
key PgpPublicKey The key the certifications are to be removed from.
userAttributes PgpUserAttributeSubpacketVector The user attributes that the certfication is to be removed from.
certification PgpSignature The certification to be removed.
return PgpPublicKey

RemoveCertification() public static method

Remove any certifications associated with a given ID on a key.
public static RemoveCertification ( PgpPublicKey key, string id ) : PgpPublicKey
key PgpPublicKey The key the certifications are to be removed from.
id string The ID that is to be removed.
return PgpPublicKey

RemoveCertification() public static method

Remove a certification associated with a given ID on a key.
public static RemoveCertification ( PgpPublicKey key, string id, PgpSignature certification ) : PgpPublicKey
key PgpPublicKey The key the certifications are to be removed from.
id string The ID that the certfication is to be removed from.
certification PgpSignature The certfication to be removed.
return PgpPublicKey