コード例 #1
0
ファイル: NativeMethods.cs プロジェクト: deimx42/DSInternals
 internal static NtStatus RtlCalculateNtOwfPassword(SafeUnicodeSecureStringPointer password, out byte[] hash)
 {
     SecureUnicodeString unicodePassword = new SecureUnicodeString(password);
     // Allocate output buffer
     hash = new byte[NTHashNumBytes];
     return RtlCalculateNtOwfPassword(ref unicodePassword, hash);
 }
コード例 #2
0
        internal static NtStatus RtlCalculateNtOwfPassword(SafeUnicodeSecureStringPointer password, out byte[] hash)
        {
            SecureUnicodeString unicodePassword = new SecureUnicodeString(password);

            // Allocate output buffer
            hash = new byte[NTHashNumBytes];
            return(RtlCalculateNtOwfPassword(ref unicodePassword, hash));
        }
コード例 #3
0
        internal NtStatus DeriveKey(SecureString password, string salt, int iterations, out byte[] key)
        {
            key = new byte[this.KeySize];
            var unicodeSalt = new UnicodeString(salt);

            using (var passwordPointer = new SafeUnicodeSecureStringPointer(password))
            {
                var unicodePassword = new SecureUnicodeString(passwordPointer);
                return(this.KeyDerivationFunction(ref unicodePassword, ref unicodeSalt, iterations, key));
            }
        }
コード例 #4
0
ファイル: LMHash.cs プロジェクト: deimx42/DSInternals
        //public static byte[] ComputeHash(SecureString password)
        //{
        //    Validator.AssertNotNull(password, "password");
        //    Validator.AssertMaxLength(password, MaxChars, "password");
        //    int oemPwdBufferLength = Encoding.ASCII.GetMaxByteCount(MaxChars);
        //    byte[] hash;
        //    using (SafeOemStringPointer oemPwdBuffer = SafeOemStringPointer.Allocate(oemPwdBufferLength))
        //    {
        //        using(SafeUnicodeSecureStringPointer unicodePwdBuffer = new SafeUnicodeSecureStringPointer(password))
        //        {

        //            NtStatus result1 = NativeMethods.RtlUpcaseUnicodeToOemN(oemPwdBuffer, (uint)oemPwdBufferLength, unicodePwdBuffer);
        //            Validator.AssertSuccess(result1);
        //        }

        //        NtStatus result2 = NativeMethods.RtlCalculateLmOwfPassword(oemPwdBuffer, out hash);
        //        Validator.AssertSuccess(result2);
        //    }
        //    return hash;
        //}

        public static byte[] ComputeHash(SecureString password)
        {
            Validator.AssertNotNull(password, "password");
            Validator.AssertMaxLength(password, MaxChars, "password");
            int oemPwdBufferLength = Encoding.ASCII.GetMaxByteCount(MaxChars);
            byte[] hash;
            using (SafeOemStringPointer oemPwdBuffer = SafeOemStringPointer.Allocate(oemPwdBufferLength))
            {
                using (SafeUnicodeSecureStringPointer unicodePwdBuffer = new SafeUnicodeSecureStringPointer(password))
                {

                    SecureUnicodeString unicodePwd = new SecureUnicodeString(unicodePwdBuffer);
                    OemString oemPwd = new OemString(oemPwdBuffer);
                    NtStatus result1 = NativeMethods.RtlUpcaseUnicodeStringToOemString(oemPwd, unicodePwd);
                    Validator.AssertSuccess(result1);
                }

                NtStatus result2 = NativeMethods.RtlCalculateLmOwfPassword(oemPwdBuffer, out hash);
                Validator.AssertSuccess(result2);
            }
            return hash;
        }
コード例 #5
0
 private static extern NtStatus RtlCalculateNtOwfPassword([In] ref SecureUnicodeString password, [MarshalAs(UnmanagedType.LPArray, SizeConst = NTHashNumBytes), In, Out] byte[] hash);
コード例 #6
0
 internal static NtStatus RtlUpcaseUnicodeStringToOemString(OemString destinationString, SecureUnicodeString sourceString)
 {
     return(RtlUpcaseUnicodeStringToOemString(ref destinationString, ref sourceString, false));
 }
コード例 #7
0
 private static extern NtStatus RtlUpcaseUnicodeStringToOemString([In, Out] ref OemString destinationString, [In] ref SecureUnicodeString sourceString, [MarshalAs(UnmanagedType.Bool)] bool allocateDestinationString);
コード例 #8
0
ファイル: NativeMethods.cs プロジェクト: deimx42/DSInternals
 internal static NtStatus RtlUpcaseUnicodeStringToOemString(OemString destinationString, SecureUnicodeString sourceString)
 {
     return RtlUpcaseUnicodeStringToOemString(ref destinationString, ref sourceString, false);
 }