You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@@ -2,18 +2,14 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
internal static class CryptoHelpers
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 needed for compat.")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5351", Justification = "HMACMD5 needed for compat.")]
|
||||
[SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 needed for compat.")]
|
||||
[SuppressMessage("Microsoft.Security", "CA5351", Justification = "HMACMD5 needed for compat.")]
|
||||
public static object CreateFromName(string name)
|
||||
{
|
||||
switch (name)
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
@@ -16,9 +12,9 @@ namespace System.Security.Cryptography.Xml
|
||||
|
||||
public DSASignatureDescription()
|
||||
{
|
||||
KeyAlgorithm = typeof(System.Security.Cryptography.DSA).AssemblyQualifiedName;
|
||||
FormatterAlgorithm = typeof(System.Security.Cryptography.DSASignatureFormatter).AssemblyQualifiedName;
|
||||
DeformatterAlgorithm = typeof(System.Security.Cryptography.DSASignatureDeformatter).AssemblyQualifiedName;
|
||||
KeyAlgorithm = typeof(DSA).AssemblyQualifiedName;
|
||||
FormatterAlgorithm = typeof(DSASignatureFormatter).AssemblyQualifiedName;
|
||||
DeformatterAlgorithm = typeof(DSASignatureDeformatter).AssemblyQualifiedName;
|
||||
DigestAlgorithm = "SHA1";
|
||||
}
|
||||
|
||||
@@ -38,7 +34,7 @@ namespace System.Security.Cryptography.Xml
|
||||
return item;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 needed for compat.")]
|
||||
[SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 needed for compat.")]
|
||||
public sealed override HashAlgorithm CreateDigest()
|
||||
{
|
||||
return SHA1.Create();
|
||||
|
||||
@@ -106,10 +106,10 @@ namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
if (value.Name != KeyValueElementName
|
||||
if (value.LocalName != KeyValueElementName
|
||||
|| value.NamespaceURI != SignedXml.XmlDsigNamespaceUrl)
|
||||
{
|
||||
throw new CryptographicException($"Root element must be {KeyValueElementName} element in namepsace {SignedXml.XmlDsigNamespaceUrl}");
|
||||
throw new CryptographicException($"Root element must be {KeyValueElementName} element in namespace {SignedXml.XmlDsigNamespaceUrl}");
|
||||
}
|
||||
|
||||
const string xmlDsigNamespacePrefix = "dsig";
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
@@ -16,7 +12,7 @@ namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 needed for compat.")]
|
||||
[SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 needed for compat.")]
|
||||
public sealed override HashAlgorithm CreateDigest()
|
||||
{
|
||||
return SHA1.Create();
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
internal class RSAPKCS1SHA256SignatureDescription : RSAPKCS1SignatureDescription
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
internal class RSAPKCS1SHA384SignatureDescription : RSAPKCS1SignatureDescription
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
internal class RSAPKCS1SHA512SignatureDescription : RSAPKCS1SignatureDescription
|
||||
|
||||
@@ -2,21 +2,15 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Security.Cryptography.Xml
|
||||
{
|
||||
internal abstract class RSAPKCS1SignatureDescription : SignatureDescription
|
||||
{
|
||||
public RSAPKCS1SignatureDescription(string hashAlgorithmName)
|
||||
{
|
||||
KeyAlgorithm = typeof(System.Security.Cryptography.RSA).AssemblyQualifiedName;
|
||||
FormatterAlgorithm = typeof(System.Security.Cryptography.RSAPKCS1SignatureFormatter).AssemblyQualifiedName;
|
||||
DeformatterAlgorithm = typeof(System.Security.Cryptography.RSAPKCS1SignatureDeformatter).AssemblyQualifiedName;
|
||||
KeyAlgorithm = typeof(RSA).AssemblyQualifiedName;
|
||||
FormatterAlgorithm = typeof(RSAPKCS1SignatureFormatter).AssemblyQualifiedName;
|
||||
DeformatterAlgorithm = typeof(RSAPKCS1SignatureDeformatter).AssemblyQualifiedName;
|
||||
DigestAlgorithm = hashAlgorithmName;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
{
|
||||
EncryptionMethod method = new EncryptionMethod();
|
||||
if (PlatformDetection.IsFullFramework)
|
||||
Assert.Throws<ArgumentOutOfRangeException>("The key size should be a non negative integer.", () => method.KeySize = value);
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("The key size should be a non negative integer.", () => method.KeySize = value);
|
||||
else
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("value", () => method.KeySize = value);
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
encPropertyCollection.Add(new EncryptionProperty());
|
||||
}
|
||||
EncryptionProperty[] encPropertyArray = new EncryptionProperty[1];
|
||||
Assert.Throws<ArgumentException>(() => encPropertyCollection.CopyTo(encPropertyArray, 0));
|
||||
AssertExtensions.Throws<ArgumentException>("destinationArray", "", () => encPropertyCollection.CopyTo(encPropertyArray, 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -81,6 +81,22 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
Assert.Equal(rsaKey, s);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadXml_GetXml_With_NS_Prefix()
|
||||
{
|
||||
string rsaKeyWithPrefix = "<ds:KeyValue xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"><ds:RSAKeyValue><ds:Modulus>ogZ1/O7iks9ncETqNxLDKoPvgrT4nFx1a3lOmpywEmgbc5+8vI5dSzReH4v0YrflY75rIJx13CYWMsaHfQ78GtXvaeshHlQ3lLTuSdYEJceKll/URlBoKQtOj5qYIVSFOIVGHv4Y/0lnLftOzIydem29KKH6lJQlJawBBssR12s=</ds:Modulus><ds:Exponent>AQAB</ds:Exponent></ds:RSAKeyValue></ds:KeyValue>";
|
||||
string rsaKeyWithoutPrefix = "<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>ogZ1/O7iks9ncETqNxLDKoPvgrT4nFx1a3lOmpywEmgbc5+8vI5dSzReH4v0YrflY75rIJx13CYWMsaHfQ78GtXvaeshHlQ3lLTuSdYEJceKll/URlBoKQtOj5qYIVSFOIVGHv4Y/0lnLftOzIydem29KKH6lJQlJawBBssR12s=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue>";
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(rsaKeyWithPrefix);
|
||||
|
||||
RSAKeyValue rsa1 = new RSAKeyValue();
|
||||
rsa1.LoadXml(doc.DocumentElement);
|
||||
|
||||
string s = rsa1.GetXml().OuterXml;
|
||||
//Comparing with rsaKeyWithoutPrefix because RSAKeyValue.GetXml().OuterXml returns the markup without the namespace prefixes
|
||||
Assert.Equal(rsaKeyWithoutPrefix, s);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadXml_Null()
|
||||
{
|
||||
|
||||
@@ -54,9 +54,6 @@
|
||||
<Compile Include="XmlDsigXsltTransformTest.cs" />
|
||||
<Compile Include="XmlLicenseEncryptedRef.cs" />
|
||||
<Compile Include="XmlLicenseTransformTest.cs" />
|
||||
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
|
||||
<Link>Common\System\AssertExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
|
||||
<Link>Common\System\PlatformDetection.cs</Link>
|
||||
</Compile>
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
doc.LoadXml(xml);
|
||||
|
||||
transform.LoadInput(doc);
|
||||
Assert.Throws<ArgumentException>(() => transform.GetOutput(typeof(string)));
|
||||
AssertExtensions.Throws<ArgumentException>("type", () => transform.GetOutput(typeof(string)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
public void UnsupportedOutput()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
Assert.Throws<ArgumentException>(() => transform.GetOutput(doc.GetType()));
|
||||
AssertExtensions.Throws<ArgumentException>("type", () => transform.GetOutput(doc.GetType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
{
|
||||
XmlDsigC14NTransform transform = new XmlDsigC14NTransform();
|
||||
byte[] bad = { 0xBA, 0xD };
|
||||
Assert.Throws<ArgumentException>(() => transform.LoadInput(bad));
|
||||
AssertExtensions.Throws<ArgumentException>("obj", () => transform.LoadInput(bad));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -148,7 +148,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
{
|
||||
XmlDsigC14NTransform transform = new XmlDsigC14NTransform();
|
||||
XmlDocument doc = new XmlDocument();
|
||||
Assert.Throws<ArgumentException>(() => transform.GetOutput(doc.GetType()));
|
||||
AssertExtensions.Throws<ArgumentException>("type", () => transform.GetOutput(doc.GetType()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
public void LoadInput_UnsupportedType(object input)
|
||||
{
|
||||
XmlDsigC14NWithCommentsTransform xmlDsigC14NWithCommentsTransform = new XmlDsigC14NWithCommentsTransform();
|
||||
Assert.Throws<ArgumentException>(() => xmlDsigC14NWithCommentsTransform.LoadInput(input));
|
||||
AssertExtensions.Throws<ArgumentException>("obj", () => xmlDsigC14NWithCommentsTransform.LoadInput(input));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -65,7 +65,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
public void GetOutput_UnsupportedType(Type type)
|
||||
{
|
||||
XmlDsigC14NWithCommentsTransform xmlDsigC14NWithCommentsTransform = new XmlDsigC14NWithCommentsTransform();
|
||||
Assert.Throws<ArgumentException>(() => xmlDsigC14NWithCommentsTransform.GetOutput(type));
|
||||
AssertExtensions.Throws<ArgumentException>("type", () => xmlDsigC14NWithCommentsTransform.GetOutput(type));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -280,14 +280,14 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
public void LoadInputWithUnsupportedType()
|
||||
{
|
||||
byte[] bad = { 0xBA, 0xD };
|
||||
Assert.Throws<ArgumentException>(() => transform.LoadInput(bad));
|
||||
AssertExtensions.Throws<ArgumentException>("obj", () => transform.LoadInput(bad));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnsupportedOutput()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
Assert.Throws<ArgumentException>(() => transform.GetOutput(doc.GetType()));
|
||||
AssertExtensions.Throws<ArgumentException>("type", () => transform.GetOutput(doc.GetType()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
public void UnsupportedOutput()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
Assert.Throws<ArgumentException>(() => transform.GetOutput(doc.GetType()));
|
||||
AssertExtensions.Throws<ArgumentException>("type", () => transform.GetOutput(doc.GetType()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
public void UnsupportedOutput()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
Assert.Throws<ArgumentException>(() => transform.GetOutput(doc.GetType()));
|
||||
AssertExtensions.Throws<ArgumentException>("type", () => transform.GetOutput(doc.GetType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace System.Security.Cryptography.Xml.Tests
|
||||
[Fact]
|
||||
public void GetOutput_InvalidType()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => transform.GetOutput(typeof(string)));
|
||||
AssertExtensions.Throws<ArgumentException>("type", () => transform.GetOutput(typeof(string)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user