diff --git a/src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlSample5.xml b/src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlSample5.xml index 7f176e58daf0b1..cdbbf4001a8bf0 100644 --- a/src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlSample5.xml +++ b/src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlSample5.xml @@ -25,96 +25,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlTests.cs b/src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlTests.cs index 686f52724648d4..2d4c848028d143 100644 --- a/src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlTests.cs +++ b/src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlTests.cs @@ -15,6 +15,7 @@ namespace System.Security.Cryptography.Xml.Tests public static class EncryptedXmlTests { private const string AllowDangerousEncryptedXmlTransformsAppContextSwitch = "System.Security.Cryptography.Xml.AllowDangerousEncryptedXmlTransforms"; + private const int DefaultMaxTransformsPerChain = 20; private const string MaxTransformsPerChainAppContextSwitch = "System.Security.Cryptography.Xml.MaxTransformsPerChain"; private const string MalformedTransformsMessage = "Malformed element Transforms."; @@ -1662,9 +1663,9 @@ public static void EncryptedXml_LoadDeepFile() [Fact] public static void EncryptedXml_DecryptedEncodedDtd() { - // The payload contains more transforms than the default limit, so - // deserialization of the transform chain should fail. - Assert.True(GetEncodedDtdPayloadTransformCount() > 20); + // Keep the payload just above the default limit so deserialization fails + // without executing an unnecessarily expensive transform chain. + Assert.Equal(DefaultMaxTransformsPerChain + 1, GetEncodedDtdPayloadTransformCount()); EncryptedXml encryptedXml = CreateEncryptedXmlWithEncodedDtdPayload(); CryptographicException ex = Assert.Throws(() => encryptedXml.DecryptDocument());