You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@@ -2,7 +2,7 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.0.2.0</AssemblyVersion>
|
||||
<IsDesktopFacade>true</IsDesktopFacade>
|
||||
<AssemblyVersion>4.0.3.0</AssemblyVersion>
|
||||
<AssemblyKey>MSFT</AssemblyKey>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -3,12 +3,16 @@
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ref\System.Security.Cryptography.Pkcs.csproj">
|
||||
<SupportedFramework>net46;netcore50;netcoreapp1.0</SupportedFramework>
|
||||
<SupportedFramework>net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\src\System.Security.Cryptography.Pkcs.csproj" />
|
||||
<_xamarinFrameworks Include="$(AllXamarinFrameworks)" />
|
||||
<HarvestSuppressPaths Include="@(_xamarinFrameworks->'ref/%(Identity)')" />
|
||||
<HarvestSuppressPaths Include="@(_xamarinFrameworks->'lib/%(Identity)')" />
|
||||
<HarvestIncludePaths Include="ref/net46;lib/net46;runtimes/win/lib/net46" />
|
||||
<HarvestIncludePaths Include="runtimes/win/lib/netcore50" />
|
||||
<HarvestIncludePaths Include="ref/netstandard1.3;runtimes/win/lib/netstandard1.3" />
|
||||
<HarvestIncludePaths Include="runtimes/unix/lib/netstandard1.3">
|
||||
<!-- package unix impl (platform not supported) as RID agnostic -->
|
||||
<TargetPath>lib/netstandard1.3</TargetPath>
|
||||
</HarvestIncludePaths>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard;
|
||||
netfx;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -3,11 +3,19 @@
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{881269F5-9F22-4427-8DC5-63E2C05875BA}</ProjectGuid>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="System.Security.Cryptography.Pkcs.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Security" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard-Windows_NT;
|
||||
netstandard-Unix;
|
||||
netstandard;
|
||||
netfx-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -341,13 +341,16 @@ namespace Internal.Cryptography.Pal.Windows
|
||||
{
|
||||
string oidValue = pCryptAttribute->pszObjId.ToStringAnsi();
|
||||
Oid oid = new Oid(oidValue);
|
||||
AsnEncodedDataCollection attributeCollection = new AsnEncodedDataCollection();
|
||||
|
||||
for (int i = 0; i < pCryptAttribute->cValue; i++)
|
||||
{
|
||||
byte[] encodedAttribute = pCryptAttribute->rgValue[i].ToByteArray();
|
||||
AsnEncodedData attributeObject = Helpers.CreateBestPkcs9AttributeObjectAvailable(oid, encodedAttribute);
|
||||
collection.Add(attributeObject);
|
||||
attributeCollection.Add(attributeObject);
|
||||
}
|
||||
|
||||
collection.Add(new CryptographicAttributeObject(oid, attributeCollection));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,4 +100,7 @@
|
||||
<data name="InvalidOperation_WrongOidInAsnCollection" xml:space="preserve">
|
||||
<value>AsnEncodedData element in the collection has wrong Oid value: expected = '{0}', actual = '{1}'.</value>
|
||||
</data>
|
||||
<data name="PlatformNotSupported_CryptographyPkcs" xml:space="preserve">
|
||||
<value>System.Security.Cryptography.Pkcs is only supported on Windows platforms.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
@@ -7,20 +7,20 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
|
||||
<ResourcesSourceOutputDirectory Condition="'$(IsPartialFacadeAssembly)' == 'true'">None</ResourcesSourceOutputDirectory>
|
||||
<GeneratePlatformNotSupportedAssembly Condition="'$(TargetsUnix)' == 'true'">true</GeneratePlatformNotSupportedAssembly>
|
||||
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetGroup)' == 'netstandard' AND '$(TargetsWindows)' != 'true'">SR.PlatformNotSupported_CryptographyPkcs</GeneratePlatformNotSupportedAssemblyMessage>
|
||||
<UsePackageTargetRuntimeDefaults Condition="'$(IsPartialFacadeAssembly)' != 'true'">true</UsePackageTargetRuntimeDefaults>
|
||||
<IncludeDllSafeSearchPathAttribute>true</IncludeDllSafeSearchPathAttribute>
|
||||
</PropertyGroup>
|
||||
<!-- Don't delete these clauses even if they look useless. They tell the VS IDE that "Windows_Debug", etc., are
|
||||
valid configuration for this project and stop it from trying to "fix up" the .sln file -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netfx-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netfx-Windows_NT-Release|AnyCPU'" />
|
||||
|
||||
<!-- API types (platform independent) -->
|
||||
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true' AND '$(GeneratePlatformNotSupportedAssembly)' != 'true'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true' AND ('$(TargetGroup)' != 'netstandard' OR '$(TargetsWindows)' == 'true')">
|
||||
<Compile Include="System\Security\Cryptography\CryptographicAttributeObject.cs" />
|
||||
<Compile Include="System\Security\Cryptography\CryptographicAttributeObjectCollection.cs" />
|
||||
<Compile Include="System\Security\Cryptography\CryptographicAttributeObjectEnumerator.cs" />
|
||||
@@ -50,7 +50,7 @@
|
||||
<Compile Include="System\Security\Cryptography\Xml\X509IssuerSerial.cs" />
|
||||
</ItemGroup>
|
||||
<!-- Internal types (platform independent) -->
|
||||
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true' AND '$(GeneratePlatformNotSupportedAssembly)' != 'true'">
|
||||
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true' AND ('$(TargetGroup)' != 'netstandard' OR '$(TargetsWindows)' == 'true')">
|
||||
<Compile Include="Internal\Cryptography\DecryptorPal.cs" />
|
||||
<Compile Include="Internal\Cryptography\KeyAgreeRecipientInfoPal.cs" />
|
||||
<Compile Include="Internal\Cryptography\KeyLengths.cs" />
|
||||
@@ -61,7 +61,7 @@
|
||||
<Compile Include="Internal\Cryptography\RecipientInfoPal.cs" />
|
||||
</ItemGroup>
|
||||
<!-- Internal types (platform: Windows) -->
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true' AND '$(GeneratePlatformNotSupportedAssembly)' != 'true'">
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true'">
|
||||
<Compile Include="Internal\Cryptography\Pal\Windows\AlgId.cs" />
|
||||
<Compile Include="Internal\Cryptography\Pal\Windows\DecryptorPalWindows.cs" />
|
||||
<Compile Include="Internal\Cryptography\Pal\Windows\DecryptorPalWindows.Decode.cs" />
|
||||
@@ -81,7 +81,7 @@
|
||||
<Compile Include="Microsoft\Win32\SafeHandles\SafeProvOrNCryptKeyHandleUwp.cs" />
|
||||
</ItemGroup>
|
||||
<!-- Interop types (platform: Windows) -->
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true' AND '$(GeneratePlatformNotSupportedAssembly)' != 'true'">
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true'">
|
||||
<Compile Include="Interop\Windows\Crypt32\Interop.CERT_CONTEXT.cs" />
|
||||
<Compile Include="Interop\Windows\Crypt32\Interop.CERT_ID.cs" />
|
||||
<Compile Include="Interop\Windows\Crypt32\Interop.CERT_INFO.cs" />
|
||||
@@ -141,7 +141,7 @@
|
||||
<Compile Include="Interop\Windows\Heap\Interop.Heap.cs" />
|
||||
</ItemGroup>
|
||||
<!-- Common types (platform: Windows) -->
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true' AND '$(GeneratePlatformNotSupportedAssembly)' != 'true'">
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true'">
|
||||
<Compile Include="$(CommonPath)\Internal\Cryptography\Windows\CryptoThrowHelper.cs">
|
||||
<Link>Common\Internal\Cryptography\Windows\CryptoThrowHelper.cs</Link>
|
||||
</Compile>
|
||||
@@ -165,7 +165,7 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<!-- Internal types (platform: Unix) -->
|
||||
<ItemGroup Condition="'$(TargetsUnix)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true' AND '$(GeneratePlatformNotSupportedAssembly)' != 'true'">
|
||||
<ItemGroup Condition="'$(TargetsUnix)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true' AND '$(TargetGroup)' != 'netstandard'">
|
||||
<Compile Include="Internal\Cryptography\Pal\Unix\PkcsPal.Unix.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' == 'true'">
|
||||
@@ -173,4 +173,4 @@
|
||||
<Reference Include="System.Security" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -170,9 +170,12 @@ namespace System.Security.Cryptography.Pkcs.Tests
|
||||
Assert.Throws<ArgumentException>(() => ic.CopyTo(new CmsRecipient[2, 2], 1));
|
||||
Assert.Throws<InvalidCastException>(() => ic.CopyTo(new int[10], 1));
|
||||
|
||||
// Array has non-zero lower bound
|
||||
Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 });
|
||||
Assert.Throws<IndexOutOfRangeException>(() => ic.CopyTo(array, 0));
|
||||
if (PlatformDetection.IsNonZeroLowerBoundArraySupported)
|
||||
{
|
||||
// Array has non-zero lower bound
|
||||
Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 });
|
||||
Assert.Throws<IndexOutOfRangeException>(() => ic.CopyTo(array, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -162,9 +162,12 @@ namespace System.Security.Cryptography.Pkcs.Tests
|
||||
Assert.Throws<ArgumentException>(() => ic.CopyTo(new CryptographicAttributeObject[2, 2], 0));
|
||||
Assert.Throws<InvalidCastException>(() => ic.CopyTo(new int[10], 0));
|
||||
|
||||
// Array has non-zero lower bound
|
||||
Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 });
|
||||
Assert.Throws<IndexOutOfRangeException>(() => ic.CopyTo(array, 0));
|
||||
if (PlatformDetection.IsNonZeroLowerBoundArraySupported)
|
||||
{
|
||||
// Array has non-zero lower bound
|
||||
Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 });
|
||||
Assert.Throws<IndexOutOfRangeException>(() => ic.CopyTo(array, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertEquals(CryptographicAttributeObjectCollection c, IList<CryptographicAttributeObject> expected)
|
||||
|
||||
@@ -21,7 +21,9 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
{
|
||||
public static partial class DecryptTests
|
||||
{
|
||||
[Fact]
|
||||
public static bool SupportsCngCertificates { get; } = (!PlatformDetection.IsFullFramework || PlatformDetection.IsNetfx462OrNewer());
|
||||
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void Decrypt_IssuerAndSerial()
|
||||
{
|
||||
@@ -30,7 +32,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
TestSimpleDecrypt_RoundTrip(Certificates.RSAKeyTransfer1, contentInfo, Oids.Aes256, SubjectIdentifierType.IssuerAndSerialNumber);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void Decrypt_Ski()
|
||||
{
|
||||
@@ -48,7 +50,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
TestSimpleDecrypt_RoundTrip(Certificates.RSAKeyTransferCapi1, contentInfo, Oids.Aes256, SubjectIdentifierType.IssuerAndSerialNumber);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void Decrypt_256()
|
||||
{
|
||||
@@ -57,7 +59,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
TestSimpleDecrypt_RoundTrip(Certificates.RSASha256KeyTransfer1, contentInfo, Oids.Aes256, SubjectIdentifierType.IssuerAndSerialNumber);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void Decrypt_384()
|
||||
{
|
||||
@@ -66,7 +68,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
TestSimpleDecrypt_RoundTrip(Certificates.RSASha384KeyTransfer1, contentInfo, Oids.Aes256, SubjectIdentifierType.IssuerAndSerialNumber);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void Decrypt_512()
|
||||
{
|
||||
@@ -119,7 +121,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
TestSimpleDecrypt_RoundTrip(Certificates.RSAKeyTransferCapi1, contentInfo, Oids.Aes256, SubjectIdentifierType.IssuerAndSerialNumber);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void DecryptMultipleRecipients()
|
||||
{
|
||||
|
||||
@@ -21,7 +21,9 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
{
|
||||
public static partial class EdgeCasesTests
|
||||
{
|
||||
[Fact]
|
||||
public static bool SupportsCngCertificates { get; } = (!PlatformDetection.IsFullFramework || PlatformDetection.IsNetfx462OrNewer());
|
||||
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void ImportEdgeCase()
|
||||
{
|
||||
@@ -54,7 +56,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void ImportEdgeCaseSki()
|
||||
{
|
||||
@@ -92,6 +94,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
|
||||
[Fact]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Desktop rejects zero length content: corefx#18724")]
|
||||
public static void ZeroLengthContent_RoundTrip()
|
||||
{
|
||||
ContentInfo contentInfo = new ContentInfo(Array.Empty<byte>());
|
||||
@@ -99,20 +102,13 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
using (X509Certificate2 cert = Certificates.RSAKeyTransfer1.GetCertificate())
|
||||
{
|
||||
CmsRecipient cmsRecipient = new CmsRecipient(cert);
|
||||
try
|
||||
{
|
||||
ecms.Encrypt(cmsRecipient);
|
||||
}
|
||||
catch (CryptographicException e)
|
||||
{
|
||||
throw new Exception("ecms.Encrypt() threw " + e.Message + ".\nIf you're running on the desktop CLR, this is actually an expected result.");
|
||||
}
|
||||
ecms.Encrypt(cmsRecipient);
|
||||
}
|
||||
byte[] encodedMessage = ecms.Encode();
|
||||
ValidateZeroLengthContent(encodedMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void ZeroLengthContent_FixedValue()
|
||||
{
|
||||
@@ -175,10 +171,9 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
ecms.Decrypt(extraStore);
|
||||
ContentInfo contentInfo = ecms.ContentInfo;
|
||||
byte[] content = contentInfo.Content;
|
||||
if (content.Length == 6)
|
||||
throw new Exception("ContentInfo expected to be 0 but was actually 6. If you're running on the desktop CLR, this is actually a known bug.");
|
||||
|
||||
Assert.Equal(0, content.Length);
|
||||
int expected = PlatformDetection.IsFullFramework ? 6 : 0; // Desktop bug gives 6
|
||||
Assert.Equal(expected, content.Length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
{
|
||||
public static partial class StateTests
|
||||
{
|
||||
public static bool SupportsCngCertificates { get; } = (!PlatformDetection.IsFullFramework || PlatformDetection.IsNetfx462OrNewer());
|
||||
|
||||
//
|
||||
// Exercises various edge cases when EnvelopedCms methods and properties are called out of the "expected" order.
|
||||
//
|
||||
@@ -203,7 +205,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp | TargetFrameworkMonikers.Uap)]
|
||||
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
|
||||
public static void PostDecode_Encode_net46()
|
||||
{
|
||||
PostDecode_Encode(isRunningOnDesktop: true);
|
||||
@@ -238,7 +240,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp | TargetFrameworkMonikers.Uap)]
|
||||
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
|
||||
public static void PostDecode_ContentInfo_net46()
|
||||
{
|
||||
PostDecode_ContentInfo(isRunningOnDesktop: true);
|
||||
@@ -254,12 +256,11 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
//
|
||||
// State 4: Called Decode() + Decrypt()
|
||||
//
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void PostDecrypt_Encode()
|
||||
{
|
||||
byte[] expectedContent = { 6, 3, 128, 33, 44 };
|
||||
|
||||
EnvelopedCms ecms = new EnvelopedCms(new ContentInfo(expectedContent));
|
||||
ecms.Encrypt(new CmsRecipient(Certificates.RSAKeyTransfer1.GetCertificate()));
|
||||
byte[] encodedMessage =
|
||||
@@ -287,7 +288,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void PostDecrypt_RecipientInfos()
|
||||
{
|
||||
@@ -326,7 +327,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact(nameof(SupportsCngCertificates))]
|
||||
[OuterLoop(/* Leaks key on disk if interrupted */)]
|
||||
public static void PostDecrypt_Decrypt()
|
||||
{
|
||||
|
||||
@@ -267,6 +267,60 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests
|
||||
attributes[2].AssertIsDocumentationDescription("My Description 2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestUnprotectedAttributes1_EmptySet()
|
||||
{
|
||||
// This tests the behavior of unprotected attribute extraction when one of the attribute sequences declares an
|
||||
// attribute type, but the contained SET OF AttributeValue is empty.
|
||||
//
|
||||
// Attribute ::= SEQUENCE {
|
||||
// attrType OBJECT IDENTIFIER,
|
||||
// attrValues SET OF AttributeValue }
|
||||
//
|
||||
// The encoded message was built in ASN.1 editor and tested in framework.It contains an enveloped message
|
||||
// version 2 with a key transport recipient, the enveloped message contains data encrypted with 3DES.
|
||||
//
|
||||
// The attributes set is built as
|
||||
// {
|
||||
// { attrType: document description, attrValues: { value1, value2 } },
|
||||
// { attrType: document name, attrValues: { } },
|
||||
// }
|
||||
//
|
||||
// The important part of this test is that there are 0 attributes of a type that is declared within the encoded message.
|
||||
// This should return 2 as it should create a CryptographicAttributeObjectCollection with two CryptographicAttributeObjects,
|
||||
// the first one holding a list of document description with the two values, the second one holding an empty list of
|
||||
// document name.
|
||||
|
||||
byte[] encodedMessage =
|
||||
("3082017806092A864886F70D010703A0820169308201650201023181C83081C5020100302E301A311830160603550403"
|
||||
+ "130F5253414B65795472616E7366657231021031D935FB63E8CFAB48A0BF7B397B67C0300D06092A864886F70D010101"
|
||||
+ "05000481802EE6A4AAA9F907E8EF472D8CD8603098488EC1C462815E6FC5A53A3DF6EB730F3D191746FDBBCA89114C6D"
|
||||
+ "45FB6C4F26088043894D5A706889A29D52E03ABEDFAC98336BD01B0A9CFA57CC6C80908F4B42EFCE5E60E7A761451A4D"
|
||||
+ "1A39783072000E551062027795A1CEB079791BA48C5F77D360EE48E185DE6C8CCB1C093D4B302B06092A864886F70D01"
|
||||
+ "0701301406082A864886F70D03070408F55F613664678EE9800800BC3504D1F59470A168300E060A2B06010401823758"
|
||||
+ "020131003056060A2B060104018237580202314804224D00790020004400650073006300720069007000740069006F00"
|
||||
+ "6E0020003100000004224D00790020004400650073006300720069007000740069006F006E00200032000000").HexToByteArray();
|
||||
|
||||
EnvelopedCms ecms = new EnvelopedCms();
|
||||
ecms.Decode(encodedMessage);
|
||||
|
||||
Assert.Equal(2, ecms.UnprotectedAttributes.Count);
|
||||
|
||||
CryptographicAttributeObjectCollection collection = ecms.UnprotectedAttributes;
|
||||
string attrObj0Oid = collection[0].Oid.Value;
|
||||
|
||||
CryptographicAttributeObject documentDescObj = (attrObj0Oid == Oids.DocumentDescription) ?
|
||||
collection[0] :
|
||||
collection[1];
|
||||
|
||||
CryptographicAttributeObject documentNameObj = (attrObj0Oid == Oids.DocumentName) ?
|
||||
collection[0] :
|
||||
collection[1];
|
||||
|
||||
Assert.Equal(0, documentNameObj.Values.Count);
|
||||
Assert.Equal(2, documentDescObj.Values.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestUnprotectedAttributes1_Arbitrary_RoundTrip()
|
||||
{
|
||||
|
||||
@@ -140,9 +140,12 @@ namespace System.Security.Cryptography.Pkcs.Tests
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => col.CopyTo(recipients, -1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => col.CopyTo(recipients, 6));
|
||||
|
||||
// Array has non-zero lower bound
|
||||
Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 });
|
||||
Assert.Throws<IndexOutOfRangeException>(() => col.CopyTo(array, 0));
|
||||
if (PlatformDetection.IsNonZeroLowerBoundArraySupported)
|
||||
{
|
||||
// Array has non-zero lower bound
|
||||
Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 });
|
||||
Assert.Throws<IndexOutOfRangeException>(() => col.CopyTo(array, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<Compile Include="$(CommonTestPath)\System\Security\Cryptography\ByteUtils.cs">
|
||||
<Link>CommonTest\System\Security\Cryptography\ByteUtils.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
|
||||
<Link>CommonTest\System\PlatformDetection.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Certificates.cs" />
|
||||
|
||||
Reference in New Issue
Block a user