private static IntPtr ImportKey(IntPtr hAlg, byte[] key, out IntPtr hKey) { int num = BitConverter.ToInt32(AesGcm.GetProperty(hAlg, BCrypt.BCRYPT_OBJECT_LENGTH), 0); IntPtr intPtr = Marshal.AllocHGlobal(num); byte[] numArray = Arrays.Concat(new byte[][] { BCrypt.BCRYPT_KEY_DATA_BLOB_MAGIC, BitConverter.GetBytes(1), BitConverter.GetBytes((int)key.Length), key }); uint num1 = BCrypt.BCryptImportKey(hAlg, IntPtr.Zero, BCrypt.BCRYPT_KEY_DATA_BLOB, out hKey, intPtr, num, numArray, (int)numArray.Length, 0); if (num1 != 0) { throw new CryptographicException(string.Format("BCrypt.BCryptImportKey() failed with status code:{0}", num1)); } return(intPtr); }
private static int MaxAuthTagSize(IntPtr hAlg) { byte[] property = AesGcm.GetProperty(hAlg, BCrypt.BCRYPT_AUTH_TAG_LENGTH); return(BitConverter.ToInt32(new byte[] { property[4], property[5], property[6], property[7] }, 0)); }