summary refs log tree commit diff
path: root/Crypto/src/crypto/parameters/ECPublicKeyParameters.cs
blob: 9e71c2a255be53564d8f79ea1a8d75109bcd971b (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Globalization;

using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Math.EC;

namespace Org.BouncyCastle.Crypto.Parameters
{
    public class ECPublicKeyParameters
		: ECKeyParameters
    {
        private readonly ECPoint q;

		public ECPublicKeyParameters(
			ECPoint				q,
			ECDomainParameters	parameters)
			: this("EC", q, parameters)
		{
		}

		[Obsolete("Use version with explicit 'algorithm' parameter")]
		public ECPublicKeyParameters(
			ECPoint				q,
			DerObjectIdentifier publicKeyParamSet)
			: base("ECGOST3410", false, publicKeyParamSet)
		{
			if (q == null)
				throw new ArgumentNullException("q");

			this.q = q;
		}

		public ECPublicKeyParameters(
			string				algorithm,
			ECPoint				q,
			ECDomainParameters	parameters)
			: base(algorithm, false, parameters)
        {
			if (q == null)
				throw new ArgumentNullException("q");

			this.q = q;
		}

		public ECPublicKeyParameters(
			string				algorithm,
			ECPoint				q,
			DerObjectIdentifier publicKeyParamSet)
			: base(algorithm, false, publicKeyParamSet)
        {
			if (q == null)
				throw new ArgumentNullException("q");

			this.q = q;
		}

		public ECPoint Q
        {
			get { return q; }
        }

		public override bool Equals(object obj)
        {
			if (obj == this)
				return true;

			ECPublicKeyParameters other = obj as ECPublicKeyParameters;

			if (other == null)
				return false;

			return Equals(other);
        }

		protected bool Equals(
			ECPublicKeyParameters other)
		{
			return q.Equals(other.q) && base.Equals(other);
		}

		public override int GetHashCode()
        {
            return q.GetHashCode() ^ base.GetHashCode();
        }
    }
}