Inheritance: GeneralDigest
Ejemplo n.º 1
0
        /**
         * Copy constructor.  This will copy the state of the provided
         * message digest.
         */
        public MD4Digest(MD4Digest t) : base(t)
        {
            H1 = t.H1;
            H2 = t.H2;
            H3 = t.H3;
            H4 = t.H4;

            Array.Copy(t.X, 0, X, 0, t.X.Length);
            xOff = t.xOff;
        }
Ejemplo n.º 2
0
        /**
        * Copy constructor.  This will copy the state of the provided
        * message digest.
        */
        public MD4Digest(MD4Digest t) : base(t)
        {
            H1 = t.H1;
            H2 = t.H2;
            H3 = t.H3;
            H4 = t.H4;

            Array.Copy(t.X, 0, X, 0, t.X.Length);
            xOff = t.xOff;
        }
Ejemplo n.º 3
0
 private void CopyIn(MD4Digest t)
 {
     base.CopyIn(t);
     this.H1 = t.H1;
     this.H2 = t.H2;
     this.H3 = t.H3;
     this.H4 = t.H4;
     Array.Copy(t.X, 0, this.X, 0, t.X.Length);
     this.xOff = t.xOff;
 }
Ejemplo n.º 4
0
 private void CopyIn(MD4Digest t)
 {
     CopyIn((GeneralDigest)t);
     H1 = t.H1;
     H2 = t.H2;
     H3 = t.H3;
     H4 = t.H4;
     global::System.Array.Copy((global::System.Array)t.X, 0, (global::System.Array)X, 0, t.X.Length);
     xOff = t.xOff;
 }
Ejemplo n.º 5
0
 private void CopyIn(MD4Digest t)
 {
     CopyIn((GeneralDigest)t);
     H1 = t.H1;
     H2 = t.H2;
     H3 = t.H3;
     H4 = t.H4;
     Array.Copy(t.X, 0, X, 0, t.X.Length);
     xOff = t.xOff;
 }
Ejemplo n.º 6
0
		private void CopyIn(MD4Digest t)
		{
			base.CopyIn(t);
            H1 = t.H1;
            H2 = t.H2;
            H3 = t.H3;
            H4 = t.H4;

            Array.Copy(t.X, 0, X, 0, t.X.Length);
            xOff = t.xOff;
        }
Ejemplo n.º 7
0
 /**
  * Copy constructor.  This will copy the state of the provided
  * message digest.
  */
 public MD4Digest(MD4Digest t) : base(t)
 {
     CopyIn(t);
 }
Ejemplo n.º 8
0
        public override void Reset(IMemoable other)
        {
            MD4Digest d = (MD4Digest)other;

            CopyIn(d);
        }
Ejemplo n.º 9
0
        public ITestResult Perform()
        {
            IDigest  digest = new MD4Digest();
            byte[]  resBuf = new byte[digest.GetDigestSize()];
            string  resStr;

            //
            // test 1
            //
            digest.DoFinal(resBuf, 0);

            resStr = Hex.ToHexString(resBuf);
            if (!resVec1.Equals(resStr))
            {
                return new SimpleTestResult(false,
                    "MD4 failing standard vector test 1"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec1
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }

            //
            // test 2
            //
            byte[]  bytes = Hex.Decode(testVec2);

            digest.BlockUpdate(bytes, 0, bytes.Length);

            digest.DoFinal(resBuf, 0);

            resStr = Hex.ToHexString(resBuf);
            if (!resVec2.Equals(resStr))
            {
                return new SimpleTestResult(false,
                    "MD4 failing standard vector test 2"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec2
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }

            //
            // test 3
            //
            bytes = Hex.Decode(testVec3);

            digest.BlockUpdate(bytes, 0, bytes.Length);

            digest.DoFinal(resBuf, 0);

            resStr = Hex.ToHexString(resBuf);
            if (!resVec3.Equals(resStr))
            {
                return new SimpleTestResult(false,
                    "MD4 failing standard vector test 3"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec3
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }

            //
            // test 4
            //
            bytes = Hex.Decode(testVec4);

            digest.BlockUpdate(bytes, 0, bytes.Length);

            digest.DoFinal(resBuf, 0);

            resStr = Hex.ToHexString(resBuf);
            if (!resVec4.Equals(resStr))
            {
                return new SimpleTestResult(false,
                    "MD4 failing standard vector test 4"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec4
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }

            //
            // test 5
            //
            bytes = Hex.Decode(testVec4);

            digest.BlockUpdate(bytes, 0, bytes.Length/2);

            // clone the IDigest
            IDigest d = new MD4Digest((MD4Digest)digest);

            digest.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
            digest.DoFinal(resBuf, 0);

            resStr = Hex.ToHexString(resBuf);
            if (!resVec4.Equals(resStr))
            {
                return new SimpleTestResult(false,
                    "MD4 failing standard vector test 5"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec4
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }

            d.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
            d.DoFinal(resBuf, 0);

            resStr = Hex.ToHexString(resBuf);
            if (!resVec4.Equals(resStr))
            {
                return new SimpleTestResult(false,
                    "MD4 failing standard vector test 5"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec4
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }
            return new SimpleTestResult(true, Name + ": Okay");
        }
Ejemplo n.º 10
0
        /**
        * Copy constructor.  This will copy the state of the provided
        * message digest.
        */
        public MD4Digest(MD4Digest t) : base(t)
		{
			CopyIn(t);
		}
Ejemplo n.º 11
0
 public MD4Digest(MD4Digest t) : base(t)
 {
     this.CopyIn(t);
 }
Ejemplo n.º 12
0
        public override void Reset(IMemoable other)
        {
            MD4Digest t = (MD4Digest)other;

            this.CopyIn(t);
        }
Ejemplo n.º 13
0
        public override string hash(string pw)
        {
            MD4Digest digest = new MD4Digest();

            // We want Unicode here (UTF-16)
            byte[] password = Encoding.Unicode.GetBytes(pw);

            digest.BlockUpdate(password, 0, password.Length);
            int digestSize = digest.GetDigestSize();
            byte[] hashData = new byte[digestSize];
            digest.DoFinal(hashData, 0);

            // Convert to HEX and return
            return string.Concat(hashData.Select(b => b.ToString("X2")));
        }
Ejemplo n.º 14
0
 public MD4Digest(MD4Digest t) : base(t)
 {
     this.X = new int[0x10];
     this.CopyIn(t);
 }