/// <summary>Constructor</summary> /// <param name="eaa">EnumDigitalSignAlgorithm</param> /// <param name="hashAlgorithm">HashAlgorithm</param> public DigitalSignECDsaOpenSsl(EnumDigitalSignAlgorithm eaa, HashAlgorithm hashAlgorithm) { AsymmetricAlgorithm aa = null; HashAlgorithm ha = null; AsymmetricAlgorithmCmnFunc.CreateDigitalSignSP(eaa, out aa, out ha); ECDsaOpenSsl ecdsa = (ECDsaOpenSsl)aa; this._privateKey = ecdsa.ExportParameters(true); this._publicKey = ecdsa.ExportParameters(false); this.AsymmetricAlgorithm = aa; this.HashAlgorithm = hashAlgorithm; }
/// <summary>Constructor</summary> /// <param name="eCParameters">ECParameters(任意)</param> /// <param name="hashAlgorithm">HashAlgorithm</param> public DigitalSignECDsaOpenSsl(ECParameters eCParameters, HashAlgorithm hashAlgorithm) { ECDsaOpenSsl ecdsa = new ECDsaOpenSsl(eCParameters.Curve); ecdsa.ImportParameters(eCParameters); if (eCParameters.D != null) { this._privateKey = ecdsa.ExportParameters(true); } this._publicKey = ecdsa.ExportParameters(false); this.AsymmetricAlgorithm = ecdsa; this.AsymmetricAlgorithm = ecdsa; this.HashAlgorithm = hashAlgorithm; }
public void LookupCurveByOidWindowsFriendlyName(string friendlyName) { ECDsaOpenSsl ec = new ECDsaOpenSsl(ECCurve.CreateFromFriendlyName(friendlyName)); ECParameters param = ec.ExportParameters(false); param.Validate(); }
public void KeySizePropWithExercise() { using (ECDsaOpenSsl e = new ECDsaOpenSsl()) { e.KeySize = 384; Assert.Equal(384, e.KeySize); e.Exercise(); ECParameters p384 = e.ExportParameters(false); Assert.Equal(ECCurve.ECCurveType.Named, p384.Curve.CurveType); e.KeySize = 521; Assert.Equal(521, e.KeySize); e.Exercise(); ECParameters p521 = e.ExportParameters(false); Assert.Equal(ECCurve.ECCurveType.Named, p521.Curve.CurveType); // ensure the key was regenerated Assert.NotEqual(p384.Curve.Oid.Value, p521.Curve.Oid.Value); } }
public void LookupCurveByOidValue() { ECDsaOpenSsl ec = null; ec = new ECDsaOpenSsl(ECCurve.CreateFromValue(ECDSA_P256_OID_VALUE)); // Same as nistP256 ECParameters param = ec.ExportParameters(false); param.Validate(); Assert.Equal(256, ec.KeySize); Assert.True(param.Curve.IsNamed); Assert.Equal("ECDSA_P256", param.Curve.Oid.FriendlyName); Assert.Equal(ECDSA_P256_OID_VALUE, param.Curve.Oid.Value); }
public void LookupCurveByOidFriendlyName() { ECDsaOpenSsl ec = null; // prime256v1 is alias for nistP256 for OpenSsl ec = new ECDsaOpenSsl(ECCurve.CreateFromFriendlyName("prime256v1")); ECParameters param = ec.ExportParameters(false); param.Validate(); Assert.Equal(256, ec.KeySize); Assert.True(param.Curve.IsNamed); Assert.Equal("ECDSA_P256", param.Curve.Oid.FriendlyName); // OpenSsl maps prime256v1 to ECDSA_P256 Assert.Equal(ECDSA_P256_OID_VALUE, param.Curve.Oid.Value); // secp521r1 is same as nistP521; note Windows uses secP521r1 (uppercase P) ec = new ECDsaOpenSsl(ECCurve.CreateFromFriendlyName("secp521r1")); param = ec.ExportParameters(false); param.Validate(); Assert.Equal(521, ec.KeySize); Assert.True(param.Curve.IsNamed); Assert.Equal("ECDSA_P521", param.Curve.Oid.FriendlyName); // OpenSsl maps secp521r1 to ECDSA_P521 Assert.Equal(ECDSA_P521_OID_VALUE, param.Curve.Oid.Value); }