public static HandshakeMessage ReadMessage (TlsContext context, HandshakeType handshakeType, TlsBuffer incoming)
		{
			HandshakeMessage message;
			switch (handshakeType) {
			case HandshakeType.HelloRequest:
				message = new TlsHelloRequest ();
				break;
			case HandshakeType.ServerHello:
				return new TlsServerHello (context, incoming);
			case HandshakeType.Certificate:
				return new TlsCertificate (incoming);
			case HandshakeType.ServerHelloDone:
				message = new TlsServerHelloDone ();
				break;
			case HandshakeType.Finished:
				return new TlsFinished (incoming);
			case HandshakeType.ClientHello:
				return new TlsClientHello (context, incoming);
			case HandshakeType.ClientKeyExchange:
				return new TlsClientKeyExchange (context, incoming);
			case HandshakeType.CertificateRequest:
				return new TlsCertificateRequest (context.NegotiatedProtocol, incoming);
			case HandshakeType.CertificateVerify:
				return new TlsCertificateVerify (context.NegotiatedProtocol, incoming);
			case HandshakeType.ServerKeyExchange:
				return new TlsServerKeyExchange (context, incoming);
			default:
				throw new TlsException (AlertDescription.UnexpectedMessage, "Unknown server handshake message received: {0}", handshakeType);
			}

			message.Read (incoming);
			return message;
		}
Beispiel #2
0
        public static HandshakeMessage ReadMessage(TlsContext context, HandshakeType handshakeType, TlsBuffer incoming)
        {
            HandshakeMessage message;

            switch (handshakeType)
            {
            case HandshakeType.HelloRequest:
                message = new TlsHelloRequest();
                break;

            case HandshakeType.ServerHello:
                return(new TlsServerHello(context, incoming));

            case HandshakeType.Certificate:
                return(new TlsCertificate(incoming));

            case HandshakeType.ServerHelloDone:
                message = new TlsServerHelloDone();
                break;

            case HandshakeType.Finished:
                return(new TlsFinished(incoming));

            case HandshakeType.ClientHello:
                return(new TlsClientHello(context, incoming));

            case HandshakeType.ClientKeyExchange:
                return(new TlsClientKeyExchange(context, incoming));

            case HandshakeType.CertificateRequest:
                return(new TlsCertificateRequest(context.NegotiatedProtocol, incoming));

            case HandshakeType.CertificateVerify:
                return(new TlsCertificateVerify(context.NegotiatedProtocol, incoming));

            case HandshakeType.ServerKeyExchange:
                return(new TlsServerKeyExchange(context, incoming));

            default:
                throw new TlsException(AlertDescription.UnexpectedMessage, "Unknown server handshake message received: {0}", handshakeType);
            }

            message.Read(incoming);
            return(message);
        }