summary refs log tree commit diff
path: root/crypto/src/asn1/x9/DHPublicKey.cs
blob: 74a14a2eea14126b9550d528b24555d9eaca321b (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
43
44
45
46
using System;

using Org.BouncyCastle.Utilities;

namespace Org.BouncyCastle.Asn1.X9
{
	public class DHPublicKey
		: Asn1Encodable
	{
		private readonly DerInteger y;

		public static DHPublicKey GetInstance(Asn1TaggedObject obj, bool isExplicit)
		{
			return GetInstance(DerInteger.GetInstance(obj, isExplicit));
		}

		public static DHPublicKey GetInstance(object obj)
		{
			if (obj == null || obj is DHPublicKey)
				return (DHPublicKey)obj;

			if (obj is DerInteger)
				return new DHPublicKey((DerInteger)obj);

			throw new ArgumentException("Invalid DHPublicKey: " + Platform.GetTypeName(obj), "obj");
		}

		public DHPublicKey(DerInteger y)
		{
			if (y == null)
				throw new ArgumentNullException("y");

			this.y = y;
		}

		public DerInteger Y
		{
			get { return this.y; }
		}

		public override Asn1Object ToAsn1Object()
		{
			return this.y;
		}
	}
}