static string GetProviderName(ProviderHandle providerHandle) { if (providerHandle == null) { throw new ArgumentNullException(nameof(providerHandle)); } var providerNameLength_Bytes = 0; if (CryptGetProvParam(providerHandle, CryptGetProvParamParameterTypes.PP_NAME, null, ref providerNameLength_Bytes, 0) == false) { throw new Win32Exception(); } var providerName = new byte[providerNameLength_Bytes]; if (CryptGetProvParam(providerHandle, CryptGetProvParamParameterTypes.PP_NAME, providerName, ref providerNameLength_Bytes, 0) == false) { throw new Win32Exception(); } return(Encoding.ASCII.GetString(providerName).TrimEnd('\0')); }
static bool CryptGetSecurityDescriptor(ProviderHandle providerHandle, byte[] securityDescriptor, ref int securityDescriptorLength_Bytes, SecurityDescriptorFlags flags) { return(CryptGetProvParam(providerHandle, CryptGetProvParamParameterTypes.PP_KEYSET_SEC_DESCR, securityDescriptor, ref securityDescriptorLength_Bytes, (uint)flags)); }
static bool CryptEnumerateContainerNames(ProviderHandle providerHandle, byte[] containerName, ref int containerNameLength_Bytes, EnumerationFlags flags) { return(CryptGetProvParam(providerHandle, CryptGetProvParamParameterTypes.PP_ENUMCONTAINERS, containerName, ref containerNameLength_Bytes, (uint)flags)); }
static extern bool CryptGetProvParam(ProviderHandle hProv, CryptGetProvParamParameterTypes dwParam, [Out] byte[] pbData, ref int dwDataLen, uint dwFlags);
static extern bool CryptAcquireContext(out ProviderHandle hProv, string pszContainer, string pszProvider, ProviderType.Ids dwProvType, CryptAcquireContextFlags dwFlags);