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

Remove the wrec record layer field

We used to use the wrec field in the record layer for keeping track of the
current record that we are writing out. As part of the pipelining changes
this has been moved to stack allocated variables to do the same thing,
therefore the field is no longer needed.
Reviewed-by: NTim Hudson <tjh@openssl.org>
上级 d3b324a1
...@@ -1035,7 +1035,7 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf, ...@@ -1035,7 +1035,7 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
int i, mac_size, clear = 0; int i, mac_size, clear = 0;
int prefix_len = 0; int prefix_len = 0;
int eivlen; int eivlen;
SSL3_RECORD *wr; SSL3_RECORD wr;
SSL3_BUFFER *wb; SSL3_BUFFER *wb;
SSL_SESSION *sess; SSL_SESSION *sess;
...@@ -1061,7 +1061,6 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf, ...@@ -1061,7 +1061,6 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
if (len == 0 && !create_empty_fragment) if (len == 0 && !create_empty_fragment)
return 0; return 0;
wr = &s->rlayer.wrec;
sess = s->session; sess = s->session;
if ((sess == NULL) || if ((sess == NULL) ||
...@@ -1081,7 +1080,7 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf, ...@@ -1081,7 +1080,7 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
/* write the header */ /* write the header */
*(p++) = type & 0xff; *(p++) = type & 0xff;
SSL3_RECORD_set_type(wr, type); SSL3_RECORD_set_type(&wr, type);
/* /*
* Special case: for hello verify request, client version 1.0 and we * Special case: for hello verify request, client version 1.0 and we
* haven't decided which version to use yet send back using version 1.0 * haven't decided which version to use yet send back using version 1.0
...@@ -1118,47 +1117,47 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf, ...@@ -1118,47 +1117,47 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
eivlen = 0; eivlen = 0;
/* lets setup the record stuff. */ /* lets setup the record stuff. */
SSL3_RECORD_set_data(wr, p + eivlen); /* make room for IV in case of CBC */ SSL3_RECORD_set_data(&wr, p + eivlen); /* make room for IV in case of CBC */
SSL3_RECORD_set_length(wr, (int)len); SSL3_RECORD_set_length(&wr, (int)len);
SSL3_RECORD_set_input(wr, (unsigned char *)buf); SSL3_RECORD_set_input(&wr, (unsigned char *)buf);
/* /*
* we now 'read' from wr->input, wr->length bytes into wr->data * we now 'read' from wr.input, wr.length bytes into wr.data
*/ */
/* first we compress */ /* first we compress */
if (s->compress != NULL) { if (s->compress != NULL) {
if (!ssl3_do_compress(s, wr)) { if (!ssl3_do_compress(s, &wr)) {
SSLerr(SSL_F_DO_DTLS1_WRITE, SSL_R_COMPRESSION_FAILURE); SSLerr(SSL_F_DO_DTLS1_WRITE, SSL_R_COMPRESSION_FAILURE);
goto err; goto err;
} }
} else { } else {
memcpy(SSL3_RECORD_get_data(wr), SSL3_RECORD_get_input(wr), memcpy(SSL3_RECORD_get_data(&wr), SSL3_RECORD_get_input(&wr),
SSL3_RECORD_get_length(wr)); SSL3_RECORD_get_length(&wr));
SSL3_RECORD_reset_input(wr); SSL3_RECORD_reset_input(&wr);
} }
/* /*
* we should still have the output to wr->data and the input from * we should still have the output to wr.data and the input from
* wr->input. Length should be wr->length. wr->data still points in the * wr.input. Length should be wr.length. wr.data still points in the
* wb->buf * wb->buf
*/ */
if (mac_size != 0) { if (mac_size != 0) {
if (s->method->ssl3_enc->mac(s, wr, if (s->method->ssl3_enc->mac(s, &wr,
&(p[SSL3_RECORD_get_length(wr) + eivlen]), 1) < 0) &(p[SSL3_RECORD_get_length(&wr) + eivlen]), 1) < 0)
goto err; goto err;
SSL3_RECORD_add_length(wr, mac_size); SSL3_RECORD_add_length(&wr, mac_size);
} }
/* this is true regardless of mac size */ /* this is true regardless of mac size */
SSL3_RECORD_set_data(wr, p); SSL3_RECORD_set_data(&wr, p);
SSL3_RECORD_reset_input(wr); SSL3_RECORD_reset_input(&wr);
if (eivlen) if (eivlen)
SSL3_RECORD_add_length(wr, eivlen); SSL3_RECORD_add_length(&wr, eivlen);
if (s->method->ssl3_enc->enc(s, wr, 1, 1) < 1) if (s->method->ssl3_enc->enc(s, &wr, 1, 1) < 1)
goto err; goto err;
/* record length after mac and block padding */ /* record length after mac and block padding */
...@@ -1178,18 +1177,18 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf, ...@@ -1178,18 +1177,18 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
memcpy(pseq, &(s->rlayer.write_sequence[2]), 6); memcpy(pseq, &(s->rlayer.write_sequence[2]), 6);
pseq += 6; pseq += 6;
s2n(SSL3_RECORD_get_length(wr), pseq); s2n(SSL3_RECORD_get_length(&wr), pseq);
if (s->msg_callback) if (s->msg_callback)
s->msg_callback(1, 0, SSL3_RT_HEADER, pseq - DTLS1_RT_HEADER_LENGTH, s->msg_callback(1, 0, SSL3_RT_HEADER, pseq - DTLS1_RT_HEADER_LENGTH,
DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg); DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg);
/* /*
* we should now have wr->data pointing to the encrypted data, which is * we should now have wr.data pointing to the encrypted data, which is
* wr->length long * wr->length long
*/ */
SSL3_RECORD_set_type(wr, type); /* not needed but helps for debugging */ SSL3_RECORD_set_type(&wr, type); /* not needed but helps for debugging */
SSL3_RECORD_add_length(wr, DTLS1_RT_HEADER_LENGTH); SSL3_RECORD_add_length(&wr, DTLS1_RT_HEADER_LENGTH);
ssl3_record_sequence_update(&(s->rlayer.write_sequence[0])); ssl3_record_sequence_update(&(s->rlayer.write_sequence[0]));
...@@ -1198,11 +1197,11 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf, ...@@ -1198,11 +1197,11 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
* we are in a recursive call; just return the length, don't write * we are in a recursive call; just return the length, don't write
* out anything here * out anything here
*/ */
return wr->length; return wr.length;
} }
/* now let's set up wb */ /* now let's set up wb */
SSL3_BUFFER_set_left(wb, prefix_len + SSL3_RECORD_get_length(wr)); SSL3_BUFFER_set_left(wb, prefix_len + SSL3_RECORD_get_length(&wr));
SSL3_BUFFER_set_offset(wb, 0); SSL3_BUFFER_set_offset(wb, 0);
/* /*
......
...@@ -136,7 +136,6 @@ void RECORD_LAYER_init(RECORD_LAYER *rl, SSL *s) ...@@ -136,7 +136,6 @@ void RECORD_LAYER_init(RECORD_LAYER *rl, SSL *s)
{ {
rl->s = s; rl->s = s;
SSL3_RECORD_clear(rl->rrec, SSL_MAX_PIPELINES); SSL3_RECORD_clear(rl->rrec, SSL_MAX_PIPELINES);
SSL3_RECORD_clear(&rl->wrec, 1);
} }
void RECORD_LAYER_clear(RECORD_LAYER *rl) void RECORD_LAYER_clear(RECORD_LAYER *rl)
...@@ -167,7 +166,6 @@ void RECORD_LAYER_clear(RECORD_LAYER *rl) ...@@ -167,7 +166,6 @@ void RECORD_LAYER_clear(RECORD_LAYER *rl)
SSL3_BUFFER_clear(&rl->wbuf[pipes]); SSL3_BUFFER_clear(&rl->wbuf[pipes]);
rl->numwpipes = 0; rl->numwpipes = 0;
SSL3_RECORD_clear(rl->rrec, SSL_MAX_PIPELINES); SSL3_RECORD_clear(rl->rrec, SSL_MAX_PIPELINES);
SSL3_RECORD_clear(&rl->wrec, 1);
RECORD_LAYER_reset_read_sequence(rl); RECORD_LAYER_reset_read_sequence(rl);
RECORD_LAYER_reset_write_sequence(rl); RECORD_LAYER_reset_write_sequence(rl);
...@@ -182,7 +180,6 @@ void RECORD_LAYER_release(RECORD_LAYER *rl) ...@@ -182,7 +180,6 @@ void RECORD_LAYER_release(RECORD_LAYER *rl)
ssl3_release_read_buffer(rl->s); ssl3_release_read_buffer(rl->s);
if (rl->numwpipes > 0) if (rl->numwpipes > 0)
ssl3_release_write_buffer(rl->s); ssl3_release_write_buffer(rl->s);
/* TODO: Check why there is no release of wrec here?? */
SSL3_RECORD_release(rl->rrec, SSL_MAX_PIPELINES); SSL3_RECORD_release(rl->rrec, SSL_MAX_PIPELINES);
} }
......
...@@ -265,8 +265,6 @@ typedef struct record_layer_st { ...@@ -265,8 +265,6 @@ typedef struct record_layer_st {
SSL3_BUFFER wbuf[SSL_MAX_PIPELINES]; SSL3_BUFFER wbuf[SSL_MAX_PIPELINES];
/* each decoded record goes in here */ /* each decoded record goes in here */
SSL3_RECORD rrec[SSL_MAX_PIPELINES]; SSL3_RECORD rrec[SSL_MAX_PIPELINES];
/* goes out from here */
SSL3_RECORD wrec;
/* used internally to point at a raw packet */ /* used internally to point at a raw packet */
unsigned char *packet; unsigned char *packet;
......
...@@ -121,7 +121,6 @@ ...@@ -121,7 +121,6 @@
#define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf) #define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf)
#define RECORD_LAYER_get_wbuf(rl) ((rl)->wbuf) #define RECORD_LAYER_get_wbuf(rl) ((rl)->wbuf)
#define RECORD_LAYER_get_rrec(rl) ((rl)->rrec) #define RECORD_LAYER_get_rrec(rl) ((rl)->rrec)
#define RECORD_LAYER_get_wrec(rl) (&(rl)->wrec)
#define RECORD_LAYER_set_packet(rl, p) ((rl)->packet = (p)) #define RECORD_LAYER_set_packet(rl, p) ((rl)->packet = (p))
#define RECORD_LAYER_reset_packet_length(rl) ((rl)->packet_length = 0) #define RECORD_LAYER_reset_packet_length(rl) ((rl)->packet_length = 0)
#define RECORD_LAYER_get_rstate(rl) ((rl)->rstate) #define RECORD_LAYER_get_rstate(rl) ((rl)->rstate)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册