示例#1
0
        protected override void ProcessAsTls1()
        {
            processProtocol(ReadInt16());
            random = ReadBytes(32);
            int num = ReadByte();

            if (num > 0)
            {
                sessionId = ReadBytes(num);
                ClientSessionCache.Add(base.Context.ClientSettings.TargetHost, sessionId);
                base.Context.AbbreviatedHandshake = HandshakeMessage.Compare(sessionId, base.Context.SessionId);
            }
            else
            {
                base.Context.AbbreviatedHandshake = false;
            }
            short code = ReadInt16();

            if (base.Context.SupportedCiphers.IndexOf(code) == -1)
            {
                throw new TlsException(AlertDescription.InsuficientSecurity, "Invalid cipher suite received from server");
            }
            cipherSuite       = base.Context.SupportedCiphers[code];
            compressionMethod = (SecurityCompressionType)ReadByte();
        }
示例#2
0
        protected override void ProcessAsTls1()
        {
            this.processProtocol(this.ReadInt16());
            this.random = this.ReadBytes(32);
            int count = (int)this.ReadByte();

            if (count > 0)
            {
                this.sessionId = this.ReadBytes(count);
                ClientSessionCache.Add(this.Context.ClientSettings.TargetHost, this.sessionId);
                this.Context.AbbreviatedHandshake = HandshakeMessage.Compare(this.sessionId, this.Context.SessionId);
            }
            else
            {
                this.Context.AbbreviatedHandshake = false;
            }
            short code = this.ReadInt16();

            if (this.Context.SupportedCiphers.IndexOf(code) == -1)
            {
                throw new TlsException(AlertDescription.InsuficientSecurity, "Invalid cipher suite received from server");
            }
            this.cipherSuite       = this.Context.SupportedCiphers[code];
            this.compressionMethod = (SecurityCompressionType)this.ReadByte();
        }
示例#3
0
        protected override void ProcessAsTls1()
        {
            byte[]        buffer2       = this.ReadBytes((int)this.Length);
            HashAlgorithm hashAlgorithm = (HashAlgorithm) new MD5SHA1();

            byte[] array = this.Context.HandshakeMessages.ToArray();
            if (!HandshakeMessage.Compare(this.Context.Current.Cipher.PRF(this.Context.MasterSecret, "server finished", hashAlgorithm.ComputeHash(array, 0, array.Length), 12), buffer2))
            {
                throw new TlsException("Invalid ServerFinished message received.");
            }
        }
		protected override void ProcessAsTls1()
		{
			byte[] buffer = base.ReadBytes((int)this.Length);
			HashAlgorithm hashAlgorithm = new MD5SHA1();
			byte[] array = base.Context.HandshakeMessages.ToArray();
			byte[] data = hashAlgorithm.ComputeHash(array, 0, array.Length);
			byte[] buffer2 = base.Context.Current.Cipher.PRF(base.Context.MasterSecret, "client finished", data, 12);
			if (!HandshakeMessage.Compare(buffer, buffer2))
			{
				throw new TlsException(AlertDescription.DecryptError, "Decrypt error.");
			}
		}
        protected override void ProcessAsSsl3()
        {
            HashAlgorithm hashAlgorithm = (HashAlgorithm) new SslHandshakeHash(this.Context.MasterSecret);
            TlsStream     tlsStream     = new TlsStream();

            tlsStream.Write(this.Context.HandshakeMessages.ToArray());
            tlsStream.Write(1129074260);
            hashAlgorithm.TransformFinalBlock(tlsStream.ToArray(), 0, (int)tlsStream.Length);
            tlsStream.Reset();
            if (!HandshakeMessage.Compare(this.ReadBytes((int)this.Length), hashAlgorithm.Hash))
            {
                throw new TlsException(AlertDescription.DecryptError, "Decrypt error.");
            }
        }
示例#6
0
        protected override void ProcessAsSsl3()
        {
            HashAlgorithm hashAlgorithm = (HashAlgorithm) new SslHandshakeHash(this.Context.MasterSecret);

            byte[] array = this.Context.HandshakeMessages.ToArray();
            hashAlgorithm.TransformBlock(array, 0, array.Length, array, 0);
            hashAlgorithm.TransformBlock(TlsServerFinished.Ssl3Marker, 0, TlsServerFinished.Ssl3Marker.Length, TlsServerFinished.Ssl3Marker, 0);
            hashAlgorithm.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
            byte[] buffer2 = this.ReadBytes((int)this.Length);
            if (!HandshakeMessage.Compare(hashAlgorithm.Hash, buffer2))
            {
                throw new TlsException(AlertDescription.InsuficientSecurity, "Invalid ServerFinished message received.");
            }
        }