Ejemplo n.º 1
0
        private static void Send(TlsConnection connection, byte type, ref byte[] data)
        {
            if (connection.SendEncrypted)
            {
                data = Encrypt(connection, type, ref data);
            }

            byte[] resultData = new byte[data.Length + 5];
            resultData[0] = type;
            resultData[1] = 3;
            resultData[2] = 3;
            resultData[3] = (byte)(data.Length >> 8);
            resultData[4] = (byte)data.Length;
            Buffer.BlockCopy(data, 0, resultData, 5, data.Length);

            connection.Send(resultData);
        }
Ejemplo n.º 2
0
        private static void Send(TlsConnection connection, string header, string response)
        {
            StringBuilder builder = new StringBuilder(header, header.Length + response.Length + 24);

            builder.Append("\r\nl:");
            builder.Append(response.Length);
            builder.Append("\r\ns:");
            builder.Append(connection.StsSequence);
            builder.Append("R\r\n\r\n");
            builder.Append(response);

            byte[] data = Encoding.ASCII.GetBytes(builder.ToString());

            if (connection.SendEncrypted)
            {
                TlsResponse.Message(connection, ref data);
            }
            else
            {
                connection.Send(data);
            }
        }