From 22e7c8ec21de552fb9b9f01aad43889665d1a2b5 Mon Sep 17 00:00:00 2001 From: Tammy Qiu Date: Thu, 6 May 2021 14:36:02 -0400 Subject: [PATCH 01/10] [Android] Rename System.Security.Cryptography.Native.OpenSsl on Android --- .../sfx/Microsoft.NETCore.App/Directory.Build.props | 12 ++++++------ .../Common/src/Interop/Unix/Interop.Libraries.cs | 2 +- .../tests/TestUtilities/Interop/Interop.Libraries.cs | 2 +- .../CMakeLists.txt | 4 ++-- src/libraries/pretest.proj | 4 ++-- src/native/corehost/apphost/static/CMakeLists.txt | 4 ++-- .../corehost/hostpolicy/hostpolicy_context.cpp | 2 +- .../AndroidAppBuilder/Templates/MonoRunner.java | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props index e01cf16aae410c..696499a12e9aff 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props @@ -46,9 +46,9 @@ <_pastShimFiles Include="System.Net.Security.Native.so" /> <_pastShimFiles Include="System.Security.Cryptography.Native.Apple.a" /> <_pastShimFiles Include="System.Security.Cryptography.Native.Apple.dylib" /> - <_pastShimFiles Include="System.Security.Cryptography.Native.OpenSsl.a" /> - <_pastShimFiles Include="System.Security.Cryptography.Native.OpenSsl.dylib" /> - <_pastShimFiles Include="System.Security.Cryptography.Native.OpenSsl.so" /> + <_pastShimFiles Include="System.Security.Cryptography.Native.Android.a" /> + <_pastShimFiles Include="System.Security.Cryptography.Native.Android.dylib" /> + <_pastShimFiles Include="System.Security.Cryptography.Native.Android.so" /> <_pastShimFiles Include="clrcompression.dll" /> @@ -91,9 +91,9 @@ - - - + + + diff --git a/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs index bccd11e9a517cf..2b90015f752fb5 100644 --- a/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs @@ -8,7 +8,7 @@ internal static partial class Libraries // Shims internal const string SystemNative = "libSystem.Native"; internal const string NetSecurityNative = "libSystem.Net.Security.Native"; - internal const string CryptoNative = "libSystem.Security.Cryptography.Native.OpenSsl"; + internal const string CryptoNative = "libSystem.Security.Cryptography.Native.Android"; internal const string CompressionNative = "libSystem.IO.Compression.Native"; internal const string GlobalizationNative = "libSystem.Globalization.Native"; internal const string IOPortsNative = "libSystem.IO.Ports.Native"; diff --git a/src/libraries/Common/tests/TestUtilities/Interop/Interop.Libraries.cs b/src/libraries/Common/tests/TestUtilities/Interop/Interop.Libraries.cs index c182dbeb51bef4..72cb6e5b38a2d9 100644 --- a/src/libraries/Common/tests/TestUtilities/Interop/Interop.Libraries.cs +++ b/src/libraries/Common/tests/TestUtilities/Interop/Interop.Libraries.cs @@ -6,7 +6,7 @@ internal static partial class Interop internal static partial class Libraries { // Shims - public const string CryptoNative = "libSystem.Security.Cryptography.Native.OpenSsl"; + public const string CryptoNative = "libSystem.Security.Cryptography.Native.Android"; public const string SystemNative = "libSystem.Native"; } } diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt index 5ec5a520e63238..39a658d805daed 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt @@ -45,8 +45,8 @@ target_link_libraries(System.Security.Cryptography.Native.Android ) # TODO: Use "System.Security.Cryptography.Native.Android" name (will require a lot of csproj changes here and there) -set_target_properties(System.Security.Cryptography.Native.Android PROPERTIES OUTPUT_NAME "System.Security.Cryptography.Native.OpenSsl") -set_target_properties(System.Security.Cryptography.Native.Android-Static PROPERTIES OUTPUT_NAME "System.Security.Cryptography.Native.OpenSsl") +set_target_properties(System.Security.Cryptography.Native.Android PROPERTIES OUTPUT_NAME "System.Security.Cryptography.Native.Android") +set_target_properties(System.Security.Cryptography.Native.Android-Static PROPERTIES OUTPUT_NAME "System.Security.Cryptography.Native.Android") install_with_stripped_symbols (System.Security.Cryptography.Native.Android PROGRAMS .) install (TARGETS System.Security.Cryptography.Native.Android-Static DESTINATION .) diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 176842f5d62846..dda433464f66e7 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -38,9 +38,9 @@ - + - + Date: Thu, 6 May 2021 15:06:53 -0400 Subject: [PATCH 02/10] revert naming changes for non-android specific cases --- .../sfx/Microsoft.NETCore.App/Directory.Build.props | 12 ++++++------ .../tests/TestUtilities/Interop/Interop.Libraries.cs | 2 +- src/native/corehost/apphost/static/CMakeLists.txt | 4 ++-- .../corehost/hostpolicy/hostpolicy_context.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props index 696499a12e9aff..e01cf16aae410c 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props @@ -46,9 +46,9 @@ <_pastShimFiles Include="System.Net.Security.Native.so" /> <_pastShimFiles Include="System.Security.Cryptography.Native.Apple.a" /> <_pastShimFiles Include="System.Security.Cryptography.Native.Apple.dylib" /> - <_pastShimFiles Include="System.Security.Cryptography.Native.Android.a" /> - <_pastShimFiles Include="System.Security.Cryptography.Native.Android.dylib" /> - <_pastShimFiles Include="System.Security.Cryptography.Native.Android.so" /> + <_pastShimFiles Include="System.Security.Cryptography.Native.OpenSsl.a" /> + <_pastShimFiles Include="System.Security.Cryptography.Native.OpenSsl.dylib" /> + <_pastShimFiles Include="System.Security.Cryptography.Native.OpenSsl.so" /> <_pastShimFiles Include="clrcompression.dll" /> @@ -91,9 +91,9 @@ - - - + + + diff --git a/src/libraries/Common/tests/TestUtilities/Interop/Interop.Libraries.cs b/src/libraries/Common/tests/TestUtilities/Interop/Interop.Libraries.cs index 72cb6e5b38a2d9..c182dbeb51bef4 100644 --- a/src/libraries/Common/tests/TestUtilities/Interop/Interop.Libraries.cs +++ b/src/libraries/Common/tests/TestUtilities/Interop/Interop.Libraries.cs @@ -6,7 +6,7 @@ internal static partial class Interop internal static partial class Libraries { // Shims - public const string CryptoNative = "libSystem.Security.Cryptography.Native.Android"; + public const string CryptoNative = "libSystem.Security.Cryptography.Native.OpenSsl"; public const string SystemNative = "libSystem.Native"; } } diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index f7298a020810b5..5e3aaf3c70831d 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -141,7 +141,7 @@ else() System.IO.Compression.Native-Static System.Net.Security.Native-Static System.Native-Static - System.Security.Cryptography.Native.Android-Static + System.Security.Cryptography.Native.OpenSsl-Static palrt coreclrpal @@ -161,7 +161,7 @@ else() include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Native/extra_libs.cmake) append_extra_system_libs(NATIVE_LIBS) - # Additional requirements for System.Security.Cryptography.Native.Android + # Additional requirements for System.Security.Cryptography.Native.OpenSsl include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake) append_extra_cryptography_libs(NATIVE_LIBS) diff --git a/src/native/corehost/hostpolicy/hostpolicy_context.cpp b/src/native/corehost/hostpolicy/hostpolicy_context.cpp index 8d9aa29f20a398..4c7ad15f2cb2bf 100644 --- a/src/native/corehost/hostpolicy/hostpolicy_context.cpp +++ b/src/native/corehost/hostpolicy/hostpolicy_context.cpp @@ -75,7 +75,7 @@ namespace return SystemResolveDllImport(entrypointName); } - if (strcmp(libraryName, "libSystem.Security.Cryptography.Native.Android") == 0) + if (strcmp(libraryName, "libSystem.Security.Cryptography.Native.OpenSsl") == 0) { return CryptoResolveDllImport(entrypointName); } From 0c47200affeaa3f06602e78b5a7c602a6e0c306a Mon Sep 17 00:00:00 2001 From: Tammy Qiu Date: Mon, 10 May 2021 18:49:50 -0400 Subject: [PATCH 03/10] [Android] Split Interop.Libraries --- .../sfx/Microsoft.NETCore.App/Directory.Build.props | 2 ++ .../Common/src/Interop/Android/Interop.Libraries.cs | 1 + .../Common/src/Interop/Unix/Interop.CryptoNative.cs | 10 ++++++++++ .../Common/src/Interop/Unix/Interop.Libraries.cs | 1 - .../System.Net.Http/src/System.Net.Http.csproj | 2 ++ .../System.Net.Security/src/System.Net.Security.csproj | 4 ++++ .../src/System.Security.Cryptography.Algorithms.csproj | 4 ++++ ...ystem.Security.Cryptography.X509Certificates.csproj | 4 ++++ 8 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/libraries/Common/src/Interop/Unix/Interop.CryptoNative.cs diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props index e01cf16aae410c..bdb2be8a515443 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props @@ -91,6 +91,8 @@ + + diff --git a/src/libraries/Common/src/Interop/Android/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Android/Interop.Libraries.cs index 5aaa93dbd2f2cb..8dc933c58ac05e 100644 --- a/src/libraries/Common/src/Interop/Android/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Android/Interop.Libraries.cs @@ -6,5 +6,6 @@ internal static partial class Interop internal static partial class Libraries { internal const string Liblog = "liblog"; + internal const string CryptoNative = "libSystem.Security.Cryptography.Native.Android"; } } diff --git a/src/libraries/Common/src/Interop/Unix/Interop.CryptoNative.cs b/src/libraries/Common/src/Interop/Unix/Interop.CryptoNative.cs new file mode 100644 index 00000000000000..1c03fbdd6738b8 --- /dev/null +++ b/src/libraries/Common/src/Interop/Unix/Interop.CryptoNative.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +internal static partial class Interop +{ + internal static partial class Libraries + { + internal const string CryptoNative = "libSystem.Security.Cryptography.Native.OpenSsl"; + } +} \ No newline at end of file diff --git a/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs index 2b90015f752fb5..93ded34b368fc6 100644 --- a/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs @@ -8,7 +8,6 @@ internal static partial class Libraries // Shims internal const string SystemNative = "libSystem.Native"; internal const string NetSecurityNative = "libSystem.Net.Security.Native"; - internal const string CryptoNative = "libSystem.Security.Cryptography.Native.Android"; internal const string CompressionNative = "libSystem.IO.Compression.Native"; internal const string GlobalizationNative = "libSystem.Globalization.Native"; internal const string IOPortsNative = "libSystem.IO.Ports.Native"; diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 201d0acd63e5de..838d74834d19da 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -518,6 +518,8 @@ Link="Common\Interop\Unix\Interop.IOErrors.cs" /> + + + diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj b/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj index 2c54324bfb4d67..475107853b6d41 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj @@ -574,6 +574,8 @@ Link="Common\System\Security\Cryptography\ECOpenSsl.cs" /> + + + + Date: Tue, 11 May 2021 11:38:08 -0400 Subject: [PATCH 04/10] PR feedback --- .../System.Security.Cryptography.Native.Android/CMakeLists.txt | 1 - src/libraries/pretest.proj | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt index 39a658d805daed..44986a1bfe67f5 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/CMakeLists.txt @@ -44,7 +44,6 @@ target_link_libraries(System.Security.Cryptography.Native.Android -llog ) -# TODO: Use "System.Security.Cryptography.Native.Android" name (will require a lot of csproj changes here and there) set_target_properties(System.Security.Cryptography.Native.Android PROPERTIES OUTPUT_NAME "System.Security.Cryptography.Native.Android") set_target_properties(System.Security.Cryptography.Native.Android-Static PROPERTIES OUTPUT_NAME "System.Security.Cryptography.Native.Android") diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index dda433464f66e7..bccc988a0fbf01 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -39,8 +39,9 @@ + - + Date: Tue, 11 May 2021 13:10:04 -0400 Subject: [PATCH 05/10] Continue adding Interop.CryptoNative.cs to csproj files --- .../src/System.Security.Cryptography.Encoding.csproj | 2 ++ .../src/System.Security.Cryptography.OpenSsl.csproj | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj b/src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj index ea5329594dcfb0..5ae6f9e4c7363f 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj +++ b/src/libraries/System.Security.Cryptography.Encoding/src/System.Security.Cryptography.Encoding.csproj @@ -63,6 +63,8 @@ + + Date: Tue, 11 May 2021 15:39:53 -0400 Subject: [PATCH 06/10] Move Interop.CryptoNative to include OSX --- .../src/System.Security.Cryptography.Algorithms.csproj | 6 +++--- .../System.Security.Cryptography.Algorithms.Tests.csproj | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj b/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj index cd7fadf475fdf5..c05e52ed87c968 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj @@ -1,4 +1,4 @@ - + true $(DefineConstants);INTERNAL_ASYMMETRIC_IMPLEMENTATIONS @@ -586,6 +586,8 @@ Link="Common\System\Security\Cryptography\ECDiffieHellmanDerivation.cs" /> + @@ -601,8 +603,6 @@ Link="Common\System\Security\Cryptography\ECOpenSsl.cs" /> - + From f4d84f16e667a9848347b8d385491f09d7ac3876 Mon Sep 17 00:00:00 2001 From: Tammy Qiu Date: Tue, 11 May 2021 17:54:27 -0400 Subject: [PATCH 07/10] More CryptoNative additions --- .../tests/System.Security.Cryptography.OpenSsl.Tests.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/tests/System.Security.Cryptography.OpenSsl.Tests.csproj b/src/libraries/System.Security.Cryptography.OpenSsl/tests/System.Security.Cryptography.OpenSsl.Tests.csproj index e2d4f1aa634fc1..c400d32d2c66ae 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/tests/System.Security.Cryptography.OpenSsl.Tests.csproj +++ b/src/libraries/System.Security.Cryptography.OpenSsl/tests/System.Security.Cryptography.OpenSsl.Tests.csproj @@ -10,6 +10,8 @@ + Date: Tue, 11 May 2021 21:03:29 -0400 Subject: [PATCH 08/10] Add CryptoNative to System.Security.Cryptography.X509Certificates.Tests --- .../System.Security.Cryptography.X509Certificates.Tests.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj b/src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj index 4aebe6daec3aa4..304cfe0ecf4de3 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj @@ -77,6 +77,8 @@ + Date: Thu, 13 May 2021 18:05:27 -0400 Subject: [PATCH 09/10] [Android] Split System.Security.Cryptography.Native.Android files to use Interop.AndroidCryptoNative headers instead --- .../Android/Interop.JObjectLifetime.cs | 4 +- .../src/Interop/Android/Interop.Libraries.cs | 2 +- .../Interop.Bignum.cs | 4 +- .../Interop.Cipher.cs | 76 +++++------ .../Interop.Dsa.cs | 16 +-- .../Interop.EcDsa.ImportExport.cs | 8 +- .../Interop.EcDsa.cs | 6 +- .../Interop.EcKey.cs | 10 +- .../Interop.Ecdh.cs | 2 +- .../Interop.Err.cs | 118 ++++++++++++++++++ .../Interop.Evp.DigestAlgs.cs | 58 +++++++++ .../Interop.Evp.cs | 79 ++++++++++++ .../Interop.Hmac.cs | 33 +++++ .../Interop.Initialization.cs | 54 ++++++++ .../Interop.Random.cs | 22 ++++ .../Interop.Rsa.cs | 24 ++-- .../Interop.Ssl.ProtocolSupport.cs | 4 +- .../Interop.Ssl.cs | 36 +++--- .../Interop.X509.cs | 12 +- .../Interop.X509Chain.cs | 20 +-- .../Interop.X509Store.cs | 14 +-- .../src/Interop/Unix/Interop.CryptoNative.cs | 10 -- .../src/Interop/Unix/Interop.Libraries.cs | 1 + .../tests/TestUtilities/TestUtilities.csproj | 2 + .../src/System.Net.Http.csproj | 2 - .../src/System.Net.Security.csproj | 2 - ...em.Security.Cryptography.Algorithms.csproj | 42 ++++--- .../tests/DefaultECDsaProvider.Android.cs | 4 +- ...urity.Cryptography.Algorithms.Tests.csproj | 16 +-- ...urity.Cryptography.X509Certificates.csproj | 2 - 30 files changed, 522 insertions(+), 161 deletions(-) create mode 100644 src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Err.cs create mode 100644 src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.DigestAlgs.cs create mode 100644 src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.cs create mode 100644 src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Hmac.cs create mode 100644 src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Initialization.cs create mode 100644 src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Random.cs delete mode 100644 src/libraries/Common/src/Interop/Unix/Interop.CryptoNative.cs diff --git a/src/libraries/Common/src/Interop/Android/Interop.JObjectLifetime.cs b/src/libraries/Common/src/Interop/Android/Interop.JObjectLifetime.cs index 5127ea5e50ec24..77a8f42da866d1 100644 --- a/src/libraries/Common/src/Interop/Android/Interop.JObjectLifetime.cs +++ b/src/libraries/Common/src/Interop/Android/Interop.JObjectLifetime.cs @@ -10,10 +10,10 @@ internal static partial class Interop { internal static partial class JObjectLifetime { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_NewGlobalReference")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_NewGlobalReference")] internal static extern IntPtr NewGlobalReference(IntPtr obj); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DeleteGlobalReference")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DeleteGlobalReference")] internal static extern void DeleteGlobalReference(IntPtr obj); internal class SafeJObjectHandle : SafeHandle diff --git a/src/libraries/Common/src/Interop/Android/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Android/Interop.Libraries.cs index 8dc933c58ac05e..c59ba46ce732ca 100644 --- a/src/libraries/Common/src/Interop/Android/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Android/Interop.Libraries.cs @@ -6,6 +6,6 @@ internal static partial class Interop internal static partial class Libraries { internal const string Liblog = "liblog"; - internal const string CryptoNative = "libSystem.Security.Cryptography.Native.Android"; + internal const string AndroidCryptoNative = "libSystem.Security.Cryptography.Native.Android"; } } diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Bignum.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Bignum.cs index 5936cee56d6d33..42caf771e436df 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Bignum.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Bignum.cs @@ -10,10 +10,10 @@ internal static partial class Interop // TODO: [AndroidCrypto] Rename class to AndroidCrypto once all consumers are split in Android vs. Unix internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_BigNumToBinary")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_BigNumToBinary")] private static extern unsafe int BigNumToBinary(SafeBignumHandle a, byte* to); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_GetBigNumBytes")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetBigNumBytes")] private static extern int GetBigNumBytes(SafeBignumHandle a); internal static unsafe byte[]? ExtractBignum(SafeBignumHandle? bignum, int targetSize) diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Cipher.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Cipher.cs index 23caee885edf4c..bed79c75f775a3 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Cipher.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Cipher.cs @@ -10,7 +10,7 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherCreate")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCreate")] internal static extern SafeEvpCipherCtxHandle EvpCipherCreate( IntPtr cipher, ref byte key, @@ -19,11 +19,11 @@ internal static extern SafeEvpCipherCtxHandle EvpCipherCreate( ref byte iv, int enc); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherCreatePartial")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCreatePartial")] internal static extern SafeEvpCipherCtxHandle EvpCipherCreatePartial( IntPtr cipher); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetKeyAndIV")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetKeyAndIV")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool EvpCipherSetKeyAndIV( SafeEvpCipherCtxHandle ctx, @@ -47,7 +47,7 @@ ref MemoryMarshal.GetReference(iv), } } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetNonceLength")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetNonceLength")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool AndroidCryptoNative_CipherSetNonceLength( SafeEvpCipherCtxHandle ctx, int nonceLength); @@ -60,18 +60,18 @@ internal static void CipherSetNonceLength(SafeEvpCipherCtxHandle ctx, int nonceL } } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherDestroy")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherDestroy")] internal static extern void EvpCipherDestroy(IntPtr ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherReset")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherReset")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool EvpCipherReset(SafeEvpCipherCtxHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherCtxSetPadding")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCtxSetPadding")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool EvpCipherCtxSetPadding(SafeEvpCipherCtxHandle x, int padding); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherUpdate")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherUpdate")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool EvpCipherUpdate( SafeEvpCipherCtxHandle ctx, @@ -94,7 +94,7 @@ ref MemoryMarshal.GetReference(input), input.Length); } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherUpdateAAD")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherUpdateAAD")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool CipherUpdateAAD( SafeEvpCipherCtxHandle ctx, @@ -114,7 +114,7 @@ ref MemoryMarshal.GetReference(input), } } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherFinalEx")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherFinalEx")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool EvpCipherFinalEx( SafeEvpCipherCtxHandle ctx, @@ -129,91 +129,91 @@ internal static bool EvpCipherFinalEx( return EvpCipherFinalEx(ctx, ref MemoryMarshal.GetReference(output), out bytesWritten); } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetTagLength")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetTagLength")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool CipherSetTagLength( SafeEvpCipherCtxHandle ctx, int tagLength); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Ecb")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Ecb")] internal static extern IntPtr EvpAes128Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cbc")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cbc")] internal static extern IntPtr EvpAes128Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Gcm")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Gcm")] internal static extern IntPtr EvpAes128Gcm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cfb8")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cfb8")] internal static extern IntPtr EvpAes128Cfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cfb128")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cfb128")] internal static extern IntPtr EvpAes128Cfb128(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Ccm")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Ccm")] internal static extern IntPtr EvpAes128Ccm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Ecb")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Ecb")] internal static extern IntPtr EvpAes192Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cbc")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cbc")] internal static extern IntPtr EvpAes192Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Gcm")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Gcm")] internal static extern IntPtr EvpAes192Gcm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cfb8")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cfb8")] internal static extern IntPtr EvpAes192Cfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cfb128")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cfb128")] internal static extern IntPtr EvpAes192Cfb128(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Ccm")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Ccm")] internal static extern IntPtr EvpAes192Ccm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Ecb")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Ecb")] internal static extern IntPtr EvpAes256Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cbc")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cbc")] internal static extern IntPtr EvpAes256Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Gcm")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Gcm")] internal static extern IntPtr EvpAes256Gcm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cfb128")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cfb128")] internal static extern IntPtr EvpAes256Cfb128(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cfb8")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cfb8")] internal static extern IntPtr EvpAes256Cfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Ccm")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Ccm")] internal static extern IntPtr EvpAes256Ccm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DesCbc")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesCbc")] internal static extern IntPtr EvpDesCbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DesEcb")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesEcb")] internal static extern IntPtr EvpDesEcb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DesCfb8")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesCfb8")] internal static extern IntPtr EvpDesCfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cbc")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cbc")] internal static extern IntPtr EvpDes3Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Des3Ecb")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Ecb")] internal static extern IntPtr EvpDes3Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cfb8")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cfb8")] internal static extern IntPtr EvpDes3Cfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cfb64")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cfb64")] internal static extern IntPtr EvpDes3Cfb64(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RC2Cbc")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RC2Cbc")] internal static extern IntPtr EvpRC2Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RC2Ecb")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RC2Ecb")] internal static extern IntPtr EvpRC2Ecb(); internal enum EvpCipherDirection : int diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Dsa.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Dsa.cs index a27d9b07761c88..95a90cb092b99b 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Dsa.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Dsa.cs @@ -11,11 +11,11 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DsaGenerateKey")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaGenerateKey")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool DsaGenerateKey(out SafeDsaHandle dsa, int bits); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DsaSizeSignature")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSizeSignature")] private static extern int DsaSizeSignature(SafeDsaHandle dsa); /// @@ -27,7 +27,7 @@ internal static int DsaEncodedSignatureSize(SafeDsaHandle dsa) return size; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DsaSignatureFieldSize")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSignatureFieldSize")] private static extern int AndroidCryptoNative_DsaSignatureFieldSize(SafeDsaHandle dsa); /// @@ -41,7 +41,7 @@ internal static int DsaSignatureFieldSize(SafeDsaHandle dsa) return size; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DsaSizeP")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSizeP")] private static extern int DsaSizeP(SafeDsaHandle dsa); /// @@ -59,7 +59,7 @@ internal static int DsaKeySize(SafeDsaHandle dsa) internal static bool DsaSign(SafeDsaHandle dsa, ReadOnlySpan hash, Span refSignature, out int outSignatureLength) => DsaSign(dsa, ref MemoryMarshal.GetReference(hash), hash.Length, ref MemoryMarshal.GetReference(refSignature), out outSignatureLength); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DsaSign")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSign")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool DsaSign(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte refSignature, out int outSignatureLength); @@ -80,7 +80,7 @@ ref MemoryMarshal.GetReference(signature), return ret == 1; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DsaVerify")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaVerify")] private static extern int DsaVerify(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte signature, int signatureLength); internal static DSAParameters ExportDsaParameters(SafeDsaHandle key, bool includePrivateParameters) @@ -141,7 +141,7 @@ internal static DSAParameters ExportDsaParameters(SafeDsaHandle key, bool includ } } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_GetDsaParameters")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetDsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool GetDsaParameters( SafeDsaHandle key, @@ -151,7 +151,7 @@ private static extern bool GetDsaParameters( out SafeBignumHandle y, out int y_cb, out SafeBignumHandle x, out int x_cb); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DsaKeyCreateByExplicitParameters")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaKeyCreateByExplicitParameters")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool DsaKeyCreateByExplicitParameters( out SafeDsaHandle dsa, diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs index 1b757f8814b54e..0395a10764ed50 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.ImportExport.cs @@ -10,7 +10,7 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByKeyParameters", CharSet = CharSet.Ansi)] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByKeyParameters", CharSet = CharSet.Ansi)] private static extern int EcKeyCreateByKeyParameters( out SafeEcKeyHandle key, string oid, @@ -35,7 +35,7 @@ internal static SafeEcKeyHandle EcKeyCreateByKeyParameters( return key; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByExplicitParameters")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByExplicitParameters")] internal static extern SafeEcKeyHandle EcKeyCreateByExplicitParameters( ECCurve.ECCurveType curveType, byte[]? qx, int qxLength, @@ -91,7 +91,7 @@ internal static SafeEcKeyHandle EcKeyCreateByExplicitCurve(ECCurve curve) } - [DllImport(Libraries.CryptoNative)] + [DllImport(Libraries.AndroidCryptoNative)] private static extern int AndroidCryptoNative_GetECKeyParameters( SafeEcKeyHandle key, bool includePrivate, @@ -149,7 +149,7 @@ internal static ECParameters GetECKeyParameters( return parameters; } - [DllImport(Libraries.CryptoNative)] + [DllImport(Libraries.AndroidCryptoNative)] private static extern int AndroidCryptoNative_GetECCurveParameters( SafeEcKeyHandle key, bool includePrivate, diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.cs index 8f107321374195..53e0dcdddf8202 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcDsa.cs @@ -12,7 +12,7 @@ internal static partial class AndroidCrypto internal static bool EcDsaSign(ReadOnlySpan dgst, Span sig, out int siglen, SafeEcKeyHandle ecKey) => EcDsaSign(ref MemoryMarshal.GetReference(dgst), dgst.Length, ref MemoryMarshal.GetReference(sig), out siglen, ecKey); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaSign")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaSign")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool EcDsaSign(ref byte dgst, int dlen, ref byte sig, out int siglen, SafeEcKeyHandle ecKey); @@ -34,11 +34,11 @@ ref MemoryMarshal.GetReference(sigbuf), * 0: incorrect signature * -1: error */ - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaVerify")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaVerify")] private static extern int EcDsaVerify(ref byte dgst, int dgst_len, ref byte sigbuf, int sig_len, SafeEcKeyHandle ecKey); // returns the maximum length of a DER encoded ECDSA signature created with this key. - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaSize")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaSize")] private static extern int AndroidCryptoNative_EcDsaSize(SafeEcKeyHandle ecKey); internal static int EcDsaSize(SafeEcKeyHandle ecKey) diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs index 775c9fef6af6ba..a905d489ea2b43 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.EcKey.cs @@ -10,7 +10,7 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByOid")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByOid")] private static extern SafeEcKeyHandle AndroidCryptoNative_EcKeyCreateByOid(string oid); internal static SafeEcKeyHandle? EcKeyCreateByOid(string oid) { @@ -19,14 +19,14 @@ internal static partial class AndroidCrypto return handle; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyDestroy")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyDestroy")] internal static extern void EcKeyDestroy(IntPtr a); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyUpRef")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyUpRef")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool EcKeyUpRef(IntPtr r); - [DllImport(Libraries.CryptoNative)] + [DllImport(Libraries.AndroidCryptoNative)] private static extern int AndroidCryptoNative_EcKeyGetSize(SafeEcKeyHandle ecKey, out int keySize); internal static int EcKeyGetSize(SafeEcKeyHandle key) { @@ -39,7 +39,7 @@ internal static int EcKeyGetSize(SafeEcKeyHandle key) throw new CryptographicException(); } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyGetCurveName")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyGetCurveName")] private static extern int AndroidCryptoNative_EcKeyGetCurveName(SafeEcKeyHandle ecKey, out IntPtr curveName); internal static string? EcKeyGetCurveName(SafeEcKeyHandle key) diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ecdh.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ecdh.cs index 4a396e5e731953..4ea8ddbc5fabeb 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ecdh.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ecdh.cs @@ -13,7 +13,7 @@ internal static partial class AndroidCrypto internal static bool EcdhDeriveKey(SafeEcKeyHandle ourKey, SafeEcKeyHandle peerKey, Span buffer, out int usedBuffer) => EcdhDeriveKey(ourKey, peerKey, ref MemoryMarshal.GetReference(buffer), buffer.Length, out usedBuffer); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_EcdhDeriveKey")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcdhDeriveKey")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool EcdhDeriveKey(SafeEcKeyHandle ourKey, SafeEcKeyHandle peerKey, ref byte buffer, int bufferLength, out int usedBuffer); } diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Err.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Err.cs new file mode 100644 index 00000000000000..86259a717ddc01 --- /dev/null +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Err.cs @@ -0,0 +1,118 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Security.Cryptography; + +internal static partial class Interop +{ + internal static partial class Crypto + { + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrClearError")] + internal static extern ulong ErrClearError(); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrGetErrorAlloc")] + private static extern ulong ErrGetErrorAlloc([MarshalAs(UnmanagedType.Bool)] out bool isAllocFailure); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrPeekError")] + internal static extern ulong ErrPeekError(); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrPeekLastError")] + internal static extern ulong ErrPeekLastError(); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrReasonErrorString")] + internal static extern IntPtr ErrReasonErrorString(ulong error); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrErrorStringN")] + private static extern unsafe void ErrErrorStringN(ulong e, byte* buf, int len); + + private static unsafe string ErrErrorStringN(ulong error) + { + var buffer = new byte[1024]; + fixed (byte* buf = &buffer[0]) + { + ErrErrorStringN(error, buf, buffer.Length); + return Marshal.PtrToStringAnsi((IntPtr)buf)!; + } + } + + internal static Exception CreateOpenSslCryptographicException() + { + // The Windows cryptography library reports error codes through + // Marshal.GetLastWin32Error, which has a single value when the + // function exits, last writer wins. + // + // OpenSSL maintains an error queue. Calls to ERR_get_error read + // values out of the queue in the order that ERR_set_error wrote + // them. Nothing enforces that a single call into an OpenSSL + // function will guarantee at-most one error being set. + // + // In order to maintain parity in how error flows look between the + // Windows code and the OpenSSL-calling code, drain the queue + // whenever an Exception is desired, and report the exception + // related to the last value in the queue. + bool isAllocFailure; + ulong error = ErrGetErrorAlloc(out isAllocFailure); + ulong lastRead = error; + bool lastIsAllocFailure = isAllocFailure; + + // 0 (there's no named constant) is only returned when the calls + // to ERR_get_error exceed the calls to ERR_set_error. + while (lastRead != 0) + { + error = lastRead; + isAllocFailure = lastIsAllocFailure; + + lastRead = ErrGetErrorAlloc(out lastIsAllocFailure); + } + + // If we're in an error flow which results in an Exception, but + // no calls to ERR_set_error were made, throw the unadorned + // CryptographicException. + if (error == 0) + { + return new CryptographicException(); + } + + if (isAllocFailure) + { + return new OutOfMemoryException(); + } + + // Even though ErrGetError returns ulong (C++ unsigned long), we + // really only expect error codes in the UInt32 range + Debug.Assert(error <= uint.MaxValue, "ErrGetError should only return error codes in the UInt32 range."); + + // If there was an error code, and it wasn't something handled specially, + // use the OpenSSL error string as the message to a CryptographicException. + return new OpenSslCryptographicException(unchecked((int)error), ErrErrorStringN(error)); + } + + internal static void CheckValidOpenSslHandle(SafeHandle handle) + { + if (handle == null || handle.IsInvalid) + { + throw CreateOpenSslCryptographicException(); + } + } + + internal static void CheckValidOpenSslHandle(IntPtr handle) + { + if (handle == IntPtr.Zero) + { + throw CreateOpenSslCryptographicException(); + } + } + + private sealed class OpenSslCryptographicException : CryptographicException + { + internal OpenSslCryptographicException(int errorCode, string message) + : base(message) + { + HResult = errorCode; + } + } + } +} diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.DigestAlgs.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.DigestAlgs.cs new file mode 100644 index 00000000000000..03906d6378f6dc --- /dev/null +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.DigestAlgs.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +using System.Security.Cryptography; + +internal static partial class Interop +{ + internal static partial class Crypto + { + private static volatile IntPtr s_evpMd5; + private static volatile IntPtr s_evpSha1; + private static volatile IntPtr s_evpSha256; + private static volatile IntPtr s_evpSha384; + private static volatile IntPtr s_evpSha512; + + [DllImport(Libraries.AndroidCryptoNative)] + private static extern IntPtr CryptoNative_EvpMd5(); + + internal static IntPtr EvpMd5() => + s_evpMd5 != IntPtr.Zero ? s_evpMd5 : (s_evpMd5 = CryptoNative_EvpMd5()); + + [DllImport(Libraries.AndroidCryptoNative)] + internal static extern IntPtr CryptoNative_EvpSha1(); + + internal static IntPtr EvpSha1() => + s_evpSha1 != IntPtr.Zero ? s_evpSha1 : (s_evpSha1 = CryptoNative_EvpSha1()); + + [DllImport(Libraries.AndroidCryptoNative)] + internal static extern IntPtr CryptoNative_EvpSha256(); + + internal static IntPtr EvpSha256() => + s_evpSha256 != IntPtr.Zero ? s_evpSha256 : (s_evpSha256 = CryptoNative_EvpSha256()); + + [DllImport(Libraries.AndroidCryptoNative)] + internal static extern IntPtr CryptoNative_EvpSha384(); + + internal static IntPtr EvpSha384() => + s_evpSha384 != IntPtr.Zero ? s_evpSha384 : (s_evpSha384 = CryptoNative_EvpSha384()); + + [DllImport(Libraries.AndroidCryptoNative)] + internal static extern IntPtr CryptoNative_EvpSha512(); + + internal static IntPtr EvpSha512() => + s_evpSha512 != IntPtr.Zero ? s_evpSha512 : (s_evpSha512 = CryptoNative_EvpSha512()); + + internal static IntPtr HashAlgorithmToEvp(string hashAlgorithmId) => hashAlgorithmId switch + { + nameof(HashAlgorithmName.SHA1) => EvpSha1(), + nameof(HashAlgorithmName.SHA256) => EvpSha256(), + nameof(HashAlgorithmName.SHA384) => EvpSha384(), + nameof(HashAlgorithmName.SHA512) => EvpSha512(), + nameof(HashAlgorithmName.MD5) => EvpMd5(), + _ => throw new CryptographicException(SR.Format(SR.Cryptography_UnknownHashAlgorithm, hashAlgorithmId)) + }; + } +} diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.cs new file mode 100644 index 00000000000000..66eaaa6f7ef0f5 --- /dev/null +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Evp.cs @@ -0,0 +1,79 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using Microsoft.Win32.SafeHandles; + +internal static partial class Interop +{ + internal static partial class Crypto + { + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdCtxCreate")] + internal static extern SafeEvpMdCtxHandle EvpMdCtxCreate(IntPtr type); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdCtxDestroy")] + internal static extern void EvpMdCtxDestroy(IntPtr ctx); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestReset")] + internal static extern int EvpDigestReset(SafeEvpMdCtxHandle ctx, IntPtr type); + + internal static int EvpDigestUpdate(SafeEvpMdCtxHandle ctx, ReadOnlySpan d, int cnt) => + EvpDigestUpdate(ctx, ref MemoryMarshal.GetReference(d), cnt); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestUpdate")] + private static extern int EvpDigestUpdate(SafeEvpMdCtxHandle ctx, ref byte d, int cnt); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestFinalEx")] + internal static extern int EvpDigestFinalEx(SafeEvpMdCtxHandle ctx, ref byte md, ref uint s); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestCurrent")] + internal static extern int EvpDigestCurrent(SafeEvpMdCtxHandle ctx, ref byte md, ref uint s); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestOneShot")] + internal static unsafe extern int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, ref uint mdSize); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdSize")] + internal static extern int EvpMdSize(IntPtr md); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_GetMaxMdSize")] + private static extern int GetMaxMdSize(); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_Pbkdf2")] + private static unsafe extern int Pbkdf2( + byte* pPassword, + int passwordLength, + byte* pSalt, + int saltLength, + int iterations, + IntPtr digestEvp, + byte* pDestination, + int destinationLength); + + internal static unsafe int Pbkdf2( + ReadOnlySpan password, + ReadOnlySpan salt, + int iterations, + IntPtr digestEvp, + Span destination) + { + fixed (byte* pPassword = password) + fixed (byte* pSalt = salt) + fixed (byte* pDestination = destination) + { + return Pbkdf2( + pPassword, + password.Length, + pSalt, + salt.Length, + iterations, + digestEvp, + pDestination, + destination.Length); + } + } + + internal static readonly int EVP_MAX_MD_SIZE = GetMaxMdSize(); + } +} diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Hmac.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Hmac.cs new file mode 100644 index 00000000000000..f3329463321360 --- /dev/null +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Hmac.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +using Microsoft.Win32.SafeHandles; + +internal static partial class Interop +{ + internal static partial class Crypto + { + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacCreate")] + internal static extern SafeHmacCtxHandle HmacCreate(ref byte key, int keyLen, IntPtr md); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacDestroy")] + internal static extern void HmacDestroy(IntPtr ctx); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacReset")] + internal static extern int HmacReset(SafeHmacCtxHandle ctx); + + internal static int HmacUpdate(SafeHmacCtxHandle ctx, ReadOnlySpan data, int len) => + HmacUpdate(ctx, ref MemoryMarshal.GetReference(data), len); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacUpdate")] + private static extern int HmacUpdate(SafeHmacCtxHandle ctx, ref byte data, int len); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacFinal")] + internal static extern int HmacFinal(SafeHmacCtxHandle ctx, ref byte data, ref int len); + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacCurrent")] + internal static extern int HmacCurrent(SafeHmacCtxHandle ctx, ref byte data, ref int len); + } +} diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Initialization.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Initialization.cs new file mode 100644 index 00000000000000..b55f361f6666ab --- /dev/null +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Initialization.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + // Initialization of libcrypto threading support is done in a static constructor. + // This enables a project simply to include this file, and any usage of any of + // the System.Security.Cryptography.Native functions will trigger + // initialization of the threading support. + + internal static partial class Crypto + { + static Crypto() + { + CryptoInitializer.Initialize(); + } + } + + internal static partial class OpenSsl + { + static OpenSsl() + { + CryptoInitializer.Initialize(); + } + } + + internal static class CryptoInitializer + { + static CryptoInitializer() + { + if (EnsureOpenSslInitialized() != 0) + { + // Ideally this would be a CryptographicException, but we use + // OpenSSL in libraries lower than System.Security.Cryptography. + // It's not a big deal, though: this will already be wrapped in a + // TypeLoadException, and this failing means something is very + // wrong with the system's configuration and any code using + // these libraries will be unable to operate correctly. + throw new InvalidOperationException(); + } + } + + internal static void Initialize() + { + // No-op that exists to provide a hook for other static constructors. + } + + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EnsureOpenSslInitialized")] + private static extern int EnsureOpenSslInitialized(); + } +} diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Random.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Random.cs new file mode 100644 index 00000000000000..964d844f20fa0c --- /dev/null +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Random.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Crypto + { + internal static unsafe bool GetRandomBytes(byte* pbBuffer, int count) + { + Debug.Assert(count >= 0); + + return CryptoNative_GetRandomBytes(pbBuffer, count); + } + + [DllImport(Libraries.AndroidCryptoNative)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern unsafe bool CryptoNative_GetRandomBytes(byte* buf, int num); + } +} diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Rsa.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Rsa.cs index b7e3ab4baa6a87..8d501ecbf24932 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Rsa.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Rsa.cs @@ -11,20 +11,20 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaCreate")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaCreate")] internal static extern SafeRsaHandle RsaCreate(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaUpRef")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaUpRef")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool RsaUpRef(IntPtr rsa); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaDestroy")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaDestroy")] internal static extern void RsaDestroy(IntPtr rsa); internal static SafeRsaHandle DecodeRsaSubjectPublicKeyInfo(ReadOnlySpan buf) => DecodeRsaSubjectPublicKeyInfo(ref MemoryMarshal.GetReference(buf), buf.Length); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_DecodeRsaSubjectPublicKeyInfo")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DecodeRsaSubjectPublicKeyInfo")] private static extern SafeRsaHandle DecodeRsaSubjectPublicKeyInfo(ref byte buf, int len); internal static int RsaPublicEncrypt( @@ -35,7 +35,7 @@ internal static int RsaPublicEncrypt( RsaPadding padding) => RsaPublicEncrypt(flen, ref MemoryMarshal.GetReference(from), ref MemoryMarshal.GetReference(to), rsa, padding); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaPublicEncrypt")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaPublicEncrypt")] private static extern int RsaPublicEncrypt( int flen, ref byte from, @@ -51,7 +51,7 @@ internal static int RsaPrivateDecrypt( RsaPadding padding) => RsaPrivateDecrypt(flen, ref MemoryMarshal.GetReference(from), ref MemoryMarshal.GetReference(to), rsa, padding); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaPrivateDecrypt")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaPrivateDecrypt")] private static extern int RsaPrivateDecrypt( int flen, ref byte from, @@ -65,7 +65,7 @@ internal static int RsaSignPrimitive( SafeRsaHandle rsa) => RsaSignPrimitive(from.Length, ref MemoryMarshal.GetReference(from), ref MemoryMarshal.GetReference(to), rsa); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaSignPrimitive")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaSignPrimitive")] private static extern int RsaSignPrimitive( int flen, ref byte from, @@ -78,17 +78,17 @@ internal static int RsaVerificationPrimitive( SafeRsaHandle rsa) => RsaVerificationPrimitive(from.Length, ref MemoryMarshal.GetReference(from), ref MemoryMarshal.GetReference(to), rsa); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaVerificationPrimitive")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaVerificationPrimitive")] private static extern int RsaVerificationPrimitive( int flen, ref byte from, ref byte to, SafeRsaHandle rsa); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaSize")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaSize")] internal static extern int RsaSize(SafeRsaHandle rsa); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_RsaGenerateKeyEx")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaGenerateKeyEx")] internal static extern int RsaGenerateKeyEx(SafeRsaHandle rsa, int bits); internal static RSAParameters ExportRsaParameters(SafeRsaHandle key, bool includePrivateParameters) @@ -159,7 +159,7 @@ internal static RSAParameters ExportRsaParameters(SafeRsaHandle key, bool includ } } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_GetRsaParameters")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetRsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool GetRsaParameters( SafeRsaHandle key, @@ -172,7 +172,7 @@ private static extern bool GetRsaParameters( out SafeBignumHandle dmq1, out SafeBignumHandle iqmp); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SetRsaParameters")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SetRsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool SetRsaParameters( SafeRsaHandle key, diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.ProtocolSupport.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.ProtocolSupport.cs index ad49c6276ac29d..29efbe7b040b26 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.ProtocolSupport.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.ProtocolSupport.cs @@ -8,10 +8,10 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLGetSupportedProtocols")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLGetSupportedProtocols")] internal static extern SslProtocols SSLGetSupportedProtocols(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLSupportsApplicationProtocolsConfiguration")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLSupportsApplicationProtocolsConfiguration")] [return:MarshalAs(UnmanagedType.U1)] internal static extern bool SSLSupportsApplicationProtocolsConfiguration(); } diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.cs index debe6ca458017c..bf558daead9342 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.cs @@ -29,10 +29,10 @@ internal enum PAL_SSLStreamStatus Closed = 4, }; - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamCreate")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamCreate")] internal static extern SafeSslHandle SSLStreamCreate(); - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamCreateWithCertificates")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamCreateWithCertificates")] private static extern SafeSslHandle SSLStreamCreateWithCertificates( ref byte pkcs8PrivateKey, int pkcs8PrivateKeyLen, @@ -49,7 +49,7 @@ ref MemoryMarshal.GetReference(pkcs8PrivateKey), certificates.Length); } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamInitialize")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamInitialize")] private static extern int SSLStreamInitializeImpl( SafeSslHandle sslHandle, [MarshalAs(UnmanagedType.U1)] bool isServer, @@ -68,7 +68,7 @@ internal static void SSLStreamInitialize( throw new SslException(); } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamSetTargetHost")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamSetTargetHost")] private static extern int SSLStreamSetTargetHostImpl( SafeSslHandle sslHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string targetHost); @@ -81,7 +81,7 @@ internal static void SSLStreamSetTargetHost( throw new SslException(); } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamRequestClientAuthentication")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamRequestClientAuthentication")] internal static extern void SSLStreamRequestClientAuthentication(SafeSslHandle sslHandle); [StructLayout(LayoutKind.Sequential)] @@ -91,7 +91,7 @@ private unsafe struct ApplicationProtocolData public int Length; } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamSetApplicationProtocols")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamSetApplicationProtocols")] private static unsafe extern int SSLStreamSetApplicationProtocols(SafeSslHandle sslHandle, ApplicationProtocolData[] protocolData, int count); internal static unsafe void SSLStreamSetApplicationProtocols(SafeSslHandle sslHandle, List protocols) { @@ -125,7 +125,7 @@ internal static unsafe void SSLStreamSetApplicationProtocols(SafeSslHandle sslHa } } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamSetEnabledProtocols")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamSetEnabledProtocols")] private static extern int SSLStreamSetEnabledProtocols(SafeSslHandle sslHandle, ref SslProtocols protocols, int length); internal static void SSLStreamSetEnabledProtocols(SafeSslHandle sslHandle, ReadOnlySpan protocols) { @@ -134,10 +134,10 @@ internal static void SSLStreamSetEnabledProtocols(SafeSslHandle sslHandle, ReadO throw new SslException(); } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamHandshake")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamHandshake")] internal static extern PAL_SSLStreamStatus SSLStreamHandshake(SafeSslHandle sslHandle); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetApplicationProtocol")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetApplicationProtocol")] private static extern int SSLStreamGetApplicationProtocol(SafeSslHandle ssl, [Out] byte[]? buf, ref int len); internal static byte[]? SSLStreamGetApplicationProtocol(SafeSslHandle ssl) { @@ -154,7 +154,7 @@ internal static void SSLStreamSetEnabledProtocols(SafeSslHandle sslHandle, ReadO return bytes; } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamRead")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamRead")] private static unsafe extern PAL_SSLStreamStatus SSLStreamRead( SafeSslHandle sslHandle, byte* buffer, @@ -171,7 +171,7 @@ internal static unsafe PAL_SSLStreamStatus SSLStreamRead( } } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamWrite")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamWrite")] private static unsafe extern PAL_SSLStreamStatus SSLStreamWrite( SafeSslHandle sslHandle, byte* buffer, @@ -186,7 +186,7 @@ internal static unsafe PAL_SSLStreamStatus SSLStreamWrite( } } - [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamRelease")] + [DllImport(Interop.Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamRelease")] internal static extern void SSLStreamRelease(IntPtr ptr); internal sealed class SslException : Exception @@ -201,7 +201,7 @@ internal SslException(int errorCode) } } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetProtocol")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetProtocol")] private static extern int SSLStreamGetProtocol(SafeSslHandle ssl, out IntPtr protocol); internal static string SSLStreamGetProtocol(SafeSslHandle ssl) { @@ -218,10 +218,10 @@ internal static string SSLStreamGetProtocol(SafeSslHandle ssl) return protocol; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetPeerCertificate")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetPeerCertificate")] internal static extern SafeX509Handle SSLStreamGetPeerCertificate(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetPeerCertificates")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetPeerCertificates")] private static extern void SSLStreamGetPeerCertificates( SafeSslHandle ssl, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out IntPtr[] certs, @@ -234,7 +234,7 @@ private static extern void SSLStreamGetPeerCertificates( return ptrs; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetCipherSuite")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamGetCipherSuite")] private static extern int SSLStreamGetCipherSuite(SafeSslHandle ssl, out IntPtr cipherSuite); internal static string SSLStreamGetCipherSuite(SafeSslHandle ssl) { @@ -251,11 +251,11 @@ internal static string SSLStreamGetCipherSuite(SafeSslHandle ssl) return cipherSuite; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamShutdown")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamShutdown")] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool SSLStreamShutdown(SafeSslHandle ssl); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamVerifyHostname")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SSLStreamVerifyHostname")] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool SSLStreamVerifyHostname( SafeSslHandle ssl, diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509.cs index b40581f15b8d2b..5c3f986eb314d3 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509.cs @@ -13,10 +13,10 @@ internal static partial class AndroidCrypto private const int INSUFFICIENT_BUFFER = -1; private const int SUCCESS = 1; - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509Decode")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509Decode")] internal static extern SafeX509Handle X509Decode(ref byte buf, int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509Encode")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509Encode")] private static extern int X509Encode(SafeX509Handle x, [Out] byte[]? buf, ref int len); internal static byte[] X509Encode(SafeX509Handle x) { @@ -33,7 +33,7 @@ internal static byte[] X509Encode(SafeX509Handle x) return encoded; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509DecodeCollection")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509DecodeCollection")] private static extern int X509DecodeCollection(ref byte buf, int bufLen, IntPtr[]? ptrs, ref int handlesLen); internal static SafeX509Handle[] X509DecodeCollection(ReadOnlySpan data) { @@ -60,7 +60,7 @@ internal static SafeX509Handle[] X509DecodeCollection(ReadOnlySpan data) return handles; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ExportPkcs7")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ExportPkcs7")] private static extern int X509ExportPkcs7(IntPtr[] certs, int certsLen, [Out] byte[]? buf, ref int len); internal static byte[] X509ExportPkcs7(IntPtr[] certHandles) { @@ -77,7 +77,7 @@ internal static byte[] X509ExportPkcs7(IntPtr[] certHandles) return encoded; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509GetContentType")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509GetContentType")] private static extern X509ContentType X509GetContentType(ref byte buf, int len); internal static X509ContentType X509GetContentType(ReadOnlySpan data) { @@ -92,7 +92,7 @@ internal enum PAL_KeyAlgorithm UnknownAlgorithm = -1, } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509PublicKey")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509PublicKey")] internal static extern IntPtr X509GetPublicKey(SafeX509Handle x, PAL_KeyAlgorithm algorithm); } } diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Chain.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Chain.cs index 2590f256925e2a..e0ba47617f0b5a 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Chain.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Chain.cs @@ -12,25 +12,25 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainCreateContext")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainCreateContext")] internal static extern SafeX509ChainContextHandle X509ChainCreateContext( SafeX509Handle cert, IntPtr[] extraStore, int extraStoreLen); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainDestroyContext")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainDestroyContext")] internal static extern void X509ChainDestroyContext(IntPtr ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainBuild")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainBuild")] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool X509ChainBuild( SafeX509ChainContextHandle ctx, long timeInMsFromUnixEpoch); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainGetCertificateCount")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainGetCertificateCount")] private static extern int X509ChainGetCertificateCount(SafeX509ChainContextHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainGetCertificates")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainGetCertificates")] private static extern int X509ChainGetCertificates( SafeX509ChainContextHandle ctx, IntPtr[] certs, @@ -69,10 +69,10 @@ internal struct ValidationError public int Status; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainGetErrorCount")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainGetErrorCount")] private static extern int X509ChainGetErrorCount(SafeX509ChainContextHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainGetErrors")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainGetErrors")] private static unsafe extern int X509ChainGetErrors( SafeX509ChainContextHandle ctx, [Out] ValidationError[] errors, @@ -92,17 +92,17 @@ internal static ValidationError[] X509ChainGetErrors(SafeX509ChainContextHandle return errors; } - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainSetCustomTrustStore")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainSetCustomTrustStore")] internal static extern int X509ChainSetCustomTrustStore( SafeX509ChainContextHandle ctx, IntPtr[] customTrustStore, int customTrustStoreLen); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainSupportsRevocationOptions")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainSupportsRevocationOptions")] [return:MarshalAs(UnmanagedType.U1)] internal static extern bool X509ChainSupportsRevocationOptions(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainValidate")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509ChainValidate")] internal static extern int X509ChainValidate( SafeX509ChainContextHandle ctx, X509RevocationMode revocationMode, diff --git a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs index 52e12eb9fcd523..5393865243ced5 100644 --- a/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs +++ b/src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.X509Store.cs @@ -11,14 +11,14 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreAddCertificate")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreAddCertificate")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern unsafe bool X509StoreAddCertificate( SafeX509StoreHandle store, SafeX509Handle cert, string hashString); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreAddCertificateWithPrivateKey")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreAddCertificateWithPrivateKey")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern unsafe bool X509StoreAddCertificateWithPrivateKey( SafeX509StoreHandle store, @@ -27,31 +27,31 @@ internal static extern unsafe bool X509StoreAddCertificateWithPrivateKey( PAL_KeyAlgorithm algorithm, string hashString); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreContainsCertificate")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreContainsCertificate")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern unsafe bool X509StoreContainsCertificate( SafeX509StoreHandle store, SafeX509Handle cert, string hashString); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreEnumerateCertificates")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreEnumerateCertificates")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern unsafe bool X509StoreEnumerateCertificates( SafeX509StoreHandle storeHandle, delegate* unmanaged callback, void *callbackContext); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreEnumerateTrustedCertificates")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreEnumerateTrustedCertificates")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern unsafe bool X509StoreEnumerateTrustedCertificates( byte systemOnly, delegate* unmanaged callback, void *callbackContext); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreOpenDefault")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreOpenDefault")] internal static extern unsafe SafeX509StoreHandle X509StoreOpenDefault(); - [DllImport(Libraries.CryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreRemoveCertificate")] + [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_X509StoreRemoveCertificate")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern unsafe bool X509StoreRemoveCertificate( SafeX509StoreHandle store, diff --git a/src/libraries/Common/src/Interop/Unix/Interop.CryptoNative.cs b/src/libraries/Common/src/Interop/Unix/Interop.CryptoNative.cs deleted file mode 100644 index 1c03fbdd6738b8..00000000000000 --- a/src/libraries/Common/src/Interop/Unix/Interop.CryptoNative.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -internal static partial class Interop -{ - internal static partial class Libraries - { - internal const string CryptoNative = "libSystem.Security.Cryptography.Native.OpenSsl"; - } -} \ No newline at end of file diff --git a/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs index 93ded34b368fc6..bccd11e9a517cf 100644 --- a/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs @@ -8,6 +8,7 @@ internal static partial class Libraries // Shims internal const string SystemNative = "libSystem.Native"; internal const string NetSecurityNative = "libSystem.Net.Security.Native"; + internal const string CryptoNative = "libSystem.Security.Cryptography.Native.OpenSsl"; internal const string CompressionNative = "libSystem.IO.Compression.Native"; internal const string GlobalizationNative = "libSystem.Globalization.Native"; internal const string IOPortsNative = "libSystem.IO.Ports.Native"; diff --git a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj index d92276310dc84f..731a0965f297f7 100644 --- a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj +++ b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj @@ -72,6 +72,8 @@ + diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 93902c056b02b5..bbe75c7576a233 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -527,8 +527,6 @@ Link="Common\Interop\Unix\Interop.IOErrors.cs" /> - - + true $(DefineConstants);INTERNAL_ASYMMETRIC_IMPLEMENTATIONS @@ -453,18 +453,10 @@ Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.Nid.cs" /> - - - - - - - + + @@ -601,8 +593,6 @@ Link="Common\System\Security\Cryptography\ECOpenSsl.cs" /> - + + + + + + + + + + - - - - - - - - + + + + + + diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj b/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj index 56173733fe780b..afce0f5da94a40 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj @@ -320,8 +320,6 @@ - Date: Thu, 13 May 2021 18:51:34 -0400 Subject: [PATCH 10/10] correct wrong filename --- .../src/System.Security.Cryptography.Algorithms.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj b/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj index 19f73f72608f7a..833822b03c7fdc 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj @@ -453,7 +453,7 @@ Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.Nid.cs" /> -