private static ProtocolVersion GetUnknownVersion(int major, int minor, string prefix)
    {
        TlsUtilities.CheckUint8(major);
        TlsUtilities.CheckUint8(minor);
        int    num = (major << 8) | minor;
        string str = Platform.ToUpperInvariant(Convert.ToString(0x10000 | num, 16).Substring(1));

        return(new ProtocolVersion(num, prefix + " 0x" + str));
    }
예제 #2
0
        private static ProtocolVersion GetUnknownVersion(int major, int minor, string prefix)
        {
            TlsUtilities.CheckUint8(major);
            TlsUtilities.CheckUint8(minor);

            int    v   = (major << 8) | minor;
            String hex = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.ToUpperInvariant(Convert.ToString(0x10000 | v, 16).Substring(1));

            return(new ProtocolVersion(v, prefix + " 0x" + hex));
        }
        protected static byte[] PatchClientHelloWithCookie(byte[] clientHelloBody, byte[] cookie)
        {
            int sessionIDPos    = 34;
            int sessionIDLength = TlsUtilities.ReadUint8(clientHelloBody, sessionIDPos);

            int cookieLengthPos = sessionIDPos + 1 + sessionIDLength;
            int cookiePos       = cookieLengthPos + 1;

            byte[] patched = new byte[clientHelloBody.Length + cookie.Length];
            Array.Copy(clientHelloBody, 0, patched, 0, cookieLengthPos);
            TlsUtilities.CheckUint8(cookie.Length);
            TlsUtilities.WriteUint8((byte)cookie.Length, patched, cookieLengthPos);
            Array.Copy(cookie, 0, patched, cookiePos, cookie.Length);
            Array.Copy(clientHelloBody, cookiePos, patched, cookiePos + cookie.Length, clientHelloBody.Length - cookiePos);

            return(patched);
        }