Some corrections of SSL_EncryptApplicationData function. By SSL/TLS protocol data is send in packets not more than defined value(as i know 16Kb). That's why we must define this function differently and add one function for freeing buffers:
typedef struct TBUFS { char *buf; int buf_len; }; int SSL_EncryptApplicationData(char *buf_in, int buf_in_len, TBUFS *bufs_out, int bufs_out_count); void SSL_FreeEncryptBuffes(TBUFS *buf, int bufs_out_count); So this function must allocate memory for output buffers and fill them with encrypted data. After that I must only send these buffers over net through the socket.