summary refs log tree commit diff
path: root/crypto/src/openpgp/PgpPrivateKey.cs
blob: 154c87cd757202931ade47e0cc2a8382ebb556f2 (plain) (blame)
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 long keyId;
        private readonly AsymmetricKeyParameter privateKey;

		/// <summary>
		/// Create a PgpPrivateKey from a regular private key and the ID of its
		/// associated public key.
		/// </summary>
		/// <param name="privateKey">Private key to use.</param>
		/// <param name="keyId">ID of the corresponding public key.</param>
		public PgpPrivateKey(
            AsymmetricKeyParameter	privateKey,
            long					keyId)
        {
			if (!privateKey.IsPrivate)
				throw new ArgumentException("Expected a private key", "privateKey");

			this.privateKey = privateKey;
            this.keyId = keyId;
        }

		/// <summary>The keyId associated with the contained private key.</summary>
        public long KeyId
        {
			get { return keyId; }
        }

		/// <summary>The contained private key.</summary>
        public AsymmetricKeyParameter Key
        {
			get { return privateKey; }
        }
    }
}