Ejemplo n.º 1
0
        static internal HashAlgorithm CreateFromName(string name)
        {
#if FULL_AOT_RUNTIME
            switch (name)
            {
            case "MD2":
                return(MD2.Create());

            case "MD4":
                return(MD4.Create());

            case "MD5":
                return(MD5.Create());

            case "SHA1":
                return(SHA1.Create());

            case "SHA256":
                return(SHA256.Create());

            case "SHA384":
                return(SHA384.Create());

            case "SHA512":
                return(SHA512.Create());

            case "RIPEMD160":
                return(RIPEMD160.Create());

            default:
                try {
                    return((HashAlgorithm)Activator.CreateInstance(Type.GetType(name)));
                }
                catch {
                    throw new CryptographicException("Unsupported hash algorithm: " + name);
                }
            }
#else
            return(HashAlgorithm.Create(name));
#endif
        }
Ejemplo n.º 2
0
 public new static MD2 Create()
 {
     return(MD2.Create(nameof(MD2)));
 }
Ejemplo n.º 3
0
		public void RFC1319_e (string testName, MD2 hash, byte[] input, byte[] result) 
		{
			byte[] copy = new byte [input.Length];
			for (int i=0; i < input.Length - 1; i++)
				hash.TransformBlock (input, i, 1, copy, i);
			byte[] output = hash.TransformFinalBlock (input, input.Length - 1, 1);
			AssertEquals (testName + ".e.1", input [input.Length - 1], output [0]);
			AssertEquals (testName + ".e.2", result, hash.Hash);
			// required or next operation will still return old hash
			hash.Initialize ();
		}
Ejemplo n.º 4
0
		public void RFC1319_d (string testName, MD2 hash, byte[] input, byte[] result) 
		{
			byte[] output = hash.TransformFinalBlock (input, 0, input.Length);
			AssertEquals (testName + ".d.1", input, output);
			AssertEquals (testName + ".d.2", result, hash.Hash);
			// required or next operation will still return old hash
			hash.Initialize ();
		}
Ejemplo n.º 5
0
		public void RFC1319_c (string testName, MD2 hash, byte[] input, byte[] result) 
		{
			MemoryStream ms = new MemoryStream (input);
			byte[] output = hash.ComputeHash (ms); 
			AssertEquals (testName + ".c.1", result, output);
			AssertEquals (testName + ".c.2", result, hash.Hash);
			// required or next operation will still return old hash
			hash.Initialize ();
		}
Ejemplo n.º 6
0
		public void RFC1319_b (string testName, MD2 hash, byte[] input, byte[] result) 
		{
			byte[] output = hash.ComputeHash (input, 0, input.Length); 
			AssertEquals (testName + ".b.1", result, output);
			AssertEquals (testName + ".b.2", result, hash.Hash);
			// required or next operation will still return old hash
			hash.Initialize ();
		}
Ejemplo n.º 7
0
 public new static MD2 Create()
 {
     return(MD2.Create("MD2"));
 }