protected override byte[] GetFinishedMessage() {
			HandshakeMessage hm = new HandshakeMessage(HandshakeType.Finished, new byte[36]);
			Ssl3HandshakeMac md5 = new Ssl3HandshakeMac(HashType.MD5, m_LocalMD5Hash, m_MasterSecret);
			Ssl3HandshakeMac sha1 = new Ssl3HandshakeMac(HashType.SHA1, m_LocalSHA1Hash, m_MasterSecret);
			md5.TransformFinalBlock(new byte[]{0x53, 0x52, 0x56, 0x52}, 0, 4);
			sha1.TransformFinalBlock(new byte[]{0x53, 0x52, 0x56, 0x52}, 0, 4);
			Array.Copy(md5.Hash, 0, hm.fragment, 0, 16);
			Array.Copy(sha1.Hash, 0, hm.fragment, 16, 20);
			md5.Clear();
			sha1.Clear();
			return hm.ToBytes();
		}
		protected override byte[] HashFinal() {
			if (m_Protocol == SecureProtocol.Ssl3) {
				m_MD5 = new Ssl3HandshakeMac(HashType.MD5, m_MD5, m_MasterKey);
				m_SHA1 = new Ssl3HandshakeMac(HashType.SHA1, m_SHA1, m_MasterKey);
			}
			byte[] hash = new byte[36];
			m_MD5.TransformFinalBlock(hash, 0, 0);
			m_SHA1.TransformFinalBlock(hash, 0, 0);
			Array.Copy(m_MD5.Hash, 0, hash, 0, 16);
			Array.Copy(m_SHA1.Hash, 0, hash, 16, 20);
			return hash;
		}
Exemplo n.º 3
0
        protected override byte[] GetFinishedMessage()
        {
            HandshakeMessage hm   = new HandshakeMessage(HandshakeType.Finished, new byte[36]);
            Ssl3HandshakeMac md5  = new Ssl3HandshakeMac(HashType.MD5, m_LocalMD5Hash, m_MasterSecret);
            Ssl3HandshakeMac sha1 = new Ssl3HandshakeMac(HashType.SHA1, m_LocalSHA1Hash, m_MasterSecret);

            md5.TransformFinalBlock(new byte[] { 0x53, 0x52, 0x56, 0x52 }, 0, 4);
            sha1.TransformFinalBlock(new byte[] { 0x53, 0x52, 0x56, 0x52 }, 0, 4);
            Buffer.BlockCopy(md5.Hash, 0, hm.fragment, 0, 16);
            Buffer.BlockCopy(sha1.Hash, 0, hm.fragment, 16, 20);
            md5.Clear();
            sha1.Clear();
            return(hm.ToBytes());
        }
Exemplo n.º 4
0
        protected override void VerifyFinishedMessage(byte[] peerFinished)
        {
            if (peerFinished.Length != 36)
            {
                throw new SslException(AlertDescription.IllegalParameter, "The message is invalid.");
            }
            byte[]           hash = new byte[36];
            Ssl3HandshakeMac md5  = new Ssl3HandshakeMac(HashType.MD5, m_RemoteMD5Hash, m_MasterSecret);
            Ssl3HandshakeMac sha1 = new Ssl3HandshakeMac(HashType.SHA1, m_RemoteSHA1Hash, m_MasterSecret);

            md5.TransformFinalBlock(new byte[] { 0x43, 0x4C, 0x4E, 0x54 }, 0, 4);
            sha1.TransformFinalBlock(new byte[] { 0x43, 0x4C, 0x4E, 0x54 }, 0, 4);
            Buffer.BlockCopy(md5.Hash, 0, hash, 0, 16);
            Buffer.BlockCopy(sha1.Hash, 0, hash, 16, 20);
            for (int i = 0; i < hash.Length; i++)
            {
                if (hash[i] != peerFinished[i])
                {
                    throw new SslException(AlertDescription.HandshakeFailure, "The computed hash verification does not correspond with the one of the client.");
                }
            }
            md5.Clear();
            sha1.Clear();
        }
 protected override void VerifyFinishedMessage(byte[] peerFinished)
 {
     if (peerFinished.Length != 36)
         throw new SslException(AlertDescription.IllegalParameter, "The message is invalid.");
     byte[] hash = new byte[36];
     Ssl3HandshakeMac md5 = new Ssl3HandshakeMac(HashType.MD5, m_RemoteMD5Hash, m_MasterSecret);
     Ssl3HandshakeMac sha1 = new Ssl3HandshakeMac(HashType.SHA1, m_RemoteSHA1Hash, m_MasterSecret);
     md5.TransformFinalBlock(new byte[]{0x43, 0x4C, 0x4E, 0x54}, 0, 4);
     sha1.TransformFinalBlock(new byte[]{0x43, 0x4C, 0x4E, 0x54}, 0, 4);
     Buffer.BlockCopy(md5.Hash, 0, hash, 0, 16);
     Buffer.BlockCopy(sha1.Hash, 0, hash, 16, 20);
     for(int i = 0; i < hash.Length; i++) {
         if (hash[i] != peerFinished[i])
             throw new SslException(AlertDescription.HandshakeFailure, "The computed hash verification does not correspond with the one of the client.");
     }
     md5.Clear();
     sha1.Clear();
 }