void RECORD_LAYER_release(RECORD_LAYER *rl);
int RECORD_LAYER_read_pending(RECORD_LAYER *rl);
int RECORD_LAYER_write_pending(RECORD_LAYER *rl);
+int RECORD_LAYER_set_data(RECORD_LAYER *rl, const unsigned char *buf, int len);
__owur int ssl23_read_bytes(SSL *s, int n);
__owur int ssl23_write_bytes(SSL *s);
__owur int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
return SSL3_BUFFER_get_left(&rl->wbuf) != 0;
}
+int RECORD_LAYER_set_data(RECORD_LAYER *rl, const unsigned char *buf, int len)
+{
+ rl->s->packet_length = len;
+ if(len != 0) {
+ rl->s->rstate = SSL_ST_READ_HEADER;
+ if (!SSL3_BUFFER_is_initialised(&rl->rbuf))
+ if (!ssl3_setup_read_buffer(rl->s))
+ return 0;
+ }
+
+ rl->s->packet = SSL3_BUFFER_get_buf(&rl->rbuf);
+ SSL3_BUFFER_set_data(&rl->rbuf, buf, len);
+
+ return 1;
+}
+
int ssl3_read_n(SSL *s, int n, int max, int extend)
{
/*
#include "../ssl_locl.h"
-void SSL3_BUFFER_set_data(SSL3_BUFFER *b, unsigned char *d, int n)
+void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, int n)
{
if(d != NULL)
memcpy(b->buf, d, n);
#define SSL3_BUFFER_get_left(b) ((b)->left)
#define SSL3_BUFFER_is_initialised(b) ((b)->buf != NULL)
-void SSL3_BUFFER_set_data(SSL3_BUFFER *b, unsigned char *d, int n);
+void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, int n);
void SSL3_BUFFER_release(SSL3_BUFFER *b);
__owur int ssl3_setup_buffers(SSL *s);
__owur int ssl3_setup_read_buffer(SSL *s);
/*
* put the 7 bytes we have read into the input buffer for SSLv3
*/
- s->rstate = SSL_ST_READ_HEADER;
- s->packet_length = n;
- if (!SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer)))
- if (!ssl3_setup_read_buffer(s))
- goto err;
- s->packet = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer));
- SSL3_BUFFER_set_data(RECORD_LAYER_get_rbuf(&s->rlayer), buf, n);
+ if(!RECORD_LAYER_set_data(&s->rlayer, buf, n))
+ goto err;
s->handshake_func = s->method->ssl_connect;
} else {
/*
* put the 'n' bytes we have read into the input buffer for SSLv3
*/
- s->rstate = SSL_ST_READ_HEADER;
- s->packet_length = n;
- if (!SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer)))
- if (!ssl3_setup_read_buffer(s))
- goto err;
-
- s->packet = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer));
- SSL3_BUFFER_set_data(RECORD_LAYER_get_rbuf(&s->rlayer), buf, n);
+ if(!RECORD_LAYER_set_data(&s->rlayer, buf, n))
+ goto err;
} else {
- s->packet_length = 0;
- SSL3_BUFFER_set_data(RECORD_LAYER_get_rbuf(&s->rlayer), NULL, 0);
+ if(!RECORD_LAYER_set_data(&s->rlayer, NULL, 0))
+ goto err;
}
s->handshake_func = s->method->ssl_accept;
} else {