ReadUInt24() public static method

public static ReadUInt24 ( byte buffer, int offset ) : uint
buffer byte
offset int
return uint
Beispiel #1
0
        TLSMessage ReadPlainText(ContentType type, ProtocolVersion ver, int offset, ushort length)
        {
            switch (type)
            {
            case ContentType.Alert:
                return(new Alert((AlertLevel)_recvBuffer[offset], (AlertDescription)_recvBuffer[offset + 1]));

            case ContentType.ChangeCipherSpec:
                _recvSeq = 0;
                return(ChangeCipherSpec.Instance);

            case ContentType.Handshake:
                HandshakeType htype   = (HandshakeType)_recvBuffer[offset];
                uint          hlength = BitConverterBE.ReadUInt24(_recvBuffer, offset + 1);
                if (hlength > MaxFragmentSize - 9)
                {
                    throw new Exception();                              // TODO
                }
                if (htype == HandshakeType.Finished)
                {
                    ComputeHandshakeHash(false);
                }
                byte[] temp = new byte[length];
                Buffer.BlockCopy(_recvBuffer, offset, temp, 0, length);
                _handshakePackets.Add(temp);
                return(Handshake.HandshakeMessage.Create(ver, htype, _recvBuffer, offset + 4, hlength));

            case ContentType.ApplicationData:
                return(new ApplicationData(_recvBuffer, offset, length));

            default:
                throw new Exception();
            }
        }