* Add S.S.C.Pkcs and S.S.C.Cng netstandard2.1 ref and lib
The netstandard2.1 ref is equivalent to the netcoreapp3.0 ref in these two
OOB packages.
Ref changes:
Cng:
* Adds DSACng and ECDiffieHellmanCng (and related types)
Pkcs:
* Adds RSA-OAEP option to CmsRecipient
* Adds custom private key option to CmsSigner
* Adds custom private key decrypt option to EnvelopedCms
* Adds Pkcs12Info and Pkcs12Builder (and associated types)
* Adds Pkcs8PrivateKeyInfo
* Adds RFC3161 timestamp types
* Adds AddCertificate/RemoveCertificate to SignedCms
* Adds AddUnsignedAttribute/RemoveUnsignedAttribute to SignerInfo
* Adds SignatureAlgorithm/GetSignature to SignerInfo
* Adds MatchesCertificate to SubjectIdentifier
Impl changes:
Cng:
* The netstandard2.1 impl is a generated PNSE, the real impl is inbox on Windows.
Pkcs:
* The impls are the same as the netcoreapp3.0 impls, but are required
because netstandard2.0 is a better match for netstandard2.1 than netcoreapp3.0 is.
* Use shared netstandard21 DefineConstant
* Add netstandard2.1 to ref AdditionalBuildConfigurations
Commit migrated from https://github.com/dotnet/corefx/commit/
985334c90d6b181cd47cd42c4c958d9dd34ab90b
}
public
-#if netcoreapp || uap || NETCOREAPP
+#if netcoreapp || uap || NETCOREAPP || netstandard21
override
#endif
int GetByteCount(ReadOnlySpan<char> chars)
}
public
-#if netcoreapp || uap || NETCOREAPP
+#if netcoreapp || uap || NETCOREAPP || netstandard21
override
#endif
int GetCharCount(ReadOnlySpan<byte> bytes)
return s_utf8Encoding.GetByteCount(s);
}
-#if netcoreapp || uap || NETCOREAPP
+#if netcoreapp || uap || NETCOREAPP || netstandard21
public override int GetByteCount(ReadOnlySpan<char> chars)
{
return s_utf8Encoding.GetByteCount(chars);
}
}
-#if netcoreapp || uap || NETCOREAPP
+#if netcoreapp || uap || NETCOREAPP || netstandard21
public override int GetCharCount(ReadOnlySpan<byte> bytes)
{
try
_offset += bitString.Length;
}
-#if netcoreapp || uap || NETCOREAPP
+#if netcoreapp || uap || NETCOREAPP || netstandard21
/// <summary>
/// Write a Bit String value via a callback, with a tag UNIVERSAL 3.
/// </summary>
if (!clearWholeArray && clearSize != 0)
{
-#if netcoreapp || uap || NETCOREAPP
+#if netcoreapp || uap || NETCOREAPP || netstandard21
CryptographicOperations.ZeroMemory(array.AsSpan(0, clearSize));
#else
Array.Clear(array, 0, clearSize);
<PropertyGroup>
<PackageConfigurations>
netcoreapp;
+ netstandard2.1;
net461;
net462;
net47;
uap;
</BuildConfigurations>
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
<DefineConstants Condition="'$(TargetGroup)' != 'net461' AND '$(TargetGroup)' != 'net462'">$(DefineConstants);FEATURE_ECPARAMETERS</DefineConstants>
<ProjectGuid>{9FD12550-3A7C-49D3-9A1E-C4B7410989DD}</ProjectGuid>
<!-- FEATURE_DSA_HASHDATA is technically also available on net462+, but it doesn't require being enabled since it is a facade -->
- <DefineConstants Condition="'$(TargetGroup)' == 'uap' Or '$(TargetGroup)' == 'netcoreapp'">$(DefineConstants);FEATURE_DSA_HASHDATA</DefineConstants>
+ <DefineConstants Condition="'$(TargetGroup)' == 'uap' Or '$(TargetGroup)' == 'netcoreapp' OR '$(TargetsNetStandard)' == 'true'">$(DefineConstants);FEATURE_DSA_HASHDATA</DefineConstants>
<!-- FEATURE_ECDH_DERIVEFROM is technically also available on net462+, but it doesn't require being enabled since it is a facade -->
- <DefineConstants Condition="'$(TargetGroup)' == 'uap' Or '$(TargetGroup)' == 'netcoreapp'">$(DefineConstants);FEATURE_ECDH_DERIVEFROM</DefineConstants>
+ <DefineConstants Condition="'$(TargetGroup)' == 'uap' Or '$(TargetGroup)' == 'netcoreapp' OR '$(TargetsNetStandard)' == 'true'">$(DefineConstants);FEATURE_ECDH_DERIVEFROM</DefineConstants>
<IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true'">true</IsPartialFacadeAssembly>
- <Configurations>net461-Debug;net461-Release;net462-Debug;net462-Release;net47-Debug;net47-Release;netcoreapp-Debug;netcoreapp-Release;netfx-Debug;netfx-Release;uap-Debug;uap-Release</Configurations>
+ <Configurations>net461-Debug;net461-Release;net462-Debug;net462-Release;net47-Debug;net47-Release;netcoreapp-Debug;netcoreapp-Release;netfx-Debug;netfx-Release;netstandard2.1-Debug;netstandard2.1-Release;uap-Debug;uap-Release</Configurations>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Security.Cryptography.Cng.cs" />
<PropertyGroup>
<PackageConfigurations>
netstandard;
+ netstandard2.1;
net461-Windows_NT;
netcoreapp-Windows_NT;
netcoreapp;
uap-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
<IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true'">true</IsPartialFacadeAssembly>
<OmitResources Condition="'$(IsPartialFacadeAssembly)' == 'true'">true</OmitResources>
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)' == 'net461'">true</GenFacadesIgnoreMissingTypes>
- <Configurations>net461-Windows_NT-Debug;net461-Windows_NT-Release;net462-Windows_NT-Debug;net462-Windows_NT-Release;net47-Windows_NT-Debug;net47-Windows_NT-Release;netcoreapp-Debug;netcoreapp-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;netfx-Windows_NT-Debug;netfx-Windows_NT-Release;netstandard-Debug;netstandard-Release;uap-Windows_NT-Debug;uap-Windows_NT-Release</Configurations>
+ <Configurations>net461-Windows_NT-Debug;net461-Windows_NT-Release;net462-Windows_NT-Debug;net462-Windows_NT-Release;net47-Windows_NT-Debug;net47-Windows_NT-Release;netcoreapp-Debug;netcoreapp-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;netfx-Windows_NT-Debug;netfx-Windows_NT-Release;netstandard-Debug;netstandard-Release;netstandard2.1-Debug;netstandard2.1-Release;uap-Windows_NT-Debug;uap-Windows_NT-Release</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsWindows)' != 'true'">
<GeneratePlatformNotSupportedAssemblyMessage>SR.PlatformNotSupported_CryptographyCng</GeneratePlatformNotSupportedAssemblyMessage>
</Compile>
</ItemGroup>
<ItemGroup>
- <None Include="@(AsnXml)" />
+ <None Include="@(AsnXml)" />
</ItemGroup>
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' == 'true'">
<Reference Include="mscorlib" />
<Reference Include="System.Text.Encoding.Extensions" />
<Reference Include="System.Threading" />
</ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
<PropertyGroup>
<PackageConfigurations>
netcoreapp;
+ netstandard2.1;
net461;
</PackageConfigurations>
<BuildConfigurations>
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{881269F5-9F22-4427-8DC5-63E2C05875BA}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true'">true</IsPartialFacadeAssembly>
- <Configurations>net461-Debug;net461-Release;netcoreapp-Debug;netcoreapp-Release;netfx-Debug;netfx-Release;uap-Debug;uap-Release</Configurations>
+ <Configurations>net461-Debug;net461-Release;netcoreapp-Debug;netcoreapp-Release;netfx-Debug;netfx-Release;netstandard2.1-Debug;netstandard2.1-Release;uap-Debug;uap-Release</Configurations>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Security.Cryptography.Pkcs.cs" />
- <Compile Include="System.Security.Cryptography.Pkcs.netcoreapp.cs" Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap'" />
+ <Compile Include="System.Security.Cryptography.Pkcs.netcoreapp.cs" Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap' OR '$(TargetsNetStandard)' == 'true'" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsNetFx)' == 'true'">
<Reference Include="mscorlib" />
<PackageConfigurations>
netstandard;
netstandard-Windows_NT;
+ netstandard2.1;
+ netstandard2.1-Windows_NT;
netcoreapp-Windows_NT;
netcoreapp;
net461-Windows_NT;
return null;
}
-#if netcoreapp
+#if netcoreapp || netstandard21
byte[] cek = null;
int cekLength = 0;
return (T)(object)certificate.GetRSAPrivateKey();
if (typeof(T) == typeof(ECDsa))
return (T)(object)certificate.GetECDsaPrivateKey();
-#if netcoreapp
+#if netcoreapp || netstandard21
if (typeof(T) == typeof(DSA))
return (T)(object)certificate.GetDSAPrivateKey();
#endif
{
private static readonly byte[] s_pSpecifiedDefaultParameters = { 0x04, 0x00 };
-#if !netcoreapp
+#if !netcoreapp && !netstandard21
// Compatibility API.
internal static void AppendData(this IncrementalHash hasher, ReadOnlySpan<byte> data)
{
return ToUpperHexString(serialBytes);
}
-#if netcoreapp
+#if netcoreapp || netstandard21
private static unsafe string ToUpperHexString(ReadOnlySpan<byte> ba)
{
fixed (byte* baPtr = ba)
attributeObject = Upgrade<Pkcs9MessageDigest>(attributeObject);
break;
-#if netcoreapp
+#if netcoreapp || netstandard21
case Oids.LocalKeyId:
attributeObject = Upgrade<Pkcs9LocalKeyId>(attributeObject);
break;
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{03D84CBD-896D-4B2F-9A22-07034F51E73D}</ProjectGuid>
<AssemblyName>System.Security.Cryptography.Pkcs</AssemblyName>
<UsePackageTargetRuntimeDefaults Condition="'$(IsPartialFacadeAssembly)' != 'true'">true</UsePackageTargetRuntimeDefaults>
<IncludeDllSafeSearchPathAttribute>true</IncludeDllSafeSearchPathAttribute>
<NoWarn>$(NoWarn);CS1574;CS3016</NoWarn>
- <Configurations>net461-Windows_NT-Debug;net461-Windows_NT-Release;netcoreapp-Debug;netcoreapp-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;netfx-Windows_NT-Debug;netfx-Windows_NT-Release;netstandard-Debug;netstandard-Release;netstandard-Windows_NT-Debug;netstandard-Windows_NT-Release</Configurations>
+ <Configurations>net461-Windows_NT-Debug;net461-Windows_NT-Release;netcoreapp-Debug;netcoreapp-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;netfx-Windows_NT-Debug;netfx-Windows_NT-Release;netstandard-Debug;netstandard-Release;netstandard-Windows_NT-Debug;netstandard-Windows_NT-Release;netstandard2.1-Debug;netstandard2.1-Release;netstandard2.1-Windows_NT-Debug;netstandard2.1-Windows_NT-Release</Configurations>
</PropertyGroup>
<Import Project="$(CommonPath)\System\Security\Cryptography\Asn1\AsnXml.targets" Condition="'$(IsPartialFacadeAssembly)' != 'true'" />
<Import Project="$(CommonPath)\System\Security\Cryptography\Asn1Reader\System.Security.Cryptography.Asn1Reader.Shared.projitems" Condition="'$(IsPartialFacadeAssembly)' != 'true'" />
<Reference Include="mscorlib" />
<Reference Include="System.Security" />
</ItemGroup>
- <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
+ <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'netstandard2.1'">
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Numerics" />
<Reference Include="System.Collections" />
<Reference Include="System.Linq" />
<Reference Include="System.Text.Encoding.Extensions" />
</ItemGroup>
- <ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
+ <ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true' AND '$(TargetGroup)' != 'netstandard2.1'">
<Reference Include="System.Buffers" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<Reference Include="System.Memory" />
<Reference Include="System.Security.Cryptography.Cng" />
</ItemGroup>
<Compile Include="System\Security\Cryptography\Pkcs\SignerInfoCollection.cs" />
<Compile Include="System\Security\Cryptography\Pkcs\SignerInfoEnumerator.cs" />
</ItemGroup>
- <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
+ <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'netstandard2.1'">
<Compile Include="$(CommonPath)\System\Security\Cryptography\KeyFormatHelper.cs">
<Link>Common\System\Security\Cryptography\KeyFormatHelper.cs</Link>
</Compile>
}
internal override bool VerifySignature(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> valueHash,
ReadOnlyMemory<byte> signature,
#else
DSAParameters dsaParameters = dsa.ExportParameters(false);
int bufSize = 2 * dsaParameters.Q.Length;
-#if netcoreapp
+#if netcoreapp || netstandard21
byte[] rented = CryptoPool.Rent(bufSize);
Span<byte> ieee = new Span<byte>(rented, 0, bufSize);
}
return dsa.VerifySignature(valueHash, ieee);
-#if netcoreapp
+#if netcoreapp || netstandard21
}
finally
{
}
protected override bool Sign(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> dataHash,
#else
byte[] dataHash,
signatureAlgorithm = new Oid(oidValue, oidValue);
-#if netcoreapp
+#if netcoreapp || netstandard21
// The Q size cannot be bigger than the KeySize.
byte[] rented = CryptoPool.Rent(dsa.KeySize / 8);
int bytesWritten = 0;
}
internal override bool VerifySignature(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> valueHash,
ReadOnlyMemory<byte> signature,
#else
bufSize = 2 * fieldSize;
}
-#if netcoreapp
+#if netcoreapp || netstandard21
byte[] rented = CryptoPool.Rent(bufSize);
Span<byte> ieee = new Span<byte>(rented, 0, bufSize);
}
return key.VerifyHash(valueHash, ieee);
-#if netcoreapp
+#if netcoreapp || netstandard21
}
finally
{
}
protected override bool Sign(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> dataHash,
#else
byte[] dataHash,
signatureAlgorithm = new Oid(oidValue, oidValue);
-#if netcoreapp
+#if netcoreapp || netstandard21
int bufSize;
checked
{
#endif
signatureValue = DsaIeeeToDer(key.SignHash(
-#if netcoreapp
+#if netcoreapp || netstandard21
dataHash.ToArray()
#else
dataHash
}
internal override bool VerifySignature(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> valueHash,
ReadOnlyMemory<byte> signature,
#else
return publicKey.VerifyHash(
valueHash,
-#if netcoreapp
+#if netcoreapp || netstandard21
signature.Span,
#else
signature,
}
protected override bool Sign(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> dataHash,
#else
byte[] dataHash,
signatureAlgorithm = new Oid(Oids.Rsa, Oids.Rsa);
-#if netcoreapp
+#if netcoreapp || netstandard21
byte[] signature = new byte[privateKey.KeySize / 8];
bool signed = privateKey.TrySignHash(
}
#endif
signatureValue = privateKey.SignHash(
-#if netcoreapp
+#if netcoreapp || netstandard21
dataHash.ToArray(),
#else
dataHash,
}
protected override bool Sign(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> dataHash,
#else
byte[] dataHash,
protected abstract bool VerifyKeyType(AsymmetricAlgorithm key);
internal abstract bool VerifySignature(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> valueHash,
ReadOnlyMemory<byte> signature,
#else
X509Certificate2 certificate);
protected abstract bool Sign(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> dataHash,
#else
byte[] dataHash,
}
internal static bool Sign(
-#if netcoreapp
+#if netcoreapp || netstandard21
ReadOnlySpan<byte> dataHash,
#else
byte[] dataHash,
{
writer.PushSequence();
-#if netcoreapp
+#if netcoreapp || netstandard21
// r
BigInteger val = new BigInteger(
ieeeSignature.Slice(0, fieldSize),
{
writer.PopSequence();
-#if netcoreapp
+#if netcoreapp || netstandard21
Span<byte> setOfTag = stackalloc byte[1];
setOfTag[0] = 0x31;
{
writer.PopSetOf();
-#if netcoreapp
+#if netcoreapp || netstandard21
hasher.AppendData(writer.EncodeAsSpan());
#else
hasher.AppendData(writer.Encode());
return false;
}
-#if netcoreapp
+#if netcoreapp || netstandard21
// SHA-2-512 is the biggest digest type we know about.
Span<byte> digestValue = stackalloc byte[512 / 8];
ReadOnlySpan<byte> digest = digestValue;
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
<PropertyGroup>
- <AdditionalBuildConfigurations>$(AdditionalBuildConfigurations);netstandard-$(OSGroup)-$(ConfigurationGroup)-$(ArchGroup)</AdditionalBuildConfigurations>
+ <AdditionalBuildConfigurations>$(AdditionalBuildConfigurations);netstandard-$(OSGroup)-$(ConfigurationGroup)-$(ArchGroup);netstandard2.1-$(OSGroup)-$(ConfigurationGroup)</AdditionalBuildConfigurations>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)dir.traversal.targets" />
-</Project>
\ No newline at end of file
+</Project>