private bool DecryptRC4WithKey(KerberosKey key, RC4KeyUsage key_usage, out byte[] decrypted) { HMACMD5 hmac = new HMACMD5(key.Key); byte[] key1 = hmac.ComputeHash(BitConverter.GetBytes((int)key_usage)); hmac = new HMACMD5(key1); byte[] checksum = new byte[16]; Buffer.BlockCopy(CipherText, 0, checksum, 0, checksum.Length); byte[] key2 = hmac.ComputeHash(checksum); byte[] result = ARC4.Transform(CipherText, 16, CipherText.Length - 16, key2); hmac = new HMACMD5(key1); byte[] calculated_checksum = hmac.ComputeHash(result); decrypted = new byte[result.Length - 8]; Buffer.BlockCopy(result, 8, decrypted, 0, decrypted.Length); return(NtObjectUtils.EqualByteArray(checksum, calculated_checksum)); }
public bool Equals(KerberosKey x, KerberosKey y) { if (x.Version != y.Version) { return(false); } if (!x.Principal.Equals(y.Principal, StringComparison.OrdinalIgnoreCase)) { return(false); } if (x.NameType != y.NameType) { return(false); } if (x.KeyEncryption != y.KeyEncryption) { return(false); } if (!NtObjectUtils.EqualByteArray(x.Key, y.Key)) { return(false); } return(true); }