| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | using Renci.SshNet.Security.Org.BouncyCastle.Math; |
| | | 4 | | |
| | | 5 | | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Parameters |
| | | 6 | | { |
| | | 7 | | internal class ECPrivateKeyParameters |
| | | 8 | | : ECKeyParameters |
| | | 9 | | { |
| | | 10 | | private readonly BigInteger d; |
| | | 11 | | |
| | | 12 | | public ECPrivateKeyParameters( |
| | | 13 | | BigInteger d, |
| | | 14 | | ECDomainParameters parameters) |
| | 0 | 15 | | : this("EC", d, parameters) |
| | 0 | 16 | | { |
| | 0 | 17 | | } |
| | | 18 | | |
| | | 19 | | public ECPrivateKeyParameters( |
| | | 20 | | string algorithm, |
| | | 21 | | BigInteger d, |
| | | 22 | | ECDomainParameters parameters) |
| | 9 | 23 | | : base(algorithm, true, parameters) |
| | 9 | 24 | | { |
| | 9 | 25 | | if (d == null) |
| | 0 | 26 | | throw new ArgumentNullException("d"); |
| | | 27 | | |
| | 9 | 28 | | this.d = d; |
| | 9 | 29 | | } |
| | | 30 | | |
| | | 31 | | public BigInteger D |
| | | 32 | | { |
| | 27 | 33 | | get { return d; } |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | public override bool Equals( |
| | | 37 | | object obj) |
| | 0 | 38 | | { |
| | 0 | 39 | | if (obj == this) |
| | 0 | 40 | | return true; |
| | | 41 | | |
| | 0 | 42 | | ECPrivateKeyParameters other = obj as ECPrivateKeyParameters; |
| | | 43 | | |
| | 0 | 44 | | if (other == null) |
| | 0 | 45 | | return false; |
| | | 46 | | |
| | 0 | 47 | | return Equals(other); |
| | 0 | 48 | | } |
| | | 49 | | |
| | | 50 | | protected bool Equals( |
| | | 51 | | ECPrivateKeyParameters other) |
| | 0 | 52 | | { |
| | 0 | 53 | | return d.Equals(other.d) && base.Equals(other); |
| | 0 | 54 | | } |
| | | 55 | | |
| | | 56 | | public override int GetHashCode() |
| | 0 | 57 | | { |
| | 0 | 58 | | return d.GetHashCode() ^ base.GetHashCode(); |
| | 0 | 59 | | } |
| | | 60 | | } |
| | | 61 | | } |