提交 4b055094 编写于 作者: J Jeff Handley 提交者: Matt Mitchell

Merged PR 32017: [7.0] Fix regression loading null-password encrypted PFX certificates

When decrypting the payload with empty string and null passwords, try reading the payload with the Asn reader to ensure the header matches the expected format. If that succeeds, then proceed with the iteration counting. This guards against a false-positive match that previously caused our iteration count work to throw/abort, thus preventing some null-password encrypted payloads from being loaded.
上级 d9294c81
......@@ -249,6 +249,12 @@ private static ArraySegment<byte> DecryptContentInfo(ContentInfoAsn contentInfo,
default,
encryptedData.EncryptedContentInfo.EncryptedContent.Value.Span,
destination);
// When padding happens to be as expected (false-positive), we can detect gibberish and prevent unexpected failures later
// This extra check makes it so it's very unlikely we'll end up with false positive.
AsnValueReader outerSafeBag = new AsnValueReader(destination.AsSpan(0, written), AsnEncodingRules.BER);
AsnValueReader safeBagReader = outerSafeBag.ReadSequence();
outerSafeBag.ThrowIfNotEmpty();
}
catch
{
......@@ -259,6 +265,12 @@ private static ArraySegment<byte> DecryptContentInfo(ContentInfoAsn contentInfo,
default,
encryptedData.EncryptedContentInfo.EncryptedContent.Value.Span,
destination);
// When padding happens to be as expected (false-positive), we can detect gibberish and prevent unexpected failures later
// This extra check makes it so it's very unlikely we'll end up with false positive.
AsnValueReader outerSafeBag = new AsnValueReader(destination.AsSpan(0, written), AsnEncodingRules.BER);
AsnValueReader safeBagReader = outerSafeBag.ReadSequence();
outerSafeBag.ThrowIfNotEmpty();
}
}
finally
......
......@@ -5,8 +5,8 @@
<!-- Reference the outputs for the dependency nodes calculation. -->
<NoTargetsDoNotReferenceOutputAssemblies>false</NoTargetsDoNotReferenceOutputAssemblies>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<ServicingVersion>3</ServicingVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ServicingVersion>4</ServicingVersion>
<!-- This is a meta package and doesn't contain any libs. -->
<NoWarn>$(NoWarn);NU5128</NoWarn>
<PackageDescription>This Windows Compatibility Pack provides access to APIs that were previously available only for .NET Framework. It can be used from both .NET as well as .NET Standard.</PackageDescription>
......
......@@ -7,8 +7,8 @@
<NoWarn>$(NoWarn);CA5384</NoWarn>
<IsPackable>true</IsPackable>
<!-- If you enable GeneratePackageOnBuild for this package and bump ServicingVersion, make sure to also bump ServicingVersion in Microsoft.Windows.Compatibility.csproj once for the next release. -->
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<ServicingVersion>2</ServicingVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ServicingVersion>3</ServicingVersion>
<PackageDescription>Provides support for PKCS and CMS algorithms.
Commonly Used Types:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册