Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetPrivateKeyCsp()

unsafe CspParameters Internal.Cryptography.Pal.CertificatePal.GetPrivateKeyCsp ( )
inlineprivate

Definition at line 830 of file CertificatePal.cs.

831 {
832 int pcbData = 0;
833 if (!global::Interop.crypt32.CertGetCertificateContextProperty(_certContext, CertContextPropId.CERT_KEY_PROV_INFO_PROP_ID, null, ref pcbData))
834 {
836 if (lastWin32Error == -2146885628)
837 {
838 return null;
839 }
840 throw lastWin32Error.ToCryptographicException();
841 }
842 byte[] array = new byte[pcbData];
843 fixed (byte* ptr = array)
844 {
845 if (!global::Interop.crypt32.CertGetCertificateContextProperty(_certContext, CertContextPropId.CERT_KEY_PROV_INFO_PROP_ID, array, ref pcbData))
846 {
847 throw Marshal.GetLastWin32Error().ToCryptographicException();
848 }
851 cspParameters.ProviderName = Marshal.PtrToStringUni((IntPtr)ptr2->pwszProvName);
852 cspParameters.KeyContainerName = Marshal.PtrToStringUni((IntPtr)ptr2->pwszContainerName);
853 cspParameters.ProviderType = ptr2->dwProvType;
854 cspParameters.KeyNumber = ptr2->dwKeySpec;
855 cspParameters.Flags = (((ptr2->dwFlags & CryptAcquireContextFlags.CRYPT_MACHINE_KEYSET) == CryptAcquireContextFlags.CRYPT_MACHINE_KEYSET) ? CspProviderFlags.UseMachineKeyStore : CspProviderFlags.NoFlags);
856 return cspParameters;
857 }
858 }
static unsafe? string PtrToStringUni(IntPtr ptr)
Definition Marshal.cs:652

References Internal.Cryptography.Pal.CertificatePal._certContext, System.array, System.Runtime.InteropServices.Marshal.GetLastWin32Error(), and System.Runtime.InteropServices.Marshal.PtrToStringUni().

Referenced by Internal.Cryptography.Pal.CertificatePal.AppendPrivateKeyInfo(), and Internal.Cryptography.Pal.CertificatePal.GetPrivateKey< T >().