public static void TestNamedImportValidationNegative() { unchecked { using (ECDsa ec = ECDsaFactory.Create()) { ECParameters p = ECDsaTestData.GetNistP224KeyTestData(); Assert.True(p.Curve.IsNamed); var q = p.Q; var c = p.Curve; ec.ImportParameters(p); ECParameters temp = p; temp.Q.X = null; Assert.ThrowsAny <CryptographicException>(() => ec.ImportParameters(temp)); temp.Q.X = new byte[] { }; Assert.ThrowsAny <CryptographicException>(() => ec.ImportParameters(temp)); temp.Q.X = new byte[1] { 0x10 }; Assert.ThrowsAny <CryptographicException>(() => ec.ImportParameters(temp)); temp.Q.X = (byte[])p.Q.X.Clone(); temp.Q.X[0]--; Assert.ThrowsAny <CryptographicException>(() => ec.ImportParameters(temp)); temp = p; temp.Q.Y = null; Assert.ThrowsAny <CryptographicException>(() => ec.ImportParameters(temp)); temp.Q.Y = new byte[] { }; Assert.ThrowsAny <CryptographicException>(() => ec.ImportParameters(temp)); temp.Q.Y = new byte[1] { 0x10 }; Assert.ThrowsAny <CryptographicException>(() => ec.ImportParameters(temp)); temp.Q.Y = (byte[])p.Q.Y.Clone(); temp.Q.Y[0]--; Assert.ThrowsAny <CryptographicException>(() => ec.ImportParameters(temp)); temp = p; temp.Curve = ECCurve.CreateFromOid(new Oid("Invalid", "Invalid")); Assert.ThrowsAny <PlatformNotSupportedException>(() => ec.ImportParameters(temp)); } } }
public static void TestNamedCurveWithExplicitKey() { using (ECDsa ec = ECDsaFactory.Create()) { ECParameters parameters = ECDsaTestData.GetNistP224KeyTestData(); ec.ImportParameters(parameters); VerifyNamedCurve(parameters, ec, 224, true); } }