diff --git a/src/libraries/Common/src/Interop/Android/Interop.JObjectLifetime.cs b/src/libraries/Common/src/Interop/Android/Interop.JObjectLifetime.cs index 77a8f42da866d..6dc8dee6c26e9 100644 --- a/src/libraries/Common/src/Interop/Android/Interop.JObjectLifetime.cs +++ b/src/libraries/Common/src/Interop/Android/Interop.JObjectLifetime.cs @@ -10,11 +10,11 @@ internal static partial class Interop { internal static partial class JObjectLifetime { - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_NewGlobalReference")] - internal static extern IntPtr NewGlobalReference(IntPtr obj); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_NewGlobalReference")] + internal static partial IntPtr NewGlobalReference(IntPtr obj); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DeleteGlobalReference")] - internal static extern void DeleteGlobalReference(IntPtr obj); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DeleteGlobalReference")] + internal static partial void DeleteGlobalReference(IntPtr obj); internal class SafeJObjectHandle : SafeHandle { 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 42caf771e436d..3bbc00aab0a8b 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,11 +10,11 @@ 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.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_BigNumToBinary")] - private static extern unsafe int BigNumToBinary(SafeBignumHandle a, byte* to); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_BigNumToBinary")] + private static unsafe partial int BigNumToBinary(SafeBignumHandle a, byte* to); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetBigNumBytes")] - private static extern int GetBigNumBytes(SafeBignumHandle a); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetBigNumBytes")] + private static partial 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 42020d9217b9a..39c980bdfab12 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,21 +10,21 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCreate")] - internal static extern SafeEvpCipherCtxHandle EvpCipherCreate( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCreate")] + internal static partial SafeEvpCipherCtxHandle EvpCipherCreate( IntPtr cipher, ref byte key, int keyLength, ref byte iv, int enc); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCreatePartial")] - internal static extern SafeEvpCipherCtxHandle EvpCipherCreatePartial( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCreatePartial")] + internal static partial SafeEvpCipherCtxHandle EvpCipherCreatePartial( IntPtr cipher); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetKeyAndIV")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetKeyAndIV")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherSetKeyAndIV( + private static partial bool EvpCipherSetKeyAndIV( SafeEvpCipherCtxHandle ctx, ref byte key, ref byte iv, @@ -46,9 +46,9 @@ ref MemoryMarshal.GetReference(iv), } } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetNonceLength")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetNonceLength")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool AndroidCryptoNative_CipherSetNonceLength( + private static partial bool AndroidCryptoNative_CipherSetNonceLength( SafeEvpCipherCtxHandle ctx, int nonceLength); internal static void CipherSetNonceLength(SafeEvpCipherCtxHandle ctx, int nonceLength) @@ -59,20 +59,20 @@ internal static void CipherSetNonceLength(SafeEvpCipherCtxHandle ctx, int nonceL } } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherDestroy")] - internal static extern void EvpCipherDestroy(IntPtr ctx); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherDestroy")] + internal static partial void EvpCipherDestroy(IntPtr ctx); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherReset")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherReset")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EvpCipherReset(SafeEvpCipherCtxHandle ctx); + internal static partial bool EvpCipherReset(SafeEvpCipherCtxHandle ctx); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCtxSetPadding")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherCtxSetPadding")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EvpCipherCtxSetPadding(SafeEvpCipherCtxHandle x, int padding); + internal static partial bool EvpCipherCtxSetPadding(SafeEvpCipherCtxHandle x, int padding); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherUpdate")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherUpdate")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherUpdate( + private static partial bool EvpCipherUpdate( SafeEvpCipherCtxHandle ctx, ref byte @out, out int outl, @@ -93,9 +93,9 @@ ref MemoryMarshal.GetReference(input), input.Length); } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherUpdateAAD")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherUpdateAAD")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CipherUpdateAAD( + private static partial bool CipherUpdateAAD( SafeEvpCipherCtxHandle ctx, ref byte @in, int inl); @@ -113,9 +113,9 @@ ref MemoryMarshal.GetReference(input), } } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherFinalEx")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherFinalEx")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool EvpCipherFinalEx( + private static partial bool EvpCipherFinalEx( SafeEvpCipherCtxHandle ctx, ref byte outm, out int outl); @@ -128,99 +128,99 @@ internal static bool EvpCipherFinalEx( return EvpCipherFinalEx(ctx, ref MemoryMarshal.GetReference(output), out bytesWritten); } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetTagLength")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherSetTagLength")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CipherSetTagLength( + internal static partial bool CipherSetTagLength( SafeEvpCipherCtxHandle ctx, int tagLength); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherIsSupported")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_CipherIsSupported")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CipherIsSupported(IntPtr cipher); + internal static partial bool CipherIsSupported(IntPtr cipher); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Ecb")] - internal static extern IntPtr EvpAes128Ecb(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Ecb")] + internal static partial IntPtr EvpAes128Ecb(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cbc")] - internal static extern IntPtr EvpAes128Cbc(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cbc")] + internal static partial IntPtr EvpAes128Cbc(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Gcm")] - internal static extern IntPtr EvpAes128Gcm(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Gcm")] + internal static partial IntPtr EvpAes128Gcm(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cfb8")] - internal static extern IntPtr EvpAes128Cfb8(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cfb8")] + internal static partial IntPtr EvpAes128Cfb8(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cfb128")] - internal static extern IntPtr EvpAes128Cfb128(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Cfb128")] + internal static partial IntPtr EvpAes128Cfb128(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Ccm")] - internal static extern IntPtr EvpAes128Ccm(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes128Ccm")] + internal static partial IntPtr EvpAes128Ccm(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Ecb")] - internal static extern IntPtr EvpAes192Ecb(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Ecb")] + internal static partial IntPtr EvpAes192Ecb(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cbc")] - internal static extern IntPtr EvpAes192Cbc(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cbc")] + internal static partial IntPtr EvpAes192Cbc(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Gcm")] - internal static extern IntPtr EvpAes192Gcm(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Gcm")] + internal static partial IntPtr EvpAes192Gcm(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cfb8")] - internal static extern IntPtr EvpAes192Cfb8(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cfb8")] + internal static partial IntPtr EvpAes192Cfb8(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cfb128")] - internal static extern IntPtr EvpAes192Cfb128(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Cfb128")] + internal static partial IntPtr EvpAes192Cfb128(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Ccm")] - internal static extern IntPtr EvpAes192Ccm(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes192Ccm")] + internal static partial IntPtr EvpAes192Ccm(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Ecb")] - internal static extern IntPtr EvpAes256Ecb(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Ecb")] + internal static partial IntPtr EvpAes256Ecb(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cbc")] - internal static extern IntPtr EvpAes256Cbc(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cbc")] + internal static partial IntPtr EvpAes256Cbc(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Gcm")] - internal static extern IntPtr EvpAes256Gcm(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Gcm")] + internal static partial IntPtr EvpAes256Gcm(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cfb128")] - internal static extern IntPtr EvpAes256Cfb128(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cfb128")] + internal static partial IntPtr EvpAes256Cfb128(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cfb8")] - internal static extern IntPtr EvpAes256Cfb8(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Cfb8")] + internal static partial IntPtr EvpAes256Cfb8(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Ccm")] - internal static extern IntPtr EvpAes256Ccm(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Aes256Ccm")] + internal static partial IntPtr EvpAes256Ccm(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesCbc")] - internal static extern IntPtr EvpDesCbc(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesCbc")] + internal static partial IntPtr EvpDesCbc(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesEcb")] - internal static extern IntPtr EvpDesEcb(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesEcb")] + internal static partial IntPtr EvpDesEcb(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesCfb8")] - internal static extern IntPtr EvpDesCfb8(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DesCfb8")] + internal static partial IntPtr EvpDesCfb8(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cbc")] - internal static extern IntPtr EvpDes3Cbc(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cbc")] + internal static partial IntPtr EvpDes3Cbc(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Ecb")] - internal static extern IntPtr EvpDes3Ecb(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Ecb")] + internal static partial IntPtr EvpDes3Ecb(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cfb8")] - internal static extern IntPtr EvpDes3Cfb8(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cfb8")] + internal static partial IntPtr EvpDes3Cfb8(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cfb64")] - internal static extern IntPtr EvpDes3Cfb64(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_Des3Cfb64")] + internal static partial IntPtr EvpDes3Cfb64(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RC2Cbc")] - internal static extern IntPtr EvpRC2Cbc(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RC2Cbc")] + internal static partial IntPtr EvpRC2Cbc(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RC2Ecb")] - internal static extern IntPtr EvpRC2Ecb(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RC2Ecb")] + internal static partial IntPtr EvpRC2Ecb(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_ChaCha20Poly1305")] - internal static extern IntPtr EvpChaCha20Poly1305(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_ChaCha20Poly1305")] + internal static partial IntPtr EvpChaCha20Poly1305(); 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 95a90cb092b99..623b69772d6aa 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,12 +11,12 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaGenerateKey")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaGenerateKey")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DsaGenerateKey(out SafeDsaHandle dsa, int bits); + internal static partial bool DsaGenerateKey(out SafeDsaHandle dsa, int bits); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSizeSignature")] - private static extern int DsaSizeSignature(SafeDsaHandle dsa); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSizeSignature")] + private static partial int DsaSizeSignature(SafeDsaHandle dsa); /// /// Return the maximum size of the DER-encoded key in bytes. @@ -27,8 +27,8 @@ internal static int DsaEncodedSignatureSize(SafeDsaHandle dsa) return size; } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSignatureFieldSize")] - private static extern int AndroidCryptoNative_DsaSignatureFieldSize(SafeDsaHandle dsa); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSignatureFieldSize")] + private static partial int AndroidCryptoNative_DsaSignatureFieldSize(SafeDsaHandle dsa); /// /// Return the size of the 'r' or 's' signature fields in bytes. @@ -41,8 +41,8 @@ internal static int DsaSignatureFieldSize(SafeDsaHandle dsa) return size; } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSizeP")] - private static extern int DsaSizeP(SafeDsaHandle dsa); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSizeP")] + private static partial int DsaSizeP(SafeDsaHandle dsa); /// /// Return the size of the key in bytes. @@ -59,9 +59,9 @@ 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.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaSign")] + [GeneratedDllImport(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); + private static partial bool DsaSign(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte refSignature, out int outSignatureLength); internal static bool DsaVerify(SafeDsaHandle dsa, ReadOnlySpan hash, ReadOnlySpan signature) { @@ -80,8 +80,8 @@ ref MemoryMarshal.GetReference(signature), return ret == 1; } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaVerify")] - private static extern int DsaVerify(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte signature, int signatureLength); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaVerify")] + private static partial int DsaVerify(SafeDsaHandle dsa, ref byte hash, int hashLength, ref byte signature, int signatureLength); internal static DSAParameters ExportDsaParameters(SafeDsaHandle key, bool includePrivateParameters) { @@ -141,9 +141,9 @@ internal static DSAParameters ExportDsaParameters(SafeDsaHandle key, bool includ } } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetDsaParameters")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetDsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool GetDsaParameters( + private static partial bool GetDsaParameters( SafeDsaHandle key, out SafeBignumHandle p, out int p_cb, out SafeBignumHandle q, out int q_cb, @@ -151,9 +151,9 @@ private static extern bool GetDsaParameters( out SafeBignumHandle y, out int y_cb, out SafeBignumHandle x, out int x_cb); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaKeyCreateByExplicitParameters")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DsaKeyCreateByExplicitParameters")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DsaKeyCreateByExplicitParameters( + internal static partial bool DsaKeyCreateByExplicitParameters( out SafeDsaHandle dsa, byte[] p, int pLength, 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 0395a10764ed5..0a309400e001b 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,8 +10,8 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByKeyParameters", CharSet = CharSet.Ansi)] - private static extern int EcKeyCreateByKeyParameters( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByKeyParameters", CharSet = CharSet.Ansi)] + private static partial int EcKeyCreateByKeyParameters( out SafeEcKeyHandle key, string oid, byte[]? qx, int qxLength, @@ -35,8 +35,8 @@ internal static SafeEcKeyHandle EcKeyCreateByKeyParameters( return key; } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByExplicitParameters")] - internal static extern SafeEcKeyHandle EcKeyCreateByExplicitParameters( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByExplicitParameters")] + internal static partial SafeEcKeyHandle EcKeyCreateByExplicitParameters( ECCurve.ECCurveType curveType, byte[]? qx, int qxLength, byte[]? qy, int qyLength, @@ -91,8 +91,8 @@ internal static SafeEcKeyHandle EcKeyCreateByExplicitCurve(ECCurve curve) } - [DllImport(Libraries.AndroidCryptoNative)] - private static extern int AndroidCryptoNative_GetECKeyParameters( + [GeneratedDllImport(Libraries.AndroidCryptoNative)] + private static partial int AndroidCryptoNative_GetECKeyParameters( SafeEcKeyHandle key, bool includePrivate, out SafeBignumHandle qx_bn, out int x_cb, @@ -149,8 +149,8 @@ internal static ECParameters GetECKeyParameters( return parameters; } - [DllImport(Libraries.AndroidCryptoNative)] - private static extern int AndroidCryptoNative_GetECCurveParameters( + [GeneratedDllImport(Libraries.AndroidCryptoNative)] + private static partial int AndroidCryptoNative_GetECCurveParameters( SafeEcKeyHandle key, bool includePrivate, out ECCurve.ECCurveType curveType, 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 53e0dcdddf820..e81681e958ac8 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,9 +12,9 @@ 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.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaSign")] + [GeneratedDllImport(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); + private static partial bool EcDsaSign(ref byte dgst, int dlen, ref byte sig, out int siglen, SafeEcKeyHandle ecKey); internal static int EcDsaVerify(ReadOnlySpan dgst, ReadOnlySpan sigbuf, SafeEcKeyHandle ecKey) { @@ -34,12 +34,12 @@ ref MemoryMarshal.GetReference(sigbuf), * 0: incorrect signature * -1: error */ - [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); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaVerify")] + private static partial 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.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaSize")] - private static extern int AndroidCryptoNative_EcDsaSize(SafeEcKeyHandle ecKey); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcDsaSize")] + private static partial 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 a905d489ea2b4..ca8d82680d1b1 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,8 +10,8 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByOid")] - private static extern SafeEcKeyHandle AndroidCryptoNative_EcKeyCreateByOid(string oid); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyCreateByOid", CharSet = CharSet.Ansi)] + private static partial SafeEcKeyHandle AndroidCryptoNative_EcKeyCreateByOid(string oid); internal static SafeEcKeyHandle? EcKeyCreateByOid(string oid) { SafeEcKeyHandle handle = AndroidCryptoNative_EcKeyCreateByOid(oid); @@ -19,15 +19,15 @@ internal static partial class AndroidCrypto return handle; } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyDestroy")] - internal static extern void EcKeyDestroy(IntPtr a); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyDestroy")] + internal static partial void EcKeyDestroy(IntPtr a); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyUpRef")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyUpRef")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EcKeyUpRef(IntPtr r); + internal static partial bool EcKeyUpRef(IntPtr r); - [DllImport(Libraries.AndroidCryptoNative)] - private static extern int AndroidCryptoNative_EcKeyGetSize(SafeEcKeyHandle ecKey, out int keySize); + [GeneratedDllImport(Libraries.AndroidCryptoNative)] + private static partial int AndroidCryptoNative_EcKeyGetSize(SafeEcKeyHandle ecKey, out int keySize); internal static int EcKeyGetSize(SafeEcKeyHandle key) { int keySize; @@ -39,8 +39,8 @@ internal static int EcKeyGetSize(SafeEcKeyHandle key) throw new CryptographicException(); } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyGetCurveName")] - private static extern int AndroidCryptoNative_EcKeyGetCurveName(SafeEcKeyHandle ecKey, out IntPtr curveName); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcKeyGetCurveName")] + private static partial 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 4ea8ddbc5fabe..c5bbd4c9abebd 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,8 +13,8 @@ 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.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_EcdhDeriveKey")] + [GeneratedDllImport(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); + private static partial 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 index 86259a717ddc0..96d983bf70141 100644 --- 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 @@ -10,23 +10,23 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrClearError")] - internal static extern ulong ErrClearError(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrClearError")] + internal static partial ulong ErrClearError(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrGetErrorAlloc")] - private static extern ulong ErrGetErrorAlloc([MarshalAs(UnmanagedType.Bool)] out bool isAllocFailure); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrGetErrorAlloc")] + private static partial ulong ErrGetErrorAlloc([MarshalAs(UnmanagedType.Bool)] out bool isAllocFailure); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrPeekError")] - internal static extern ulong ErrPeekError(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrPeekError")] + internal static partial ulong ErrPeekError(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrPeekLastError")] - internal static extern ulong ErrPeekLastError(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrPeekLastError")] + internal static partial ulong ErrPeekLastError(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrReasonErrorString")] - internal static extern IntPtr ErrReasonErrorString(ulong error); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrReasonErrorString")] + internal static partial IntPtr ErrReasonErrorString(ulong error); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrErrorStringN")] - private static extern unsafe void ErrErrorStringN(ulong e, byte* buf, int len); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_ErrErrorStringN")] + private static unsafe partial void ErrErrorStringN(ulong e, byte* buf, int len); private static unsafe string ErrErrorStringN(ulong error) { 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 index 03906d6378f6d..b233af7d4dcc4 100644 --- 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 @@ -15,32 +15,32 @@ internal static partial class Crypto private static volatile IntPtr s_evpSha384; private static volatile IntPtr s_evpSha512; - [DllImport(Libraries.AndroidCryptoNative)] - private static extern IntPtr CryptoNative_EvpMd5(); + [GeneratedDllImport(Libraries.AndroidCryptoNative)] + private static partial 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(); + [GeneratedDllImport(Libraries.AndroidCryptoNative)] + internal static partial 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(); + [GeneratedDllImport(Libraries.AndroidCryptoNative)] + internal static partial 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(); + [GeneratedDllImport(Libraries.AndroidCryptoNative)] + internal static partial 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(); + [GeneratedDllImport(Libraries.AndroidCryptoNative)] + internal static partial IntPtr CryptoNative_EvpSha512(); internal static IntPtr EvpSha512() => s_evpSha512 != IntPtr.Zero ? s_evpSha512 : (s_evpSha512 = CryptoNative_EvpSha512()); 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 index 393f1bd7ba59d..251f5bfc22042 100644 --- 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 @@ -10,38 +10,38 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdCtxCreate")] - internal static extern SafeEvpMdCtxHandle EvpMdCtxCreate(IntPtr type); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdCtxCreate")] + internal static partial SafeEvpMdCtxHandle EvpMdCtxCreate(IntPtr type); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdCtxDestroy")] - internal static extern void EvpMdCtxDestroy(IntPtr ctx); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdCtxDestroy")] + internal static partial void EvpMdCtxDestroy(IntPtr ctx); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestReset")] - internal static extern int EvpDigestReset(SafeEvpMdCtxHandle ctx, IntPtr type); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestReset")] + internal static partial 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); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestUpdate")] + private static partial 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); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestFinalEx")] + internal static partial 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); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestCurrent")] + internal static partial 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, uint* mdSize); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestOneShot")] + internal static unsafe partial int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, uint* mdSize); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdSize")] - internal static extern int EvpMdSize(IntPtr md); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpMdSize")] + internal static partial int EvpMdSize(IntPtr md); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_GetMaxMdSize")] - private static extern int GetMaxMdSize(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_GetMaxMdSize")] + private static partial int GetMaxMdSize(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_Pbkdf2")] - private static unsafe extern int Pbkdf2( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_Pbkdf2")] + private static unsafe partial int Pbkdf2( byte* pPassword, int passwordLength, byte* pSalt, 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 index 38ed53453b676..6f9cfefbff4ad 100644 --- 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 @@ -10,29 +10,29 @@ 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); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacCreate")] + internal static partial SafeHmacCtxHandle HmacCreate(ref byte key, int keyLen, IntPtr md); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacDestroy")] - internal static extern void HmacDestroy(IntPtr ctx); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacDestroy")] + internal static partial void HmacDestroy(IntPtr ctx); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacReset")] - internal static extern int HmacReset(SafeHmacCtxHandle ctx); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacReset")] + internal static partial 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); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacUpdate")] + private static partial 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); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacFinal")] + internal static partial 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); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacCurrent")] + internal static partial int HmacCurrent(SafeHmacCtxHandle ctx, ref byte data, ref int len); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacOneShot")] - private static unsafe extern int HmacOneShot(IntPtr type, byte* key, int keySize, byte* source, int sourceSize, byte* md, ref int mdSize); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_HmacOneShot")] + private static unsafe partial int HmacOneShot(IntPtr type, byte* key, int keySize, byte* source, int sourceSize, byte* md, ref int mdSize); internal static unsafe int HmacOneShot(IntPtr type, ReadOnlySpan key, ReadOnlySpan source, Span destination) { 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 index b55f361f6666a..9585bafbc576c 100644 --- 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 @@ -27,7 +27,7 @@ static OpenSsl() } } - internal static class CryptoInitializer + internal static partial class CryptoInitializer { static CryptoInitializer() { @@ -48,7 +48,7 @@ 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(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EnsureOpenSslInitialized")] + private static partial 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 index 964d844f20fa0..fa8e5ff3711b1 100644 --- 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 @@ -15,8 +15,8 @@ internal static unsafe bool GetRandomBytes(byte* pbBuffer, int count) return CryptoNative_GetRandomBytes(pbBuffer, count); } - [DllImport(Libraries.AndroidCryptoNative)] + [GeneratedDllImport(Libraries.AndroidCryptoNative)] [return: MarshalAs(UnmanagedType.Bool)] - private static extern unsafe bool CryptoNative_GetRandomBytes(byte* buf, int num); + private static unsafe partial 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 8d501ecbf2493..2623cbcdcee13 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,21 +11,21 @@ internal static partial class Interop { internal static partial class AndroidCrypto { - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaCreate")] - internal static extern SafeRsaHandle RsaCreate(); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaCreate")] + internal static partial SafeRsaHandle RsaCreate(); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaUpRef")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaUpRef")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool RsaUpRef(IntPtr rsa); + internal static partial bool RsaUpRef(IntPtr rsa); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaDestroy")] - internal static extern void RsaDestroy(IntPtr rsa); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaDestroy")] + internal static partial void RsaDestroy(IntPtr rsa); internal static SafeRsaHandle DecodeRsaSubjectPublicKeyInfo(ReadOnlySpan buf) => DecodeRsaSubjectPublicKeyInfo(ref MemoryMarshal.GetReference(buf), buf.Length); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DecodeRsaSubjectPublicKeyInfo")] - private static extern SafeRsaHandle DecodeRsaSubjectPublicKeyInfo(ref byte buf, int len); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_DecodeRsaSubjectPublicKeyInfo")] + private static partial SafeRsaHandle DecodeRsaSubjectPublicKeyInfo(ref byte buf, int len); internal static int RsaPublicEncrypt( int flen, @@ -35,8 +35,8 @@ internal static int RsaPublicEncrypt( RsaPadding padding) => RsaPublicEncrypt(flen, ref MemoryMarshal.GetReference(from), ref MemoryMarshal.GetReference(to), rsa, padding); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaPublicEncrypt")] - private static extern int RsaPublicEncrypt( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaPublicEncrypt")] + private static partial int RsaPublicEncrypt( int flen, ref byte from, ref byte to, @@ -51,8 +51,8 @@ internal static int RsaPrivateDecrypt( RsaPadding padding) => RsaPrivateDecrypt(flen, ref MemoryMarshal.GetReference(from), ref MemoryMarshal.GetReference(to), rsa, padding); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaPrivateDecrypt")] - private static extern int RsaPrivateDecrypt( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaPrivateDecrypt")] + private static partial int RsaPrivateDecrypt( int flen, ref byte from, ref byte to, @@ -65,8 +65,8 @@ internal static int RsaSignPrimitive( SafeRsaHandle rsa) => RsaSignPrimitive(from.Length, ref MemoryMarshal.GetReference(from), ref MemoryMarshal.GetReference(to), rsa); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaSignPrimitive")] - private static extern int RsaSignPrimitive( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaSignPrimitive")] + private static partial int RsaSignPrimitive( int flen, ref byte from, ref byte to, @@ -78,18 +78,18 @@ internal static int RsaVerificationPrimitive( SafeRsaHandle rsa) => RsaVerificationPrimitive(from.Length, ref MemoryMarshal.GetReference(from), ref MemoryMarshal.GetReference(to), rsa); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaVerificationPrimitive")] - private static extern int RsaVerificationPrimitive( + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaVerificationPrimitive")] + private static partial int RsaVerificationPrimitive( int flen, ref byte from, ref byte to, SafeRsaHandle rsa); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaSize")] - internal static extern int RsaSize(SafeRsaHandle rsa); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaSize")] + internal static partial int RsaSize(SafeRsaHandle rsa); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaGenerateKeyEx")] - internal static extern int RsaGenerateKeyEx(SafeRsaHandle rsa, int bits); + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_RsaGenerateKeyEx")] + internal static partial int RsaGenerateKeyEx(SafeRsaHandle rsa, int bits); internal static RSAParameters ExportRsaParameters(SafeRsaHandle key, bool includePrivateParameters) { @@ -159,9 +159,9 @@ internal static RSAParameters ExportRsaParameters(SafeRsaHandle key, bool includ } } - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetRsaParameters")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_GetRsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool GetRsaParameters( + private static partial bool GetRsaParameters( SafeRsaHandle key, out SafeBignumHandle n, out SafeBignumHandle e, @@ -172,9 +172,9 @@ private static extern bool GetRsaParameters( out SafeBignumHandle dmq1, out SafeBignumHandle iqmp); - [DllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SetRsaParameters")] + [GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "AndroidCryptoNative_SetRsaParameters")] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetRsaParameters( + internal static partial bool SetRsaParameters( SafeRsaHandle key, byte[]? n, int nLength, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Digest.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Digest.cs index 5a6939e0fb4b5..5834de129d765 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Digest.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Digest.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestFree")] - internal static extern void DigestFree(IntPtr handle); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestFree")] + internal static partial void DigestFree(IntPtr handle); [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestCreate")] internal static partial SafeDigestCtxHandle DigestCreate(PAL_HashAlgorithm algorithm, out int cbDigest); @@ -33,8 +33,8 @@ internal static int DigestCurrent(SafeDigestCtxHandle ctx, Span output) => [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestCurrent")] private static partial int DigestCurrent(SafeDigestCtxHandle ctx, ref byte pbOutput, int cbOutput); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestOneShot")] - internal static unsafe extern int DigestOneShot(PAL_HashAlgorithm algorithm, byte* pbData, int cbData, byte* pbOutput, int cbOutput, int* cbDigest); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestOneShot")] + internal static unsafe partial int DigestOneShot(PAL_HashAlgorithm algorithm, byte* pbData, int cbData, byte* pbOutput, int cbOutput, int* cbDigest); [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_DigestReset")] internal static partial int DigestReset(SafeDigestCtxHandle ctx); diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs index 5b4e18c2e71a2..6cf3766ad8ed5 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Hmac.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class AppleCrypto { - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacFree")] - internal static extern void HmacFree(IntPtr handle); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacFree")] + internal static partial void HmacFree(IntPtr handle); [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacCreate")] internal static partial SafeHmacHandle HmacCreate(PAL_HashAlgorithm algorithm, ref int cbDigest); @@ -36,8 +36,8 @@ internal static int HmacCurrent(SafeHmacHandle ctx, ReadOnlySpan output) = [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacCurrent")] private static partial int HmacCurrent(SafeHmacHandle ctx, ref byte pbOutput, int cbOutput); - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacOneShot")] - internal static unsafe extern int HmacOneShot( + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_HmacOneShot")] + internal static unsafe partial int HmacOneShot( PAL_HashAlgorithm algorithm, byte* pKey, int cbKey, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Pbkdf2.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Pbkdf2.cs index 04fc12ac935e3..dac63e66f987e 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Pbkdf2.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Pbkdf2.cs @@ -48,8 +48,8 @@ internal static unsafe void Pbkdf2( } } - [DllImport(Libraries.AppleCryptoNative)] - private static extern unsafe int AppleCryptoNative_Pbkdf2( + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static unsafe partial int AppleCryptoNative_Pbkdf2( PAL_HashAlgorithm prfAlgorithm, byte* password, int passwordLen, diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Random.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Random.cs index aceadb978eae5..2832aa3d9c0f1 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Random.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Random.cs @@ -27,7 +27,7 @@ internal static unsafe void GetRandomBytes(byte* pbBuffer, int count) } } - [DllImport(Libraries.AppleCryptoNative)] - private static extern unsafe int AppleCryptoNative_GetRandomBytes(byte* buf, int num, int* errorCode); + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static unsafe partial int AppleCryptoNative_GetRandomBytes(byte* buf, int num, int* errorCode); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Symmetric.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Symmetric.cs index bdd2a97f35abc..9e6d56e2e7487 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Symmetric.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Symmetric.cs @@ -42,8 +42,8 @@ internal enum PAL_SymmetricOptions None = 0, } - [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorFree")] - internal static extern void CryptorFree(IntPtr handle); + [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorFree")] + internal static partial void CryptorFree(IntPtr handle); [GeneratedDllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_CryptorCreate")] internal static unsafe partial int CryptorCreate( diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Bignum.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Bignum.cs index b6eb67c99f023..a4ab395987281 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Bignum.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Bignum.cs @@ -10,11 +10,11 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BigNumDestroy")] - internal static extern void BigNumDestroy(IntPtr a); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BigNumDestroy")] + internal static partial void BigNumDestroy(IntPtr a); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BigNumFromBinary")] - private static extern unsafe IntPtr BigNumFromBinary(byte* s, int len); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BigNumFromBinary")] + private static unsafe partial IntPtr BigNumFromBinary(byte* s, int len); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BigNumToBinary")] private static unsafe partial int BigNumToBinary(SafeBignumHandle a, byte* to); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs index 54d868ecc185c..ebce6ab847a03 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs @@ -15,8 +15,8 @@ internal static partial class Crypto [return: MarshalAs(UnmanagedType.Bool)] internal static partial bool DsaUpRef(IntPtr dsa); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaDestroy")] - internal static extern void DsaDestroy(IntPtr dsa); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaDestroy")] + internal static partial void DsaDestroy(IntPtr dsa); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaGenerateKey")] [return: MarshalAs(UnmanagedType.Bool)] diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs index ce77602722126..68d18a56983d4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs @@ -71,8 +71,8 @@ internal static void EvpCipherSetCcmNonceLength(SafeEvpCipherCtxHandle ctx, int } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherDestroy")] - internal static extern void EvpCipherDestroy(IntPtr ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherDestroy")] + internal static partial void EvpCipherDestroy(IntPtr ctx); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpCipherReset")] [return: MarshalAs(UnmanagedType.Bool)] @@ -228,89 +228,89 @@ internal static void EvpCipherSetCcmTagLength(SafeEvpCipherCtxHandle ctx, int ta } } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Ecb")] - internal static extern IntPtr EvpAes128Ecb(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Ecb")] + internal static partial IntPtr EvpAes128Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Cbc")] - internal static extern IntPtr EvpAes128Cbc(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Cbc")] + internal static partial IntPtr EvpAes128Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Gcm")] - internal static extern IntPtr EvpAes128Gcm(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Gcm")] + internal static partial IntPtr EvpAes128Gcm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Cfb8")] - internal static extern IntPtr EvpAes128Cfb8(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Cfb8")] + internal static partial IntPtr EvpAes128Cfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Cfb128")] - internal static extern IntPtr EvpAes128Cfb128(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Cfb128")] + internal static partial IntPtr EvpAes128Cfb128(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Ccm")] - internal static extern IntPtr EvpAes128Ccm(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes128Ccm")] + internal static partial IntPtr EvpAes128Ccm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Ecb")] - internal static extern IntPtr EvpAes192Ecb(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Ecb")] + internal static partial IntPtr EvpAes192Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Cbc")] - internal static extern IntPtr EvpAes192Cbc(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Cbc")] + internal static partial IntPtr EvpAes192Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Gcm")] - internal static extern IntPtr EvpAes192Gcm(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Gcm")] + internal static partial IntPtr EvpAes192Gcm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Cfb8")] - internal static extern IntPtr EvpAes192Cfb8(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Cfb8")] + internal static partial IntPtr EvpAes192Cfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Cfb128")] - internal static extern IntPtr EvpAes192Cfb128(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Cfb128")] + internal static partial IntPtr EvpAes192Cfb128(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Ccm")] - internal static extern IntPtr EvpAes192Ccm(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes192Ccm")] + internal static partial IntPtr EvpAes192Ccm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Ecb")] - internal static extern IntPtr EvpAes256Ecb(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Ecb")] + internal static partial IntPtr EvpAes256Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Cbc")] - internal static extern IntPtr EvpAes256Cbc(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Cbc")] + internal static partial IntPtr EvpAes256Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Gcm")] - internal static extern IntPtr EvpAes256Gcm(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Gcm")] + internal static partial IntPtr EvpAes256Gcm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Cfb128")] - internal static extern IntPtr EvpAes256Cfb128(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Cfb128")] + internal static partial IntPtr EvpAes256Cfb128(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Cfb8")] - internal static extern IntPtr EvpAes256Cfb8(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Cfb8")] + internal static partial IntPtr EvpAes256Cfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Ccm")] - internal static extern IntPtr EvpAes256Ccm(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpAes256Ccm")] + internal static partial IntPtr EvpAes256Ccm(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDesCbc")] - internal static extern IntPtr EvpDesCbc(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDesCbc")] + internal static partial IntPtr EvpDesCbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDesEcb")] - internal static extern IntPtr EvpDesEcb(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDesEcb")] + internal static partial IntPtr EvpDesEcb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDesCfb8")] - internal static extern IntPtr EvpDesCfb8(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDesCfb8")] + internal static partial IntPtr EvpDesCfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDes3Cbc")] - internal static extern IntPtr EvpDes3Cbc(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDes3Cbc")] + internal static partial IntPtr EvpDes3Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDes3Ecb")] - internal static extern IntPtr EvpDes3Ecb(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDes3Ecb")] + internal static partial IntPtr EvpDes3Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDes3Cfb8")] - internal static extern IntPtr EvpDes3Cfb8(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDes3Cfb8")] + internal static partial IntPtr EvpDes3Cfb8(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDes3Cfb64")] - internal static extern IntPtr EvpDes3Cfb64(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDes3Cfb64")] + internal static partial IntPtr EvpDes3Cfb64(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpRC2Cbc")] - internal static extern IntPtr EvpRC2Cbc(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpRC2Cbc")] + internal static partial IntPtr EvpRC2Cbc(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpRC2Ecb")] - internal static extern IntPtr EvpRC2Ecb(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpRC2Ecb")] + internal static partial IntPtr EvpRC2Ecb(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpChaCha20Poly1305")] - internal static extern IntPtr EvpChaCha20Poly1305(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpChaCha20Poly1305")] + internal static partial IntPtr EvpChaCha20Poly1305(); internal enum EvpCipherDirection : int { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.DigestAlgs.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.DigestAlgs.cs index 53ef644d84b97..465d67c0eccfe 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.DigestAlgs.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.DigestAlgs.cs @@ -15,32 +15,32 @@ internal static partial class Crypto private static volatile IntPtr s_evpSha384; private static volatile IntPtr s_evpSha512; - [DllImport(Libraries.CryptoNative)] - private static extern IntPtr CryptoNative_EvpMd5(); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial IntPtr CryptoNative_EvpMd5(); internal static IntPtr EvpMd5() => s_evpMd5 != IntPtr.Zero ? s_evpMd5 : (s_evpMd5 = CryptoNative_EvpMd5()); - [DllImport(Libraries.CryptoNative)] - internal static extern IntPtr CryptoNative_EvpSha1(); + [GeneratedDllImport(Libraries.CryptoNative)] + internal static partial IntPtr CryptoNative_EvpSha1(); internal static IntPtr EvpSha1() => s_evpSha1 != IntPtr.Zero ? s_evpSha1 : (s_evpSha1 = CryptoNative_EvpSha1()); - [DllImport(Libraries.CryptoNative)] - internal static extern IntPtr CryptoNative_EvpSha256(); + [GeneratedDllImport(Libraries.CryptoNative)] + internal static partial IntPtr CryptoNative_EvpSha256(); internal static IntPtr EvpSha256() => s_evpSha256 != IntPtr.Zero ? s_evpSha256 : (s_evpSha256 = CryptoNative_EvpSha256()); - [DllImport(Libraries.CryptoNative)] - internal static extern IntPtr CryptoNative_EvpSha384(); + [GeneratedDllImport(Libraries.CryptoNative)] + internal static partial IntPtr CryptoNative_EvpSha384(); internal static IntPtr EvpSha384() => s_evpSha384 != IntPtr.Zero ? s_evpSha384 : (s_evpSha384 = CryptoNative_EvpSha384()); - [DllImport(Libraries.CryptoNative)] - internal static extern IntPtr CryptoNative_EvpSha512(); + [GeneratedDllImport(Libraries.CryptoNative)] + internal static partial IntPtr CryptoNative_EvpSha512(); internal static IntPtr EvpSha512() => s_evpSha512 != IntPtr.Zero ? s_evpSha512 : (s_evpSha512 = CryptoNative_EvpSha512()); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.cs index 1c853dfb47cc2..42adb07994d2d 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.cs @@ -13,8 +13,8 @@ internal static partial class Crypto [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdCtxCreate")] internal static partial SafeEvpMdCtxHandle EvpMdCtxCreate(IntPtr type); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdCtxDestroy")] - internal static extern void EvpMdCtxDestroy(IntPtr ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdCtxDestroy")] + internal static partial void EvpMdCtxDestroy(IntPtr ctx); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestReset")] internal static partial int EvpDigestReset(SafeEvpMdCtxHandle ctx, IntPtr type); @@ -31,17 +31,17 @@ internal static int EvpDigestUpdate(SafeEvpMdCtxHandle ctx, ReadOnlySpan d [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestCurrent")] internal static partial int EvpDigestCurrent(SafeEvpMdCtxHandle ctx, ref byte md, ref uint s); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestOneShot")] - internal static unsafe extern int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, uint* mdSize); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpDigestOneShot")] + internal static unsafe partial int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, uint* mdSize); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdSize")] - internal static extern int EvpMdSize(IntPtr md); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpMdSize")] + internal static partial int EvpMdSize(IntPtr md); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetMaxMdSize")] - private static extern int GetMaxMdSize(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetMaxMdSize")] + private static partial int GetMaxMdSize(); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pbkdf2")] - private static unsafe extern int Pbkdf2( + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pbkdf2")] + private static unsafe partial int Pbkdf2( byte* pPassword, int passwordLength, byte* pSalt, diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs index 44cc49e07be94..8051dc5bfd3cf 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs @@ -23,8 +23,8 @@ internal static partial class Crypto return handle; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyDestroy")] - internal static extern void EcKeyDestroy(IntPtr a); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyDestroy")] + internal static partial void EcKeyDestroy(IntPtr a); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyGenerateKey")] [return: MarshalAs(UnmanagedType.Bool)] diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Ecdh.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Ecdh.cs index a097a5bf31ad5..01e12ffbb55bf 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Ecdh.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.Ecdh.cs @@ -20,8 +20,8 @@ private static partial int EvpPKeyDeriveSecretAgreement( uint secretLength, SafeEvpPKeyCtxHandle ctx); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeyCtxDestroy")] - internal static extern void EvpPKeyCtxDestroy(IntPtr ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeyCtxDestroy")] + internal static partial void EvpPKeyCtxDestroy(IntPtr ctx); internal static void EvpPKeyDeriveSecretAgreement(SafeEvpPKeyCtxHandle ctx, Span destination) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs index 0cea642fcf90b..593c6f4e593f6 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.cs @@ -13,8 +13,8 @@ internal static partial class Crypto [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyCreate")] internal static partial SafeEvpPKeyHandle EvpPkeyCreate(); - [DllImport(Libraries.CryptoNative)] - private static extern SafeEvpPKeyHandle CryptoNative_EvpPKeyDuplicate( + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial SafeEvpPKeyHandle CryptoNative_EvpPKeyDuplicate( SafeEvpPKeyHandle currentKey, EvpAlgorithmId algorithmId); @@ -37,8 +37,8 @@ internal static SafeEvpPKeyHandle EvpPKeyDuplicate( return pkey; } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyDestroy")] - internal static extern void EvpPkeyDestroy(IntPtr pkey); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPkeyDestroy")] + internal static partial void EvpPkeyDestroy(IntPtr pkey); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EvpPKeySize")] internal static partial int EvpPKeySize(SafeEvpPKeyHandle pkey); @@ -104,8 +104,8 @@ internal static unsafe SafeEvpPKeyHandle DecodePkcs8PrivateKey( return handle; } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_GetPkcs8PrivateKeySize(IntPtr pkey); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_GetPkcs8PrivateKeySize(IntPtr pkey); private static int GetPkcs8PrivateKeySize(IntPtr pkey) { @@ -119,8 +119,8 @@ private static int GetPkcs8PrivateKeySize(IntPtr pkey) return ret; } - [DllImport(Libraries.CryptoNative)] - private static extern unsafe int CryptoNative_EncodePkcs8PrivateKey(IntPtr pkey, byte* buf); + [GeneratedDllImport(Libraries.CryptoNative)] + private static unsafe partial int CryptoNative_EncodePkcs8PrivateKey(IntPtr pkey, byte* buf); internal static ArraySegment RentEncodePkcs8PrivateKey(SafeEvpPKeyHandle pkey) { @@ -155,8 +155,8 @@ internal static ArraySegment RentEncodePkcs8PrivateKey(SafeEvpPKeyHandle p } } - [DllImport(Libraries.CryptoNative)] - private static extern int CryptoNative_GetSubjectPublicKeyInfoSize(IntPtr pkey); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial int CryptoNative_GetSubjectPublicKeyInfoSize(IntPtr pkey); private static int GetSubjectPublicKeyInfoSize(IntPtr pkey) { @@ -170,8 +170,8 @@ private static int GetSubjectPublicKeyInfoSize(IntPtr pkey) return ret; } - [DllImport(Libraries.CryptoNative)] - private static extern unsafe int CryptoNative_EncodeSubjectPublicKeyInfo(IntPtr pkey, byte* buf); + [GeneratedDllImport(Libraries.CryptoNative)] + private static unsafe partial int CryptoNative_EncodeSubjectPublicKeyInfo(IntPtr pkey, byte* buf); internal static ArraySegment RentEncodeSubjectPublicKeyInfo(SafeEvpPKeyHandle pkey) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs index e689be5b60bcc..88cae2dad5ac1 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Hmac.cs @@ -13,8 +13,8 @@ internal static partial class Crypto [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacCreate")] internal static partial SafeHmacCtxHandle HmacCreate(ref byte key, int keyLen, IntPtr md); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacDestroy")] - internal static extern void HmacDestroy(IntPtr ctx); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacDestroy")] + internal static partial void HmacDestroy(IntPtr ctx); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacReset")] internal static partial int HmacReset(SafeHmacCtxHandle ctx); @@ -31,8 +31,8 @@ internal static int HmacUpdate(SafeHmacCtxHandle ctx, ReadOnlySpan data, i [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacCurrent")] internal static partial int HmacCurrent(SafeHmacCtxHandle ctx, ref byte data, ref int len); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacOneShot")] - private static unsafe extern int HmacOneShot(IntPtr type, byte* key, int keySize, byte* source, int sourceSize, byte* md, int* mdSize); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_HmacOneShot")] + private static unsafe partial int HmacOneShot(IntPtr type, byte* key, int keySize, byte* source, int sourceSize, byte* md, int* mdSize); internal static unsafe int HmacOneShot(IntPtr type, ReadOnlySpan key, ReadOnlySpan source, Span destination) { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LegacyAlgorithms.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LegacyAlgorithms.cs index 5304a67af688a..d3fada1b91498 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LegacyAlgorithms.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.LegacyAlgorithms.cs @@ -10,8 +10,8 @@ internal static partial class Crypto private static volatile bool s_loadedLegacy; private static readonly object s_legacyLoadLock = new object(); - [DllImport(Libraries.CryptoNative)] - private static extern void CryptoNative_RegisterLegacyAlgorithms(); + [GeneratedDllImport(Libraries.CryptoNative)] + private static partial void CryptoNative_RegisterLegacyAlgorithms(); internal static void EnsureLegacyAlgorithmsRegistered() { diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSslAvailable.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSslAvailable.cs index 66b3f72ddd02e..696efb3b209a1 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSslAvailable.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSslAvailable.cs @@ -6,10 +6,10 @@ internal static partial class Interop { - internal static class OpenSslNoInit + internal static partial class OpenSslNoInit { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OpenSslAvailable")] - private static extern int OpenSslAvailable(); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OpenSslAvailable")] + private static partial int OpenSslAvailable(); private static readonly Lazy s_openSslAvailable = new Lazy(() => OpenSslAvailable() != 0); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs index f01afda233ca6..10e501f7631b0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs @@ -15,7 +15,7 @@ internal static unsafe bool GetRandomBytes(byte* pbBuffer, int count) return CryptoNative_GetRandomBytes(pbBuffer, count) != 0; } - [DllImport(Libraries.CryptoNative)] - private static extern unsafe int CryptoNative_GetRandomBytes(byte* buf, int num); + [GeneratedDllImport(Libraries.CryptoNative)] + private static unsafe partial int CryptoNative_GetRandomBytes(byte* buf, int num); } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs index eaafec4d7f807..2ddaade387b70 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs @@ -137,7 +137,7 @@ public static unsafe NTSTATUS BCryptSetIntProperty(SafeBCryptHandle hObject, str } } - internal sealed class SafeAlgorithmHandle : SafeBCryptHandle + internal sealed partial class SafeAlgorithmHandle : SafeBCryptHandle { protected sealed override bool ReleaseHandle() { @@ -145,11 +145,11 @@ protected sealed override bool ReleaseHandle() return ntStatus == 0; } - [DllImport(Libraries.BCrypt)] - private static extern uint BCryptCloseAlgorithmProvider(IntPtr hAlgorithm, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt)] + private static partial uint BCryptCloseAlgorithmProvider(IntPtr hAlgorithm, int dwFlags); } - internal sealed class SafeKeyHandle : SafeBCryptHandle + internal sealed partial class SafeKeyHandle : SafeBCryptHandle { private SafeAlgorithmHandle? _parentHandle; @@ -177,7 +177,7 @@ protected sealed override bool ReleaseHandle() return ntStatus == 0; } - [DllImport(Libraries.BCrypt)] - private static extern uint BCryptDestroyKey(IntPtr hKey); + [GeneratedDllImport(Libraries.BCrypt)] + private static partial uint BCryptDestroyKey(IntPtr hKey); } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCloseAlgorithmProvider.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCloseAlgorithmProvider.cs index 1a08654c8b2b2..8856ae73881b8 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCloseAlgorithmProvider.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptCloseAlgorithmProvider.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class BCrypt { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static extern NTSTATUS BCryptCloseAlgorithmProvider(IntPtr hAlgorithm, int dwFlags); + [GeneratedDllImport(Libraries.BCrypt)] + internal static partial NTSTATUS BCryptCloseAlgorithmProvider(IntPtr hAlgorithm, int dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDestroyHash.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDestroyHash.cs index 5466f24e6eec3..0ed212f321030 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDestroyHash.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDestroyHash.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class BCrypt { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static extern NTSTATUS BCryptDestroyHash(IntPtr hHash); + [GeneratedDllImport(Libraries.BCrypt)] + internal static partial NTSTATUS BCryptDestroyHash(IntPtr hHash); } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDestroyKey.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDestroyKey.cs index 329d22cd14903..4cf579126cfb0 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDestroyKey.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDestroyKey.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class BCrypt { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static extern NTSTATUS BCryptDestroyKey(IntPtr hKey); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + internal static partial NTSTATUS BCryptDestroyKey(IntPtr hKey); } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs index d7372bc653271..e6ce2a9db5306 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs @@ -10,7 +10,7 @@ internal static partial class BCrypt { internal const int BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002; - [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + [GeneratedDllImport(Libraries.BCrypt)] internal static unsafe partial NTSTATUS BCryptGenRandom(IntPtr hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs index e93128c465027..e490fe07eaecb 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptHash.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class BCrypt { - [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] - internal static unsafe extern NTSTATUS BCryptHash(nuint hAlgorithm, byte* pbSecret, int cbSecret, byte* pbInput, int cbInput, byte* pbOutput, int cbOutput); + [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)] + internal static unsafe partial NTSTATUS BCryptHash(nuint hAlgorithm, byte* pbSecret, int cbSecret, byte* pbInput, int cbInput, byte* pbOutput, int cbOutput); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertCreateCertificateContext.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertCreateCertificateContext.cs index ece64b3abd651..4b96a878897fd 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertCreateCertificateContext.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertCreateCertificateContext.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Crypt32 { - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe SafeCertContextHandle CertCreateCertificateContext( + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + internal static unsafe partial SafeCertContextHandle CertCreateCertificateContext( MsgEncodingType dwCertEncodingType, void* pbCertEncoded, int cbCertEncoded); diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContext_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContext_IntPtr.cs index 3f952d4413370..804d67115e598 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContext_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertDuplicateCertificateContext_IntPtr.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Crypt32 { - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern IntPtr CertDuplicateCertificateContext(IntPtr pCertContext); + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + internal static partial IntPtr CertDuplicateCertificateContext(IntPtr pCertContext); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetPublicKeyLength.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetPublicKeyLength.cs index 2bafe99799b3d..7bf838e548fa4 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetPublicKeyLength.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertGetPublicKeyLength.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Crypt32 { - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern int CertGetPublicKeyLength(MsgEncodingType dwCertEncodingType, [In] ref CERT_PUBLIC_KEY_INFO pPublicKey); + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial int CertGetPublicKeyLength(MsgEncodingType dwCertEncodingType, ref CERT_PUBLIC_KEY_INFO pPublicKey); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptAcquireCertificatePrivateKey.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptAcquireCertificatePrivateKey.cs index 12e8dd949e222..16989e24a5588 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptAcquireCertificatePrivateKey.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptAcquireCertificatePrivateKey.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Crypt32 { - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool CryptAcquireCertificatePrivateKey( + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial bool CryptAcquireCertificatePrivateKey( SafeCertContextHandle pCert, CryptAcquireCertificatePrivateKeyFlags dwFlags, IntPtr pvParameters, diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObject.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObject.cs index a2975e2a82b43..4f77e5a9e6c00 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObject.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptDecodeObject.cs @@ -13,8 +13,8 @@ internal static unsafe bool CryptDecodeObject(CryptDecodeObjectStructType lpszSt return CryptDecodeObject(MsgEncodingType.All, (IntPtr)lpszStructType, pbEncoded, cbEncoded, 0, pvStructInfo, ref pcbStructInfo); } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern unsafe bool CryptDecodeObject( + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + private static unsafe partial bool CryptDecodeObject( MsgEncodingType dwCertEncodingType, IntPtr lpszStructType, IntPtr pbEncoded, diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptEncodeObject.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptEncodeObject.cs index 454355a75a7b8..cf0d7754abb13 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptEncodeObject.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptEncodeObject.cs @@ -10,15 +10,15 @@ internal static partial class Crypt32 { internal static unsafe bool CryptEncodeObject(MsgEncodingType dwCertEncodingType, CryptDecodeObjectStructType lpszStructType, void* pvStructInfo, byte[]? pbEncoded, ref int pcbEncoded) { - return CryptEncodeObject(dwCertEncodingType, (IntPtr)lpszStructType, pvStructInfo, pbEncoded, ref pcbEncoded); + return CryptEncodeObject(dwCertEncodingType, (nint)lpszStructType, pvStructInfo, pbEncoded, ref pcbEncoded); } - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - private static extern unsafe bool CryptEncodeObject( + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + private static unsafe partial bool CryptEncodeObject( MsgEncodingType dwCertEncodingType, - IntPtr lpszStructType, + nint lpszStructType, void* pvStructInfo, - [Out] byte[]? pbEncoded, - [In, Out] ref int pcbEncoded); + byte[]? pbEncoded, + ref int pcbEncoded); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgControl.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgControl.cs index 6bc536407a9f9..6bd86b24e18e2 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgControl.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgControl.cs @@ -8,18 +8,22 @@ internal static partial class Interop { internal static partial class Crypt32 { +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time + // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we add support for non-blittable struct marshalling. [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool CryptMsgControl( SafeCryptMsgHandle hCryptMsg, int dwFlags, MsgControlType dwCtrlType, - [In] ref CMSG_CTRL_DECRYPT_PARA pvCtrlPara); + ref CMSG_CTRL_DECRYPT_PARA pvCtrlPara); [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern bool CryptMsgControl( SafeCryptMsgHandle hCryptMsg, int dwFlags, MsgControlType dwCtrlType, - [In] ref CMSG_CTRL_KEY_AGREE_DECRYPT_PARA pvCtrlPara); + ref CMSG_CTRL_KEY_AGREE_DECRYPT_PARA pvCtrlPara); +#pragma warning restore DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time + } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgOpenToDecode.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgOpenToDecode.cs index eeab2204e1574..35461f94a4c27 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgOpenToDecode.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgOpenToDecode.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Crypt32 { - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern SafeCryptMsgHandle CryptMsgOpenToDecode( + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + internal static partial SafeCryptMsgHandle CryptMsgOpenToDecode( MsgEncodingType dwMsgEncodingType, int dwFlags, int dwMsgType, diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgOpenToEncode.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgOpenToEncode.cs index c3ef575759960..2d0bfdac4bb75 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgOpenToEncode.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgOpenToEncode.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Crypt32 { - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe SafeCryptMsgHandle CryptMsgOpenToEncode( + [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static unsafe partial SafeCryptMsgHandle CryptMsgOpenToEncode( MsgEncodingType dwMsgEncodingType, int dwFlags, CryptMsgType dwMsgType, diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgUpdate.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgUpdate.cs index cfa26203da764..a30c2d8b74b86 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgUpdate.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptMsgUpdate.cs @@ -9,13 +9,13 @@ internal static partial class Interop { internal static partial class Crypt32 { - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool CryptMsgUpdate(SafeCryptMsgHandle hCryptMsg, [In] byte[] pbData, int cbData, bool fFinal); + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + internal static partial bool CryptMsgUpdate(SafeCryptMsgHandle hCryptMsg, byte[] pbData, int cbData, bool fFinal); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool CryptMsgUpdate(SafeCryptMsgHandle hCryptMsg, IntPtr pbData, int cbData, bool fFinal); + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + internal static partial bool CryptMsgUpdate(SafeCryptMsgHandle hCryptMsg, IntPtr pbData, int cbData, bool fFinal); - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool CryptMsgUpdate(SafeCryptMsgHandle hCryptMsg, ref byte pbData, int cbData, bool fFinal); + [GeneratedDllImport(Libraries.Crypt32, SetLastError = true)] + internal static partial bool CryptMsgUpdate(SafeCryptMsgHandle hCryptMsg, ref byte pbData, int cbData, bool fFinal); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.FindOidInfo.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.FindOidInfo.cs index 3df34615836a6..761a68fbf8fda 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.FindOidInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.FindOidInfo.cs @@ -124,7 +124,7 @@ private static bool OidGroupWillNotUseActiveDirectory(OidGroup group) group == OidGroup.KeyDerivationFunction; } - [DllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode)] - private static extern IntPtr CryptFindOIDInfo(CryptOidInfoKeyType dwKeyType, IntPtr pvKey, OidGroup group); + [GeneratedDllImport(Interop.Libraries.Crypt32)] + private static partial IntPtr CryptFindOIDInfo(CryptOidInfoKeyType dwKeyType, IntPtr pvKey, OidGroup group); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.HashIdAlg.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.HashIdAlg.cs index 926d8f463024e..ec136c7c041ce 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.HashIdAlg.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.HashIdAlg.cs @@ -12,8 +12,8 @@ internal static partial class Crypt32 /// /// Version used for a buffer containing a scalar integer (not an IntPtr) /// - [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode)] - private static unsafe extern IntPtr CryptFindOIDInfo(CryptOidInfoKeyType dwKeyType, int* pvKey, OidGroup group); + [GeneratedDllImport(Libraries.Crypt32)] + private static unsafe partial IntPtr CryptFindOIDInfo(CryptOidInfoKeyType dwKeyType, int* pvKey, OidGroup group); public static CRYPT_OID_INFO FindAlgIdOidInfo(Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM algId) { diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Heap.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Heap.cs index a5198b12a3688..3a55d7109be30 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Heap.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Heap.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode)] - internal static extern IntPtr GetProcessHeap(); + [GeneratedDllImport(Libraries.Kernel32)] + internal static partial IntPtr GetProcessHeap(); [Flags] internal enum HeapAllocFlags : int @@ -21,15 +21,10 @@ internal enum HeapAllocFlags : int HEAP_GENERATE_EXCEPTIONS = 0x00000004, } - internal static SafeHeapAllocHandle HeapAlloc(IntPtr hHeap, HeapAllocFlags dwFlags, int dwBytes) - { - return HeapAlloc(hHeap, dwFlags, new IntPtr(dwBytes)); - } - - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode)] - private static extern SafeHeapAllocHandle HeapAlloc(IntPtr hHeap, HeapAllocFlags dwFlags, IntPtr dwBytes); + [GeneratedDllImport(Libraries.Kernel32)] + internal static partial SafeHeapAllocHandle HeapAlloc(IntPtr hHeap, HeapAllocFlags dwFlags, nint dwBytes); - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode)] - internal static extern bool HeapFree(IntPtr hHeap, HeapAllocFlags dwFlags, IntPtr lpMem); + [GeneratedDllImport(Libraries.Kernel32)] + internal static partial bool HeapFree(IntPtr hHeap, HeapAllocFlags dwFlags, IntPtr lpMem); } } diff --git a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptFreeObject.cs b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptFreeObject.cs index 3e5b6ef367433..d97f1b1a94135 100644 --- a/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptFreeObject.cs +++ b/src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptFreeObject.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class NCrypt { - [DllImport(Interop.Libraries.NCrypt, CharSet = CharSet.Unicode)] - internal static extern ErrorCode NCryptFreeObject(IntPtr hObject); + [GeneratedDllImport(Interop.Libraries.NCrypt)] + internal static partial ErrorCode NCryptFreeObject(IntPtr hObject); } }