mirrored from https://www.bouncycastle.org/repositories/bc-csharp
-
Notifications
You must be signed in to change notification settings - Fork 602
Expand file tree
/
Copy pathPgpPrivateKey.cs
More file actions
42 lines (35 loc) · 1.78 KB
/
Copy pathPgpPrivateKey.cs
File metadata and controls
42 lines (35 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using Org.BouncyCastle.Crypto;
namespace Org.BouncyCastle.Bcpg.OpenPgp
{
/// <remarks>General class to contain a private key for use with other OpenPGP objects.</remarks>
public class PgpPrivateKey
{
private readonly ulong m_keyID;
private readonly PublicKeyPacket m_publicKeyPacket;
private readonly AsymmetricKeyParameter m_privateKey;
/// <summary>
/// Create a PgpPrivateKey from a keyID, the associated public data packet, and a regular private key.
/// </summary>
/// <param name="keyID">ID of the corresponding public key.</param>
/// <param name="publicKeyPacket">the public key data packet to be associated with this private key.</param>
/// <param name="privateKey">the private key data packet to be associated with this private key.</param>
public PgpPrivateKey(long keyID, PublicKeyPacket publicKeyPacket, AsymmetricKeyParameter privateKey)
{
if (!privateKey.IsPrivate)
throw new ArgumentException("Expected a private key", nameof(privateKey));
m_keyID = (ulong)keyID;
m_publicKeyPacket = publicKeyPacket;
m_privateKey = privateKey;
}
/// <summary>The Key ID associated with the contained private key.</summary>
/// <remarks>
/// A Key ID is an 8-octet scalar. We convert it (big-endian) to an Int64 (UInt64 is not CLS compliant).
/// </remarks>
public long KeyId => (long)m_keyID;
/// <summary>The public key packet associated with this private key, if available.</summary>
public PublicKeyPacket PublicKeyPacket => m_publicKeyPacket;
/// <summary>The contained private key.</summary>
public AsymmetricKeyParameter Key => m_privateKey;
}
}