protected override void ProcessAsTls1()
		{
			ServerContext context = (ServerContext)this.Context;
			int length = this.ReadInt16 ();
			byte[] signature = this.ReadBytes (length);

			// Verify signature
			MD5SHA1 hash = new MD5SHA1();
			hash.ComputeHash(
				context.HandshakeMessages.ToArray(),
				0,
				(int)context.HandshakeMessages.Length);

			if (!hash.VerifySignature(context.ClientSettings.CertificateRSA, signature))
			{
				throw new TlsException (AlertDescription.HandshakeFailiure, "Handshake Failure.");
			}
		}
Exemplo n.º 2
0
		private void verifySignature()
		{
			MD5SHA1 hash = new MD5SHA1();

			// Calculate size of server params
			int size = rsaParams.Modulus.Length + rsaParams.Exponent.Length + 4;

			// Create server params array
			TlsStream stream = new TlsStream();

			stream.Write(this.Context.RandomCS);
			stream.Write(this.ToArray(), 0, size);

			hash.ComputeHash(stream.ToArray());

			stream.Reset();
			
			bool isValidSignature = hash.VerifySignature(
				this.Context.ServerSettings.CertificateRSA,
				this.signedParams);

			if (!isValidSignature)
			{
				throw new TlsException(
					AlertDescription.DecodeError,
					"Data was not signed with the server certificate.");
			}
		}