Inheritance: IDigest, IMemoable
コード例 #1
0
 public MD2Digest(MD2Digest t)
 {
     this.X = new byte[0x30];
     this.M = new byte[0x10];
     this.C = new byte[0x10];
     this.CopyIn(t);
 }
コード例 #2
0
 public MD2Digest(MD2Digest t)
 {
     Array.Copy(t.X, 0, X, 0, t.X.Length);
     xOff = t.xOff;
     Array.Copy(t.M, 0, M, 0, t.M.Length);
     mOff = t.mOff;
     Array.Copy(t.C, 0, C, 0, t.C.Length);
     COff = t.COff;
 }
コード例 #3
0
ファイル: MD2Digest.cs プロジェクト: 894880010/MP
 private void CopyIn(MD2Digest t)
 {
     Array.Copy(t.X, 0, X, 0, t.X.Length);
     xOff = t.xOff;
     Array.Copy(t.M, 0, M, 0, t.M.Length);
     mOff = t.mOff;
     Array.Copy(t.C, 0, C, 0, t.C.Length);
     COff = t.COff;
 }
コード例 #4
0
ファイル: MD2Digest.cs プロジェクト: ubberkid/PeerATT
		private void CopyIn(MD2Digest t)
		{
            Array.Copy(t.X, 0, X, 0, t.X.Length);
            xOff = t.xOff;
            Array.Copy(t.M, 0, M, 0, t.M.Length);
            mOff = t.mOff;
            Array.Copy(t.C, 0, C, 0, t.C.Length);
            COff = t.COff;
        }
コード例 #5
0
 public MD2Digest(MD2Digest t)
 {
     Array.Copy(t.X, 0, X, 0, t.X.Length);
     xOff = t.xOff;
     Array.Copy(t.M, 0, M, 0, t.M.Length);
     mOff = t.mOff;
     Array.Copy(t.C, 0, C, 0, t.C.Length);
     COff = t.COff;
 }
コード例 #6
0
 private void CopyIn(MD2Digest t)
 {
     global::System.Array.Copy((global::System.Array)t.X, 0, (global::System.Array)X, 0, t.X.Length);
     xOff = t.xOff;
     global::System.Array.Copy((global::System.Array)t.M, 0, (global::System.Array)M, 0, t.M.Length);
     mOff = t.mOff;
     global::System.Array.Copy((global::System.Array)t.C, 0, (global::System.Array)C, 0, t.C.Length);
     COff = t.COff;
 }
コード例 #7
0
 private void CopyIn(MD2Digest t)
 {
     Array.Copy(t.X, 0, this.X, 0, t.X.Length);
     this.xOff = t.xOff;
     Array.Copy(t.M, 0, this.M, 0, t.M.Length);
     this.mOff = t.mOff;
     Array.Copy(t.C, 0, this.C, 0, t.C.Length);
     this.COff = t.COff;
 }
コード例 #8
0
ファイル: MD2DigestTest.cs プロジェクト: randombit/hacrypto
		public ITestResult Perform()
        {
            IDigest digest = new MD2Digest();
            byte[] resBuf = new byte[digest.GetDigestSize()];
            string resStr;

            //
            // test 1
            //
            byte[]  bytes = Hex.Decode(testVec1);
            digest.BlockUpdate(bytes, 0, bytes.Length);
            digest.DoFinal(resBuf, 0);

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

            //
            // test 2
            //
            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,
                    "MD2 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,
                    "MD2 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,
                    "MD2 failing standard vector test 4"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec4
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }
            //
            // test 5
            //
            bytes = Hex.Decode(testVec5);

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

            digest.DoFinal(resBuf, 0);

            resStr = Hex.ToHexString(resBuf);
            if (!resVec5.Equals(resStr))
            {
                return new SimpleTestResult(false,
                    //System.err.println(
                    "MD2 failing standard vector test 5"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec5
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }
            //
            // test 6
            //
            bytes = Hex.Decode(testVec6);

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

            digest.DoFinal(resBuf, 0);

            resStr = Hex.ToHexString(resBuf);
            if (!resVec6.Equals(resStr))
            {
                return new SimpleTestResult(false,
                    "MD2 failing standard vector test 6"
                    + SimpleTest.NewLine
                    + "    expected: " + resVec6
                    + SimpleTest.NewLine
                    + "    got     : " + resStr);
            }
            //
            // test 7
            //
            bytes = Hex.Decode(testVec7);

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

            digest.DoFinal(resBuf, 0);

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

            return new SimpleTestResult(true, Name + ": Okay");
        }
コード例 #9
0
ファイル: Digester.cs プロジェクト: bibou1324/clienteafirma
        public static byte[] Digest(byte[] data, String algo)
        {
            if (algo == null)
            {
                throw new ArgumentNullException("El algoritmo de huella digital no puede ser nulo");
            }
            if (data == null)
            {
                throw new ArgumentNullException("Los datos no pueden ser nulos");
            }

            switch (algo)
            {
                /**
                 * ALGORITMOS DE HASING
                 */
                case AOSignConstants.SIGN_ALGORITHM_SHA1:
                    {
                        Sha1Digest dig = new Sha1Digest();
                        dig.BlockUpdate(data, 0, data.Length);
                        byte[] result = new byte[dig.GetDigestSize()];
                        dig.DoFinal(result, 0);
                        return result;
                    }

                case AOSignConstants.SIGN_ALGORITHM_SHA256:
                    {
                        Sha256Digest dig = new Sha256Digest();
                        dig.BlockUpdate(data, 0, data.Length);
                        byte[] result = new byte[dig.GetDigestSize()];
                        dig.DoFinal(result, 0);
                        return result;
                    }

                case AOSignConstants.SIGN_ALGORITHM_SHA384:
                    {
                        Sha384Digest dig = new Sha384Digest();
                        dig.BlockUpdate(data, 0, data.Length);
                        byte[] result = new byte[dig.GetDigestSize()];
                        dig.DoFinal(result, 0);
                        return result;
                    }

                case AOSignConstants.SIGN_ALGORITHM_SHA512:
                    {
                        Sha512Digest dig = new Sha512Digest();
                        dig.BlockUpdate(data, 0, data.Length);
                        byte[] result = new byte[dig.GetDigestSize()];
                        dig.DoFinal(result, 0);
                        return result;
                    }

                case AOSignConstants.SIGN_ALGORITHM_RIPEMD160:
                    {
                        RipeMD160Digest dig = new RipeMD160Digest();
                        dig.BlockUpdate(data, 0, data.Length);
                        byte[] result = new byte[dig.GetDigestSize()];
                        dig.DoFinal(result, 0);
                        return result;
                    }
                case AOSignConstants.SIGN_ALGORITHM_MD5:
                    {
                        MD5Digest dig = new MD5Digest();
                        dig.BlockUpdate(data, 0, data.Length);
                        byte[] result = new byte[dig.GetDigestSize()];
                        dig.DoFinal(result, 0);
                        return result;
                    }

                case AOSignConstants.SIGN_ALGORITHM_MD2:
                    {
                        MD2Digest dig = new MD2Digest();
                        dig.BlockUpdate(data, 0, data.Length);
                        byte[] result = new byte[dig.GetDigestSize()];
                        dig.DoFinal(result, 0);
                        return result;
                    }

                default:
                    // You can use the default case.
                    throw new ArgumentNullException("El algoritmo no es reconocido");
            }

            throw new ArgumentNullException("Algoritmo de hash no soportado: " + algo);
        }
コード例 #10
0
ファイル: MD2Digest.cs プロジェクト: 894880010/MP
 public MD2Digest(MD2Digest t)
 {
     CopyIn(t);
 }
コード例 #11
0
ファイル: MD2Digest.cs プロジェクト: 894880010/MP
        public void Reset(IMemoable other)
        {
            MD2Digest d = (MD2Digest)other;

            CopyIn(d);
        }
コード例 #12
0
ファイル: MD2Digest.cs プロジェクト: ubberkid/PeerATT
        public MD2Digest(MD2Digest t)
		{
			CopyIn(t);
		}
コード例 #13
0
        public void Reset(IMemoable other)
        {
            MD2Digest t = (MD2Digest)other;

            this.CopyIn(t);
        }
コード例 #14
0
 public MD2Digest(MD2Digest t)
 {
     this.CopyIn(t);
 }