Added nullability to Vanara.PInvoke.Cryptography

nullableenabled
David Hall 2023-02-20 15:35:21 -07:00
parent 20011e1970
commit 523b1a5e75
27 changed files with 58657 additions and 58650 deletions

View File

@ -6,8 +6,8 @@ using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.NCrypt;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in BCrypt.dll.</summary>
public static partial class BCrypt
{
@ -1125,7 +1125,8 @@ namespace Vanara.PInvoke
// cbSecret, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "deb02f67-f3d3-4542-8245-fd4982c3190b")]
public static extern NTStatus BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, SafeAllocatedMemoryHandle pbHashObject, uint cbHashObject, [Optional] IntPtr pbSecret, [Optional] uint cbSecret, AlgProviderFlags dwFlags = 0);
public static extern NTStatus BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, SafeAllocatedMemoryHandle pbHashObject,
uint cbHashObject, [Optional] IntPtr pbSecret, [Optional] uint cbSecret, AlgProviderFlags dwFlags = 0);
/// <summary>
/// <para>The <c>BCryptCreateHash</c> function is called to create a hash or Message Authentication Code (MAC) object.</para>
@ -1240,7 +1241,8 @@ namespace Vanara.PInvoke
// cbSecret, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "deb02f67-f3d3-4542-8245-fd4982c3190b", MinClient = PInvokeClient.Windows7)]
public static extern NTStatus BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, [Optional] IntPtr pbHashObject, [Optional] uint cbHashObject, [Optional] IntPtr pbSecret, [Optional] uint cbSecret, AlgProviderFlags dwFlags = 0);
public static extern NTStatus BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, [Optional] IntPtr pbHashObject,
[Optional] uint cbHashObject, [Optional] IntPtr pbSecret, [Optional] uint cbSecret, AlgProviderFlags dwFlags = 0);
/// <summary>
/// <para>
@ -1434,7 +1436,8 @@ namespace Vanara.PInvoke
// ULONG cbSecret, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "AAF91460-AEFB-4E16-91EA-4A60272B3839", MinClient = PInvokeClient.Windows7)]
public static extern NTStatus BCryptCreateMultiHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, uint nHashes, [Optional] IntPtr pbHashObject, [Optional] uint cbHashObject, SafeAllocatedMemoryHandle pbSecret, uint cbSecret, AlgProviderFlags dwFlags);
public static extern NTStatus BCryptCreateMultiHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, uint nHashes,
[Optional] IntPtr pbHashObject, [Optional] uint cbHashObject, SafeAllocatedMemoryHandle pbSecret, uint cbSecret, AlgProviderFlags dwFlags);
/// <summary>
/// <para>The <c>BCryptDecrypt</c> function decrypts a block of data.</para>
@ -1610,7 +1613,8 @@ namespace Vanara.PInvoke
// *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "62286f6b-0d57-4691-83fc-2b9a9740af71")]
public static extern NTStatus BCryptDecrypt(BCRYPT_KEY_HANDLE hKey, SafeAllocatedMemoryHandle pbInput, uint cbInput, IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbIV, uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
public static extern NTStatus BCryptDecrypt(BCRYPT_KEY_HANDLE hKey, SafeAllocatedMemoryHandle pbInput, uint cbInput, IntPtr pPaddingInfo,
SafeAllocatedMemoryHandle pbIV, uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
/// <summary>
/// <para>The <c>BCryptDecrypt</c> function decrypts a block of data.</para>
@ -2167,7 +2171,7 @@ namespace Vanara.PInvoke
// ULONG *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "33c3cbf7-6c08-42ed-ac3f-feb71f3a9cbf")]
public static extern NTStatus BCryptDeriveKey(BCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc pParameterList, SafeAllocatedMemoryHandle pbDerivedKey,
public static extern NTStatus BCryptDeriveKey(BCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc? pParameterList, SafeAllocatedMemoryHandle pbDerivedKey,
uint cbDerivedKey, out uint pcbResult, DeriveKeyFlags dwFlags);
/// <summary>The <c>BCryptDeriveKey</c> function derives a key from a secret agreement value.</summary>
@ -2491,8 +2495,8 @@ namespace Vanara.PInvoke
// ULONG *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "33c3cbf7-6c08-42ed-ac3f-feb71f3a9cbf")]
public static extern NTStatus BCryptDeriveKey(BCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc pParameterList, [Optional] IntPtr pbDerivedKey,
[Optional] uint cbDerivedKey, out uint pcbResult, DeriveKeyFlags dwFlags);
public static extern NTStatus BCryptDeriveKey(BCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF,
[Optional] NCryptBufferDesc? pParameterList, [Optional] IntPtr pbDerivedKey, [Optional] uint cbDerivedKey, out uint pcbResult, DeriveKeyFlags dwFlags);
/// <summary>
/// <para>The <c>BCryptDeriveKeyCapi</c> function derives a key from a hash value.</para>
@ -3303,7 +3307,8 @@ namespace Vanara.PInvoke
// *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "69fe4530-4b7c-40db-a85c-f9dc458735e7")]
public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbIV, uint cbIV, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo,
SafeAllocatedMemoryHandle pbIV, uint cbIV, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
/// <summary>The <c>BCryptEncrypt</c> function encrypts a block of data.</summary>
/// <param name="hKey">
@ -3462,7 +3467,8 @@ namespace Vanara.PInvoke
// *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "69fe4530-4b7c-40db-a85c-f9dc458735e7")]
public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbIV, uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo,
SafeAllocatedMemoryHandle pbIV, uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
/// <summary>The <c>BCryptEncrypt</c> function encrypts a block of data.</summary>
/// <param name="hKey">
@ -3621,7 +3627,8 @@ namespace Vanara.PInvoke
// *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "69fe4530-4b7c-40db-a85c-f9dc458735e7")]
public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo, [Optional] IntPtr pbIV, [Optional] uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo,
[Optional] IntPtr pbIV, [Optional] uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
/// <summary>The <c>BCryptEnumAlgorithms</c> function gets a list of the registered algorithm identifiers.</summary>
/// <param name="dwAlgOperations">
@ -3740,7 +3747,7 @@ namespace Vanara.PInvoke
public static BCRYPT_ALGORITHM_IDENTIFIER[] BCryptEnumAlgorithms(AlgOperations dwAlgOperations)
{
BCryptEnumAlgorithms(dwAlgOperations, out var sz, out var mem).ThrowIfFailed();
return mem.DangerousGetHandle().ToArray<BCRYPT_ALGORITHM_IDENTIFIER>((int)sz);
return mem.DangerousGetHandle().ToArray<BCRYPT_ALGORITHM_IDENTIFIER>((int)sz)!;
}
/// <summary>
@ -3953,7 +3960,7 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>An array of strings that contains the identifiers of the function providers contained in this set.</returns>
[PInvokeData("bcrypt.h", MSDNShortId = "82776e61-03bb-463b-8767-fa4f70fe1341")]
public static string[] BCryptEnumContextFunctionProviders(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction)
public static string?[] BCryptEnumContextFunctionProviders(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction)
{
BCryptEnumContextFunctionProviders(dwTable, pszContext, dwInterface, pszFunction, out var _, out var mem).ThrowIfFailed();
return mem.ToStructure<CRYPT_CONTEXT_FUNCTION_PROVIDERS>()._rgpszProviders.ToArray();
@ -4157,7 +4164,7 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>An array of strings that contains the names of the identifiers of the cryptographic functions.</returns>
[PInvokeData("bcrypt.h", MSDNShortId = "81bdfd47-7001-4e63-a8b3-33dae99f2c66")]
public static string[] BCryptEnumContextFunctions(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface)
public static string?[] BCryptEnumContextFunctions(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface)
{
BCryptEnumContextFunctions(dwTable, pszContext, dwInterface, out _, out var buf).ThrowIfFailed();
return buf.ToStructure<CRYPT_CONTEXT_FUNCTIONS>()._rgpszFunctions.ToArray();
@ -4278,7 +4285,7 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>An array of strings that contains the names of the identifiers of the contexts.</returns>
[PInvokeData("bcrypt.h", MSDNShortId = "02646a80-6e93-4169-83da-0488ff3da56f")]
public static string[] BCryptEnumContexts(ContextConfigTable dwTable)
public static string?[] BCryptEnumContexts(ContextConfigTable dwTable)
{
BCryptEnumContexts(dwTable, out _, out var buf).ThrowIfFailed();
return buf.ToStructure<CRYPT_CONTEXTS>()._rgpszContexts.ToArray();
@ -4340,7 +4347,7 @@ namespace Vanara.PInvoke
public static string[] BCryptEnumProviders(string pszAlgId)
{
BCryptEnumProviders(pszAlgId, out var sz, out var buf).ThrowIfFailed();
return buf.DangerousGetHandle().ToArray<BCRYPT_PROVIDER_NAME>((int)sz).Select(s => s.pszProviderName).ToArray();
return Array.ConvertAll(buf.DangerousGetHandle().ToArray<BCRYPT_PROVIDER_NAME>((int)sz)!, s => s.pszProviderName);
}
/// <summary>The <c>BCryptEnumRegisteredProviders</c> function retrieves information about the registered providers.</summary>
@ -4428,7 +4435,7 @@ namespace Vanara.PInvoke
/// <summary>The <c>BCryptEnumRegisteredProviders</c> function retrieves information about the registered providers.</summary>
/// <returns>An array of strings that contains the names of the registered providers.</returns>
[PInvokeData("bcrypt.h", MSDNShortId = "a01adfec-dbe0-4817-af97-63163760fafc")]
public static string[] BCryptEnumRegisteredProviders()
public static string?[] BCryptEnumRegisteredProviders()
{
BCryptEnumRegisteredProviders(out _, out var buf).ThrowIfFailed();
return buf.ToStructure<CRYPT_PROVIDERS>()._rgpszProviders.ToArray();
@ -4856,7 +4863,8 @@ namespace Vanara.PInvoke
// hKey, BCRYPT_KEY_HANDLE hExportKey, LPCWSTR pszBlobType, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "a5d73143-c1d6-43b3-a724-7e27c68a5ade")]
public static extern NTStatus BCryptExportKey(BCRYPT_KEY_HANDLE hKey, BCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, uint dwFlags = 0);
public static extern NTStatus BCryptExportKey(BCRYPT_KEY_HANDLE hKey, BCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType,
[Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, uint dwFlags = 0);
/// <summary>
/// The <c>BCryptFinalizeKeyPair</c> function completes a public/private key pair. The key cannot be used until this function has
@ -5210,7 +5218,8 @@ namespace Vanara.PInvoke
// pbSecret, ULONG cbSecret, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "c55d714f-f47e-4ddf-97b9-985c0441bb2d")]
public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] SafeAllocatedMemoryHandle pbKeyObject, [Optional] uint cbKeyObject, byte[] pbSecret, uint cbSecret, uint dwFlags = 0);
public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey,
[Optional] SafeAllocatedMemoryHandle pbKeyObject, [Optional] uint cbKeyObject, byte[] pbSecret, uint cbSecret, uint dwFlags = 0);
/// <summary>
/// The <c>BCryptGenerateSymmetricKey</c> function creates a key object for use with a symmetrical key encryption algorithm from a
@ -5302,7 +5311,8 @@ namespace Vanara.PInvoke
// pbSecret, ULONG cbSecret, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "c55d714f-f47e-4ddf-97b9-985c0441bb2d")]
public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject, [Optional] uint cbKeyObject, byte[] pbSecret, uint cbSecret, uint dwFlags = 0);
public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject,
[Optional] uint cbKeyObject, byte[] pbSecret, uint cbSecret, uint dwFlags = 0);
/// <summary>
/// The <c>BCryptGenerateSymmetricKey</c> function creates a key object for use with a symmetrical key encryption algorithm from a
@ -5394,7 +5404,8 @@ namespace Vanara.PInvoke
// pbSecret, ULONG cbSecret, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "c55d714f-f47e-4ddf-97b9-985c0441bb2d")]
public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject, [Optional] uint cbKeyObject, IntPtr pbSecret, uint cbSecret, uint dwFlags = 0);
public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject,
[Optional] uint cbKeyObject, IntPtr pbSecret, uint cbSecret, uint dwFlags = 0);
/// <summary>The <c>BCryptGenRandom</c> function generates a random number.</summary>
/// <param name="hAlgorithm">
@ -5684,7 +5695,7 @@ namespace Vanara.PInvoke
using var mem = SafeCoTaskMemHandle.CreateFromStructure<T>();
BCryptGetProperty(hObject, pszProperty, mem, (uint)mem.Size, out var sz).ThrowIfFailed();
if (mem.Size != sz) throw new InvalidCastException("Requested type and system defined sizes do not match.");
return mem.ToStructure<T>();
return mem.ToStructure<T>()!;
}
/// <summary>
@ -6165,7 +6176,8 @@ namespace Vanara.PInvoke
// PUCHAR pbInput, ULONG cbInput, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "6b9683f4-10f2-40e4-9757-a1f01991bef7")]
public static extern NTStatus BCryptImportKey(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject, [Optional] uint cbKeyObject, IntPtr pbInput, uint cbInput, uint dwFlags = 0);
public static extern NTStatus BCryptImportKey(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType,
out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject, [Optional] uint cbKeyObject, IntPtr pbInput, uint cbInput, uint dwFlags = 0);
/// <summary>
/// The <c>BCryptImportKeyPair</c> function imports a public/private key pair from a key BLOB. The BCryptImportKey function is used
@ -6369,7 +6381,8 @@ namespace Vanara.PInvoke
// cbInput, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "271fc084-6121-4666-b521-b849c7d7966c")]
public static extern NTStatus BCryptImportKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, [Optional] BCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbInput, [Optional] uint cbInput, ImportFlags dwFlags = 0);
public static extern NTStatus BCryptImportKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, [Optional] BCRYPT_KEY_HANDLE hImportKey,
[MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbInput, [Optional] uint cbInput, ImportFlags dwFlags = 0);
/// <summary>
/// The <c>BCryptImportKeyPair</c> function imports a public/private key pair from a key BLOB. The BCryptImportKey function is used
@ -6573,7 +6586,8 @@ namespace Vanara.PInvoke
// cbInput, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "271fc084-6121-4666-b521-b849c7d7966c")]
public static extern NTStatus BCryptImportKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, [Optional] BCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, SafeAllocatedMemoryHandle pbInput, uint cbInput, ImportFlags dwFlags = 0);
public static extern NTStatus BCryptImportKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, [Optional] BCRYPT_KEY_HANDLE hImportKey,
[MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, SafeAllocatedMemoryHandle pbInput, uint cbInput, ImportFlags dwFlags = 0);
/// <summary>
/// <para>
@ -6754,7 +6768,8 @@ namespace Vanara.PInvoke
// BCRYPT_KEY_HANDLE hKey, BCryptBufferDesc *pParameterList, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "D0B91FFE-2E72-4AE3-A84F-DC598C02CF53")]
public static extern NTStatus BCryptKeyDerivation(BCRYPT_KEY_HANDLE hKey, [Optional] NCryptBufferDesc pParameterList, IntPtr pbDerivedKey, uint cbDerivedKey, out uint pcbResult, KeyDerivationFlags dwFlags);
public static extern NTStatus BCryptKeyDerivation(BCRYPT_KEY_HANDLE hKey, [Optional] NCryptBufferDesc? pParameterList, IntPtr pbDerivedKey,
uint cbDerivedKey, out uint pcbResult, KeyDerivationFlags dwFlags);
/// <summary>
/// <para>
@ -6935,7 +6950,8 @@ namespace Vanara.PInvoke
// BCRYPT_KEY_HANDLE hKey, BCryptBufferDesc *pParameterList, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "D0B91FFE-2E72-4AE3-A84F-DC598C02CF53")]
public static extern NTStatus BCryptKeyDerivation(BCRYPT_KEY_HANDLE hKey, [Optional] NCryptBufferDesc pParameterList, SafeAllocatedMemoryHandle pbDerivedKey, uint cbDerivedKey, out uint pcbResult, KeyDerivationFlags dwFlags);
public static extern NTStatus BCryptKeyDerivation(BCRYPT_KEY_HANDLE hKey, [Optional] NCryptBufferDesc? pParameterList,
SafeAllocatedMemoryHandle pbDerivedKey, uint cbDerivedKey, out uint pcbResult, KeyDerivationFlags dwFlags);
/// <summary>
/// <para>The <c>BCryptOpenAlgorithmProvider</c> function loads and initializes a CNG provider.</para>
@ -7060,7 +7076,7 @@ namespace Vanara.PInvoke
// BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *phAlgorithm, LPCWSTR pszAlgId, LPCWSTR pszImplementation, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("bcrypt.h", MSDNShortId = "aceba9c0-19e6-4f3c-972a-752feed4a9f8")]
public static extern NTStatus BCryptOpenAlgorithmProvider(out SafeBCRYPT_ALG_HANDLE phAlgorithm, string pszAlgId, [Optional] string pszImplementation, AlgProviderFlags dwFlags = 0);
public static extern NTStatus BCryptOpenAlgorithmProvider(out SafeBCRYPT_ALG_HANDLE phAlgorithm, string pszAlgId, [Optional] string? pszImplementation, AlgProviderFlags dwFlags = 0);
/// <summary>
/// <para>The <c>BCryptProcessMultiOperations</c> function processes a sequence of operations on a multi-object state.</para>
@ -7959,7 +7975,7 @@ namespace Vanara.PInvoke
// PCRYPT_PROVIDER_REFS *ppBuffer );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("bcrypt.h", MSDNShortId = "cf30f635-4918-4911-9db0-df90d26a2f1a")]
public static extern NTStatus BCryptResolveProviders([Optional] string pszContext, InterfaceId dwInterface, [Optional] string pszFunction, [Optional] string pszProvider, ProviderInfoType dwMode,
public static extern NTStatus BCryptResolveProviders([Optional] string? pszContext, InterfaceId dwInterface, [Optional] string? pszFunction, [Optional] string? pszProvider, ProviderInfoType dwMode,
ResolveProviderFlags dwFlags, out uint pcbBuffer, out SafeBCryptBuffer ppBuffer);
/// <summary>
@ -8502,7 +8518,8 @@ namespace Vanara.PInvoke
// hKey, VOID *pPaddingInfo, PUCHAR pbInput, ULONG cbInput, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "f402ea9e-89ae-4ccc-9591-aa2328287c0e")]
public static extern NTStatus BCryptSignHash(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbInput, uint cbInput, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
public static extern NTStatus BCryptSignHash(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbInput,
uint cbInput, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
/// <summary>
/// <para>The <c>BCryptSignHash</c> function creates a signature of a hash value.</para>
@ -8613,7 +8630,8 @@ namespace Vanara.PInvoke
// hKey, VOID *pPaddingInfo, PUCHAR pbInput, ULONG cbInput, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "f402ea9e-89ae-4ccc-9591-aa2328287c0e")]
public static extern NTStatus BCryptSignHash(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbInput, uint cbInput, [Optional] IntPtr pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
public static extern NTStatus BCryptSignHash(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbInput,
uint cbInput, [Optional] IntPtr pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags);
/// <summary>
/// The <c>BCryptUnregisterConfigChangeNotify(PRKEVENT)</c> function removes a kernel mode CNG configuration change event handler
@ -8764,7 +8782,8 @@ namespace Vanara.PInvoke
// BCRYPT_KEY_HANDLE hKey, VOID *pPaddingInfo, PUCHAR pbHash, ULONG cbHash, PUCHAR pbSignature, ULONG cbSignature, ULONG dwFlags );
[DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("bcrypt.h", MSDNShortId = "95c32056-e444-441c-bbc1-c5ae82aba964")]
public static extern NTStatus BCryptVerifySignature(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbHash, uint cbHash, SafeAllocatedMemoryHandle pbSignature, uint cbSignature, EncryptFlags dwFlags);
public static extern NTStatus BCryptVerifySignature(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbHash,
uint cbHash, SafeAllocatedMemoryHandle pbSignature, uint cbSignature, EncryptFlags dwFlags);
/// <summary>Provides a handle to an algorithm provider.</summary>
[StructLayout(LayoutKind.Sequential)]
@ -8777,7 +8796,7 @@ namespace Vanara.PInvoke
public BCRYPT_ALG_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="BCRYPT_ALG_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static BCRYPT_ALG_HANDLE NULL => new BCRYPT_ALG_HANDLE(IntPtr.Zero);
public static BCRYPT_ALG_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -8790,7 +8809,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="BCRYPT_ALG_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator BCRYPT_ALG_HANDLE(IntPtr h) => new BCRYPT_ALG_HANDLE(h);
public static implicit operator BCRYPT_ALG_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -8805,7 +8824,7 @@ namespace Vanara.PInvoke
public static bool operator ==(BCRYPT_ALG_HANDLE h1, BCRYPT_ALG_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is BCRYPT_ALG_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is BCRYPT_ALG_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -8856,7 +8875,7 @@ namespace Vanara.PInvoke
public BCRYPT_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="BCRYPT_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static BCRYPT_HANDLE NULL => new BCRYPT_HANDLE(IntPtr.Zero);
public static BCRYPT_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -8869,7 +8888,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="BCRYPT_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator BCRYPT_HANDLE(IntPtr h) => new BCRYPT_HANDLE(h);
public static implicit operator BCRYPT_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -8884,7 +8903,7 @@ namespace Vanara.PInvoke
public static bool operator ==(BCRYPT_HANDLE h1, BCRYPT_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is BCRYPT_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is BCRYPT_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -8904,7 +8923,7 @@ namespace Vanara.PInvoke
public BCRYPT_HASH_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="BCRYPT_HASH_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static BCRYPT_HASH_HANDLE NULL => new BCRYPT_HASH_HANDLE(IntPtr.Zero);
public static BCRYPT_HASH_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -8917,7 +8936,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="BCRYPT_HASH_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator BCRYPT_HASH_HANDLE(IntPtr h) => new BCRYPT_HASH_HANDLE(h);
public static implicit operator BCRYPT_HASH_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -8932,7 +8951,7 @@ namespace Vanara.PInvoke
public static bool operator ==(BCRYPT_HASH_HANDLE h1, BCRYPT_HASH_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is BCRYPT_HASH_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is BCRYPT_HASH_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -8952,7 +8971,7 @@ namespace Vanara.PInvoke
public BCRYPT_KEY_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="BCRYPT_KEY_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static BCRYPT_KEY_HANDLE NULL => new BCRYPT_KEY_HANDLE(IntPtr.Zero);
public static BCRYPT_KEY_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -8965,7 +8984,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="BCRYPT_KEY_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator BCRYPT_KEY_HANDLE(IntPtr h) => new BCRYPT_KEY_HANDLE(h);
public static implicit operator BCRYPT_KEY_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -8980,7 +8999,7 @@ namespace Vanara.PInvoke
public static bool operator ==(BCRYPT_KEY_HANDLE h1, BCRYPT_KEY_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is BCRYPT_KEY_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is BCRYPT_KEY_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -9211,7 +9230,7 @@ namespace Vanara.PInvoke
public BCRYPT_SECRET_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="BCRYPT_SECRET_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static BCRYPT_SECRET_HANDLE NULL => new BCRYPT_SECRET_HANDLE(IntPtr.Zero);
public static BCRYPT_SECRET_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -9224,7 +9243,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="BCRYPT_SECRET_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator BCRYPT_SECRET_HANDLE(IntPtr h) => new BCRYPT_SECRET_HANDLE(h);
public static implicit operator BCRYPT_SECRET_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -9239,7 +9258,7 @@ namespace Vanara.PInvoke
public static bool operator ==(BCRYPT_SECRET_HANDLE h1, BCRYPT_SECRET_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is BCRYPT_SECRET_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is BCRYPT_SECRET_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -9342,7 +9361,7 @@ namespace Vanara.PInvoke
/// </summary>
public IntPtr rgpszProviders;
internal IEnumerable<string> _rgpszProviders => rgpszProviders.ToStringEnum((int)cProviders, CharSet.Unicode);
internal IEnumerable<string?> _rgpszProviders => rgpszProviders.ToStringEnum((int)cProviders, CharSet.Unicode);
}
/// <summary>
@ -9367,7 +9386,7 @@ namespace Vanara.PInvoke
/// </summary>
public IntPtr rgpszFunctions;
internal IEnumerable<string> _rgpszFunctions => rgpszFunctions.ToStringEnum((int)cFunctions, CharSet.Unicode);
internal IEnumerable<string?> _rgpszFunctions => rgpszFunctions.ToStringEnum((int)cFunctions, CharSet.Unicode);
}
/// <summary>
@ -9392,7 +9411,7 @@ namespace Vanara.PInvoke
/// </summary>
public IntPtr rgpszContexts;
internal IEnumerable<string> _rgpszContexts => rgpszContexts.ToStringEnum((int)cContexts, CharSet.Unicode);
internal IEnumerable<string?> _rgpszContexts => rgpszContexts.ToStringEnum((int)cContexts, CharSet.Unicode);
}
/// <summary>
@ -9414,7 +9433,7 @@ namespace Vanara.PInvoke
/// </summary>
public IntPtr rgpszProviders;
internal IEnumerable<string> _rgpszProviders => rgpszProviders.ToStringEnum((int)cProviders, CharSet.Unicode);
internal IEnumerable<string?> _rgpszProviders => rgpszProviders.ToStringEnum((int)cProviders, CharSet.Unicode);
}
/// <summary>Blob type string references.</summary>
@ -10067,10 +10086,9 @@ namespace Vanara.PInvoke
/// <summary>Marshals data to a newly allocated managed object of the type specified by a generic type parameter.</summary>
/// <typeparam name="T">The type of the object to which the data is to be copied. This must be a structure.</typeparam>
/// <returns>A managed object that this buffer points to.</returns>
public T ToStructure<T>() => IsInvalid || IsClosed ? default : handle.ToStructure<T>();
public T? ToStructure<T>() => IsInvalid || IsClosed ? default : handle.ToStructure<T>();
/// <inheritdoc/>
protected override bool InternalReleaseHandle() { BCryptFreeBuffer(handle); return true; }
}
}
}

View File

@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -997,7 +997,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "7c092bf5-f8b2-47d0-94ee-c8e0f4bca62d")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CertAddEncodedCertificateToStore(HCERTSTORE hCertStore, CertEncodingType dwCertEncodingType, [In] IntPtr pbCertEncoded, uint cbCertEncoded, CertStoreAdd dwAddDisposition, [Optional] IntPtr ppCertContext);
public static extern bool CertAddEncodedCertificateToStore(HCERTSTORE hCertStore, CertEncodingType dwCertEncodingType, [In] IntPtr pbCertEncoded,
uint cbCertEncoded, CertStoreAdd dwAddDisposition, [Optional] IntPtr ppCertContext);
/// <summary>
/// The <c>CertAddRefServerOcspResponse</c> function increments the reference count for an <c>HCERT_SERVER_OCSP_RESPONSE</c> handle.
@ -2703,8 +2704,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "b740772b-d25b-4b3d-9acb-03f7018750d6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CertSelectCertificateChains(in Guid pSelectionContext, CertSelection dwFlags, [Optional] IntPtr pChainParameters, uint cCriteria, [In, Optional, MarshalAs(UnmanagedType.LPArray)] CERT_SELECT_CRITERIA[] rgpCriteria,
HCERTSTORE hStore, out uint pcSelection, out IntPtr pprgpSelection);
public static extern bool CertSelectCertificateChains(in Guid pSelectionContext, CertSelection dwFlags, [Optional] IntPtr pChainParameters, uint cCriteria,
[In, Optional, MarshalAs(UnmanagedType.LPArray)] CERT_SELECT_CRITERIA[]? rgpCriteria, HCERTSTORE hStore, out uint pcSelection, out IntPtr pprgpSelection);
/// <summary>The <c>CertSelectCertificateChains</c> function retrieves certificate chains based on specified selection criteria.</summary>
/// <param name="pSelectionContext">A pointer to the GUID of the certificate selection scenario to use for this call.</param>
@ -2877,8 +2878,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "b740772b-d25b-4b3d-9acb-03f7018750d6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CertSelectCertificateChains([Optional] IntPtr pSelectionContext, CertSelection dwFlags, [Optional] IntPtr pChainParameters, uint cCriteria, [In, Optional, MarshalAs(UnmanagedType.LPArray)] CERT_SELECT_CRITERIA[] rgpCriteria,
HCERTSTORE hStore, out uint pcSelection, out IntPtr pprgpSelection);
public static extern bool CertSelectCertificateChains([Optional] IntPtr pSelectionContext, CertSelection dwFlags, [Optional] IntPtr pChainParameters,
uint cCriteria, [In, Optional, MarshalAs(UnmanagedType.LPArray)] CERT_SELECT_CRITERIA[]? rgpCriteria, HCERTSTORE hStore, out uint pcSelection, out IntPtr pprgpSelection);
/// <summary>
/// The <c>CertSerializeCertificateStoreElement</c> function serializes a certificate context's encoded certificate and its encoded
@ -3464,7 +3465,7 @@ namespace Vanara.PInvoke
public HCERT_SERVER_OCSP_RESPONSE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCERT_SERVER_OCSP_RESPONSE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCERT_SERVER_OCSP_RESPONSE NULL => new HCERT_SERVER_OCSP_RESPONSE(IntPtr.Zero);
public static HCERT_SERVER_OCSP_RESPONSE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3477,7 +3478,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCERT_SERVER_OCSP_RESPONSE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCERT_SERVER_OCSP_RESPONSE(IntPtr h) => new HCERT_SERVER_OCSP_RESPONSE(h);
public static implicit operator HCERT_SERVER_OCSP_RESPONSE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -3492,7 +3493,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HCERT_SERVER_OCSP_RESPONSE h1, HCERT_SERVER_OCSP_RESPONSE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCERT_SERVER_OCSP_RESPONSE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCERT_SERVER_OCSP_RESPONSE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3518,6 +3519,7 @@ namespace Vanara.PInvoke
//[return: MarshalAs(UnmanagedType.Bool)]
//private static extern unsafe bool CertSelectCertificateChains(in Guid pSelectionContext, CertSelection dwFlags, [In, Optional] CERT_SELECT_CHAIN_PARA* pChainParameters, int cCriteria,
// [In, Optional, MarshalAs(UnmanagedType.LPArray)] CERT_SELECT_CRITERIA[] rgpCriteria, HCERTSTORE hStore, out int pcSelection, out CERT_CHAIN_CONTEXT*[] pprgpSelection);
/// <summary>Provides a handle to a Certificate Chain Engine.</summary>
[StructLayout(LayoutKind.Sequential)]
public struct HCERTCHAINENGINE : IHandle
@ -3529,7 +3531,7 @@ namespace Vanara.PInvoke
public HCERTCHAINENGINE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCERTCHAINENGINE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCERTCHAINENGINE NULL => new HCERTCHAINENGINE(IntPtr.Zero);
public static HCERTCHAINENGINE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3542,7 +3544,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCERTCHAINENGINE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCERTCHAINENGINE(IntPtr h) => new HCERTCHAINENGINE(h);
public static implicit operator HCERTCHAINENGINE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -3557,7 +3559,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HCERTCHAINENGINE h1, HCERTCHAINENGINE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCERTCHAINENGINE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCERTCHAINENGINE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3579,7 +3581,7 @@ namespace Vanara.PInvoke
/// <summary>
/// Returns an invalid handle by instantiating a <see cref="PCCERT_SERVER_OCSP_RESPONSE_CONTEXT"/> object with <see cref="IntPtr.Zero"/>.
/// </summary>
public static PCCERT_SERVER_OCSP_RESPONSE_CONTEXT NULL => new PCCERT_SERVER_OCSP_RESPONSE_CONTEXT(IntPtr.Zero);
public static PCCERT_SERVER_OCSP_RESPONSE_CONTEXT NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3592,7 +3594,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="PCCERT_SERVER_OCSP_RESPONSE_CONTEXT"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator PCCERT_SERVER_OCSP_RESPONSE_CONTEXT(IntPtr h) => new PCCERT_SERVER_OCSP_RESPONSE_CONTEXT(h);
public static implicit operator PCCERT_SERVER_OCSP_RESPONSE_CONTEXT(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -3607,7 +3609,7 @@ namespace Vanara.PInvoke
public static bool operator ==(PCCERT_SERVER_OCSP_RESPONSE_CONTEXT h1, PCCERT_SERVER_OCSP_RESPONSE_CONTEXT h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is PCCERT_SERVER_OCSP_RESPONSE_CONTEXT h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is PCCERT_SERVER_OCSP_RESPONSE_CONTEXT h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3620,7 +3622,7 @@ namespace Vanara.PInvoke
public class SafePCCERT_CONTEXT : SafeHANDLE
{
/// <summary>Represents a NULL handle for <see cref="SafePCCERT_CONTEXT"/>. This must be used instead of <see langword="null"/>.</summary>
public static readonly SafePCCERT_CONTEXT Null = new SafePCCERT_CONTEXT(IntPtr.Zero, false);
public static readonly SafePCCERT_CONTEXT Null = new(IntPtr.Zero, false);
/// <summary>Initializes a new instance of the <see cref="SafePCCERT_CONTEXT"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
@ -3676,4 +3678,3 @@ namespace Vanara.PInvoke
protected override bool InternalReleaseHandle() { CertFreeServerOcspResponseContext(handle); return true; }
}
}
}

View File

@ -3,8 +3,8 @@ using System.Runtime.InteropServices;
using System.Text;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -1498,4 +1498,3 @@ namespace Vanara.PInvoke
public static extern bool CryptStringToBinary([MarshalAs(UnmanagedType.LPTStr)] string pszString, uint cchString, CryptStringFormat dwFlags, [Out] IntPtr pbBinary,
ref uint pcbBinary, out uint pdwSkip, out CryptStringFormat pdwFlags);
}
}

View File

@ -5,8 +5,8 @@ using Vanara.Extensions;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -795,7 +795,7 @@ namespace Vanara.PInvoke
// LPCSTR pszObjId, DWORD cAttr, CRYPT_ATTRIBUTE [] rgAttr );
[DllImport(Lib.Crypt32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "99d690fb-ea85-4cb1-9fb0-bdb02e4ac50a")]
public static extern IntPtr CertFindAttribute(SafeOID pszObjId, uint cAttr, [MarshalAs(UnmanagedType.LPArray)] CRYPT_ATTRIBUTE[] rgAttr);
public static extern IntPtr CertFindAttribute(SafeOID pszObjId, uint cAttr, [MarshalAs(UnmanagedType.LPArray)] CRYPT_ATTRIBUTE[]? rgAttr);
/// <summary>
/// The <c>CertFindAttribute</c> function finds the first attribute in the CRYPT_ATTRIBUTE array, as identified by its object
@ -807,7 +807,7 @@ namespace Vanara.PInvoke
/// <param name="pszObjId">The object identifier (OID) to use in the search.</param>
/// <param name="rgAttr">Array of CRYPT_ATTRIBUTE structures.</param>
/// <returns>Returns a reference to the attribute, if one is found. Otherwise, <see langword="null"/> is returned.</returns>
public static CRYPT_ATTRIBUTE? CertFindAttribute(string pszObjId, CRYPT_ATTRIBUTE[] rgAttr) => CertFindAttribute(pszObjId, (uint)(rgAttr?.Length ?? 0), rgAttr).ToNullableStructure<CRYPT_ATTRIBUTE>();
public static CRYPT_ATTRIBUTE? CertFindAttribute(string pszObjId, CRYPT_ATTRIBUTE[]? rgAttr) => CertFindAttribute(pszObjId, (uint)(rgAttr?.Length ?? 0), rgAttr).ToNullableStructure<CRYPT_ATTRIBUTE>();
/// <summary>
/// The <c>CertFindExtension</c> function finds the first extension in the CERT_EXTENSION array, as identified by its object
@ -823,7 +823,7 @@ namespace Vanara.PInvoke
// LPCSTR pszObjId, DWORD cExtensions, CERT_EXTENSION [] rgExtensions );
[DllImport(Lib.Crypt32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "489c58b6-a704-4f54-bc64-34eacafc347c")]
public static extern IntPtr CertFindExtension(SafeOID pszObjId, uint cExtensions, [MarshalAs(UnmanagedType.LPArray)] CERT_EXTENSION[] rgExtensions);
public static extern IntPtr CertFindExtension(SafeOID pszObjId, uint cExtensions, [MarshalAs(UnmanagedType.LPArray)] CERT_EXTENSION[]? rgExtensions);
/// <summary>
/// The <c>CertFindExtension</c> function finds the first extension in the CERT_EXTENSION array, as identified by its object
@ -835,7 +835,7 @@ namespace Vanara.PInvoke
/// <param name="pszObjId">A pointer to the object identifier (OID) to use in the search.</param>
/// <param name="rgExtensions">Array of CERT_EXTENSION structures.</param>
/// <returns>Returns a reference to the extension, if one is found. Otherwise, <see langword="null"/> is returned.</returns>
public static CERT_EXTENSION? CertFindExtension(string pszObjId, CERT_EXTENSION[] rgExtensions) => CertFindExtension(pszObjId, (uint)(rgExtensions?.Length ?? 0), rgExtensions).ToNullableStructure<CERT_EXTENSION>();
public static CERT_EXTENSION? CertFindExtension(string pszObjId, CERT_EXTENSION[]? rgExtensions) => CertFindExtension(pszObjId, (uint)(rgExtensions?.Length ?? 0), rgExtensions).ToNullableStructure<CERT_EXTENSION>();
/// <summary>
/// The <c>CertFindRDNAttr</c> function finds the first RDN attribute identified by its object identifier (OID) in a list of the
@ -1413,7 +1413,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "defd0b23-d9c2-4b28-a6a6-1be7487ae656")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptExportPKCS8(HCRYPTPROV hCryptProv, CertKeySpec dwKeySpec, SafeOID pszPrivateKeyObjId, uint dwFlags, [In, Optional] IntPtr pvAuxInfo, [Out, Optional] IntPtr pbPrivateKeyBlob, ref uint pcbPrivateKeyBlob);
public static extern bool CryptExportPKCS8(HCRYPTPROV hCryptProv, CertKeySpec dwKeySpec, SafeOID pszPrivateKeyObjId, uint dwFlags,
[In, Optional] IntPtr pvAuxInfo, [Out, Optional] IntPtr pbPrivateKeyBlob, ref uint pcbPrivateKeyBlob);
/// <summary>
/// <para>
@ -1478,7 +1479,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "82fee86a-8704-4f22-8f11-f89509c5a0aa")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptExportPKCS8Ex(in CRYPT_PKCS8_EXPORT_PARAMS psExportParams, uint dwFlags, [In, Optional] IntPtr pvAuxInfo, [Optional, Out] IntPtr pbPrivateKeyBlob, ref uint pcbPrivateKeyBlob);
public static extern bool CryptExportPKCS8Ex(in CRYPT_PKCS8_EXPORT_PARAMS psExportParams, uint dwFlags, [In, Optional] IntPtr pvAuxInfo,
[Optional, Out] IntPtr pbPrivateKeyBlob, ref uint pcbPrivateKeyBlob);
/// <summary>
/// The <c>CryptExportPublicKeyInfo</c> function exports the public key information associated with the corresponding private key of
@ -2200,7 +2202,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "9f315374-0002-499a-81ea-efcb3c19e68f")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptHashCertificate2([MarshalAs(UnmanagedType.LPWStr)] string pwszCNGHashAlgid, [Optional] uint dwFlags, [Optional] IntPtr pvReserved, [In] IntPtr pbEncoded, uint cbEncoded, [Out] IntPtr pbComputedHash, ref uint pcbComputedHash);
public static extern bool CryptHashCertificate2([MarshalAs(UnmanagedType.LPWStr)] string pwszCNGHashAlgid, [Optional] uint dwFlags,
[Optional] IntPtr pvReserved, [In] IntPtr pbEncoded, uint cbEncoded, [Out] IntPtr pbComputedHash, ref uint pcbComputedHash);
/// <summary>
/// <note>Important: This API is deprecated. New and existing software should start using Cryptography Next Generation APIs.
@ -6147,7 +6150,7 @@ namespace Vanara.PInvoke
public class CryptMemMethods : MemoryMethodsBase
{
/// <summary>Gets a static instance of this class.</summary>
public static readonly CryptMemMethods Instance = new CryptMemMethods();
public static readonly CryptMemMethods Instance = new();
/// <summary>Gets a handle to a memory allocation of the specified size.</summary>
/// <param name="size">The size, in bytes, of memory to allocate.</param>
@ -6201,7 +6204,7 @@ namespace Vanara.PInvoke
public class SafeHCRYPTKEY : SafeHANDLE
{
/// <summary>Represents a NULL handle for <see cref="SafeHCRYPTKEY"/>. This must be used instead of <see langword="null"/>.</summary>
public static readonly SafeHCRYPTKEY Null = new SafeHCRYPTKEY(IntPtr.Zero, false);
public static readonly SafeHCRYPTKEY Null = new(IntPtr.Zero, false);
/// <summary>Initializes a new instance of the <see cref="SafeHCRYPTKEY"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
@ -6225,4 +6228,3 @@ namespace Vanara.PInvoke
[return: MarshalAs(UnmanagedType.Bool)] private static extern bool CryptDestroyKey(HCRYPTKEY hKey);
}
}
}

View File

@ -4,8 +4,8 @@ using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -414,7 +414,7 @@ namespace Vanara.PInvoke
[PInvokeData("wincrypt.h", MSDNShortId = "6e57d935-4cfb-44af-b1c6-6c399c959452")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptEnumKeyIdentifierProperties(in CRYPTOAPI_BLOB pKeyIdentifier, [In, Optional] uint dwPropId, CryptKeyIdFlags dwFlags,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszComputerName, [In, Optional] IntPtr pvReserved, [In, Optional] IntPtr pvArg,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszComputerName, [In, Optional] IntPtr pvReserved, [In, Optional] IntPtr pvArg,
[MarshalAs(UnmanagedType.FunctionPtr)] PFN_CRYPT_ENUM_KEYID_PROP pfnEnum);
/// <summary>
@ -503,7 +503,7 @@ namespace Vanara.PInvoke
[PInvokeData("wincrypt.h", MSDNShortId = "6e57d935-4cfb-44af-b1c6-6c399c959452")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptEnumKeyIdentifierProperties([In, Optional] IntPtr pKeyIdentifier, [In, Optional] uint dwPropId, CryptKeyIdFlags dwFlags,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszComputerName, [In, Optional] IntPtr pvReserved, [In, Optional] IntPtr pvArg,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszComputerName, [In, Optional] IntPtr pvReserved, [In, Optional] IntPtr pvArg,
[MarshalAs(UnmanagedType.FunctionPtr)] PFN_CRYPT_ENUM_KEYID_PROP pfnEnum);
/// <summary>
@ -562,10 +562,10 @@ namespace Vanara.PInvoke
/// set to <c>NULL</c>.
/// </param>
/// <returns>A sequence of tuples containing the key identifier and an array of property identifiers and values as byte arrays.</returns>
public static IEnumerable<(byte[] keyId, (uint propId, byte[] data)[] props)> CryptEnumKeyIdentifierProperties(CRYPTOAPI_BLOB? pKeyIdentifier = null,
uint dwPropId = 0, CryptKeyIdFlags dwFlags = CryptKeyIdFlags.CRYPT_KEYID_MACHINE_FLAG, string pwszComputerName = null)
public static IEnumerable<(byte[]? keyId, (uint propId, byte[] data)[] props)> CryptEnumKeyIdentifierProperties(CRYPTOAPI_BLOB? pKeyIdentifier = null,
uint dwPropId = 0, CryptKeyIdFlags dwFlags = CryptKeyIdFlags.CRYPT_KEYID_MACHINE_FLAG, string? pwszComputerName = null)
{
List<(byte[] keyId, (uint propId, byte[] data)[] props)> output = new();
List<(byte[]? keyId, (uint propId, byte[] data)[] props)> output = new();
using SafeCoTaskMemStruct<CRYPTOAPI_BLOB> pKeyId = pKeyIdentifier.HasValue ? new(pKeyIdentifier.Value) : SafeCoTaskMemStruct<CRYPTOAPI_BLOB>.Null;
Win32Error.ThrowLastErrorIfFalse(CryptEnumKeyIdentifierProperties(pKeyId, dwPropId, dwFlags, pwszComputerName, default, default, fn));
return output;
@ -731,7 +731,7 @@ namespace Vanara.PInvoke
[PInvokeData("wincrypt.h", MSDNShortId = "bc0511c1-0699-4959-afd7-a838c91c77d5")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptGetKeyIdentifierProperty(in CRYPTOAPI_BLOB pKeyIdentifier, uint dwPropId, CryptKeyIdFlags dwFlags,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszComputerName, [Optional] IntPtr pvReserved, [Out, Optional] IntPtr pvData, ref uint pcbData);
[Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszComputerName, [Optional] IntPtr pvReserved, [Out, Optional] IntPtr pvData, ref uint pcbData);
/// <summary>
/// <para>A pointer to a CRYPT_HASH_BLOB containing the key identifier.</para>
@ -840,7 +840,7 @@ namespace Vanara.PInvoke
[PInvokeData("wincrypt.h", MSDNShortId = "0970aaaa-3f9a-4471-bd21-5de8746f94a2")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSetKeyIdentifierProperty(in CRYPTOAPI_BLOB pKeyIdentifier, uint dwPropId, CryptKeyIdFlags dwFlags,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszComputerName, [Optional] IntPtr pvReserved, [In, Optional] IntPtr pvData);
[Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszComputerName, [Optional] IntPtr pvReserved, [In, Optional] IntPtr pvData);
/// <summary>
/// <para>
@ -930,4 +930,3 @@ namespace Vanara.PInvoke
public ALG_ID aiKeyAlg;
}
}
}

View File

@ -3,8 +3,8 @@ using System.Runtime.InteropServices;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -2436,7 +2436,8 @@ namespace Vanara.PInvoke
// PCMSG_STREAM_INFO pStreamInfo );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "b3df6312-c866-4faa-8b89-bda67c697631")]
public static extern SafeHCRYPTMSG CryptMsgOpenToDecode(CertEncodingType dwMsgEncodingType, CryptMsgFlags dwFlags, CryptMsgType dwMsgType, [Optional] HCRYPTPROV hCryptProv, [Optional] IntPtr pRecipientInfo, in CMSG_STREAM_INFO pStreamInfo);
public static extern SafeHCRYPTMSG CryptMsgOpenToDecode(CertEncodingType dwMsgEncodingType, CryptMsgFlags dwFlags, CryptMsgType dwMsgType,
[Optional] HCRYPTPROV hCryptProv, [Optional] IntPtr pRecipientInfo, in CMSG_STREAM_INFO pStreamInfo);
/// <summary>
/// <para>
@ -5490,4 +5491,3 @@ namespace Vanara.PInvoke
protected override bool InternalReleaseHandle() => CryptMsgClose(handle);
}
}
}

View File

@ -182,7 +182,7 @@ public static partial class Crypt32
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "aa2fba03-183b-4b74-b306-8f4592995897")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptEnumOIDFunction(CertEncodingType dwEncodingType, [Optional, MarshalAs(UnmanagedType.LPStr)] string pszFuncName, [Optional, In] SafeOID pszOID,
public static extern bool CryptEnumOIDFunction(CertEncodingType dwEncodingType, [Optional, MarshalAs(UnmanagedType.LPStr)] string? pszFuncName, [Optional, In] SafeOID pszOID,
[Optional] uint dwFlags, [In, Out, Optional] IntPtr pvArg, PFN_CRYPT_ENUM_OID_FUNC pfnEnumOIDFunc);
/// <summary>
@ -709,7 +709,7 @@ public static partial class Crypt32
[DllImport(Lib.Crypt32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "3977368c-ad13-43f9-859b-10c7f170f482")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptGetDefaultOIDFunctionAddress([In] HCRYPTOIDFUNCSET hFuncSet, CertEncodingType dwEncodingType, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszDll,
public static extern bool CryptGetDefaultOIDFunctionAddress([In] HCRYPTOIDFUNCSET hFuncSet, CertEncodingType dwEncodingType, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszDll,
[Optional] uint dwFlags, out IntPtr ppvFuncAddr, ref HCRYPTOIDFUNCADDR phFuncAddr);
/// <summary>
@ -883,7 +883,7 @@ public static partial class Crypt32
[PInvokeData("wincrypt.h", MSDNShortId = "14eb7f10-f42a-4496-9699-62eeb9878ea2")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptGetOIDFunctionValue(CertEncodingType dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszFuncName,
[In] SafeOID pszOID, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszValueName, out REG_VALUE_TYPE pdwValueType,
[In] SafeOID pszOID, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszValueName, out REG_VALUE_TYPE pdwValueType,
[Out] IntPtr pbValueData, ref uint pcbValueData);
/// <summary>
@ -967,7 +967,7 @@ public static partial class Crypt32
[DllImport(Lib.Crypt32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "9633cce4-538e-490e-8a5a-6b28f161a09d")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptRegisterDefaultOIDFunction(CertEncodingType dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszFuncName, uint dwIndex, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszDll);
public static extern bool CryptRegisterDefaultOIDFunction(CertEncodingType dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszFuncName, uint dwIndex, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszDll);
/// <summary>
/// <para>
@ -1018,7 +1018,7 @@ public static partial class Crypt32
[PInvokeData("wincrypt.h", MSDNShortId = "b625597d-28fd-4a40-afbe-a09201d36512")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptRegisterOIDFunction(CertEncodingType dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszFuncName, SafeOID pszOID,
[MarshalAs(UnmanagedType.LPWStr)] string pwszDll, [Optional, MarshalAs(UnmanagedType.LPStr)] string pszOverrideFuncName);
[MarshalAs(UnmanagedType.LPWStr)] string pwszDll, [Optional, MarshalAs(UnmanagedType.LPStr)] string? pszOverrideFuncName);
/// <summary>
/// <para>
@ -1124,7 +1124,7 @@ public static partial class Crypt32
[PInvokeData("wincrypt.h", MSDNShortId = "3e167c5d-0000-4359-a7b0-9b3e4e64c50c")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptSetOIDFunctionValue(CertEncodingType dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszFuncName,
SafeOID pszOID, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszValueName, REG_VALUE_TYPE dwValueType, [In, Optional] IntPtr pbValueData, uint cbValueData);
SafeOID pszOID, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszValueName, REG_VALUE_TYPE dwValueType, [In, Optional] IntPtr pbValueData, uint cbValueData);
/// <summary>
/// The <c>CryptUnregisterDefaultOIDFunction</c> removes the registration of a DLL containing the default function to be called for
@ -1484,7 +1484,7 @@ public static partial class Crypt32
public HCRYPTOIDFUNCADDR(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCRYPTOIDFUNCADDR"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCRYPTOIDFUNCADDR NULL => new HCRYPTOIDFUNCADDR(IntPtr.Zero);
public static HCRYPTOIDFUNCADDR NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -1497,7 +1497,7 @@ public static partial class Crypt32
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCRYPTOIDFUNCADDR"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCRYPTOIDFUNCADDR(IntPtr h) => new HCRYPTOIDFUNCADDR(h);
public static implicit operator HCRYPTOIDFUNCADDR(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -1512,7 +1512,7 @@ public static partial class Crypt32
public static bool operator ==(HCRYPTOIDFUNCADDR h1, HCRYPTOIDFUNCADDR h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCRYPTOIDFUNCADDR h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCRYPTOIDFUNCADDR h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -1532,7 +1532,7 @@ public static partial class Crypt32
public HCRYPTOIDFUNCSET(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCRYPTOIDFUNCSET"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCRYPTOIDFUNCSET NULL => new HCRYPTOIDFUNCSET(IntPtr.Zero);
public static HCRYPTOIDFUNCSET NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -1545,7 +1545,7 @@ public static partial class Crypt32
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCRYPTOIDFUNCSET"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCRYPTOIDFUNCSET(IntPtr h) => new HCRYPTOIDFUNCSET(h);
public static implicit operator HCRYPTOIDFUNCSET(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -1560,7 +1560,7 @@ public static partial class Crypt32
public static bool operator ==(HCRYPTOIDFUNCSET h1, HCRYPTOIDFUNCSET h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCRYPTOIDFUNCSET h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCRYPTOIDFUNCSET h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -1580,7 +1580,7 @@ public static partial class Crypt32
public PCCRYPT_OID_INFO(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="PCCRYPT_OID_INFO"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static PCCRYPT_OID_INFO NULL => new PCCRYPT_OID_INFO(IntPtr.Zero);
public static PCCRYPT_OID_INFO NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -1593,7 +1593,7 @@ public static partial class Crypt32
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="PCCRYPT_OID_INFO"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator PCCRYPT_OID_INFO(IntPtr h) => new PCCRYPT_OID_INFO(h);
public static implicit operator PCCRYPT_OID_INFO(IntPtr h) => new(h);
/// <summary>Performs an explicit conversion from <see cref="PCCRYPT_OID_INFO"/> to <see cref="CRYPT_OID_INFO"/>.</summary>
/// <param name="h">The handle.</param>
@ -1613,7 +1613,7 @@ public static partial class Crypt32
public static bool operator ==(PCCRYPT_OID_INFO h1, PCCRYPT_OID_INFO h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is PCCRYPT_OID_INFO h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is PCCRYPT_OID_INFO h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();

View File

@ -2,8 +2,8 @@
using System.Runtime.InteropServices;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -1359,7 +1359,7 @@ namespace Vanara.PInvoke
public PFN_CRYPT_FREE pfnFree;
/// <summary>Gets an instance which uses the CoTaskMem... methods for allocating and freeing memory.</summary>
public static readonly CRYPT_DECODE_PARA CoTaskMemInstance = new CRYPT_DECODE_PARA { cbSize = (uint)Marshal.SizeOf(typeof(CRYPT_DECODE_PARA)), pfnAlloc = s => Marshal.AllocCoTaskMem(s), pfnFree = Marshal.FreeCoTaskMem };
public static readonly CRYPT_DECODE_PARA CoTaskMemInstance = new() { cbSize = (uint)Marshal.SizeOf(typeof(CRYPT_DECODE_PARA)), pfnAlloc = s => Marshal.AllocCoTaskMem(s), pfnFree = Marshal.FreeCoTaskMem };
}
/// <summary>
@ -1386,7 +1386,6 @@ namespace Vanara.PInvoke
public PFN_CRYPT_FREE pfnFree;
/// <summary>Gets an instance which uses the CoTaskMem... methods for allocating and freeing memory.</summary>
public static readonly CRYPT_ENCODE_PARA CoTaskMemInstance = new CRYPT_ENCODE_PARA { cbSize = (uint)Marshal.SizeOf(typeof(CRYPT_ENCODE_PARA)), pfnAlloc = s => Marshal.AllocCoTaskMem(s), pfnFree = Marshal.FreeCoTaskMem };
}
public static readonly CRYPT_ENCODE_PARA CoTaskMemInstance = new() { cbSize = (uint)Marshal.SizeOf(typeof(CRYPT_ENCODE_PARA)), pfnAlloc = s => Marshal.AllocCoTaskMem(s), pfnFree = Marshal.FreeCoTaskMem };
}
}

View File

@ -1,8 +1,8 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -510,4 +510,3 @@ namespace Vanara.PInvoke
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PFXVerifyPassword(in CRYPTOAPI_BLOB pPFX, [MarshalAs(UnmanagedType.LPWStr)] string szPassword, uint dwFlags = 0);
}
}

View File

@ -3,8 +3,8 @@ using System.Runtime.InteropServices;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -2218,4 +2218,3 @@ namespace Vanara.PInvoke
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CertSetCTLContextProperty([In] PCCTL_CONTEXT pCtlContext, CertPropId dwPropId, uint dwFlags, [In, Optional] IntPtr pvData);
}
}

View File

@ -5,8 +5,8 @@ using Vanara.Extensions;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -110,4 +110,3 @@ namespace Vanara.PInvoke
FreeCryptProvFromCertEx Releases the handle either to a cryptographic service provider (CSP) or to a Cryptography API: Next Generation (CNG) key.
*/
}
}

View File

@ -2,8 +2,8 @@
using System.Runtime.InteropServices;
using Vanara.Extensions;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -1078,7 +1078,8 @@ namespace Vanara.PInvoke
// pPrevCrlContext );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "3e481912-204a-4d86-ab67-81f8ae4d1aaa")]
public static extern SafePCCRL_CONTEXT CertFindCRLInStore(HCERTSTORE hCertStore, CertEncodingType dwCertEncodingType, CrlFindFlags dwFindFlags, CrlFindType dwFindType, [In, Optional] IntPtr pvFindPara, [In, Optional] PCCRL_CONTEXT pPrevCrlContext);
public static extern SafePCCRL_CONTEXT CertFindCRLInStore(HCERTSTORE hCertStore, CertEncodingType dwCertEncodingType, CrlFindFlags dwFindFlags,
CrlFindType dwFindType, [In, Optional] IntPtr pvFindPara, [In, Optional] PCCRL_CONTEXT pPrevCrlContext);
/// <summary>
/// <para>
@ -1261,4 +1262,3 @@ namespace Vanara.PInvoke
protected override bool InternalReleaseHandle() => CertFreeCRLContext(handle);
}
}
}

View File

@ -2,8 +2,8 @@
using System.Runtime.InteropServices;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
public static partial class Crypt32
{
/// <summary/>
@ -909,7 +909,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "2726cd34-51ba-4f68-9a3c-7cd505eb32a1")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CertAddSerializedElementToStore([Optional] HCERTSTORE hCertStore, [In] IntPtr pbElement, uint cbElement, CertStoreAdd dwAddDisposition, [Optional] uint dwFlags, CertStoreContextFlags dwContextTypeFlags, out CertStoreContextType pdwContextType, out IntPtr ppvContext);
public static extern bool CertAddSerializedElementToStore([Optional] HCERTSTORE hCertStore, [In] IntPtr pbElement, uint cbElement,
CertStoreAdd dwAddDisposition, [Optional] uint dwFlags, CertStoreContextFlags dwContextTypeFlags, out CertStoreContextType pdwContextType, out IntPtr ppvContext);
/// <summary>
/// The <c>CertAddSerializedElementToStore</c> function adds a serialized certificate, certificate revocation list (CRL), or
@ -1086,7 +1087,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "2726cd34-51ba-4f68-9a3c-7cd505eb32a1")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CertAddSerializedElementToStore([Optional] HCERTSTORE hCertStore, [In] IntPtr pbElement, uint cbElement, CertStoreAdd dwAddDisposition, [Optional] uint dwFlags, CertStoreContextFlags dwContextTypeFlags, IntPtr pdwContextType = default, IntPtr ppvContext = default);
public static extern bool CertAddSerializedElementToStore([Optional] HCERTSTORE hCertStore, [In] IntPtr pbElement, uint cbElement,
CertStoreAdd dwAddDisposition, [Optional] uint dwFlags, CertStoreContextFlags dwContextTypeFlags, IntPtr pdwContextType = default, IntPtr ppvContext = default);
/// <summary>
/// The <c>CertAddStoreToCollection</c> function adds a sibling certificate store to a collection certificate store. When a
@ -3957,7 +3959,7 @@ namespace Vanara.PInvoke
public HCERTSTORE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCERTSTORE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCERTSTORE NULL => new HCERTSTORE(IntPtr.Zero);
public static HCERTSTORE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3970,7 +3972,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCERTSTORE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCERTSTORE(IntPtr h) => new HCERTSTORE(h);
public static implicit operator HCERTSTORE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -3985,7 +3987,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HCERTSTORE h1, HCERTSTORE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCERTSTORE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCERTSTORE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -4005,7 +4007,7 @@ namespace Vanara.PInvoke
public HCRYPTMSG(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCRYPTMSG"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCRYPTMSG NULL => new HCRYPTMSG(IntPtr.Zero);
public static HCRYPTMSG NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -4018,7 +4020,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCRYPTMSG"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCRYPTMSG(IntPtr h) => new HCRYPTMSG(h);
public static implicit operator HCRYPTMSG(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -4033,7 +4035,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HCRYPTMSG h1, HCRYPTMSG h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCRYPTMSG h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCRYPTMSG h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -4130,4 +4132,3 @@ namespace Vanara.PInvoke
public const string sz_CERT_STORE_PROV_LDAP = "Ldap";
}
}
}

View File

@ -1,8 +1,8 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -713,4 +713,3 @@ namespace Vanara.PInvoke
protected override bool InternalReleaseHandle() => CertFreeCTLContext(handle);
}
}
}

View File

@ -4,8 +4,8 @@ using Vanara.Extensions;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -2714,7 +2714,7 @@ namespace Vanara.PInvoke
public PCCERT_CHAIN_CONTEXT(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="PCCERT_CHAIN_CONTEXT"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static PCCERT_CHAIN_CONTEXT NULL => new PCCERT_CHAIN_CONTEXT(IntPtr.Zero);
public static PCCERT_CHAIN_CONTEXT NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -2732,7 +2732,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="PCCERT_CHAIN_CONTEXT"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator PCCERT_CHAIN_CONTEXT(IntPtr h) => new PCCERT_CHAIN_CONTEXT(h);
public static implicit operator PCCERT_CHAIN_CONTEXT(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -2747,7 +2747,7 @@ namespace Vanara.PInvoke
public static bool operator ==(PCCERT_CHAIN_CONTEXT h1, PCCERT_CHAIN_CONTEXT h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is PCCERT_CHAIN_CONTEXT h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is PCCERT_CHAIN_CONTEXT h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -2834,4 +2834,3 @@ namespace Vanara.PInvoke
public const int CERT_CHAIN_POLICY_SSL_KEY_PIN = 12;
}
}
}

View File

@ -5,8 +5,8 @@ using Vanara.Extensions;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -2970,7 +2970,7 @@ namespace Vanara.PInvoke
/// Initializes a new instance of the <see cref="CRYPTOAPI_BLOB"/> struct from a <see cref="SafeAllocatedMemoryHandle"/> instance.
/// </summary>
/// <param name="mem">The allocated memory instance.</param>
public CRYPTOAPI_BLOB(SafeAllocatedMemoryHandle mem) { pbData = mem?.DangerousGetHandle() ?? default; cbData = mem?.Size ?? 0; }
public CRYPTOAPI_BLOB(SafeAllocatedMemoryHandle? mem) { pbData = mem?.DangerousGetHandle() ?? default; cbData = mem?.Size ?? 0; }
/// <summary>A DWORD variable that contains the count, in bytes, of data.</summary>
public uint cbData;
@ -2979,7 +2979,7 @@ namespace Vanara.PInvoke
public IntPtr pbData;
/// <summary>Gets the bytes associated with this blob.</summary>
public byte[] GetBytes() => pbData.ToByteArray((int)cbData);
public byte[]? GetBytes() => pbData.ToByteArray((int)cbData);
}
/// <summary>
@ -3159,7 +3159,7 @@ namespace Vanara.PInvoke
public HCRYPTDEFAULTCONTEXT(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCRYPTDEFAULTCONTEXT"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCRYPTDEFAULTCONTEXT NULL => new HCRYPTDEFAULTCONTEXT(IntPtr.Zero);
public static HCRYPTDEFAULTCONTEXT NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3172,7 +3172,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCRYPTDEFAULTCONTEXT"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCRYPTDEFAULTCONTEXT(IntPtr h) => new HCRYPTDEFAULTCONTEXT(h);
public static implicit operator HCRYPTDEFAULTCONTEXT(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -3187,7 +3187,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HCRYPTDEFAULTCONTEXT h1, HCRYPTDEFAULTCONTEXT h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCRYPTDEFAULTCONTEXT h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCRYPTDEFAULTCONTEXT h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3207,7 +3207,7 @@ namespace Vanara.PInvoke
public HCRYPTHASH(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCRYPTHASH"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCRYPTHASH NULL => new HCRYPTHASH(IntPtr.Zero);
public static HCRYPTHASH NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3220,7 +3220,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCRYPTHASH"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCRYPTHASH(IntPtr h) => new HCRYPTHASH(h);
public static implicit operator HCRYPTHASH(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -3235,7 +3235,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HCRYPTHASH h1, HCRYPTHASH h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCRYPTHASH h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCRYPTHASH h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3255,7 +3255,7 @@ namespace Vanara.PInvoke
public HCRYPTKEY(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCRYPTKEY"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCRYPTKEY NULL => new HCRYPTKEY(IntPtr.Zero);
public static HCRYPTKEY NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3268,7 +3268,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCRYPTKEY"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCRYPTKEY(IntPtr h) => new HCRYPTKEY(h);
public static implicit operator HCRYPTKEY(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -3283,7 +3283,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HCRYPTKEY h1, HCRYPTKEY h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCRYPTKEY h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCRYPTKEY h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3303,7 +3303,7 @@ namespace Vanara.PInvoke
public HCRYPTPROV(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="HCRYPTPROV"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static HCRYPTPROV NULL => new HCRYPTPROV(IntPtr.Zero);
public static HCRYPTPROV NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3316,7 +3316,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HCRYPTPROV"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HCRYPTPROV(IntPtr h) => new HCRYPTPROV(h);
public static implicit operator HCRYPTPROV(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -3331,7 +3331,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HCRYPTPROV h1, HCRYPTPROV h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HCRYPTPROV h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is HCRYPTPROV h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3351,7 +3351,7 @@ namespace Vanara.PInvoke
public PCCERT_CONTEXT(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="PCCERT_CONTEXT"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static PCCERT_CONTEXT NULL => new PCCERT_CONTEXT(IntPtr.Zero);
public static PCCERT_CONTEXT NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3364,7 +3364,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="PCCERT_CONTEXT"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator PCCERT_CONTEXT(IntPtr h) => new PCCERT_CONTEXT(h);
public static implicit operator PCCERT_CONTEXT(IntPtr h) => new(h);
/// <summary>Performs an explicit conversion from <see cref="PCCERT_CONTEXT"/> to <see cref="CERT_CONTEXT"/>.</summary>
/// <param name="h">The <see cref="PCCERT_CONTEXT"/> instance.</param>
@ -3384,7 +3384,7 @@ namespace Vanara.PInvoke
public static bool operator ==(PCCERT_CONTEXT h1, PCCERT_CONTEXT h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is PCCERT_CONTEXT h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is PCCERT_CONTEXT h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3404,7 +3404,7 @@ namespace Vanara.PInvoke
public PCCRL_CONTEXT(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="PCCRL_CONTEXT"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static PCCRL_CONTEXT NULL => new PCCRL_CONTEXT(IntPtr.Zero);
public static PCCRL_CONTEXT NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3417,7 +3417,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="PCCRL_CONTEXT"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator PCCRL_CONTEXT(IntPtr h) => new PCCRL_CONTEXT(h);
public static implicit operator PCCRL_CONTEXT(IntPtr h) => new(h);
/// <summary>Performs an implicit conversion from <see cref="PCCRL_CONTEXT"/> to <see cref="CRL_CONTEXT"/>.</summary>
/// <param name="h">The <see cref="PCCRL_CONTEXT"/> instance.</param>
@ -3437,7 +3437,7 @@ namespace Vanara.PInvoke
public static bool operator ==(PCCRL_CONTEXT h1, PCCRL_CONTEXT h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is PCCRL_CONTEXT h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is PCCRL_CONTEXT h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3457,7 +3457,7 @@ namespace Vanara.PInvoke
public PCCTL_CONTEXT(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="PCCTL_CONTEXT"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static PCCTL_CONTEXT NULL => new PCCTL_CONTEXT(IntPtr.Zero);
public static PCCTL_CONTEXT NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -3470,7 +3470,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="PCCTL_CONTEXT"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator PCCTL_CONTEXT(IntPtr h) => new PCCTL_CONTEXT(h);
public static implicit operator PCCTL_CONTEXT(IntPtr h) => new(h);
/// <summary>Performs an explicit conversion from <see cref="PCCTL_CONTEXT"/> to <see cref="CTL_CONTEXT"/>.</summary>
/// <param name="h">The handle.</param>
@ -3490,7 +3490,7 @@ namespace Vanara.PInvoke
public static bool operator ==(PCCTL_CONTEXT h1, PCCTL_CONTEXT h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is PCCTL_CONTEXT h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is PCCTL_CONTEXT h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -3524,8 +3524,9 @@ namespace Vanara.PInvoke
/// <summary>Initializes a new instance of the <see cref="SafeCRYPTOAPI_BLOB"/> class.</summary>
/// <param name="bytes">The bytes to copy into the blob.</param>
public SafeCRYPTOAPI_BLOB(byte[] bytes) : this(bytes?.Length ?? 0)
public SafeCRYPTOAPI_BLOB(byte[]? bytes) : this(bytes?.Length ?? 0)
{
if (bytes is not null)
Marshal.Copy(bytes, 0, pbData, bytes.Length);
}
@ -3543,7 +3544,7 @@ namespace Vanara.PInvoke
}
/// <summary>Represents an empty instance of a blob.</summary>
public static readonly SafeCRYPTOAPI_BLOB Empty = new SafeCRYPTOAPI_BLOB(IntPtr.Zero, 0);
public static readonly SafeCRYPTOAPI_BLOB Empty = new(IntPtr.Zero, 0);
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
public void Dispose()
@ -3557,7 +3558,7 @@ namespace Vanara.PInvoke
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeCRYPTOAPI_BLOB"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeCRYPTOAPI_BLOB CreateFromStructure<T>(in T value = default) => new SafeCRYPTOAPI_BLOB(InteropExtensions.MarshalToPtr(value, MemMethods.AllocMem, out int s), s);
public static SafeCRYPTOAPI_BLOB CreateFromStructure<T>(in T value = default) where T : struct => new(InteropExtensions.MarshalToPtr(value, MemMethods.AllocMem, out int s), s);
/// <summary>
/// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure
@ -3573,7 +3574,7 @@ namespace Vanara.PInvoke
/// <param name="prefixBytes">Number of bytes preceding the trailing array of structures</param>
/// <returns><see cref="SafeCRYPTOAPI_BLOB"/> object to an native (unmanaged) structure with a trail array of structures</returns>
public static SafeCRYPTOAPI_BLOB CreateFromList<T>(IEnumerable<T> values, int count = -1, int prefixBytes = 0) =>
new SafeCRYPTOAPI_BLOB(InteropExtensions.MarshalToPtr(values, MemMethods.AllocMem, out int s, prefixBytes), s);
new(InteropExtensions.MarshalToPtr(values, MemMethods.AllocMem, out int s, prefixBytes), s);
/// <summary>Allocates from unmanaged memory sufficient memory to hold an array of strings.</summary>
/// <param name="values">The list of strings.</param>
@ -3585,7 +3586,7 @@ namespace Vanara.PInvoke
/// name="packing"/> model and the character set defined by <paramref name="charSet"/>.
/// </returns>
public static SafeCRYPTOAPI_BLOB CreateFromStringList(IEnumerable<string> values, StringListPackMethod packing = StringListPackMethod.Concatenated, CharSet charSet = CharSet.Auto, int prefixBytes = 0) =>
new SafeCRYPTOAPI_BLOB(InteropExtensions.MarshalToPtr(values, packing, MemMethods.AllocMem, out int s, charSet, prefixBytes), s);
new(InteropExtensions.MarshalToPtr(values, packing, MemMethods.AllocMem, out int s, charSet, prefixBytes), s);
private static IMemoryMethods MemMethods => HGlobalMemoryMethods.Instance;
}
@ -3627,17 +3628,17 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="System.String"/> to <see cref="SafeOID"/>.</summary>
/// <param name="value">The value.</param>
/// <returns>The resulting <see cref="SafeOID"/> instance from the conversion.</returns>
public static implicit operator SafeOID(string value) => new SafeOID(value);
public static implicit operator SafeOID(string value) => new(value);
/// <summary>Performs an implicit conversion from <see cref="System.Int32"/> to <see cref="SafeOID"/>.</summary>
/// <param name="value">The value.</param>
/// <returns>The resulting <see cref="SafeOID"/> instance from the conversion.</returns>
public static implicit operator SafeOID(int value) => new SafeOID(value);
public static implicit operator SafeOID(int value) => new(value);
/// <summary>Performs an implicit conversion from <see cref="System.UInt32"/> to <see cref="SafeOID"/>.</summary>
/// <param name="value">The value.</param>
/// <returns>The resulting <see cref="SafeOID"/> instance from the conversion.</returns>
public static implicit operator SafeOID(uint value) => new SafeOID(value);
public static implicit operator SafeOID(uint value) => new(value);
/// <summary>Performs an implicit conversion from <see cref="SafeOID"/> to <see cref="StrPtrAnsi"/>.</summary>
/// <param name="value">The value.</param>
@ -3650,7 +3651,7 @@ namespace Vanara.PInvoke
/// <summary>Gets the string value, if possible.</summary>
/// <returns>The string value, if set; otherwise <see langword="null"/>.</returns>
public string GetStringValue() => IsString ? Marshal.PtrToStringAnsi(handle) : null;
public string? GetStringValue() => IsString ? Marshal.PtrToStringAnsi(handle) : null;
/// <summary>
/// Internal method that actually releases the handle. This is called by <see cref="M:Vanara.PInvoke.SafeHANDLE.ReleaseHandle"/>
@ -3666,117 +3667,117 @@ namespace Vanara.PInvoke
}
/// <summary/>
public static readonly SafeOID CRYPT_ENCODE_DECODE_NONE = new SafeOID(0);
public static readonly SafeOID CRYPT_ENCODE_DECODE_NONE = new(0);
//+-------------------------------------------------------------------------
// Predefined X509 certificate data structures that can be encoded / decoded.
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_CERT = new SafeOID(1);
public static readonly SafeOID X509_CERT = new(1);
/// <summary/>
public static readonly SafeOID X509_CERT_TO_BE_SIGNED = new SafeOID(2);
public static readonly SafeOID X509_CERT_TO_BE_SIGNED = new(2);
/// <summary/>
public static readonly SafeOID X509_CERT_CRL_TO_BE_SIGNED = new SafeOID(3);
public static readonly SafeOID X509_CERT_CRL_TO_BE_SIGNED = new(3);
/// <summary/>
public static readonly SafeOID X509_CERT_REQUEST_TO_BE_SIGNED = new SafeOID(4);
public static readonly SafeOID X509_CERT_REQUEST_TO_BE_SIGNED = new(4);
/// <summary/>
public static readonly SafeOID X509_EXTENSIONS = new SafeOID(5);
public static readonly SafeOID X509_EXTENSIONS = new(5);
/// <summary/>
public static readonly SafeOID X509_NAME_VALUE = new SafeOID(6);
public static readonly SafeOID X509_NAME_VALUE = new(6);
/// <summary/>
public static readonly SafeOID X509_NAME = new SafeOID(7);
public static readonly SafeOID X509_NAME = new(7);
/// <summary/>
public static readonly SafeOID X509_PUBLIC_KEY_INFO = new SafeOID(8);
public static readonly SafeOID X509_PUBLIC_KEY_INFO = new(8);
//+-------------------------------------------------------------------------
// Predefined X509 certificate extension data structures that can be
// encoded / decoded.
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_AUTHORITY_KEY_ID = new SafeOID(9);
public static readonly SafeOID X509_AUTHORITY_KEY_ID = new(9);
/// <summary/>
public static readonly SafeOID X509_KEY_ATTRIBUTES = new SafeOID(10);
public static readonly SafeOID X509_KEY_ATTRIBUTES = new(10);
/// <summary/>
public static readonly SafeOID X509_KEY_USAGE_RESTRICTION = new SafeOID(11);
public static readonly SafeOID X509_KEY_USAGE_RESTRICTION = new(11);
/// <summary/>
public static readonly SafeOID X509_ALTERNATE_NAME = new SafeOID(12);
public static readonly SafeOID X509_ALTERNATE_NAME = new(12);
/// <summary/>
public static readonly SafeOID X509_BASIC_CONSTRAINTS = new SafeOID(13);
public static readonly SafeOID X509_BASIC_CONSTRAINTS = new(13);
/// <summary/>
public static readonly SafeOID X509_KEY_USAGE = new SafeOID(14);
public static readonly SafeOID X509_KEY_USAGE = new(14);
/// <summary/>
public static readonly SafeOID X509_BASIC_CONSTRAINTS2 = new SafeOID(15);
public static readonly SafeOID X509_BASIC_CONSTRAINTS2 = new(15);
/// <summary/>
public static readonly SafeOID X509_CERT_POLICIES = new SafeOID(16);
public static readonly SafeOID X509_CERT_POLICIES = new(16);
//+-------------------------------------------------------------------------
// Additional predefined data structures that can be encoded / decoded.
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID PKCS_UTC_TIME = new SafeOID(17);
public static readonly SafeOID PKCS_UTC_TIME = new(17);
/// <summary/>
public static readonly SafeOID PKCS_TIME_REQUEST = new SafeOID(18);
public static readonly SafeOID PKCS_TIME_REQUEST = new(18);
/// <summary/>
public static readonly SafeOID RSA_CSP_PUBLICKEYBLOB = new SafeOID(19);
public static readonly SafeOID RSA_CSP_PUBLICKEYBLOB = new(19);
/// <summary/>
public static readonly SafeOID X509_UNICODE_NAME = new SafeOID(20);
public static readonly SafeOID X509_UNICODE_NAME = new(20);
/// <summary/>
public static readonly SafeOID X509_KEYGEN_REQUEST_TO_BE_SIGNED = new SafeOID(21);
public static readonly SafeOID X509_KEYGEN_REQUEST_TO_BE_SIGNED = new(21);
/// <summary/>
public static readonly SafeOID PKCS_ATTRIBUTE = new SafeOID(22);
public static readonly SafeOID PKCS_ATTRIBUTE = new(22);
/// <summary/>
public static readonly SafeOID PKCS_CONTENT_INFO_SEQUENCE_OF_ANY = new SafeOID(23);
public static readonly SafeOID PKCS_CONTENT_INFO_SEQUENCE_OF_ANY = new(23);
//+-------------------------------------------------------------------------
// Predefined primitive data structures that can be encoded / decoded.
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_UNICODE_NAME_VALUE = new SafeOID(24);
public static readonly SafeOID X509_UNICODE_NAME_VALUE = new(24);
/// <summary/>
public static readonly SafeOID X509_ANY_STRING = X509_NAME_VALUE;
/// <summary/>
public static readonly SafeOID X509_UNICODE_ANY_STRING = X509_UNICODE_NAME_VALUE;
/// <summary/>
public static readonly SafeOID X509_OCTET_STRING = new SafeOID(25);
public static readonly SafeOID X509_OCTET_STRING = new(25);
/// <summary/>
public static readonly SafeOID X509_BITS = new SafeOID(26);
public static readonly SafeOID X509_BITS = new(26);
/// <summary/>
public static readonly SafeOID X509_INTEGER = new SafeOID(27);
public static readonly SafeOID X509_INTEGER = new(27);
/// <summary/>
public static readonly SafeOID X509_MULTI_BYTE_INTEGER = new SafeOID(28);
public static readonly SafeOID X509_MULTI_BYTE_INTEGER = new(28);
/// <summary/>
public static readonly SafeOID X509_ENUMERATED = new SafeOID(29);
public static readonly SafeOID X509_ENUMERATED = new(29);
/// <summary/>
public static readonly SafeOID X509_CHOICE_OF_TIME = new SafeOID(30);
public static readonly SafeOID X509_CHOICE_OF_TIME = new(30);
//+-------------------------------------------------------------------------
// More predefined X509 certificate extension data structures that can be
// encoded / decoded.
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_AUTHORITY_KEY_ID2 = new SafeOID(31);
public static readonly SafeOID X509_AUTHORITY_KEY_ID2 = new(31);
/// <summary/>
public static readonly SafeOID X509_AUTHORITY_INFO_ACCESS = new SafeOID(32);
public static readonly SafeOID X509_AUTHORITY_INFO_ACCESS = new(32);
/// <summary/>
public static readonly SafeOID PKCS_CONTENT_INFO = new SafeOID(33);
public static readonly SafeOID PKCS_CONTENT_INFO = new(33);
/// <summary/>
public static readonly SafeOID X509_SEQUENCE_OF_ANY = new SafeOID(34);
public static readonly SafeOID X509_SEQUENCE_OF_ANY = new(34);
/// <summary/>
public static readonly SafeOID X509_CRL_DIST_POINTS = new SafeOID(35);
public static readonly SafeOID X509_CRL_DIST_POINTS = new(35);
/// <summary/>
public static readonly SafeOID X509_ENHANCED_KEY_USAGE = new SafeOID(36);
public static readonly SafeOID X509_ENHANCED_KEY_USAGE = new(36);
/// <summary/>
public static readonly SafeOID PKCS_CTL = new SafeOID(37);
public static readonly SafeOID PKCS_CTL = new(37);
/// <summary/>
public static readonly SafeOID X509_MULTI_BYTE_UINT = new SafeOID(38);
public static readonly SafeOID X509_MULTI_BYTE_UINT = new(38);
/// <summary/>
public static readonly SafeOID X509_DSS_PARAMETERS = new SafeOID(39);
public static readonly SafeOID X509_DSS_PARAMETERS = new(39);
/// <summary/>
public static readonly SafeOID X509_DSS_SIGNATURE = new SafeOID(40);
public static readonly SafeOID X509_DSS_SIGNATURE = new(40);
/// <summary/>
public static readonly SafeOID PKCS_RC2_CBC_PARAMETERS = new SafeOID(41);
public static readonly SafeOID PKCS_RC2_CBC_PARAMETERS = new(41);
/// <summary/>
public static readonly SafeOID PKCS_SMIME_CAPABILITIES = new SafeOID(42);
public static readonly SafeOID PKCS_SMIME_CAPABILITIES = new(42);
/// <summary/>
public static readonly SafeOID X509_SUBJECT_INFO_ACCESS = X509_AUTHORITY_INFO_ACCESS;
/// <summary/>
@ -3788,23 +3789,23 @@ namespace Vanara.PInvoke
// function as PKCS_SMIME_CAPABILITIES. Its data structures are identical
// except for the names of the fields.
/// <summary/>
public static readonly SafeOID X509_QC_STATEMENTS_EXT = new SafeOID(42);
public static readonly SafeOID X509_QC_STATEMENTS_EXT = new(42);
//+-------------------------------------------------------------------------
// data structures for private keys
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID PKCS_RSA_PRIVATE_KEY = new SafeOID(43);
public static readonly SafeOID PKCS_RSA_PRIVATE_KEY = new(43);
/// <summary/>
public static readonly SafeOID PKCS_PRIVATE_KEY_INFO = new SafeOID(44);
public static readonly SafeOID PKCS_PRIVATE_KEY_INFO = new(44);
/// <summary/>
public static readonly SafeOID PKCS_ENCRYPTED_PRIVATE_KEY_INFO = new SafeOID(45);
public static readonly SafeOID PKCS_ENCRYPTED_PRIVATE_KEY_INFO = new(45);
//+-------------------------------------------------------------------------
// certificate policy qualifier
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_PKIX_POLICY_QUALIFIER_USERNOTICE = new SafeOID(46);
public static readonly SafeOID X509_PKIX_POLICY_QUALIFIER_USERNOTICE = new(46);
//+-------------------------------------------------------------------------
// Diffie-Hellman Key Exchange
@ -3812,11 +3813,11 @@ namespace Vanara.PInvoke
/// <summary/>
public static readonly SafeOID X509_DH_PUBLICKEY = X509_MULTI_BYTE_UINT;
/// <summary/>
public static readonly SafeOID X509_DH_PARAMETERS = new SafeOID(47);
public static readonly SafeOID X509_DH_PARAMETERS = new(47);
/// <summary/>
public static readonly SafeOID PKCS_ATTRIBUTES = new SafeOID(48);
public static readonly SafeOID PKCS_ATTRIBUTES = new(48);
/// <summary/>
public static readonly SafeOID PKCS_SORTED_CTL = new SafeOID(49);
public static readonly SafeOID PKCS_SORTED_CTL = new(49);
//+-------------------------------------------------------------------------
// ECC Signature
@ -3824,140 +3825,139 @@ namespace Vanara.PInvoke
// Uses the same encode/decode function as X509_DH_PARAMETERS. Its data
// structure is identical except for the names of the fields.
/// <summary/>
public static readonly SafeOID X509_ECC_SIGNATURE = new SafeOID(47);
public static readonly SafeOID X509_ECC_SIGNATURE = new(47);
//+-------------------------------------------------------------------------
// X942 Diffie-Hellman
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X942_DH_PARAMETERS = new SafeOID(50);
public static readonly SafeOID X942_DH_PARAMETERS = new(50);
//+-------------------------------------------------------------------------
// The following is the same as X509_BITS, except before encoding,
// the bit length is decremented to exclude trailing zero bits.
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_BITS_WITHOUT_TRAILING_ZEROES = new SafeOID(51);
public static readonly SafeOID X509_BITS_WITHOUT_TRAILING_ZEROES = new(51);
//+-------------------------------------------------------------------------
// X942 Diffie-Hellman Other Info
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X942_OTHER_INFO = new SafeOID(52);
public static readonly SafeOID X942_OTHER_INFO = new(52);
/// <summary/>
public static readonly SafeOID X509_CERT_PAIR = new SafeOID(53);
public static readonly SafeOID X509_CERT_PAIR = new(53);
/// <summary/>
public static readonly SafeOID X509_ISSUING_DIST_POINT = new SafeOID(54);
public static readonly SafeOID X509_ISSUING_DIST_POINT = new(54);
/// <summary/>
public static readonly SafeOID X509_NAME_CONSTRAINTS = new SafeOID(55);
public static readonly SafeOID X509_NAME_CONSTRAINTS = new(55);
/// <summary/>
public static readonly SafeOID X509_POLICY_MAPPINGS = new SafeOID(56);
public static readonly SafeOID X509_POLICY_MAPPINGS = new(56);
/// <summary/>
public static readonly SafeOID X509_POLICY_CONSTRAINTS = new SafeOID(57);
public static readonly SafeOID X509_POLICY_CONSTRAINTS = new(57);
/// <summary/>
public static readonly SafeOID X509_CROSS_CERT_DIST_POINTS = new SafeOID(58);
public static readonly SafeOID X509_CROSS_CERT_DIST_POINTS = new(58);
//+-------------------------------------------------------------------------
// Certificate Management Messages over CMS (CMC) Data Structures
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID CMC_DATA = new SafeOID(59);
public static readonly SafeOID CMC_DATA = new(59);
/// <summary/>
public static readonly SafeOID CMC_RESPONSE = new SafeOID(60);
public static readonly SafeOID CMC_RESPONSE = new(60);
/// <summary/>
public static readonly SafeOID CMC_STATUS = new SafeOID(61);
public static readonly SafeOID CMC_STATUS = new(61);
/// <summary/>
public static readonly SafeOID CMC_ADD_EXTENSIONS = new SafeOID(62);
public static readonly SafeOID CMC_ADD_EXTENSIONS = new(62);
/// <summary/>
public static readonly SafeOID CMC_ADD_ATTRIBUTES = new SafeOID(63);
public static readonly SafeOID CMC_ADD_ATTRIBUTES = new(63);
//+-------------------------------------------------------------------------
// Certificate Template
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_CERTIFICATE_TEMPLATE = new SafeOID(64);
public static readonly SafeOID X509_CERTIFICATE_TEMPLATE = new(64);
//+-------------------------------------------------------------------------
// Online Certificate Status Protocol (OCSP) Data Structures
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID OCSP_SIGNED_REQUEST = new SafeOID(65);
public static readonly SafeOID OCSP_SIGNED_REQUEST = new(65);
/// <summary/>
public static readonly SafeOID OCSP_REQUEST = new SafeOID(66);
public static readonly SafeOID OCSP_REQUEST = new(66);
/// <summary/>
public static readonly SafeOID OCSP_RESPONSE = new SafeOID(67);
public static readonly SafeOID OCSP_RESPONSE = new(67);
/// <summary/>
public static readonly SafeOID OCSP_BASIC_SIGNED_RESPONSE = new SafeOID(68);
public static readonly SafeOID OCSP_BASIC_SIGNED_RESPONSE = new(68);
/// <summary/>
public static readonly SafeOID OCSP_BASIC_RESPONSE = new SafeOID(69);
public static readonly SafeOID OCSP_BASIC_RESPONSE = new(69);
//+-------------------------------------------------------------------------
// Logotype and Biometric Extensions
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_LOGOTYPE_EXT = new SafeOID(70);
public static readonly SafeOID X509_LOGOTYPE_EXT = new(70);
/// <summary/>
public static readonly SafeOID X509_BIOMETRIC_EXT = new SafeOID(71);
public static readonly SafeOID X509_BIOMETRIC_EXT = new(71);
/// <summary/>
public static readonly SafeOID CNG_RSA_PUBLIC_KEY_BLOB = new SafeOID(72);
public static readonly SafeOID CNG_RSA_PUBLIC_KEY_BLOB = new(72);
/// <summary/>
public static readonly SafeOID X509_OBJECT_IDENTIFIER = new SafeOID(73);
public static readonly SafeOID X509_OBJECT_IDENTIFIER = new(73);
/// <summary/>
public static readonly SafeOID X509_ALGORITHM_IDENTIFIER = new SafeOID(74);
public static readonly SafeOID X509_ALGORITHM_IDENTIFIER = new(74);
/// <summary/>
public static readonly SafeOID PKCS_RSA_SSA_PSS_PARAMETERS = new SafeOID(75);
public static readonly SafeOID PKCS_RSA_SSA_PSS_PARAMETERS = new(75);
/// <summary/>
public static readonly SafeOID PKCS_RSAES_OAEP_PARAMETERS = new SafeOID(76);
public static readonly SafeOID PKCS_RSAES_OAEP_PARAMETERS = new(76);
/// <summary/>
public static readonly SafeOID ECC_CMS_SHARED_INFO = new SafeOID(77);
public static readonly SafeOID ECC_CMS_SHARED_INFO = new(77);
//+-------------------------------------------------------------------------
// TIMESTAMP
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID TIMESTAMP_REQUEST = new SafeOID(78);
public static readonly SafeOID TIMESTAMP_REQUEST = new(78);
/// <summary/>
public static readonly SafeOID TIMESTAMP_RESPONSE = new SafeOID(79);
public static readonly SafeOID TIMESTAMP_RESPONSE = new(79);
/// <summary/>
public static readonly SafeOID TIMESTAMP_INFO = new SafeOID(80);
public static readonly SafeOID TIMESTAMP_INFO = new(80);
//+-------------------------------------------------------------------------
// CertificateBundle
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_CERT_BUNDLE = new SafeOID(81);
public static readonly SafeOID X509_CERT_BUNDLE = new(81);
//+-------------------------------------------------------------------------
// ECC Keys
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_ECC_PRIVATE_KEY = new SafeOID(82); // CRYPT_ECC_PRIVATE_KEY_INFO
public static readonly SafeOID X509_ECC_PRIVATE_KEY = new(82); // CRYPT_ECC_PRIVATE_KEY_INFO
/// <summary/>
public static readonly SafeOID CNG_RSA_PRIVATE_KEY_BLOB = new SafeOID(83); // BCRYPT_RSAKEY_BLOB
public static readonly SafeOID CNG_RSA_PRIVATE_KEY_BLOB = new(83); // BCRYPT_RSAKEY_BLOB
//+-------------------------------------------------------------------------
// Subject Directory Attributes extension
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_SUBJECT_DIR_ATTRS = new SafeOID(84);
public static readonly SafeOID X509_SUBJECT_DIR_ATTRS = new(84);
//+-------------------------------------------------------------------------
// Generic ECC Parameters
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID X509_ECC_PARAMETERS = new SafeOID(85);
public static readonly SafeOID X509_ECC_PARAMETERS = new(85);
//+-------------------------------------------------------------------------
// Predefined PKCS #7 data structures that can be encoded / decoded.
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID PKCS7_SIGNER_INFO = new SafeOID(500);
public static readonly SafeOID PKCS7_SIGNER_INFO = new(500);
//+-------------------------------------------------------------------------
// Predefined PKCS #7 data structures that can be encoded / decoded.
//--------------------------------------------------------------------------
/// <summary/>
public static readonly SafeOID CMS_SIGNER_INFO = new SafeOID(501);
}
public static readonly SafeOID CMS_SIGNER_INFO = new(501);
}
}

View File

@ -1,8 +1,8 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -176,7 +176,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dpapi.h", MSDNShortId = "765a68fd-f105-49fc-a738-4a8129eb0770")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptProtectData(in CRYPTOAPI_BLOB pDataIn, [Optional, MarshalAs(UnmanagedType.LPWStr)] string szDataDescr, in CRYPTOAPI_BLOB pOptionalEntropy,
public static extern bool CryptProtectData(in CRYPTOAPI_BLOB pDataIn, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? szDataDescr, in CRYPTOAPI_BLOB pOptionalEntropy,
[Optional] IntPtr pvReserved, in CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, CryptProtectFlags dwFlags, IntPtr pDataOut);
/// <summary>
@ -265,7 +265,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dpapi.h", MSDNShortId = "765a68fd-f105-49fc-a738-4a8129eb0770")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptProtectData(in CRYPTOAPI_BLOB pDataIn, [Optional, MarshalAs(UnmanagedType.LPWStr)] string szDataDescr, [Optional] IntPtr pOptionalEntropy,
public static extern bool CryptProtectData(in CRYPTOAPI_BLOB pDataIn, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? szDataDescr, [Optional] IntPtr pOptionalEntropy,
[Optional] IntPtr pvReserved, [Optional] IntPtr pPromptStruct, CryptProtectFlags dwFlags, IntPtr pDataOut);
/// <summary>
@ -668,7 +668,8 @@ namespace Vanara.PInvoke
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dpapi.h", MSDNShortId = "f32e8fcd-6b5b-4a43-b3f9-77e17c84deca")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptUpdateProtectedState([Optional] PSID pOldSid, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszOldPassword, [Optional] uint dwFlags, out uint pdwSuccessCount, out uint pdwFailureCount);
public static extern bool CryptUpdateProtectedState([Optional] PSID pOldSid, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszOldPassword,
[Optional] uint dwFlags, out uint pdwSuccessCount, out uint pdwFailureCount);
/// <summary>
/// The <c>CRYPTPROTECT_PROMPTSTRUCT</c> structure provides the text of a prompt and information about when and where that prompt is
@ -714,4 +715,3 @@ namespace Vanara.PInvoke
[MarshalAs(UnmanagedType.LPWStr)] public string szPrompt;
}
}
}

View File

@ -2,8 +2,8 @@
using System.Runtime.InteropServices;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in Crypt32.dll.</summary>
public static partial class Crypt32
{
@ -1028,4 +1028,3 @@ namespace Vanara.PInvoke
public IntPtr pClientData;
}
}
}

View File

@ -3,8 +3,8 @@ using System.Runtime.InteropServices;
using System.Text;
using static Vanara.PInvoke.Crypt32;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in CryptDlg.dll.</summary>
public static partial class CryptDlg
{
@ -633,4 +633,3 @@ namespace Vanara.PInvoke
public uint dwError;
}
}
}

View File

@ -4,8 +4,8 @@ using System.Runtime.InteropServices;
using static Vanara.PInvoke.Crypt32;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in CryptNet.dll.</summary>
public static partial class CryptNet
{
@ -1935,4 +1935,3 @@ namespace Vanara.PInvoke
public IntPtr rgcGroupEntry;
}
}
}

View File

@ -4,8 +4,8 @@ using Vanara.Extensions;
using Vanara.InteropServices;
using static Vanara.PInvoke.Crypt32;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in CryptUI.dll.</summary>
public static partial class CryptUI
{
@ -448,8 +448,8 @@ namespace Vanara.PInvoke
// dwDontUseColumn, DWORD dwFlags, void *pvReserved );
[DllImport(Lib.CryptUI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cryptuiapi.h", MSDNShortId = "5774af1c-f2d4-4b1e-a20b-dfb57bf9aa37")]
public static extern SafePCCERT_CONTEXT CryptUIDlgSelectCertificateFromStore([In] HCERTSTORE hCertStore, [In, Optional] HWND hwnd, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszTitle,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszDisplayString, CryptUISelect dwDontUseColumn, uint dwFlags = 0, IntPtr pvReserved = default);
public static extern SafePCCERT_CONTEXT CryptUIDlgSelectCertificateFromStore([In] HCERTSTORE hCertStore, [In, Optional] HWND hwnd, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszTitle,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszDisplayString, CryptUISelect dwDontUseColumn, uint dwFlags = 0, IntPtr pvReserved = default);
/// <summary>The <c>CryptUIDlgViewCertificate</c> function presents a dialog box that displays a specified certificate.</summary>
/// <param name="pCertViewInfo">
@ -505,7 +505,7 @@ namespace Vanara.PInvoke
[PInvokeData("cryptuiapi.h", MSDNShortId = "d4b8f01b-7c3e-4286-bc37-d5ec4a1e1c2f")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptUIDlgViewContext(CertStoreContextType dwContextType, [In] IntPtr pvContext, [In, Optional] HWND hwnd,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszTitle, uint dwFlags = 0, IntPtr pvReserved = default);
[Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszTitle, uint dwFlags = 0, IntPtr pvReserved = default);
/// <summary>
/// <para>
@ -560,7 +560,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.CryptUI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("cryptuiapi.h", MSDNShortId = "1d01523e-d47b-49be-82c8-5e98f97be800")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptUIWizDigitalSign(CryptUIWizFlags dwFlags, [In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszWizardTitle,
public static extern bool CryptUIWizDigitalSign(CryptUIWizFlags dwFlags, [In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszWizardTitle,
in CRYPTUI_WIZ_DIGITAL_SIGN_INFO pDigitalSignInfo, out SafePCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT ppSignContext);
/// <summary>
@ -643,7 +643,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.CryptUI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("cryptuiapi.h", MSDNShortId = "62537d51-c761-4180-b857-58c819ea66aa")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptUIWizExport(CryptUIWizFlags dwFlags, [In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszWizardTitle,
public static extern bool CryptUIWizExport(CryptUIWizFlags dwFlags, [In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszWizardTitle,
in CRYPTUI_WIZ_EXPORT_INFO pExportInfo, [In, Optional] IntPtr pvoid);
/// <summary>
@ -794,7 +794,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.CryptUI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("cryptuiapi.h", MSDNShortId = "6b2b9c89-229a-4626-a8b4-fe2b7cc0af86")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptUIWizImport(CryptUIWizFlags dwFlags, [In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszWizardTitle,
public static extern bool CryptUIWizImport(CryptUIWizFlags dwFlags, [In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszWizardTitle,
in CRYPTUI_WIZ_IMPORT_SRC_INFO pImportSrc, [In, Optional] HCERTSTORE hDestCertStore);
/// <summary>
@ -929,7 +929,7 @@ namespace Vanara.PInvoke
[DllImport(Lib.CryptUI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("cryptuiapi.h", MSDNShortId = "6b2b9c89-229a-4626-a8b4-fe2b7cc0af86")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptUIWizImport(CryptUIWizFlags dwFlags, [In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszWizardTitle,
public static extern bool CryptUIWizImport(CryptUIWizFlags dwFlags, [In, Optional] HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszWizardTitle,
[In, Optional] IntPtr pImportSrc, [In, Optional] HCERTSTORE hDestCertStore);
/// <summary>
@ -958,7 +958,7 @@ namespace Vanara.PInvoke
public uint cChain;
/// <summary>Gets the array of pointers to CERT_CHAIN_CONTEXT structures.</summary>
public PCCERT_CHAIN_CONTEXT[] GetChain() => prgpChain.ToArray<PCCERT_CHAIN_CONTEXT>((int)cChain);
public PCCERT_CHAIN_CONTEXT[]? GetChain() => prgpChain.ToArray<PCCERT_CHAIN_CONTEXT>((int)cChain);
}
/// <summary>The <c>CRYPTUI_CERT_MGR_STRUCT</c> structure contains information about a certificate manager dialog box.</summary>
@ -2017,7 +2017,7 @@ namespace Vanara.PInvoke
public static bool operator ==(PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT h1, PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT h && handle == h.handle;
public override bool Equals(object? obj) => obj is PCCRYPTUI_WIZ_DIGITAL_SIGN_CONTEXT h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -2052,4 +2052,3 @@ namespace Vanara.PInvoke
protected override bool InternalReleaseHandle() => CryptUIWizFreeDigitalSignContext(handle);
}
}
}

View File

@ -4,8 +4,8 @@ using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in NCrypt.dll.</summary>
public static partial class NCrypt
{
@ -575,7 +575,7 @@ namespace Vanara.PInvoke
// pbClaimBlob, DWORD cbClaimBlob, DWORD *pcbResult, DWORD dwFlags );
[DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ncrypt.h", MSDNShortId = "EBEE3A67-0693-4B85-88B1-580CB2152703")]
public static extern HRESULT NCryptCreateClaim(NCRYPT_KEY_HANDLE hSubjectKey, NCRYPT_KEY_HANDLE hAuthorityKey, uint dwClaimType, [Optional] NCryptBufferDesc[] pParameterList, IntPtr pbClaimBlob, uint cbClaimBlob, out uint pcbResult, uint dwFlags = 0);
public static extern HRESULT NCryptCreateClaim(NCRYPT_KEY_HANDLE hSubjectKey, NCRYPT_KEY_HANDLE hAuthorityKey, uint dwClaimType, [Optional] NCryptBufferDesc[]? pParameterList, IntPtr pbClaimBlob, uint cbClaimBlob, out uint pcbResult, uint dwFlags = 0);
/// <summary>
/// The <c>NCryptCreatePersistedKey</c> function creates a new key and stores it in the specified key storage provider. After you
@ -689,7 +689,7 @@ namespace Vanara.PInvoke
// dwLegacyKeySpec, DWORD dwFlags );
[DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ncrypt.h", MSDNShortId = "eeb1842f-fd9e-4edf-9db8-7b4e91760e9b")]
public static extern HRESULT NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE hProvider, out SafeNCRYPT_KEY_HANDLE phKey, string pszAlgId, [Optional] string pszKeyName, Crypt32.PrivateKeyType dwLegacyKeySpec = 0, CreatePersistedFlags dwFlags = 0);
public static extern HRESULT NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE hProvider, out SafeNCRYPT_KEY_HANDLE phKey, string pszAlgId, [Optional] string? pszKeyName, Crypt32.PrivateKeyType dwLegacyKeySpec = 0, CreatePersistedFlags dwFlags = 0);
/// <summary>The <c>NCryptDecrypt</c> function decrypts a block of encrypted data.</summary>
/// <param name="hKey">The handle of the key to use to decrypt the data.</param>
@ -1122,7 +1122,7 @@ namespace Vanara.PInvoke
// DWORD *pcbResult, ULONG dwFlags );
[DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ncrypt.h", MSDNShortId = "0ff08c6a-5f30-43ca-9db8-cda3e0704b0a")]
public static extern HRESULT NCryptDeriveKey(NCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc pParameterList, SafeAllocatedMemoryHandle pbDerivedKey,
public static extern HRESULT NCryptDeriveKey(NCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc? pParameterList, SafeAllocatedMemoryHandle pbDerivedKey,
uint cbDerivedKey, out uint pcbResult, BCrypt.DeriveKeyFlags dwFlags);
/// <summary>
@ -1381,7 +1381,7 @@ namespace Vanara.PInvoke
// DWORD *pcbResult, ULONG dwFlags );
[DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ncrypt.h", MSDNShortId = "0ff08c6a-5f30-43ca-9db8-cda3e0704b0a")]
public static extern HRESULT NCryptDeriveKey(NCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc pParameterList, [Optional] IntPtr pbDerivedKey,
public static extern HRESULT NCryptDeriveKey(NCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc? pParameterList, [Optional] IntPtr pbDerivedKey,
[Optional] uint cbDerivedKey, out uint pcbResult, BCrypt.DeriveKeyFlags dwFlags);
/// <summary>The <c>NCryptEncrypt</c> function encrypts a block of data.</summary>
@ -1693,7 +1693,7 @@ namespace Vanara.PInvoke
// NCRYPT_PROV_HANDLE hProvider, LPCWSTR pszScope, NCryptKeyName **ppKeyName, PVOID *ppEnumState, DWORD dwFlags );
[DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ncrypt.h", MSDNShortId = "ca8c5b70-ea5e-4fb9-82d3-1de839f0d244")]
public static extern HRESULT NCryptEnumKeys(NCRYPT_PROV_HANDLE hProvider, [MarshalAs(UnmanagedType.LPWStr), Optional] string pszScope, out SafeNCryptBuffer ppKeyName, ref IntPtr ppEnumState, OpenKeyFlags dwFlags);
public static extern HRESULT NCryptEnumKeys(NCRYPT_PROV_HANDLE hProvider, [MarshalAs(UnmanagedType.LPWStr), Optional] string? pszScope, out SafeNCryptBuffer ppKeyName, ref IntPtr ppEnumState, OpenKeyFlags dwFlags);
/// <summary>The <c>NCryptEnumStorageProviders</c> function obtains the names of the registered key storage providers.</summary>
/// <param name="pdwProviderCount">The address of a <c>DWORD</c> to receive the number of elements in the ppProviderList array.</param>
@ -1987,7 +1987,7 @@ namespace Vanara.PInvoke
// cbOutput, DWORD *pcbResult, DWORD dwFlags );
[DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ncrypt.h", MSDNShortId = "1588eb29-4026-4d1c-8bee-a035df38444a")]
public static extern HRESULT NCryptExportKey(NCRYPT_KEY_HANDLE hKey, NCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, [Optional] NCryptBufferDesc pParameterList, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, NCryptUIFlags dwFlags = 0);
public static extern HRESULT NCryptExportKey(NCRYPT_KEY_HANDLE hKey, NCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, [Optional] NCryptBufferDesc? pParameterList, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, NCryptUIFlags dwFlags = 0);
/// <summary>
/// <para>The <c>NCryptExportKey</c> function exports a CNG key to a memory BLOB.</para>
@ -2220,7 +2220,7 @@ namespace Vanara.PInvoke
// cbOutput, DWORD *pcbResult, DWORD dwFlags );
[DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ncrypt.h", MSDNShortId = "1588eb29-4026-4d1c-8bee-a035df38444a")]
public static extern HRESULT NCryptExportKey(NCRYPT_KEY_HANDLE hKey, NCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, [Optional] NCryptBufferDesc pParameterList, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, NCryptUIFlags dwFlags = 0);
public static extern HRESULT NCryptExportKey(NCRYPT_KEY_HANDLE hKey, NCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, [Optional] NCryptBufferDesc? pParameterList, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, NCryptUIFlags dwFlags = 0);
/// <summary>
/// <para>
@ -4203,7 +4203,7 @@ namespace Vanara.PInvoke
// pbClaimBlob, DWORD cbClaimBlob, NCryptBufferDesc *pOutput, DWORD dwFlags );
[DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ncrypt.h", MSDNShortId = "D3C837A5-49D7-4099-B8FE-37364A275A73")]
public static extern HRESULT NCryptVerifyClaim(NCRYPT_KEY_HANDLE hSubjectKey, [Optional] NCRYPT_KEY_HANDLE hAuthorityKey, uint dwClaimType, [Optional] NCryptBufferDesc[] pParameterList, [In] IntPtr pbClaimBlob, uint cbClaimBlob, out NCryptBufferDesc pOutput, uint dwFlags = 0);
public static extern HRESULT NCryptVerifyClaim(NCRYPT_KEY_HANDLE hSubjectKey, [Optional] NCRYPT_KEY_HANDLE hAuthorityKey, uint dwClaimType, [Optional] NCryptBufferDesc[]? pParameterList, [In] IntPtr pbClaimBlob, uint cbClaimBlob, out NCryptBufferDesc pOutput, uint dwFlags = 0);
/// <summary>The <c>NCryptVerifySignature</c> function verifies that the specified signature matches the specified hash.</summary>
/// <param name="hKey">
@ -4342,7 +4342,7 @@ namespace Vanara.PInvoke
public NCRYPT_HASH_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="NCRYPT_HASH_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static NCRYPT_HASH_HANDLE NULL => new NCRYPT_HASH_HANDLE(IntPtr.Zero);
public static NCRYPT_HASH_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -4355,7 +4355,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="NCRYPT_HASH_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NCRYPT_HASH_HANDLE(IntPtr h) => new NCRYPT_HASH_HANDLE(h);
public static implicit operator NCRYPT_HASH_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -4370,7 +4370,7 @@ namespace Vanara.PInvoke
public static bool operator ==(NCRYPT_HASH_HANDLE h1, NCRYPT_HASH_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is NCRYPT_HASH_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is NCRYPT_HASH_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -4390,7 +4390,7 @@ namespace Vanara.PInvoke
public NCRYPT_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="NCRYPT_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static NCRYPT_HANDLE NULL => new NCRYPT_HANDLE(IntPtr.Zero);
public static NCRYPT_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -4403,7 +4403,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="NCRYPT_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NCRYPT_HANDLE(IntPtr h) => new NCRYPT_HANDLE(h);
public static implicit operator NCRYPT_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -4418,7 +4418,7 @@ namespace Vanara.PInvoke
public static bool operator ==(NCRYPT_HANDLE h1, NCRYPT_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is NCRYPT_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is NCRYPT_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -4438,7 +4438,7 @@ namespace Vanara.PInvoke
public NCRYPT_KEY_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="NCRYPT_KEY_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static NCRYPT_KEY_HANDLE NULL => new NCRYPT_KEY_HANDLE(IntPtr.Zero);
public static NCRYPT_KEY_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -4451,7 +4451,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="NCRYPT_KEY_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NCRYPT_KEY_HANDLE(IntPtr h) => new NCRYPT_KEY_HANDLE(h);
public static implicit operator NCRYPT_KEY_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -4466,7 +4466,7 @@ namespace Vanara.PInvoke
public static bool operator ==(NCRYPT_KEY_HANDLE h1, NCRYPT_KEY_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is NCRYPT_KEY_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is NCRYPT_KEY_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -4486,7 +4486,7 @@ namespace Vanara.PInvoke
public NCRYPT_PROV_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="NCRYPT_PROV_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static NCRYPT_PROV_HANDLE NULL => new NCRYPT_PROV_HANDLE(IntPtr.Zero);
public static NCRYPT_PROV_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -4499,7 +4499,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="NCRYPT_PROV_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NCRYPT_PROV_HANDLE(IntPtr h) => new NCRYPT_PROV_HANDLE(h);
public static implicit operator NCRYPT_PROV_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -4514,7 +4514,7 @@ namespace Vanara.PInvoke
public static bool operator ==(NCRYPT_PROV_HANDLE h1, NCRYPT_PROV_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is NCRYPT_PROV_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is NCRYPT_PROV_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -4534,7 +4534,7 @@ namespace Vanara.PInvoke
public NCRYPT_SECRET_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="NCRYPT_SECRET_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static NCRYPT_SECRET_HANDLE NULL => new NCRYPT_SECRET_HANDLE(IntPtr.Zero);
public static NCRYPT_SECRET_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -4547,7 +4547,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="NCRYPT_SECRET_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NCRYPT_SECRET_HANDLE(IntPtr h) => new NCRYPT_SECRET_HANDLE(h);
public static implicit operator NCRYPT_SECRET_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -4562,7 +4562,7 @@ namespace Vanara.PInvoke
public static bool operator ==(NCRYPT_SECRET_HANDLE h1, NCRYPT_SECRET_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is NCRYPT_SECRET_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is NCRYPT_SECRET_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -5074,7 +5074,7 @@ namespace Vanara.PInvoke
set
{
((IDisposable)this).Dispose();
if (value == null) return;
if (value == null || value.Length == 0) return;
_pBuffers = InteropExtensions.MarshalToPtr<_NCryptBuffer>(value.Select(b => new _NCryptBuffer(b)), Marshal.AllocCoTaskMem, out var _);
}
}
@ -5113,7 +5113,7 @@ namespace Vanara.PInvoke
pvBuffer = b.pvBuffer?.MarshalToPtr<byte>(Marshal.AllocCoTaskMem, out var _) ?? IntPtr.Zero;
}
public static implicit operator NCryptBuffer(_NCryptBuffer b) => new NCryptBuffer { BufferType = b.BufferType, pvBuffer = b.pvBuffer.ToByteArray((int)b.cbBuffer) };
public static implicit operator NCryptBuffer(_NCryptBuffer b) => new() { BufferType = b.BufferType, pvBuffer = b.pvBuffer.ToByteArray((int)b.cbBuffer) ?? new byte[0] };
}
}
@ -5210,15 +5210,14 @@ namespace Vanara.PInvoke
/// <typeparam name="T">Type of native structure used by the C-style array.</typeparam>
/// <param name="count">The number of items in the native array.</param>
/// <returns>An array of type <typeparamref name="T"/> containing the elements of the native array.</returns>
public T[] ToArray<T>(uint count) => handle.ToArray<T>((int)count);
public T[]? ToArray<T>(uint count) => handle.ToArray<T>((int)count);
/// <summary>Marshals data to a newly allocated managed object of the type specified by a generic type parameter.</summary>
/// <typeparam name="T">The type of the object to which the data is to be copied. This must be a structure.</typeparam>
/// <returns>A managed object that contains the data pointed to by this object.</returns>
public T ToStructure<T>() => handle.ToStructure<T>();
public T? ToStructure<T>() => handle.ToStructure<T>();
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => NCryptFreeBuffer(handle).Succeeded;
}
}
}

View File

@ -3,8 +3,8 @@ using System.Runtime.InteropServices;
using System.Text;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in ncrypt.dll.</summary>
public static partial class NCrypt
{
@ -1316,7 +1316,7 @@ namespace Vanara.PInvoke
public NCRYPT_DESCRIPTOR_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="NCRYPT_DESCRIPTOR_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static NCRYPT_DESCRIPTOR_HANDLE NULL => new NCRYPT_DESCRIPTOR_HANDLE(IntPtr.Zero);
public static NCRYPT_DESCRIPTOR_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -1329,7 +1329,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="NCRYPT_DESCRIPTOR_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NCRYPT_DESCRIPTOR_HANDLE(IntPtr h) => new NCRYPT_DESCRIPTOR_HANDLE(h);
public static implicit operator NCRYPT_DESCRIPTOR_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -1344,7 +1344,7 @@ namespace Vanara.PInvoke
public static bool operator ==(NCRYPT_DESCRIPTOR_HANDLE h1, NCRYPT_DESCRIPTOR_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is NCRYPT_DESCRIPTOR_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is NCRYPT_DESCRIPTOR_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -1406,7 +1406,7 @@ namespace Vanara.PInvoke
public NCRYPT_STREAM_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>Returns an invalid handle by instantiating a <see cref="NCRYPT_STREAM_HANDLE"/> object with <see cref="IntPtr.Zero"/>.</summary>
public static NCRYPT_STREAM_HANDLE NULL => new NCRYPT_STREAM_HANDLE(IntPtr.Zero);
public static NCRYPT_STREAM_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
@ -1419,7 +1419,7 @@ namespace Vanara.PInvoke
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="NCRYPT_STREAM_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator NCRYPT_STREAM_HANDLE(IntPtr h) => new NCRYPT_STREAM_HANDLE(h);
public static implicit operator NCRYPT_STREAM_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
@ -1434,7 +1434,7 @@ namespace Vanara.PInvoke
public static bool operator ==(NCRYPT_STREAM_HANDLE h1, NCRYPT_STREAM_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is NCRYPT_STREAM_HANDLE h ? handle == h.handle : false;
public override bool Equals(object? obj) => obj is NCRYPT_STREAM_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
@ -1487,4 +1487,3 @@ namespace Vanara.PInvoke
protected override bool InternalReleaseHandle() => NCryptStreamClose(this).Succeeded;
}
}
}

View File

@ -2,8 +2,8 @@
using System.Runtime.InteropServices;
using System.Text;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in NCrypt.dll.</summary>
public static partial class NCrypt
{
@ -1714,4 +1714,3 @@ namespace Vanara.PInvoke
protected override bool InternalReleaseHandle() => SslFreeBuffer(handle).Succeeded;
}
}
}

View File

@ -1,8 +1,8 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
namespace Vanara.PInvoke;
/// <summary>Methods and data types found in TokenBinding.dll.</summary>
public static partial class TokenBinding
{
@ -423,4 +423,3 @@ namespace Vanara.PInvoke
public IntPtr resultData;
}
}
}

View File

@ -4,6 +4,7 @@
<SupportedDlls>crypt32.dll;bcrypt.dll;ncrypt.dll;tokenbinding.dll;cryptui.dll;cryptnet.dll;cryptdlg.dll</SupportedDlls>
</ProjectExtensions>
<PropertyGroup>
<Nullable>enable</Nullable>
<Description>PInvoke API (methods, structures and constants) imported from Windows crypt32.dll, bcrypt.dll, ncrypt.dll, tokenbinding.dll, cryptnet.dll, cryptdlg.dll and cryptui.dll.</Description>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<AssemblyName>Vanara.PInvoke.Cryptography</AssemblyName>

View File

@ -19,6 +19,6 @@ namespace Vanara.PInvoke
/// <summary>Lookups the specified unique identifier.</summary>
/// <param name="guid">The unique identifier.</param>
/// <returns>Corresponding BHID.</returns>
public static TEnum Lookup<TEnum>(Guid guid) where TEnum : System.Enum => AssociateAttribute.TryEnumLookup(guid, out TEnum val) ? val : (TEnum)Convert.ChangeType(-1, typeof(TEnum));
public static TEnum Lookup<TEnum>(Guid guid) where TEnum : struct, Enum => AssociateAttribute.TryEnumLookup(guid, out TEnum val) ? val : (TEnum)Convert.ChangeType(-1, typeof(TEnum));
}
}