Imported Upstream version 5.18.0.142

Former-commit-id: 7467d4b717762eeaf652d77f1486dd11ffb1ff1f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-09 08:20:59 +00:00
parent e52655b4dc
commit 0abdbe5a7d
1547 changed files with 93792 additions and 47893 deletions

View File

@@ -17,13 +17,8 @@ using X509IssuerSerial = System.Security.Cryptography.Xml.X509IssuerSerial;
namespace Internal.Cryptography
{
internal static class Helpers
internal static partial class Helpers
{
public static byte[] CloneByteArray(this byte[] a)
{
return (byte[])(a.Clone());
}
#if !netcoreapp
// Compatibility API.
internal static void AppendData(this IncrementalHash hasher, ReadOnlySpan<byte> data)

View File

@@ -54,7 +54,16 @@ namespace Internal.Cryptography.Pal.Windows
public sealed override byte[] EncodeUtcTime(DateTime utcTime)
{
long ft = utcTime.ToFileTimeUtc();
long ft;
try
{
ft = utcTime.ToFileTimeUtc();
}
catch (ArgumentException ex)
{
throw new CryptographicException(ex.Message, ex);
}
unsafe
{
return Interop.Crypt32.CryptEncodeObjectToByteArray(CryptDecodeObjectStructType.PKCS_UTC_TIME, &ft);

View File

@@ -65,6 +65,9 @@
<Compile Include="Internal\Cryptography\Helpers.cs" />
<Compile Include="Internal\Cryptography\PkcsPal.cs" />
<Compile Include="Internal\Cryptography\RecipientInfoPal.cs" />
<Compile Include="$(CommonPath)\Internal\Cryptography\Helpers.cs">
<Link>Internal\Cryptography\Helpers.cs</Link>
</Compile>
</ItemGroup>
<!-- Internal types (platform: Windows) -->
<ItemGroup Condition="'$(TargetsWindows)' == 'true' AND '$(IsPartialFacadeAssembly)' != 'true'">

View File

@@ -27,6 +27,19 @@ namespace System.Security.Cryptography.Pkcs.Tests
Assert.Throws<ArgumentNullException>(() => ign = new Pkcs9AttributeObject(a));
}
[Fact]
public static void InputDateTimeAsWindowsFileTimeBefore1601()
{
DateTime dt = new DateTime(1600, 12, 31, 11, 59, 59, DateTimeKind.Utc);
AssertExtensions.Throws<CryptographicException, ArgumentOutOfRangeException>(() => new Pkcs9SigningTime(dt));
}
[Fact]
public static void Pkcs9SigningTime_DateTimeMinValue()
{
AssertExtensions.Throws<CryptographicException, ArgumentOutOfRangeException>(() => new Pkcs9SigningTime(DateTime.MinValue));
}
[Fact]
public static void InputDateTimeAsX509TimeBefore1950_Utc()
{