Ejemplo n.º 1
0
        protected override void Read(TlsBuffer incoming)
        {
            var length    = incoming.ReadInt24();
            var endOffset = incoming.Position + length;

            while (incoming.Position < endOffset)
            {
                var certLength = incoming.ReadInt24();
                if (certLength == 0)
                {
                    break;
                }

                var buffer = incoming.ReadBytes(certLength);

                // Create a new X509 Certificate
                var certificate = new X509Certificate(buffer);
                Certificates.Add(certificate);
            }

            if (incoming.Position != endOffset || incoming.Remaining != 0)
            {
                throw new TlsException(AlertDescription.DecodeError);
            }
        }
Ejemplo n.º 2
0
		protected override void Read (TlsBuffer incoming)
		{
			var length = incoming.ReadInt24 ();
			var endOffset = incoming.Position + length;

			while (incoming.Position < endOffset) {
				var certLength = incoming.ReadInt24 ();
				if (certLength == 0)
					break;

				var buffer = incoming.ReadBytes (certLength);

				// Create a new X509 Certificate
				var certificate = new X509Certificate (buffer);
				Certificates.Add (certificate);
			}

			if (incoming.Position != endOffset || incoming.Remaining != 0)
				throw new TlsException (AlertDescription.DecodeError);

		}
Ejemplo n.º 3
0
		bool ProcessHandshakeMessage (TlsBuffer incoming, out SecurityStatus status)
		{
			var handshakeType = (HandshakeType)incoming.ReadByte ();
			#if DEBUG_FULL
			if (EnableDebugging) {
				DebugHelper.WriteLine (">>>> Processing Handshake record ({0})", handshakeType);
				DebugHelper.WriteRemaining ("HANDSHAKE", incoming);
			}
			#endif

			// Read message length
			int length = incoming.ReadInt24 ();
			if (incoming.Remaining < length) {
				cachedFragment = new TlsBuffer (length + 4);
				cachedFragment.Position = incoming.Remaining + 4;
				Buffer.BlockCopy (incoming.Buffer, incoming.Position - 4, cachedFragment.Buffer, 0, cachedFragment.Position);
				incoming.Position += incoming.Remaining;
				status = SecurityStatus.ContinueNeeded;
				return false;
			}

			var buffer = incoming.ReadBuffer (length);
			return negotiationHandler.ProcessHandshakeMessage (handshakeType, buffer, out status);
		}