Esempio n. 1
0
        void Read(TlsBuffer incoming)
        {
            if (incoming.Remaining == 0)
            {
                return;
            }

            var length = incoming.ReadInt16();

            if (incoming.Remaining != length)
            {
                throw new TlsException(AlertDescription.DecodeError);
            }

            while (incoming.Remaining > 0)
            {
                var extensionType = (ExtensionType)incoming.ReadInt16();
                length = incoming.ReadInt16();
                var extensionBuffer = incoming.ReadBuffer(length);

                var extension = CreateExtension(extensionType, extensionBuffer);
                if (extension != null)
                {
                    Add(extension);
                }
            }
        }
Esempio n. 2
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);
		}