提交 bbcd6d7f 编写于 作者: M Matt Caswell

Provide RECORD_LAYER_set_data function

Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 f161995e
......@@ -170,6 +170,7 @@ void RECORD_LAYER_clear(RECORD_LAYER *rl);
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);
......
......@@ -178,6 +178,22 @@ int RECORD_LAYER_write_pending(RECORD_LAYER *rl)
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)
{
/*
......
......@@ -111,7 +111,7 @@
#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);
......
......@@ -127,7 +127,7 @@ typedef struct ssl3_buffer_st {
#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);
......
......@@ -573,13 +573,8 @@ static int ssl23_get_server_hello(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 {
......
......@@ -556,17 +556,11 @@ int ssl23_get_client_hello(SSL *s)
/*
* 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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册