Exemple #1
0
        /// <summary>
        ///   One-way transformation.  The spec says that the password must be
        ///   padded with blanks, Samba does it iwth 0 ???
        ///   <para>OWF = Ex(P14, S8)</para>
        /// </summary>
        /// <param name = "password">password</param>
        /// <returns>byte[16]</returns>
        internal static byte[] GetLmOwf(string password)
        {
            var p14 = new byte[14];

            password = password.ToUpper();
            for (int i = 0; i < password.Length; i++)
            {
                p14[i] = (byte)(password[i] & 0xff);
            }


            var s16  = new byte[16];
            var key7 = new byte[7];
            var key8 = new byte[8];
            var e8   = new byte[8];

            for (int i = 0; i < 2; i++)
            {
                Array.Copy(p14, 7 * i, key7, 0, 7);
                Des.MakeSmbKey(key7, key8);

                var des = new Des(key8);

                des.Encrypt(S8, e8);

                Array.Copy(e8, 0, s16, 8 * i, 8);
            }

            return(s16);
        }
Exemple #2
0
        private static void E_P16(byte[] p14, byte[] p16)
        {
            var key7 = new byte[7];
            var key8 = new byte[8];
            var e8   = new byte[8];

            for (int i = 0; i < 2; i++)
            {
                Array.Copy(p14, 7 * i, key7, 0, 7);

                Des.MakeSmbKey(key7, key8);

                var des = new Des(key8);
                des.Encrypt(S8, e8);

                Array.Copy(e8, 0, p16, 8 * i, 8);
            }
        }
Exemple #3
0
        private static void E_P24(byte[] p21, byte[] c8, byte[] p24)
        {
            var key7 = new byte[7];
            var key8 = new byte[8];
            var e8   = new byte[8];

            for (int i = 0; i < 3; i++)
            {
                Array.Copy(p21, 7 * i, key7, 0, 7);
                Des.MakeSmbKey(key7, key8);

                var des = new Des(key8);

                des.Encrypt(c8, e8);

                Array.Copy(e8, 0, p24, 8 * i, 8);
            }
        }
Exemple #4
0
        /// <summary>
        ///   Encrypts password
        /// </summary>
        /// <param name = "s21">Session key</param>
        /// <param name = "c8">challange</param>
        /// <returns>byte[24]</returns>
        internal static byte[] GetAuthData(byte[] s21, byte[] c8)
        {
            var key7 = new byte[7];
            var key8 = new byte[8];
            var e8   = new byte[8];
            var rn   = new byte[24];

            for (int i = 0; i < 3; i++)
            {
                Array.Copy(s21, 7 * i, key7, 0, 7);

                Des.MakeSmbKey(key7, key8);

                var des = new Des(key8);

                des.Encrypt(c8, e8);

                Array.Copy(e8, 0, rn, 8 * i, 8);
            }
            return(rn);
        }
Exemple #5
0
        private static byte[] GetOldPwHash(byte[] p14key, byte[] in16)
        {
            var s16  = new byte[16];
            var key7 = new byte[7];
            var key8 = new byte[8];
            var e8   = new byte[8];
            var s8   = new byte[8];

            for (int i = 0; i < 2; i++)
            {
                Array.Copy(p14key, 7 * i, key7, 0, 7);
                Des.MakeSmbKey(key7, key8);

                var des = new Des(key8);
                Array.Copy(in16, 8 * i, s8, 0, 8);

                des.Encrypt(s8, e8);

                Array.Copy(e8, 0, s16, 8 * i, 8);
            }

            return(s16);
        }