using System;
using Org.BouncyCastle.Crypto;
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 PublicKeyPacket publicKeyPacket;
private readonly AsymmetricKeyParameter privateKey;
///
/// Create a PgpPrivateKey from a keyID, the associated public data packet, and a regular private key.
///
/// 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.keyID = keyID;
this.publicKeyPacket = publicKeyPacket;
this.privateKey = privateKey;
}
/// The keyId associated with the contained private key.
public long KeyId
{
get { return keyID; }
}
/// 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; }
}
}
}