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,8 +2,10 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.3.0.0</AssemblyVersion>
|
||||
<AssemblyVersion>4.3.1.0</AssemblyVersion>
|
||||
<AssemblyKey>MSFT</AssemblyKey>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsUAP>true</IsUAP>
|
||||
<IsNetFxNETStandard>true</IsNetFxNETStandard>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netcoreapp;
|
||||
netfx;
|
||||
uap;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
|
@ -99,7 +99,9 @@ namespace System.Security.Cryptography
|
||||
{
|
||||
protected DSA() { }
|
||||
public static new System.Security.Cryptography.DSA Create() { throw null; }
|
||||
public static System.Security.Cryptography.DSA Create(int keySizeInBits) { throw null; }
|
||||
public static new System.Security.Cryptography.DSA Create(string algName) { throw null; }
|
||||
public static System.Security.Cryptography.DSA Create(System.Security.Cryptography.DSAParameters parameters) { throw null; }
|
||||
public abstract byte[] CreateSignature(byte[] rgbHash);
|
||||
public abstract System.Security.Cryptography.DSAParameters ExportParameters(bool includePrivateParameters);
|
||||
public override void FromXmlString(string xmlString) { }
|
||||
@ -395,7 +397,9 @@ namespace System.Security.Cryptography
|
||||
public override string KeyExchangeAlgorithm { get { throw null; } }
|
||||
public override string SignatureAlgorithm { get { throw null; } }
|
||||
public static new System.Security.Cryptography.RSA Create() { throw null; }
|
||||
public static System.Security.Cryptography.RSA Create(int keySizeInBits) { throw null; }
|
||||
public static new System.Security.Cryptography.RSA Create(string algName) { throw null; }
|
||||
public static System.Security.Cryptography.RSA Create(System.Security.Cryptography.RSAParameters parameters) { throw null; }
|
||||
public virtual byte[] Decrypt(byte[] data, System.Security.Cryptography.RSAEncryptionPadding padding) { throw null; }
|
||||
public virtual byte[] DecryptValue(byte[] rgb) { throw null; }
|
||||
public virtual byte[] Encrypt(byte[] data, System.Security.Cryptography.RSAEncryptionPadding padding) { throw null; }
|
||||
@ -597,8 +601,6 @@ namespace System.Security.Cryptography
|
||||
{
|
||||
protected TripleDES() { }
|
||||
public override byte[] Key { get { throw null; } set { } }
|
||||
public override System.Security.Cryptography.KeySizes[] LegalBlockSizes { get { throw null; } }
|
||||
public override System.Security.Cryptography.KeySizes[] LegalKeySizes { get { throw null; } }
|
||||
public static new System.Security.Cryptography.TripleDES Create() { throw null; }
|
||||
public static new System.Security.Cryptography.TripleDES Create(string str) { throw null; }
|
||||
public static bool IsWeakKey(byte[] rgbKey) { throw null; }
|
||||
|
@ -3,20 +3,28 @@
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{102247C1-3DB9-4DB5-80B3-EE9F80DD4E8F}</ProjectGuid>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="System.Security.Cryptography.Algorithms.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
|
||||
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
|
||||
<ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" />
|
||||
<ProjectReference Include="..\..\System.IO\ref\System.IO.csproj" />
|
||||
<ProjectReference Include="..\..\System.Security.Cryptography.Encoding\ref\System.Security.Cryptography.Encoding.csproj" />
|
||||
<ProjectReference Include="..\..\System.Security.Cryptography.Primitives\ref\System.Security.Cryptography.Primitives.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
28
external/corefx/src/System.Security.Cryptography.Algorithms/src/ApiCompatBaseline.netfx.txt
vendored
Normal file
28
external/corefx/src/System.Security.Cryptography.Algorithms/src/ApiCompatBaseline.netfx.txt
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
Compat issues with assembly System.Security.Cryptography.Algorithms:
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.Create(System.Int32)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.Create(System.Security.Cryptography.DSAParameters)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.HashData(System.Byte[], System.Int32, System.Int32, System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.HashData(System.IO.Stream, System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.SignData(System.Byte[], System.Int32, System.Int32, System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.SignData(System.Byte[], System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.SignData(System.IO.Stream, System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.VerifyData(System.Byte[], System.Byte[], System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.VerifyData(System.Byte[], System.Int32, System.Int32, System.Byte[], System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.DSA.VerifyData(System.IO.Stream, System.Byte[], System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
TypesMustExist : Type 'System.Security.Cryptography.ECCurve' does not exist in the implementation but it does exist in the contract.
|
||||
CannotMakeMemberAbstract : Member 'System.Security.Cryptography.ECDiffieHellmanPublicKey.ToXmlString()' is abstract in the implementation but is not abstract in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.ECDsa.Create(System.Security.Cryptography.ECCurve)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.ECDsa.Create(System.Security.Cryptography.ECParameters)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.ECDsa.ExportExplicitParameters(System.Boolean)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.ECDsa.ExportParameters(System.Boolean)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.ECDsa.GenerateKey(System.Security.Cryptography.ECCurve)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.ECDsa.ImportParameters(System.Security.Cryptography.ECParameters)' does not exist in the implementation but it does exist in the contract.
|
||||
TypesMustExist : Type 'System.Security.Cryptography.ECParameters' does not exist in the implementation but it does exist in the contract.
|
||||
TypesMustExist : Type 'System.Security.Cryptography.ECPoint' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.Rfc2898DeriveBytes..ctor(System.Byte[], System.Byte[], System.Int32, System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.Rfc2898DeriveBytes..ctor(System.String, System.Byte[], System.Int32, System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.Rfc2898DeriveBytes..ctor(System.String, System.Int32, System.Int32, System.Security.Cryptography.HashAlgorithmName)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.Rfc2898DeriveBytes.HashAlgorithm.get()' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.RSA.Create(System.Int32)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.Security.Cryptography.RSA.Create(System.Security.Cryptography.RSAParameters)' does not exist in the implementation but it does exist in the contract.
|
||||
Total Issues: 26
|
@ -1,3 +0,0 @@
|
||||
Compat issues with assembly System.Security.Cryptography.Algorithms:
|
||||
MembersMustExist : Member 'System.Security.Cryptography.ECDsa.Create(System.Security.Cryptography.ECCurve)' does not exist in the implementation but it does exist in the contract.
|
||||
Total Issues: 1
|
@ -5,6 +5,7 @@
|
||||
netcoreapp-Unix;
|
||||
netcoreapp-OSX;
|
||||
netcoreapp-Windows_NT;
|
||||
netfx-Windows_NT;
|
||||
uap-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
|
@ -34,7 +34,7 @@ namespace Internal.Cryptography
|
||||
if (value == 192 || value == 256)
|
||||
throw new PlatformNotSupportedException(SR.Cryptography_Rijndael_BlockSize);
|
||||
|
||||
// Any other invalid block size will get the normal <EFBFBD>invalid block size<EFBFBD> exception.
|
||||
// Any other invalid block size will get the normal "invalid block size" exception.
|
||||
_impl.BlockSize = value;
|
||||
}
|
||||
}
|
||||
|
@ -13,16 +13,6 @@ namespace Internal.Cryptography
|
||||
private const int BitsPerByte = 8;
|
||||
private static readonly RandomNumberGenerator s_rng = RandomNumberGenerator.Create();
|
||||
|
||||
public override KeySizes[] LegalKeySizes
|
||||
{
|
||||
get
|
||||
{
|
||||
// CNG does not support 128-bit keys.
|
||||
// Only support 192-bit keys on all platforms for simplicity.
|
||||
return new KeySizes[] { new KeySizes(minSize: 3 * 64, maxSize: 3 * 64, skipSize: 0) };
|
||||
}
|
||||
}
|
||||
|
||||
public override ICryptoTransform CreateDecryptor()
|
||||
{
|
||||
return CreateTransform(Key, IV, encrypting: false);
|
||||
@ -75,6 +65,16 @@ namespace Internal.Cryptography
|
||||
throw new ArgumentException(SR.Cryptography_InvalidIVSize, nameof(rgbIV));
|
||||
}
|
||||
|
||||
if (rgbKey.Length == 16)
|
||||
{
|
||||
// Some platforms do not support Two-Key Triple DES, so manually support it here.
|
||||
// Two-Key Triple DES contains two 8-byte keys {K1}{K2} with {K1} appended to make {K1}{K2}{K1}.
|
||||
byte[] newkey = new byte[24];
|
||||
Array.Copy(rgbKey, 0, newkey, 0, 16);
|
||||
Array.Copy(rgbKey, 0, newkey, 16, 8);
|
||||
rgbKey = newkey;
|
||||
}
|
||||
|
||||
return CreateTransformCore(Mode, Padding, rgbKey, rgbIV, BlockSize / BitsPerByte, encrypting);
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,9 @@
|
||||
<data name="Arg_CryptographyException" xml:space="preserve">
|
||||
<value>Error occurred during a cryptographic operation.</value>
|
||||
</data>
|
||||
<data name="Cryptography_BadHashSize_ForAlgorithm" xml:space="preserve">
|
||||
<value>The provided value of {0} bytes does not match the expected size of {1} bytes for the algorithm ({2}).</value>
|
||||
</data>
|
||||
<data name="Cryptography_Config_EncodedOIDError" xml:space="preserve">
|
||||
<value>Encoded OID length is too large (greater than 0x7f bytes).</value>
|
||||
</data>
|
||||
@ -235,4 +238,10 @@
|
||||
<data name="NotSupported_SubclassOverride" xml:space="preserve">
|
||||
<value>Method not supported. Derived class must override.</value>
|
||||
</data>
|
||||
<data name="Cryptography_AlgorithmTypesMustBeVisible" xml:space="preserve">
|
||||
<value>Algorithms added to CryptoConfig must be accessable from outside their assembly.</value>
|
||||
</data>
|
||||
<data name="Cryptography_AddNullOrEmptyName" xml:space="preserve">
|
||||
<value>CryptoConfig cannot add a mapping for a null or empty name.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
@ -9,6 +9,8 @@
|
||||
<DefineConstants>INTERNAL_ASYMMETRIC_IMPLEMENTATIONS</DefineConstants>
|
||||
<NoWarn>CA5351;$(NoWarn)</NoWarn>
|
||||
<DefineConstants Condition="'$(TargetGroup)' == 'uap'">$(DefineConstants);uap</DefineConstants>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
|
||||
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)' == 'netfx'">true</GenFacadesIgnoreMissingTypes>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-OSX-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-OSX-Release|AnyCPU'" />
|
||||
@ -16,9 +18,11 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
|
||||
<Compile Include="Internal\Cryptography\AesImplementation.cs" />
|
||||
<Compile Include="Internal\Cryptography\DesImplementation.cs" />
|
||||
<Compile Include="Internal\Cryptography\Helpers.cs" />
|
||||
@ -103,7 +107,7 @@
|
||||
<Link>Internal\Cryptography\UniversalCryptoDecryptor.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetsWindows)' == 'true'">
|
||||
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' AND '$(TargetGroup)' != 'netfx'">
|
||||
<Compile Include="System\Security\Cryptography\CngKeyLite.cs" />
|
||||
<Compile Include="System\Security\Cryptography\DSACng.cs" />
|
||||
<Compile Include="System\Security\Cryptography\ECDsaCng.cs" />
|
||||
@ -460,8 +464,11 @@
|
||||
<Compile Include="Internal\Cryptography\TripleDesImplementation.OSX.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetsUnix)' == 'true'">
|
||||
<Compile Include="$(CommonPath)\Internal\Cryptography\AsymmetricAlgorithmHelpers.cs">
|
||||
<Link>Common\Internal\Cryptography\AsymmetricAlgorithmHelpers.cs</Link>
|
||||
<Compile Include="$(CommonPath)\Internal\Cryptography\AsymmetricAlgorithmHelpers.Der.cs">
|
||||
<Link>Common\Internal\Cryptography\AsymmetricAlgorithmHelpers.Der.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Internal\Cryptography\AsymmetricAlgorithmHelpers.Hash.cs">
|
||||
<Link>Common\Internal\Cryptography\AsymmetricAlgorithmHelpers.Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\Security\Cryptography\DerEncoder.cs">
|
||||
<Link>Common\System\Security\Cryptography\DerEncoder.cs</Link>
|
||||
@ -470,7 +477,7 @@
|
||||
<Link>Common\System\Security\Cryptography\DerSequenceReader.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
|
||||
<Reference Include="System.Collections" />
|
||||
<Reference Include="System.Diagnostics.Contracts" />
|
||||
<Reference Include="System.Diagnostics.Debug" />
|
||||
@ -482,10 +489,16 @@
|
||||
<Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
|
||||
<Reference Include="System.Security.Cryptography.Encoding" />
|
||||
<Reference Include="System.Security.Cryptography.Primitives" />
|
||||
<Reference Include="System.Threading" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
|
||||
<Reference Include="System.Runtime.Numerics" />
|
||||
<Reference Include="System.Threading" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Compile Include="System\Security\Cryptography\IncrementalHash.net46.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
|
@ -31,12 +31,17 @@ namespace System.Security.Cryptography
|
||||
|
||||
private static volatile Dictionary<string, string> s_defaultOidHT = null;
|
||||
private static volatile Dictionary<string, object> s_defaultNameHT = null;
|
||||
private static volatile Dictionary<string, Type> appNameHT = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
|
||||
private static volatile Dictionary<string, string> appOidHT = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static readonly char[] SepArray = { '.' }; // valid ASN.1 separators
|
||||
|
||||
// CoreFx does not support AllowOnlyFipsAlgorithms
|
||||
public static bool AllowOnlyFipsAlgorithms => false;
|
||||
|
||||
// Private object for locking instead of locking on a public type for SQL reliability work.
|
||||
private static Object s_InternalSyncObject = new Object();
|
||||
|
||||
private static Dictionary<string, string> DefaultOidHT
|
||||
{
|
||||
get
|
||||
@ -282,7 +287,34 @@ namespace System.Security.Cryptography
|
||||
|
||||
public static void AddAlgorithm(Type algorithm, params string[] names)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
if (algorithm == null)
|
||||
throw new ArgumentNullException(nameof(algorithm));
|
||||
if (!algorithm.IsVisible)
|
||||
throw new ArgumentException(SR.Cryptography_AlgorithmTypesMustBeVisible, nameof(algorithm));
|
||||
if (names == null)
|
||||
throw new ArgumentNullException(nameof(names));
|
||||
|
||||
string[] algorithmNames = new string[names.Length];
|
||||
Array.Copy(names, algorithmNames, algorithmNames.Length);
|
||||
|
||||
// Pre-check the algorithm names for validity so that we don't add a few of the names and then
|
||||
// throw an exception if we find an invalid name partway through the list.
|
||||
foreach (string name in algorithmNames)
|
||||
{
|
||||
if (String.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentException(SR.Cryptography_AddNullOrEmptyName);
|
||||
}
|
||||
}
|
||||
|
||||
// Everything looks valid, so we're safe to take the table lock and add the name mappings.
|
||||
lock (s_InternalSyncObject)
|
||||
{
|
||||
foreach (string name in algorithmNames)
|
||||
{
|
||||
appNameHT[name] = algorithm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static object CreateFromName(string name, params object[] args)
|
||||
@ -291,12 +323,21 @@ namespace System.Security.Cryptography
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
|
||||
Type retvalType = null;
|
||||
|
||||
// Check to see if we have an application defined mapping
|
||||
lock (s_InternalSyncObject)
|
||||
{
|
||||
if (!appNameHT.TryGetValue(name, out retvalType))
|
||||
{
|
||||
retvalType = null;
|
||||
}
|
||||
}
|
||||
|
||||
// We allow the default table to Types and Strings
|
||||
// Types get used for types in .Algorithms assembly.
|
||||
// strings get used for delay-loaded stuff in other assemblies such as .Csp.
|
||||
object retvalObj;
|
||||
if (DefaultNameHT.TryGetValue(name, out retvalObj))
|
||||
if (retvalType == null && DefaultNameHT.TryGetValue(name, out retvalObj))
|
||||
{
|
||||
if (retvalObj is Type)
|
||||
{
|
||||
@ -397,7 +438,32 @@ namespace System.Security.Cryptography
|
||||
|
||||
public static void AddOID(string oid, params string[] names)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
if (oid == null)
|
||||
throw new ArgumentNullException(nameof(oid));
|
||||
if (names == null)
|
||||
throw new ArgumentNullException(nameof(names));
|
||||
|
||||
string[] oidNames = new string[names.Length];
|
||||
Array.Copy(names, oidNames, oidNames.Length);
|
||||
|
||||
// Pre-check the input names for validity, so that we don't add a few of the names and throw an
|
||||
// exception if an invalid name is found further down the array.
|
||||
foreach (string name in oidNames)
|
||||
{
|
||||
if (String.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentException(SR.Cryptography_AddNullOrEmptyName);
|
||||
}
|
||||
}
|
||||
|
||||
// Everything is valid, so we're good to lock the hash table and add the application mappings
|
||||
lock (s_InternalSyncObject)
|
||||
{
|
||||
foreach (string name in oidNames)
|
||||
{
|
||||
appOidHT[name] = oid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string MapNameToOID(string name)
|
||||
@ -406,7 +472,17 @@ namespace System.Security.Cryptography
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
|
||||
string oidName;
|
||||
if (!DefaultOidHT.TryGetValue(name, out oidName))
|
||||
|
||||
// Check to see if we have an application defined mapping
|
||||
lock (s_InternalSyncObject)
|
||||
{
|
||||
if (!appOidHT.TryGetValue(name, out oidName))
|
||||
{
|
||||
oidName = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(oidName) && !DefaultOidHT.TryGetValue(name, out oidName))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -19,6 +19,38 @@ namespace System.Security.Cryptography
|
||||
return (DSA)CryptoConfig.CreateFromName(algName);
|
||||
}
|
||||
|
||||
public static DSA Create(int keySizeInBits)
|
||||
{
|
||||
DSA dsa = Create();
|
||||
|
||||
try
|
||||
{
|
||||
dsa.KeySize = keySizeInBits;
|
||||
return dsa;
|
||||
}
|
||||
catch
|
||||
{
|
||||
dsa.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static DSA Create(DSAParameters parameters)
|
||||
{
|
||||
DSA dsa = Create();
|
||||
|
||||
try
|
||||
{
|
||||
dsa.ImportParameters(parameters);
|
||||
return dsa;
|
||||
}
|
||||
catch
|
||||
{
|
||||
dsa.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// DSA does not encode the algorithm identifier into the signature blob, therefore CreateSignature and
|
||||
// VerifySignature do not need the HashAlgorithmName value, only SignData and VerifyData do.
|
||||
abstract public byte[] CreateSignature(byte[] rgbHash);
|
||||
|
@ -13,6 +13,7 @@ namespace System.Security.Cryptography
|
||||
/// The CurveType property determines whether the curve is a named curve or an explicit curve
|
||||
/// which is either a prime curve or a characteristic-2 curve.
|
||||
/// </remarks>
|
||||
[DebuggerDisplay("ECCurve: {Oid}")]
|
||||
public partial struct ECCurve
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -82,6 +82,9 @@ namespace System.Security.Cryptography
|
||||
|
||||
if (curve.IsNamed)
|
||||
{
|
||||
if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
|
||||
throw new PlatformNotSupportedException(string.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
|
||||
|
||||
// Map curve name to algorithm to support pre-Win10 curves
|
||||
algorithm = ECCng.EcdsaCurveNameToAlgorithm(curve.Oid.FriendlyName);
|
||||
if (IsECNamedCurve(algorithm))
|
||||
|
@ -19,7 +19,6 @@ namespace System.Security.Cryptography
|
||||
return new ECDsaImplementation.ECDsaCng();
|
||||
}
|
||||
|
||||
#if !uap
|
||||
/// <summary>
|
||||
/// Creates an instance of the platform specific implementation of the cref="ECDsa" algorithm.
|
||||
/// </summary>
|
||||
@ -30,7 +29,6 @@ namespace System.Security.Cryptography
|
||||
{
|
||||
return new ECDsaImplementation.ECDsaCng(curve);
|
||||
}
|
||||
#endif // uap
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of the platform specific implementation of the cref="ECDsa" algorithm.
|
||||
|
@ -40,11 +40,9 @@ namespace System.Security.Cryptography
|
||||
}
|
||||
set
|
||||
{
|
||||
// We don't have a managed implementation of HMAC
|
||||
// so we can't support this
|
||||
if (value)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(); // This relates to a quirk in the Desktop managed implementation; ours is native.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,29 +8,23 @@ namespace System.Security.Cryptography
|
||||
{
|
||||
public class PKCS1MaskGenerationMethod : MaskGenerationMethod
|
||||
{
|
||||
private readonly string _hashNameValue;
|
||||
|
||||
private string _hashNameValue;
|
||||
private const string DefaultHash = "SHA1";
|
||||
public PKCS1MaskGenerationMethod()
|
||||
{
|
||||
_hashNameValue = "SHA1";
|
||||
_hashNameValue = DefaultHash;
|
||||
}
|
||||
|
||||
public string HashName
|
||||
{
|
||||
get { return _hashNameValue; }
|
||||
set
|
||||
{
|
||||
if (value != null && value != "SHA1")
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
set { _hashNameValue = value ?? DefaultHash; }
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "CryptoConfig.CreateFromName may return platform-dependent objects, so this implementation is limited to SHA-1 for now")]
|
||||
public override byte[] GenerateMask(byte[] rgbSeed, int cbReturn)
|
||||
{
|
||||
using (HashAlgorithm hasher = SHA1.Create())
|
||||
using (HashAlgorithm hasher = (HashAlgorithm)CryptoConfig.CreateFromName(_hashNameValue))
|
||||
{
|
||||
byte[] rgbCounter = new byte[4];
|
||||
byte[] rgbT = new byte[cbReturn];
|
||||
|
@ -15,6 +15,38 @@ namespace System.Security.Cryptography
|
||||
return (RSA)CryptoConfig.CreateFromName(algName);
|
||||
}
|
||||
|
||||
public static RSA Create(int keySizeInBits)
|
||||
{
|
||||
RSA rsa = Create();
|
||||
|
||||
try
|
||||
{
|
||||
rsa.KeySize = keySizeInBits;
|
||||
return rsa;
|
||||
}
|
||||
catch
|
||||
{
|
||||
rsa.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static RSA Create(RSAParameters parameters)
|
||||
{
|
||||
RSA rsa = Create();
|
||||
|
||||
try
|
||||
{
|
||||
rsa.ImportParameters(parameters);
|
||||
return rsa;
|
||||
}
|
||||
catch
|
||||
{
|
||||
rsa.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract RSAParameters ExportParameters(bool includePrivateParameters);
|
||||
public abstract void ImportParameters(RSAParameters parameters);
|
||||
public virtual byte[] Encrypt(byte[] data, RSAEncryptionPadding padding) { throw DerivedClassMustOverride(); }
|
||||
|
@ -28,7 +28,7 @@ namespace System.Security.Cryptography
|
||||
if (value == 192 || value == 256)
|
||||
throw new PlatformNotSupportedException(SR.Cryptography_Rijndael_BlockSize);
|
||||
|
||||
// Any other invalid block size will get the normal <EFBFBD>invalid block size<EFBFBD> exception.
|
||||
// Any other invalid block size will get the normal "invalid block size" exception.
|
||||
_impl.BlockSize = value;
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user