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

◆ ImportKeyBlob()

static void Internal.NativeCrypto.CapiHelper.ImportKeyBlob ( SafeProvHandle saveProvHandle,
CspProviderFlags flags,
bool addNoSaltFlag,
byte[] keyBlob,
out SafeKeyHandle safeKeyHandle )
inlinestaticpackage

Definition at line 995 of file CapiHelper.cs.

996 {
997 bool flag = keyBlob.Length != 0 && keyBlob[0] == 6;
998 int num = MapCspKeyFlags((int)flags);
999 if (flag)
1000 {
1001 num &= -2;
1002 }
1003 if (addNoSaltFlag)
1004 {
1005 num |= 0x10;
1006 }
1007 if (!CryptImportKey(saveProvHandle, keyBlob, SafeKeyHandle.InvalidHandle, num, out var phKey))
1008 {
1009 int hRForLastWin32Error = Marshal.GetHRForLastWin32Error();
1010 phKey.Dispose();
1011 throw hRForLastWin32Error.ToCryptographicException();
1012 }
1013 phKey.PublicOnly = flag;
1014 safeKeyHandle = phKey;
1015 }
static int MapCspKeyFlags(int flags)
static unsafe bool CryptImportKey(SafeProvHandle hProv, ReadOnlySpan< byte > pbData, SafeKeyHandle hPubKey, int dwFlags, out SafeKeyHandle phKey)

References Internal.NativeCrypto.CapiHelper.CryptImportKey(), System.Runtime.InteropServices.Marshal.GetHRForLastWin32Error(), and Internal.NativeCrypto.CapiHelper.MapCspKeyFlags().

Referenced by System.Security.Cryptography.DSACryptoServiceProvider.ImportCspBlob(), System.Security.Cryptography.RSACryptoServiceProvider.ImportCspBlob(), and Internal.Cryptography.BasicSymmetricCipherCsp.ImportCspBlob().