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

◆ BCryptImportKey() [1/4]

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

Definition at line 306 of file Interop.cs.

307 {
308 int length = key.Length;
309 int num = sizeof(BCRYPT_KEY_DATA_BLOB_HEADER) + length;
310 byte[] array = new byte[num];
311 fixed (byte* ptr = array)
312 {
313 BCRYPT_KEY_DATA_BLOB_HEADER* ptr2 = (BCRYPT_KEY_DATA_BLOB_HEADER*)ptr;
314 ptr2->dwMagic = 1296188491u;
315 ptr2->dwVersion = 1u;
316 ptr2->cbKeyData = (uint)length;
317 }
318 key.CopyTo(array.AsSpan(sizeof(BCRYPT_KEY_DATA_BLOB_HEADER)));
320 NTSTATUS nTSTATUS = BCryptImportKey(hAlg, IntPtr.Zero, "KeyDataBlob", out hKey, IntPtr.Zero, 0, array, num, 0);
321 if (nTSTATUS != 0)
322 {
323 throw CreateCryptographicException(nTSTATUS);
324 }
325 return hKey;
326 }
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.CreateCryptographicException(), System.key, System.length, and System.IntPtr.Zero.