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

◆ GetKeyParameter()

static byte[] Internal.NativeCrypto.CapiHelper.GetKeyParameter ( SafeKeyHandle safeKeyHandle,
int keyParam )
inlinestaticpackage

Definition at line 775 of file CapiHelper.cs.

776 {
777 byte[] array = null;
778 int pdwDataLen = 0;
779 VerifyValidHandle(safeKeyHandle);
780 switch (keyParam)
781 {
782 case 1:
783 if (!global::Interop.Advapi32.CryptGetKeyParam(safeKeyHandle, global::Interop.Advapi32.CryptGetKeyParamFlags.KP_KEYLEN, null, ref pdwDataLen, 0))
784 {
785 throw GetErrorCode().ToCryptographicException();
786 }
787 array = new byte[pdwDataLen];
788 if (!global::Interop.Advapi32.CryptGetKeyParam(safeKeyHandle, global::Interop.Advapi32.CryptGetKeyParamFlags.KP_KEYLEN, array, ref pdwDataLen, 0))
789 {
790 throw GetErrorCode().ToCryptographicException();
791 }
792 break;
793 case 2:
794 array = new byte[1] { (byte)(safeKeyHandle.PublicOnly ? 1 : 0) };
795 break;
796 case 9:
797 if (!global::Interop.Advapi32.CryptGetKeyParam(safeKeyHandle, global::Interop.Advapi32.CryptGetKeyParamFlags.KP_ALGID, null, ref pdwDataLen, 0))
798 {
799 throw GetErrorCode().ToCryptographicException();
800 }
801 array = new byte[pdwDataLen];
802 if (!global::Interop.Advapi32.CryptGetKeyParam(safeKeyHandle, global::Interop.Advapi32.CryptGetKeyParamFlags.KP_ALGID, array, ref pdwDataLen, 0))
803 {
804 throw GetErrorCode().ToCryptographicException();
805 }
806 break;
807 }
808 return array;
809 }
static void VerifyValidHandle(SafeHandleZeroOrMinusOneIsInvalid handle)

References System.array, Internal.NativeCrypto.CapiHelper.GetErrorCode(), and Internal.NativeCrypto.CapiHelper.VerifyValidHandle().

Referenced by Internal.NativeCrypto.CapiHelper.GetKeyPairHelper().