Exemplo n.º 1
0
        public KerberosCredentialNew(SecureString password, string salt)
        {
            Validator.AssertNotNull(password, "password");
            Validator.AssertNotNull(salt, "salt");

            // Generate AES keys
            this.DefaultIterationCount = KerberosKeyDerivation.DefaultIterationCount;

            byte[] aes128Key     = KerberosKeyDerivation.DeriveKey(KerberosKeyType.AES128_CTS_HMAC_SHA1_96, password, this.DefaultSalt);
            var    aes128KeyData = new KerberosKeyDataNew(KerberosKeyType.AES128_CTS_HMAC_SHA1_96, aes128Key, KerberosKeyDerivation.DefaultIterationCount);

            byte[] aes256Key     = KerberosKeyDerivation.DeriveKey(KerberosKeyType.AES256_CTS_HMAC_SHA1_96, password, this.DefaultSalt);
            var    aes256KeyData = new KerberosKeyDataNew(KerberosKeyType.AES256_CTS_HMAC_SHA1_96_PLAIN, aes256Key, KerberosKeyDerivation.DefaultIterationCount);

            this.Credentials = new KerberosKeyDataNew[] { aes128KeyData, aes256KeyData };
        }
Exemplo n.º 2
0
        private static void WriteCredential(BinaryWriter writer, KerberosKeyDataNew credential, int keyValueOffset)
        {
            // Reserved1 (2 bytes): This value MUST be ignored by the recipient and MUST be set to zero.
            writer.Write((short)0);

            // Reserved2 (2 bytes): This value MUST be ignored by the recipient and MUST be set to zero.
            writer.Write((short)0);

            // Reserved3 (4 bytes): This value MUST be ignored by the recipient and MUST be set to zero.
            writer.Write((int)0);

            // IterationCount (4 bytes): Indicates the iteration count used to calculate the password hashes.
            writer.Write(credential.IterationCount);

            // KeyType (4 bytes): Indicates the type of key, stored as a 32-bit unsigned integer in little-endian byte order. This MUST be set to one of the following values, which are defined in section 2.2.10.8.
            writer.Write((int)credential.KeyType);

            // KeyLength (4 bytes): The length, in bytes, of the value beginning at KeyOffset. The value of this field is stored in little-endian byte order.
            writer.Write(credential.Key.Length);

            // KeyOffset (4 bytes): An offset, in little-endian byte order, from the beginning of the property value (that is, from the beginning of the Revision field of KERB_STORED_CREDENTIAL) to where the key value starts. The key value is the hash value specified according to the KeyType.
            writer.Write(keyValueOffset);
        }