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

◆ BCryptImportKey() [3/4]

static unsafe SafeKeyHandle Interop.BCrypt.BCryptImportKey ( SafeAlgorithmHandle hAlg,
ReadOnlySpan< byte > key )
inlinestaticpackage

Definition at line 361 of file Interop.cs.

362 {
363 int length = key.Length;
364 int num = sizeof(BCRYPT_KEY_DATA_BLOB_HEADER) + length;
365 byte[] array = new byte[num];
366 fixed (byte* ptr = array)
367 {
368 BCRYPT_KEY_DATA_BLOB_HEADER* ptr2 = (BCRYPT_KEY_DATA_BLOB_HEADER*)ptr;
369 ptr2->dwMagic = 1296188491u;
370 ptr2->dwVersion = 1u;
371 ptr2->cbKeyData = (uint)length;
372 }
373 key.CopyTo(array.AsSpan(sizeof(BCRYPT_KEY_DATA_BLOB_HEADER)));
374 SafeKeyHandle hKey;
375 NTSTATUS nTSTATUS = BCryptImportKey(hAlg, IntPtr.Zero, "KeyDataBlob", out hKey, IntPtr.Zero, 0, array, num, 0);
376 if (nTSTATUS != 0)
377 {
378 throw CreateCryptographicException(nTSTATUS);
379 }
380 return hKey;
381 }
static Exception CreateCryptographicException(NTSTATUS ntStatus)
Definition Interop.cs:461
static unsafe SafeKeyHandle BCryptImportKey(SafeAlgorithmHandle hAlg, ReadOnlySpan< byte > key)
Definition Interop.cs:361
static readonly IntPtr Zero
Definition IntPtr.cs:18

References System.array, Interop.BCrypt.BCryptImportKey(), Interop.BCrypt.BCRYPT_KEY_DATA_BLOB_HEADER.cbKeyData, Interop.BCrypt.CreateCryptographicException(), Interop.BCrypt.BCRYPT_KEY_DATA_BLOB_HEADER.dwMagic, Interop.BCrypt.BCRYPT_KEY_DATA_BLOB_HEADER.dwVersion, System.key, System.length, and System.IntPtr.Zero.

Referenced by Interop.BCrypt.BCryptImportKey(), and Interop.BCrypt.BCryptImportKey().