From 06ba713c9b19102310675a6c58e07c68d8efb3c7 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 12 Oct 2015 15:49:54 +0700 Subject: Port of latest PGP tests and supporting code changes --- crypto/src/openpgp/PgpPrivateKey.cs | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'crypto/src/openpgp/PgpPrivateKey.cs') diff --git a/crypto/src/openpgp/PgpPrivateKey.cs b/crypto/src/openpgp/PgpPrivateKey.cs index 154c87cd7..61487a5b2 100644 --- a/crypto/src/openpgp/PgpPrivateKey.cs +++ b/crypto/src/openpgp/PgpPrivateKey.cs @@ -7,33 +7,42 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp /// General class to contain a private key for use with other OpenPGP objects. public class PgpPrivateKey { - private readonly long keyId; + private readonly long keyID; + private readonly PublicKeyPacket publicKeyPacket; private readonly AsymmetricKeyParameter privateKey; - /// - /// Create a PgpPrivateKey from a regular private key and the ID of its - /// associated public key. + /// + /// Create a PgpPrivateKey from a keyID, the associated public data packet, and a regular private key. /// - /// Private key to use. - /// ID of the corresponding public key. - public PgpPrivateKey( - AsymmetricKeyParameter privateKey, - long keyId) + /// ID of the corresponding public key. + /// the public key data packet to be associated with this private key. + /// the private key data packet to be associated with this private key. + public PgpPrivateKey( + long keyID, + PublicKeyPacket publicKeyPacket, + AsymmetricKeyParameter privateKey) { if (!privateKey.IsPrivate) throw new ArgumentException("Expected a private key", "privateKey"); - this.privateKey = privateKey; - this.keyId = keyId; + this.keyID = keyID; + this.publicKeyPacket = publicKeyPacket; + this.privateKey = privateKey; } - /// The keyId associated with the contained private key. + /// The keyId associated with the contained private key. public long KeyId { - get { return keyId; } + get { return keyID; } } - /// The contained private key. + /// The public key packet associated with this private key, if available. + public PublicKeyPacket PublicKeyPacket + { + get { return publicKeyPacket; } + } + + /// The contained private key. public AsymmetricKeyParameter Key { get { return privateKey; } -- cgit 1.4.1