private static ECCurve CreateFromValueAndName(string oidValue, string oidFriendlyName)
{
- return ECCurve.Create(new Oid(oidValue, oidFriendlyName));
+ Oid oid = null;
+
+ if (oidValue == null && oidFriendlyName != null)
+ {
+ try
+ {
+ oid = Oid.FromFriendlyName(oidFriendlyName, OidGroup.PublicKeyAlgorithm);
+ }
+ catch (CryptographicException)
+ {
+ }
+ }
+
+ oid ??= new Oid(oidValue, oidFriendlyName);
+ return ECCurve.Create(oid);
}
public bool IsPrime
Assert.Equal(ECDSA_P256_OID_VALUE, param.Curve.Oid.Value);
}
+ [Theory]
+ [InlineData("ECDSA_P521")]
+ [InlineData("ECDSA_P384")]
+ [InlineData("ECDSA_P256")]
+ public void LookupCurveByOidWindowsFriendlyName(string friendlyName)
+ {
+ ECDsaOpenSsl ec = new ECDsaOpenSsl(ECCurve.CreateFromFriendlyName(friendlyName));
+ ECParameters param = ec.ExportParameters(false);
+ param.Validate();
+ }
+
+ [Fact]
+ public void LookupCurveByOidWithInvalidThrowsPlatformNotSupported()
+ {
+ Assert.Throws<PlatformNotSupportedException>(() => {
+ new ECDsaOpenSsl(ECCurve.CreateFromFriendlyName("Invalid"));
+ });
+ }
+
[Fact]
public void LookupCurveByOidFriendlyName()
{