< Summary

Information
Class: Renci.SshNet.Security.Org.BouncyCastle.Crypto.Parameters.ECDomainParameters
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\BouncyCastle\crypto\parameters\ECDomainParameters.cs
Line coverage
64%
Covered lines: 27
Uncovered lines: 15
Coverable lines: 42
Total lines: 91
Line coverage: 64.2%
Branch coverage
42%
Covered branches: 6
Total branches: 14
Branch coverage: 42.8%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)50%684.21%
get_Curve()100%1100%
get_G()100%1100%
get_N()100%1100%
get_H()100%1100%
get_HInv()0%20%
Validate(...)50%670%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\BouncyCastle\crypto\parameters\ECDomainParameters.cs

#LineLine coverage
 1using System;
 2
 3using Renci.SshNet.Security.Org.BouncyCastle.Math;
 4using Renci.SshNet.Security.Org.BouncyCastle.Math.EC;
 5using Renci.SshNet.Security.Org.BouncyCastle.Utilities;
 6
 7namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Parameters
 8{
 9    internal class ECDomainParameters
 10    {
 11        internal ECCurve     curve;
 12        internal byte[]      seed;
 13        internal ECPoint     g;
 14        internal BigInteger  n;
 15        internal BigInteger  h;
 16        internal BigInteger  hInv;
 17
 918        public ECDomainParameters(
 919            ECCurve     curve,
 920            ECPoint     g,
 921            BigInteger  n,
 922            BigInteger  h,
 923            byte[]      seed)
 924        {
 925            if (curve == null)
 026                throw new ArgumentNullException("curve");
 927            if (g == null)
 028                throw new ArgumentNullException("g");
 929            if (n == null)
 030                throw new ArgumentNullException("n");
 31            // we can't check for h == null here as h is optional in X9.62 as it is not required for ECDSA
 32
 933            this.curve = curve;
 934            this.g = Validate(curve, g);
 935            this.n = n;
 936            this.h = h;
 937            this.seed = Arrays.Clone(seed);
 938        }
 39
 40        public ECCurve Curve
 41        {
 10842            get { return curve; }
 43        }
 44
 45        public ECPoint G
 46        {
 2747            get { return g; }
 48        }
 49
 50        public BigInteger N
 51        {
 8152            get { return n; }
 53        }
 54
 55        public BigInteger H
 56        {
 2757            get { return h; }
 58        }
 59
 60        public BigInteger HInv
 61        {
 62            get
 063            {
 064                lock (this)
 065                {
 066                    if (hInv == null)
 067                    {
 068                        hInv = h.ModInverse(n);
 069                    }
 070                    return hInv;
 71                }
 072            }
 73        }
 74
 75        internal static ECPoint Validate(ECCurve c, ECPoint q)
 2776        {
 2777            if (q == null)
 078                throw new ArgumentException("Point has null value", "q");
 79
 2780            q = ECAlgorithms.ImportPoint(c, q).Normalize();
 81
 2782            if (q.IsInfinity)
 083                throw new ArgumentException("Point at infinity", "q");
 84
 2785            if (!q.IsValid())
 086                throw new ArgumentException("Point not on curve", "q");
 87
 2788            return q;
 2789        }
 90    }
 91}