private IntPtr ImportKey(IntPtr hAlg, byte[] key, out IntPtr hKey) { byte[] objLength = GetProperty(hAlg, BCrypt.BCRYPT_OBJECT_LENGTH); int keyDataSize = BitConverter.ToInt32(objLength, 0); IntPtr keyDataBuffer = Marshal.AllocHGlobal(keyDataSize); byte[] keyBlob = Concat(BCrypt.BCRYPT_KEY_DATA_BLOB_MAGIC, BitConverter.GetBytes(0x1), BitConverter.GetBytes(key.Length), key); uint status = BCrypt.BCryptImportKey(hAlg, IntPtr.Zero, BCrypt.BCRYPT_KEY_DATA_BLOB, out hKey, keyDataBuffer, keyDataSize, keyBlob, keyBlob.Length, 0x0); if (status != BCrypt.ERROR_SUCCESS) { throw new CryptographicException(string.Format("BCrypt.BCryptImportKey() failed with status code:{0}", status)); } return(keyDataBuffer); }
// Token: 0x0600000F RID: 15 RVA: 0x0000236C File Offset: 0x0000056C private IntPtr ImportKey(IntPtr hAlg, byte[] key, out IntPtr hKey) { byte[] property = this.GetProperty(hAlg, BCrypt.BCRYPT_OBJECT_LENGTH); int num = BitConverter.ToInt32(property, 0); IntPtr intPtr = Marshal.AllocHGlobal(num); byte[] array = this.Concat(new byte[][] { BCrypt.BCRYPT_KEY_DATA_BLOB_MAGIC, BitConverter.GetBytes(1), BitConverter.GetBytes(key.Length), key }); uint num2 = BCrypt.BCryptImportKey(hAlg, IntPtr.Zero, BCrypt.BCRYPT_KEY_DATA_BLOB, out hKey, intPtr, num, array, array.Length, 0U); bool flag = num2 > 0U; if (flag) { throw new CryptographicException(string.Format("BCrypt.BCryptImportKey() failed with status code:{0}", num2)); } return(intPtr); }