Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@ -0,0 +1,181 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Security.Cryptography.Algorithms.Tests", "tests\System.Security.Cryptography.Algorithms.Tests.csproj", "{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}"
ProjectSection(ProjectDependencies) = postProject
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9} = {81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Security.Cryptography.Algorithms", "src\System.Security.Cryptography.Algorithms.csproj", "{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU
ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU
DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU
ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU
DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU = DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU
ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU = ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU
DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU = DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU
ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU = ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU
DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU = DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU
ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU = ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU
DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU = DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU
ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU = ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU
DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU = DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU
ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU = ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU
DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU
DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU = DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU
ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU = ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU
DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU = DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU
ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU = ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{508A7D81-6462-459C-9F8F-B58FCCCFC8E7}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = net463-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnet463-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = net463-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Unix-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Unix-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Unix-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Unixnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Unix-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-OSX-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-OSX-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-OSX-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-OSX-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-OSX-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-OSX-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-OSX-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-OSX-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-OSX-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-OSX-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-OSX-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-OSX-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-OSX-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-OSX-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-OSX-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-OSXnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-OSX-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Unix|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.DebugNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{81A05E2E-E3AE-4246-B4E6-DD5F31FB71F9}.ReleaseNETCoreAppnetcoreapp-Windows_NTnetcoreapp-Windows_NT|AnyCPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<IsNETCoreApp>true</IsNETCoreApp>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netcoreapp;
uap;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,19 @@
<?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 Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-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>
<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>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@ -0,0 +1,9 @@
TypesMustExist : Type '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.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.

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
net463-Windows_NT;
netcoreapp-Unix;
netcoreapp-OSX;
netcoreapp-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Security.Cryptography;
namespace Internal.Cryptography
{
internal partial class AesImplementation
{
private static ICryptoTransform CreateTransformCore(
CipherMode cipherMode,
PaddingMode paddingMode,
byte[] key,
byte[] iv,
int blockSize,
bool encrypting)
{
BasicSymmetricCipher cipher = new AppleCCCryptor(
Interop.AppleCrypto.PAL_SymmetricAlgorithm.AES,
cipherMode,
blockSize,
key,
iv,
encrypting);
return UniversalCryptoTransform.Create(paddingMode, cipher, encrypting);
}
// -----------------------------
// ---- PAL layer ends here ----
// -----------------------------
}
}

View File

@ -0,0 +1,72 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Security.Cryptography;
namespace Internal.Cryptography
{
internal partial class AesImplementation
{
private static ICryptoTransform CreateTransformCore(
CipherMode cipherMode,
PaddingMode paddingMode,
byte[] key,
byte[] iv,
int blockSize,
bool encrypting)
{
// The algorithm pointer is a static pointer, so not having any cleanup code is correct.
IntPtr algorithm = GetAlgorithm(key.Length * 8, cipherMode);
BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, key, 0, iv, encrypting);
return UniversalCryptoTransform.Create(paddingMode, cipher, encrypting);
}
// -----------------------------
// ---- PAL layer ends here ----
// -----------------------------
private static readonly Tuple<int, CipherMode, Func<IntPtr>>[] s_algorithmInitializers =
{
// Neither OpenSSL nor Cng Aes support CTS mode.
// Cng Aes doesn't seem to support CFB mode, and that would
// require passing in the feedback size. Since Windows doesn't support it,
// we can skip it here, too.
Tuple.Create(128, CipherMode.CBC, (Func<IntPtr>)Interop.Crypto.EvpAes128Cbc),
Tuple.Create(128, CipherMode.ECB, (Func<IntPtr>)Interop.Crypto.EvpAes128Ecb),
Tuple.Create(192, CipherMode.CBC, (Func<IntPtr>)Interop.Crypto.EvpAes192Cbc),
Tuple.Create(192, CipherMode.ECB, (Func<IntPtr>)Interop.Crypto.EvpAes192Ecb),
Tuple.Create(256, CipherMode.CBC, (Func<IntPtr>)Interop.Crypto.EvpAes256Cbc),
Tuple.Create(256, CipherMode.ECB, (Func<IntPtr>)Interop.Crypto.EvpAes256Ecb),
};
private static IntPtr GetAlgorithm(int keySize, CipherMode cipherMode)
{
bool foundKeysize = false;
foreach (var triplet in s_algorithmInitializers)
{
if (triplet.Item1 == keySize && triplet.Item2 == cipherMode)
{
return triplet.Item3();
}
if (triplet.Item1 == keySize)
{
foundKeysize = true;
}
}
if (!foundKeysize)
{
throw new CryptographicException(SR.Cryptography_InvalidKeySize);
}
throw new NotSupportedException();
}
}
}

View File

@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Security.Cryptography;
using Internal.NativeCrypto;
namespace Internal.Cryptography
{
internal partial class AesImplementation
{
private static ICryptoTransform CreateTransformCore(
CipherMode cipherMode,
PaddingMode paddingMode,
byte[] key,
byte[] iv,
int blockSize,
bool encrypting)
{
SafeAlgorithmHandle algorithm = AesBCryptModes.GetSharedHandle(cipherMode);
BasicSymmetricCipher cipher = new BasicSymmetricCipherBCrypt(algorithm, cipherMode, blockSize, key, false, iv, encrypting);
return UniversalCryptoTransform.Create(paddingMode, cipher, encrypting);
}
// -----------------------------
// ---- PAL layer ends here ----
// -----------------------------
}
}

View File

@ -0,0 +1,75 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Security.Cryptography;
namespace Internal.Cryptography
{
internal sealed partial class AesImplementation : Aes
{
public sealed override ICryptoTransform CreateDecryptor()
{
return CreateTransform(Key, IV, encrypting: false);
}
public sealed override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
{
return CreateTransform(rgbKey, rgbIV.CloneByteArray(), encrypting: false);
}
public sealed override ICryptoTransform CreateEncryptor()
{
return CreateTransform(Key, IV, encrypting: true);
}
public sealed override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
{
return CreateTransform(rgbKey, rgbIV.CloneByteArray(), encrypting: true);
}
public sealed override void GenerateIV()
{
byte[] iv = new byte[BlockSize / BitsPerByte];
s_rng.GetBytes(iv);
IV = iv;
}
public sealed override void GenerateKey()
{
byte[] key = new byte[KeySize / BitsPerByte];
s_rng.GetBytes(key);
Key = key;
}
protected sealed override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
private ICryptoTransform CreateTransform(byte[] rgbKey, byte[] rgbIV, bool encrypting)
{
// note: rbgIV is guaranteed to be cloned before this method, so no need to clone it again
if (rgbKey == null)
throw new ArgumentNullException(nameof(rgbKey));
long keySize = rgbKey.Length * (long)BitsPerByte;
if (keySize > int.MaxValue || !((int)keySize).IsLegalSize(this.LegalKeySizes))
throw new ArgumentException(SR.Cryptography_InvalidKeySize, nameof(rgbKey));
if (rgbIV != null)
{
long ivSize = rgbIV.Length * (long)BitsPerByte;
if (ivSize != BlockSize)
throw new ArgumentException(SR.Cryptography_InvalidIVSize, nameof(rgbIV));
}
return CreateTransformCore(Mode, Padding, rgbKey, rgbIV, BlockSize / BitsPerByte, encrypting);
}
private const int BitsPerByte = 8;
private static readonly RandomNumberGenerator s_rng = RandomNumberGenerator.Create();
}
}

View File

@ -0,0 +1,225 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Security.Cryptography;
namespace Internal.Cryptography
{
internal sealed class AppleCCCryptor : BasicSymmetricCipher
{
private readonly bool _encrypting;
private SafeAppleCryptorHandle _cryptor;
public AppleCCCryptor(
Interop.AppleCrypto.PAL_SymmetricAlgorithm algorithm,
CipherMode cipherMode,
int blockSizeInBytes,
byte[] key,
byte[] iv,
bool encrypting)
: base(cipherMode.GetCipherIv(iv), blockSizeInBytes)
{
_encrypting = encrypting;
OpenCryptor(algorithm, cipherMode, key);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
_cryptor?.Dispose();
_cryptor = null;
}
base.Dispose(disposing);
}
public override int Transform(byte[] input, int inputOffset, int count, byte[] output, int outputOffset)
{
Debug.Assert(input != null, "Expected valid input, got null");
Debug.Assert(inputOffset >= 0, $"Expected non-negative inputOffset, got {inputOffset}");
Debug.Assert(count > 0, $"Expected positive count, got {count}");
Debug.Assert((count % BlockSizeInBytes) == 0, $"Expected count aligned to block size {BlockSizeInBytes}, got {count}");
Debug.Assert(input.Length - inputOffset >= count, $"Expected valid input length/offset/count triplet, got {input.Length}/{inputOffset}/{count}");
Debug.Assert(output != null, "Expected valid output, got null");
Debug.Assert(outputOffset >= 0, $"Expected non-negative outputOffset, got {outputOffset}");
Debug.Assert(output.Length - outputOffset >= count, $"Expected valid output length/offset/count triplet, got {output.Length}/{outputOffset}/{count}");
return CipherUpdate(input, inputOffset, count, output, outputOffset);
}
public override byte[] TransformFinal(byte[] input, int inputOffset, int count)
{
Debug.Assert(input != null, "Expected valid input, got null");
Debug.Assert(inputOffset >= 0, $"Expected non-negative inputOffset, got {inputOffset}");
Debug.Assert(count > 0, $"Expected positive count, got {count}");
Debug.Assert((count % BlockSizeInBytes) == 0, $"Expected count aligned to block size {BlockSizeInBytes}, got {count}");
Debug.Assert(input.Length - inputOffset >= count, $"Expected valid input length/offset/count triplet, got {input.Length}/{inputOffset}/{count}");
byte[] output = ProcessFinalBlock(input, inputOffset, count);
Reset();
return output;
}
private unsafe byte[] ProcessFinalBlock(byte[] input, int inputOffset, int count)
{
if (count == 0)
{
return Array.Empty<byte>();
}
byte[] output = new byte[count];
int outputBytes = CipherUpdate(input, inputOffset, count, output, 0);
int ret;
int errorCode;
fixed (byte* outputStart = output)
{
byte* outputCurrent = outputStart + outputBytes;
int bytesWritten;
ret = Interop.AppleCrypto.CryptorFinal(
_cryptor,
outputCurrent,
output.Length - outputBytes,
out bytesWritten,
out errorCode);
outputBytes += bytesWritten;
}
ProcessInteropError(ret, errorCode);
if (outputBytes == output.Length)
{
return output;
}
if (outputBytes == 0)
{
return Array.Empty<byte>();
}
byte[] userData = new byte[outputBytes];
Buffer.BlockCopy(output, 0, userData, 0, outputBytes);
return userData;
}
private unsafe int CipherUpdate(byte[] input, int inputOffset, int count, byte[] output, int outputOffset)
{
int ret;
int ccStatus;
int bytesWritten;
if (count == 0)
{
return 0;
}
fixed (byte* inputStart = input)
fixed (byte* outputStart = output)
{
byte* inputCurrent = inputStart + inputOffset;
byte* outputCurrent = outputStart + outputOffset;
ret = Interop.AppleCrypto.CryptorUpdate(
_cryptor,
inputCurrent,
count,
outputCurrent,
output.Length - outputOffset,
out bytesWritten,
out ccStatus);
}
ProcessInteropError(ret, ccStatus);
return bytesWritten;
}
private unsafe void OpenCryptor(
Interop.AppleCrypto.PAL_SymmetricAlgorithm algorithm,
CipherMode cipherMode,
byte[] key)
{
int ret;
int ccStatus;
byte[] iv = IV;
fixed (byte* pbKey = key)
fixed (byte* pbIv = iv)
{
ret = Interop.AppleCrypto.CryptorCreate(
_encrypting
? Interop.AppleCrypto.PAL_SymmetricOperation.Encrypt
: Interop.AppleCrypto.PAL_SymmetricOperation.Decrypt,
algorithm,
GetPalChainMode(cipherMode),
Interop.AppleCrypto.PAL_PaddingMode.None,
pbKey,
key.Length,
pbIv,
Interop.AppleCrypto.PAL_SymmetricOptions.None,
out _cryptor,
out ccStatus);
}
ProcessInteropError(ret, ccStatus);
}
private Interop.AppleCrypto.PAL_ChainingMode GetPalChainMode(CipherMode cipherMode)
{
switch (cipherMode)
{
case CipherMode.CBC:
return Interop.AppleCrypto.PAL_ChainingMode.CBC;
case CipherMode.ECB:
return Interop.AppleCrypto.PAL_ChainingMode.ECB;
default:
throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CipherModeNotSupported, cipherMode));
}
}
private unsafe void Reset()
{
int ret;
int ccStatus;
byte[] iv = IV;
fixed (byte* pbIv = iv)
{
ret = Interop.AppleCrypto.CryptorReset(_cryptor, pbIv, out ccStatus);
}
ProcessInteropError(ret, ccStatus);
}
private static void ProcessInteropError(int functionReturnCode, int ccStatus)
{
// Success
if (functionReturnCode == 1)
{
return;
}
// Platform error
if (functionReturnCode == 0)
{
Debug.Assert(ccStatus != 0, "Interop function returned 0 but a system code of success");
throw Interop.AppleCrypto.CreateExceptionForCCError(
ccStatus,
Interop.AppleCrypto.CCCryptorStatus);
}
// Usually this will be -1, a general indication of bad inputs.
Debug.Fail($"Interop boundary returned unexpected value {functionReturnCode}");
throw new CryptographicException();
}
}
}

View File

@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Security.Cryptography;
namespace Internal.Cryptography
{
partial class DesImplementation
{
private static ICryptoTransform CreateTransformCore(
CipherMode cipherMode,
PaddingMode paddingMode,
byte[] key,
byte[] iv,
int blockSize,
bool encrypting)
{
BasicSymmetricCipher cipher = new AppleCCCryptor(
Interop.AppleCrypto.PAL_SymmetricAlgorithm.DES,
cipherMode,
blockSize,
key,
iv,
encrypting);
return UniversalCryptoTransform.Create(paddingMode, cipher, encrypting);
}
}
}

View File

@ -0,0 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Security.Cryptography;
namespace Internal.Cryptography
{
partial class DesImplementation
{
private static ICryptoTransform CreateTransformCore(
CipherMode cipherMode,
PaddingMode paddingMode,
byte[] key,
byte[] iv,
int blockSize,
bool encrypting)
{
// The algorithm pointer is a static pointer, so not having any cleanup code is correct.
IntPtr algorithm;
switch (cipherMode)
{
case CipherMode.CBC:
algorithm = Interop.Crypto.EvpDesCbc();
break;
case CipherMode.ECB:
algorithm = Interop.Crypto.EvpDesEcb();
break;
default:
throw new NotSupportedException();
}
BasicSymmetricCipher cipher = new OpenSslCipher(algorithm, cipherMode, blockSize, key, 0, iv, encrypting);
return UniversalCryptoTransform.Create(paddingMode, cipher, encrypting);
}
}
}

View File

@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Security.Cryptography;
using Internal.NativeCrypto;
namespace Internal.Cryptography
{
partial class DesImplementation
{
private static ICryptoTransform CreateTransformCore(
CipherMode cipherMode,
PaddingMode paddingMode,
byte[] key,
byte[] iv,
int blockSize,
bool encrypting)
{
SafeAlgorithmHandle algorithm = DesBCryptModes.GetSharedHandle(cipherMode);
BasicSymmetricCipher cipher = new BasicSymmetricCipherBCrypt(algorithm, cipherMode, blockSize, key, false, iv, encrypting);
return UniversalCryptoTransform.Create(paddingMode, cipher, encrypting);
}
}
}

View File

@ -0,0 +1,81 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Security.Cryptography;
namespace Internal.Cryptography
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350")]
internal sealed partial class DesImplementation : DES
{
private const int BitsPerByte = 8;
private static readonly RandomNumberGenerator s_rng = RandomNumberGenerator.Create();
public override ICryptoTransform CreateDecryptor()
{
return CreateTransform(Key, IV, encrypting: false);
}
public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
{
return CreateTransform(rgbKey, rgbIV.CloneByteArray(), encrypting: false);
}
public override ICryptoTransform CreateEncryptor()
{
return CreateTransform(Key, IV, encrypting: true);
}
public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
{
return CreateTransform(rgbKey, rgbIV.CloneByteArray(), encrypting: true);
}
public override void GenerateIV()
{
byte[] iv = new byte[BlockSize / BitsPerByte];
s_rng.GetBytes(iv);
IV = iv;
}
public sealed override void GenerateKey()
{
byte[] key = new byte[KeySize / BitsPerByte];
s_rng.GetBytes(key);
// Never hand back a weak or semi-weak key
while (IsWeakKey(key) || IsSemiWeakKey(key))
{
s_rng.GetBytes(key);
}
KeyValue = key;
}
private ICryptoTransform CreateTransform(byte[] rgbKey, byte[] rgbIV, bool encrypting)
{
// note: rgbIV is guaranteed to be cloned before this method, so no need to clone it again
if (rgbKey == null)
throw new ArgumentNullException(nameof(rgbKey));
long keySize = rgbKey.Length * (long)BitsPerByte;
if (keySize > int.MaxValue || !((int)keySize).IsLegalSize(LegalKeySizes))
throw new ArgumentException(SR.Cryptography_InvalidKeySize, nameof(rgbKey));
if (IsWeakKey(rgbKey))
throw new CryptographicException(SR.Cryptography_InvalidKey_Weak, "DES");
if (IsSemiWeakKey(rgbKey))
throw new CryptographicException(SR.Cryptography_InvalidKey_SemiWeak, "DES");
if (rgbIV != null)
{
long ivSize = rgbIV.Length * (long)BitsPerByte;
if (ivSize != BlockSize)
throw new ArgumentException(SR.Cryptography_InvalidIVSize, nameof(rgbIV));
}
return CreateTransformCore(Mode, Padding, rgbKey, rgbIV, BlockSize / BitsPerByte, encrypting);
}
}
}

View File

@ -0,0 +1,95 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using Internal.Cryptography;
namespace Internal.Cryptography
{
//
// This class provides the common functionality for HMACSHA1, HMACSHA256, HMACMD5, etc.
// Ideally, this would be encapsulated in a common base class but the preexisting contract
// locks these public classes into deriving directly from HMAC so we have to use encapsulation
// and delegation to HMACCommon instead.
//
// This wrapper adds the ability to change the Key on the fly for compat with the desktop.
//
internal sealed class HMACCommon
{
public HMACCommon(string hashAlgorithmId, byte[] key, int blockSize)
{
Debug.Assert(!string.IsNullOrEmpty(hashAlgorithmId));
Debug.Assert(blockSize > 0 || blockSize == -1);
_hashAlgorithmId = hashAlgorithmId;
_blockSize = blockSize;
ChangeKey(key);
}
public int HashSizeInBits
{
get
{
return _hMacProvider.HashSizeInBytes * 8;
}
}
public void ChangeKey(byte[] key)
{
// If _blockSize is -1 the key isn't going to be extractable by the object holder,
// so there's no point in recalculating it in managed code.
if (key.Length > _blockSize && _blockSize > 0)
{
// Perform RFC 2104, section 2 key adjustment.
if (_lazyHashProvider == null)
_lazyHashProvider = HashProviderDispenser.CreateHashProvider(_hashAlgorithmId);
_lazyHashProvider.AppendHashData(key, 0, key.Length);
key = _lazyHashProvider.FinalizeHashAndReset();
}
HashProvider oldHashProvider = _hMacProvider;
_hMacProvider = null;
if (oldHashProvider != null)
oldHashProvider.Dispose(true);
_hMacProvider = HashProviderDispenser.CreateMacProvider(_hashAlgorithmId, key);
ActualKey = key;
}
// The actual key used for hashing. This will not be the same as the original key passed to ChangeKey() if the original key exceeded the
// hash algorithm's block size. (See RFC 2104, section 2)
public byte[] ActualKey { get; private set; }
// Adds new data to be hashed. This can be called repeatedly in order to hash data from noncontiguous sources.
public void AppendHashData(byte[] data, int offset, int count)
{
_hMacProvider.AppendHashData(data, offset, count);
}
// Compute the hash based on the appended data and resets the HashProvider for more hashing.
public byte[] FinalizeHashAndReset()
{
return _hMacProvider.FinalizeHashAndReset();
}
public void Dispose(bool disposing)
{
if (disposing)
{
if (_hMacProvider != null)
_hMacProvider.Dispose(true);
_hMacProvider = null;
}
}
private readonly String _hashAlgorithmId;
private HashProvider _hMacProvider;
private volatile HashProvider _lazyHashProvider;
private readonly int _blockSize;
}
}

View File

@ -0,0 +1,68 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
namespace Internal.Cryptography
{
internal static class HashAlgorithmNames
{
// These are accepted by CNG
public const string MD5 = "MD5";
public const string SHA1 = "SHA1";
public const string SHA256 = "SHA256";
public const string SHA384 = "SHA384";
public const string SHA512 = "SHA512";
private static readonly HashSet<string> s_allNames = CreateAllNames();
/// <summary>
/// Map HashAlgorithm type to string; desktop uses CryptoConfig functionality.
/// </summary>
public static string ToAlgorithmName(this HashAlgorithm hashAlgorithm)
{
if (hashAlgorithm is SHA1)
return HashAlgorithmNames.SHA1;
if (hashAlgorithm is SHA256)
return HashAlgorithmNames.SHA256;
if (hashAlgorithm is SHA384)
return HashAlgorithmNames.SHA384;
if (hashAlgorithm is SHA512)
return HashAlgorithmNames.SHA512;
if (hashAlgorithm is MD5)
return HashAlgorithmNames.MD5;
// Fallback to ToString() which can be extended by derived classes
return hashAlgorithm.ToString();
}
/// <summary>
/// Uppercase known hash algorithms. BCrypt is case-sensitive and requires uppercase.
/// </summary>
public static string ToUpper(string hashAlgorithName)
{
if (s_allNames.Contains(hashAlgorithName))
{
return hashAlgorithName.ToUpperInvariant();
}
return hashAlgorithName;
}
private static HashSet<string> CreateAllNames()
{
var allNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
allNames.Add(HashAlgorithmNames.SHA1);
allNames.Add(HashAlgorithmNames.SHA256);
allNames.Add(HashAlgorithmNames.SHA384);
allNames.Add(HashAlgorithmNames.SHA512);
allNames.Add(HashAlgorithmNames.MD5);
return allNames;
}
}
}

View File

@ -0,0 +1,247 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Security.Cryptography.Apple;
namespace Internal.Cryptography
{
internal static partial class HashProviderDispenser
{
public static HashProvider CreateHashProvider(string hashAlgorithmId)
{
switch (hashAlgorithmId)
{
case HashAlgorithmNames.MD5:
return new AppleDigestProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Md5);
case HashAlgorithmNames.SHA1:
return new AppleDigestProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Sha1);
case HashAlgorithmNames.SHA256:
return new AppleDigestProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Sha256);
case HashAlgorithmNames.SHA384:
return new AppleDigestProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Sha384);
case HashAlgorithmNames.SHA512:
return new AppleDigestProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Sha512);
}
throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_UnknownHashAlgorithm, hashAlgorithmId));
}
public static HashProvider CreateMacProvider(string hashAlgorithmId, byte[] key)
{
switch (hashAlgorithmId)
{
case HashAlgorithmNames.MD5:
return new AppleHmacProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Md5, key);
case HashAlgorithmNames.SHA1:
return new AppleHmacProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Sha1, key);
case HashAlgorithmNames.SHA256:
return new AppleHmacProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Sha256, key);
case HashAlgorithmNames.SHA384:
return new AppleHmacProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Sha384, key);
case HashAlgorithmNames.SHA512:
return new AppleHmacProvider(Interop.AppleCrypto.PAL_HashAlgorithm.Sha512, key);
}
throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_UnknownHashAlgorithm, hashAlgorithmId));
}
// -----------------------------
// ---- PAL layer ends here ----
// -----------------------------
private sealed class AppleHmacProvider : HashProvider
{
private readonly byte[] _key;
private readonly SafeHmacHandle _ctx;
private bool _running;
public override int HashSizeInBytes { get; }
internal AppleHmacProvider(Interop.AppleCrypto.PAL_HashAlgorithm algorithm, byte[] key)
{
_key = key.CloneByteArray();
int hashSizeInBytes = 0;
_ctx = Interop.AppleCrypto.HmacCreate(algorithm, ref hashSizeInBytes);
if (hashSizeInBytes < 0)
{
_ctx.Dispose();
throw new PlatformNotSupportedException(
SR.Format(
SR.Cryptography_UnknownHashAlgorithm,
Enum.GetName(typeof(Interop.AppleCrypto.PAL_HashAlgorithm), algorithm)));
}
if (_ctx.IsInvalid)
{
_ctx.Dispose();
throw new CryptographicException();
}
HashSizeInBytes = hashSizeInBytes;
}
public override unsafe void AppendHashDataCore(byte[] data, int offset, int count)
{
Debug.Assert(data != null);
Debug.Assert(offset >= 0);
Debug.Assert(offset < data.Length);
Debug.Assert(count >= 0);
Debug.Assert(data.Length - offset > count);
if (!_running)
{
SetKey();
}
int ret;
fixed (byte* pData = data)
{
byte* pbData = pData + offset;
ret = Interop.AppleCrypto.HmacUpdate(_ctx, pbData, count);
}
if (ret != 1)
{
throw new CryptographicException();
}
}
private unsafe void SetKey()
{
int ret;
fixed (byte* pbKey = _key)
{
ret = Interop.AppleCrypto.HmacInit(_ctx, pbKey, _key.Length);
}
if (ret != 1)
{
throw new CryptographicException();
}
_running = true;
}
public override unsafe byte[] FinalizeHashAndReset()
{
if (!_running)
{
SetKey();
}
byte[] output = new byte[HashSizeInBytes];
int ret;
fixed (byte* pbOutput = output)
{
ret = Interop.AppleCrypto.HmacFinal(_ctx, pbOutput, output.Length);
}
if (ret != 1)
{
throw new CryptographicException();
}
_running = false;
return output;
}
public override void Dispose(bool disposing)
{
if (disposing)
{
_ctx?.Dispose();
Array.Clear(_key, 0, _key.Length);
}
}
}
private sealed class AppleDigestProvider : HashProvider
{
private readonly SafeDigestCtxHandle _ctx;
public override int HashSizeInBytes { get; }
internal AppleDigestProvider(Interop.AppleCrypto.PAL_HashAlgorithm algorithm)
{
int hashSizeInBytes;
_ctx = Interop.AppleCrypto.DigestCreate(algorithm, out hashSizeInBytes);
if (hashSizeInBytes < 0)
{
_ctx.Dispose();
throw new PlatformNotSupportedException(
SR.Format(
SR.Cryptography_UnknownHashAlgorithm,
Enum.GetName(typeof(Interop.AppleCrypto.PAL_HashAlgorithm), algorithm)));
}
if (_ctx.IsInvalid)
{
_ctx.Dispose();
throw new CryptographicException();
}
HashSizeInBytes = hashSizeInBytes;
}
public override unsafe void AppendHashDataCore(byte[] data, int offset, int count)
{
Debug.Assert(data != null);
Debug.Assert(offset >= 0);
Debug.Assert(offset < data.Length);
Debug.Assert(count >= 0);
Debug.Assert(data.Length - offset > count);
int ret;
fixed (byte* pData = data)
{
byte* pbData = pData + offset;
ret = Interop.AppleCrypto.DigestUpdate(_ctx, pbData, count);
}
if (ret != 1)
{
Debug.Assert(ret == 0, $"DigestUpdate return value {ret} was not 0 or 1");
throw new CryptographicException();
}
}
public override unsafe byte[] FinalizeHashAndReset()
{
byte[] hash = new byte[HashSizeInBytes];
int ret;
fixed (byte* pHash = hash)
{
ret = Interop.AppleCrypto.DigestFinal(_ctx, pHash, hash.Length);
}
if (ret != 1)
{
Debug.Assert(ret == 0, $"DigestFinal return value {ret} was not 0 or 1");
throw new CryptographicException();
}
return hash;
}
public override void Dispose(bool disposing)
{
if (disposing)
{
_ctx?.Dispose();
}
}
}
}
}

View File

@ -0,0 +1,187 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using Microsoft.Win32.SafeHandles;
namespace Internal.Cryptography
{
internal static partial class HashProviderDispenser
{
public static HashProvider CreateHashProvider(string hashAlgorithmId)
{
switch (hashAlgorithmId)
{
case HashAlgorithmNames.SHA1:
return new EvpHashProvider(Interop.Crypto.EvpSha1());
case HashAlgorithmNames.SHA256:
return new EvpHashProvider(Interop.Crypto.EvpSha256());
case HashAlgorithmNames.SHA384:
return new EvpHashProvider(Interop.Crypto.EvpSha384());
case HashAlgorithmNames.SHA512:
return new EvpHashProvider(Interop.Crypto.EvpSha512());
case HashAlgorithmNames.MD5:
return new EvpHashProvider(Interop.Crypto.EvpMd5());
}
throw new CryptographicException();
}
public static unsafe HashProvider CreateMacProvider(string hashAlgorithmId, byte[] key)
{
switch (hashAlgorithmId)
{
case HashAlgorithmNames.SHA1:
return new HmacHashProvider(Interop.Crypto.EvpSha1(), key);
case HashAlgorithmNames.SHA256:
return new HmacHashProvider(Interop.Crypto.EvpSha256(), key);
case HashAlgorithmNames.SHA384:
return new HmacHashProvider(Interop.Crypto.EvpSha384(), key);
case HashAlgorithmNames.SHA512:
return new HmacHashProvider(Interop.Crypto.EvpSha512(), key);
case HashAlgorithmNames.MD5:
return new HmacHashProvider(Interop.Crypto.EvpMd5(), key);
}
throw new CryptographicException();
}
// -----------------------------
// ---- PAL layer ends here ----
// -----------------------------
private sealed class EvpHashProvider : HashProvider
{
private readonly IntPtr _algorithmEvp;
private readonly int _hashSize;
private readonly SafeEvpMdCtxHandle _ctx;
public EvpHashProvider(IntPtr algorithmEvp)
{
_algorithmEvp = algorithmEvp;
Debug.Assert(algorithmEvp != IntPtr.Zero);
_hashSize = Interop.Crypto.EvpMdSize(_algorithmEvp);
if (_hashSize <= 0 || _hashSize > Interop.Crypto.EVP_MAX_MD_SIZE)
{
throw new CryptographicException();
}
_ctx = Interop.Crypto.EvpMdCtxCreate(_algorithmEvp);
Interop.Crypto.CheckValidOpenSslHandle(_ctx);
}
public sealed override unsafe void AppendHashDataCore(byte[] data, int offset, int count)
{
fixed (byte* md = data)
{
Check(Interop.Crypto.EvpDigestUpdate(_ctx, md + offset, count));
}
}
public sealed override unsafe byte[] FinalizeHashAndReset()
{
byte* md = stackalloc byte[Interop.Crypto.EVP_MAX_MD_SIZE];
uint length = (uint)Interop.Crypto.EVP_MAX_MD_SIZE;
Check(Interop.Crypto.EvpDigestFinalEx(_ctx, md, ref length));
Debug.Assert(length == _hashSize);
// Reset the algorithm provider.
Check(Interop.Crypto.EvpDigestReset(_ctx, _algorithmEvp));
byte[] result = new byte[(int)length];
Marshal.Copy((IntPtr)md, result, 0, (int)length);
return result;
}
public sealed override int HashSizeInBytes
{
get { return _hashSize; }
}
public sealed override void Dispose(bool disposing)
{
if (disposing)
{
_ctx.Dispose();
}
}
}
private sealed class HmacHashProvider : HashProvider
{
private readonly int _hashSize;
private SafeHmacCtxHandle _hmacCtx;
public unsafe HmacHashProvider(IntPtr algorithmEvp, byte[] key)
{
Debug.Assert(algorithmEvp != IntPtr.Zero);
Debug.Assert(key != null);
_hashSize = Interop.Crypto.EvpMdSize(algorithmEvp);
if (_hashSize <= 0 || _hashSize > Interop.Crypto.EVP_MAX_MD_SIZE)
{
throw new CryptographicException();
}
fixed (byte* keyPtr = key)
{
_hmacCtx = Interop.Crypto.HmacCreate(keyPtr, key.Length, algorithmEvp);
Interop.Crypto.CheckValidOpenSslHandle(_hmacCtx);
}
}
public sealed override unsafe void AppendHashDataCore(byte[] data, int offset, int count)
{
fixed (byte* md = data)
{
Check(Interop.Crypto.HmacUpdate(_hmacCtx, md + offset, count));
}
}
public sealed override unsafe byte[] FinalizeHashAndReset()
{
byte* md = stackalloc byte[Interop.Crypto.EVP_MAX_MD_SIZE];
int length = Interop.Crypto.EVP_MAX_MD_SIZE;
Check(Interop.Crypto.HmacFinal(_hmacCtx, md, ref length));
Debug.Assert(length == _hashSize);
Check(Interop.Crypto.HmacReset(_hmacCtx));
byte[] result = new byte[length];
Marshal.Copy((IntPtr)md, result, 0, length);
return result;
}
public sealed override int HashSizeInBytes
{
get { return _hashSize; }
}
public sealed override void Dispose(bool disposing)
{
if (disposing)
{
if (_hmacCtx != null)
{
_hmacCtx.Dispose();
_hmacCtx = null;
}
}
}
}
private static void Check(int result)
{
const int Success = 1;
if (result != Success)
{
Debug.Assert(result == 0);
throw Interop.Crypto.CreateOpenSslCryptographicException();
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More