protected override void Read (TlsBuffer incoming)
		{
			ClientRandom = new SecureBuffer (incoming.ReadBytes (32));

			var length = (short)incoming.ReadByte ();
			SessionID = new SecureBuffer (incoming.ReadBytes (length));

			length = incoming.ReadInt16 ();
			if ((length % 2) != 0)
				throw new TlsException (AlertDescription.DecodeError);

			bool seenSCSV = false;
			ClientCiphers = new CipherSuiteCode [length >> 1];
			for (int i = 0; i < ClientCiphers.Length; i++) {
				ClientCiphers [i] = (CipherSuiteCode)incoming.ReadInt16 ();
				if (ClientCiphers [i] == CipherSuiteCode.TLS_EMPTY_RENEGOTIATION_INFO_SCSV)
					seenSCSV = true;
			}

			// Compression methods
			length = incoming.ReadByte ();
			incoming.Position += length;

			Extensions = new TlsExtensionCollection (incoming);

			if (seenSCSV)
				Extensions.AddRenegotiationExtension ();
		}
Exemple #2
0
        protected override void Read(TlsBuffer incoming)
        {
            // Server random
            ServerRandom = new SecureBuffer(incoming.ReadBytes(32));

            // Session ID
            var sessionIdLength = (int)incoming.ReadByte();

            if (sessionIdLength > 0)
            {
                SessionID = new SecureBuffer(incoming.ReadBytes(sessionIdLength));
            }

            // Cipher suite
            SelectedCipher = (CipherSuiteCode)incoming.ReadInt16();

            var compressionMethod = incoming.ReadByte();

            if (compressionMethod != 0)
            {
                throw new TlsException(AlertDescription.IlegalParameter, "Invalid compression method received from server");
            }

            Extensions = new TlsExtensionCollection(incoming);
        }
		public TlsServerHello (TlsProtocolCode protocol, SecureBuffer random, SecureBuffer session, CipherSuiteCode cipher, TlsExtensionCollection extensions)
			: base (HandshakeType.ServerHello)
		{
			ServerProtocol = protocol;
			ServerRandom = random;
			SessionID = session;
			SelectedCipher = cipher;
			Extensions = extensions;
		}
Exemple #4
0
 public TlsServerHello(TlsProtocolCode protocol, SecureBuffer random, SecureBuffer session, CipherSuiteCode cipher, TlsExtensionCollection extensions)
     : base(HandshakeType.ServerHello)
 {
     ServerProtocol = protocol;
     ServerRandom   = random;
     SessionID      = session;
     SelectedCipher = cipher;
     Extensions     = extensions;
 }
 public TlsClientHello(TlsProtocolCode protocol, SecureBuffer random, SecureBuffer session, CipherSuiteCode[] ciphers, TlsExtensionCollection extensions)
     : base(HandshakeType.ClientHello)
 {
     ClientProtocol = protocol;
     ClientRandom   = random;
     SessionID      = session;
     ClientCiphers  = ciphers;
     Extensions     = extensions;
 }
		public TlsClientHello (TlsProtocolCode protocol, SecureBuffer random, SecureBuffer session, CipherSuiteCode[] ciphers, TlsExtensionCollection extensions)
			: base (HandshakeType.ClientHello)
		{
			ClientProtocol = protocol;
			ClientRandom = random;
			SessionID = session;
			ClientCiphers = ciphers;
			Extensions = extensions;
		}
		protected override void Read (TlsBuffer incoming)
		{
			// Server random
			ServerRandom = new SecureBuffer (incoming.ReadBytes (32));

			// Session ID
			var sessionIdLength = (int)incoming.ReadByte ();
			if (sessionIdLength > 0) {
				SessionID = new SecureBuffer (incoming.ReadBytes (sessionIdLength));
			}

			// Cipher suite
			SelectedCipher = (CipherSuiteCode)incoming.ReadInt16 ();

			var compressionMethod = incoming.ReadByte ();
			if (compressionMethod != 0)
				throw new TlsException (AlertDescription.IlegalParameter, "Invalid compression method received from server");

			Extensions = new TlsExtensionCollection (incoming);
		}
        protected override void Read(TlsBuffer incoming)
        {
            ClientRandom = new SecureBuffer(incoming.ReadBytes(32));

            var length = (short)incoming.ReadByte();

            SessionID = new SecureBuffer(incoming.ReadBytes(length));

            length = incoming.ReadInt16();
            if ((length % 2) != 0)
            {
                throw new TlsException(AlertDescription.DecodeError);
            }

            bool seenSCSV = false;

            ClientCiphers = new CipherSuiteCode [length >> 1];
            for (int i = 0; i < ClientCiphers.Length; i++)
            {
                ClientCiphers [i] = (CipherSuiteCode)incoming.ReadInt16();
                if (ClientCiphers [i] == CipherSuiteCode.TLS_EMPTY_RENEGOTIATION_INFO_SCSV)
                {
                    seenSCSV = true;
                }
            }

            // Compression methods
            length             = incoming.ReadByte();
            incoming.Position += length;

            Extensions = new TlsExtensionCollection(incoming);

            if (seenSCSV)
            {
                Extensions.AddRenegotiationExtension();
            }
        }
 protected override void Clear()
 {
     base.Clear();
     requestedExtensions = null;
 }
Exemple #10
0
 protected override void Clear()
 {
     base.Clear();
     requestedExtensions         = null;
     ClientCertificateParameters = null;
 }
		protected override void Clear ()
		{
			base.Clear ();
			requestedExtensions = null;
		}