/// <summary> /// Initializes a new instance of <see cref="EllipticCurveAlgorithm"/> class. /// </summary> /// <param name="oid">Object Identifier of the curve</param> /// <param name="curveName">Curve name</param> protected EllipticCurveAlgorithm(string oid, string curveName) { if (curveName == null) { throw new ArgumentNullException("curveName"); } if (oid == null) { throw new ArgumentNullException("oid"); } CurveName = curveName; X9ECParameters x9 = CustomNamedCurves.GetByName(oid); if (x9 != null) { _info = new ECKeyParametersExt(x9); } else { DerObjectIdentifier oidDer; try { oidDer = new DerObjectIdentifier(oid); } catch (FormatException) { throw new InvalidOperationException("Unknown curve: '" + oid + "'."); } _info = new ECKeyParametersExt(oidDer); } BitLength = String.Equals(oid, "curve25519", StringComparison.OrdinalIgnoreCase) ? 256 : _info.Parameters.N.BitLength; if (BitLength <= 256) { SignatureAlgorithm = "SHA-256withECDSA"; } else if (BitLength <= 384) { SignatureAlgorithm = "SHA-384withECDSA"; } else { SignatureAlgorithm = "SHA-512withECDSA"; } }
private EllipticCurveAlgorithm(EllipticCurveAlgorithm obj) { _info = obj._info; BitLength = obj.BitLength; SignatureAlgorithm = obj.SignatureAlgorithm; }