Inheritance: HandshakeMessage
        public static ClientHello CreateFromSSL2CompatibleData(ProtocolVersion ver, byte[] buffer, int offset, uint length)
        {
            ClientHello msg = new ClientHello(ver);

            int    cipherLen    = BitConverterBE.ReadUInt16AndMoveOffset(buffer, ref offset) / 3;
            ushort sessionIdLen = BitConverterBE.ReadUInt16AndMoveOffset(buffer, ref offset);

            if (sessionIdLen != 0 && sessionIdLen != 16)
            {
                throw new Exception();
            }
            ushort challengeLen = BitConverterBE.ReadUInt16AndMoveOffset(buffer, ref offset);

            if (challengeLen < 16)
            {
                throw new Exception();
            }
            if (challengeLen > RandomData.Size)
            {
                challengeLen = RandomData.Size;
            }
            msg._cipherSuites = new CipherSuite[cipherLen];
            for (int i = 0; i < cipherLen; i++)
            {
                msg._cipherSuites[i] = (CipherSuite)BitConverterBE.ReadUInt24AndMoveOffset(buffer, ref offset);
            }
            msg._sessionId = new byte[sessionIdLen];
            Buffer.BlockCopy(buffer, offset, msg._sessionId, 0, sessionIdLen);
            offset     += sessionIdLen;
            msg._random = new byte[RandomData.Size];
            Buffer.BlockCopy(buffer, offset, msg._random, 0, challengeLen);
            return(msg);
        }
Beispiel #2
0
        public static ClientHello CreateFromSSL2CompatibleData(ProtocolVersion ver, byte[] buffer, int offset, uint length)
        {
            ClientHello msg = new ClientHello (ver);

            int cipherLen = BitConverterBE.ReadUInt16AndMoveOffset (buffer, ref offset) / 3;
            ushort sessionIdLen = BitConverterBE.ReadUInt16AndMoveOffset (buffer, ref offset);
            if (sessionIdLen != 0 && sessionIdLen != 16)
                throw new Exception ();
            ushort challengeLen = BitConverterBE.ReadUInt16AndMoveOffset (buffer, ref offset);
            if (challengeLen < 16)
                throw new Exception ();
            if (challengeLen > RandomData.Size)
                challengeLen =	RandomData.Size;
            msg._cipherSuites = new CipherSuite[cipherLen];
            for (int i = 0; i < cipherLen; i ++)
                msg._cipherSuites[i] = (CipherSuite)BitConverterBE.ReadUInt24AndMoveOffset (buffer, ref offset);
            msg._sessionId = new byte[sessionIdLen];
            Buffer.BlockCopy (buffer, offset, msg._sessionId, 0, sessionIdLen);
            offset += sessionIdLen;
            msg._random = new byte[RandomData.Size];
            Buffer.BlockCopy (buffer, offset, msg._random, 0, challengeLen);
            return msg;
        }