aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-02-16 12:10:53 +0000
committerMatt Caswell <matt@openssl.org>2016-03-07 21:39:28 +0000
commitf482740f2389946b8738b963f2cf12c5a3b4d399 (patch)
tree948884e1a32bd3a27ccc3542148c8430e358d40e
parentd3b324a1614c1fa8acaaa448eb2a101e49e86ee2 (diff)
downloadopenssl-f482740f2389946b8738b963f2cf12c5a3b4d399.zip
openssl-f482740f2389946b8738b963f2cf12c5a3b4d399.tar.gz
openssl-f482740f2389946b8738b963f2cf12c5a3b4d399.tar.bz2
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: Tim Hudson <tjh@openssl.org>
-rw-r--r--ssl/record/rec_layer_d1.c51
-rw-r--r--ssl/record/rec_layer_s3.c3
-rw-r--r--ssl/record/record.h2
-rw-r--r--ssl/record/record_locl.h1
4 files changed, 25 insertions, 32 deletions
diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c
index 86b6585..00af44e 100644
--- a/ssl/record/rec_layer_d1.c
+++ b/ssl/record/rec_layer_d1.c
@@ -1035,7 +1035,7 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
int i, mac_size, clear = 0;
int prefix_len = 0;
int eivlen;
- SSL3_RECORD *wr;
+ SSL3_RECORD wr;
SSL3_BUFFER *wb;
SSL_SESSION *sess;
@@ -1061,7 +1061,6 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
if (len == 0 && !create_empty_fragment)
return 0;
- wr = &s->rlayer.wrec;
sess = s->session;
if ((sess == NULL) ||
@@ -1081,7 +1080,7 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
/* write the header */
*(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
* 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,
eivlen = 0;
/* lets setup the record stuff. */
- 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_input(wr, (unsigned char *)buf);
+ 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_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 */
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);
goto err;
}
} else {
- memcpy(SSL3_RECORD_get_data(wr), SSL3_RECORD_get_input(wr),
- SSL3_RECORD_get_length(wr));
- SSL3_RECORD_reset_input(wr);
+ memcpy(SSL3_RECORD_get_data(&wr), SSL3_RECORD_get_input(&wr),
+ SSL3_RECORD_get_length(&wr));
+ SSL3_RECORD_reset_input(&wr);
}
/*
- * 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
+ * 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
* wb->buf
*/
if (mac_size != 0) {
- if (s->method->ssl3_enc->mac(s, wr,
- &(p[SSL3_RECORD_get_length(wr) + eivlen]), 1) < 0)
+ if (s->method->ssl3_enc->mac(s, &wr,
+ &(p[SSL3_RECORD_get_length(&wr) + eivlen]), 1) < 0)
goto err;
- SSL3_RECORD_add_length(wr, mac_size);
+ SSL3_RECORD_add_length(&wr, mac_size);
}
/* this is true regardless of mac size */
- SSL3_RECORD_set_data(wr, p);
- SSL3_RECORD_reset_input(wr);
+ SSL3_RECORD_set_data(&wr, p);
+ SSL3_RECORD_reset_input(&wr);
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;
/* record length after mac and block padding */
@@ -1178,18 +1177,18 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
memcpy(pseq, &(s->rlayer.write_sequence[2]), 6);
pseq += 6;
- s2n(SSL3_RECORD_get_length(wr), pseq);
+ s2n(SSL3_RECORD_get_length(&wr), pseq);
if (s->msg_callback)
s->msg_callback(1, 0, SSL3_RT_HEADER, pseq - DTLS1_RT_HEADER_LENGTH,
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
*/
- SSL3_RECORD_set_type(wr, type); /* not needed but helps for debugging */
- SSL3_RECORD_add_length(wr, DTLS1_RT_HEADER_LENGTH);
+ SSL3_RECORD_set_type(&wr, type); /* not needed but helps for debugging */
+ SSL3_RECORD_add_length(&wr, DTLS1_RT_HEADER_LENGTH);
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,
* we are in a recursive call; just return the length, don't write
* out anything here
*/
- return wr->length;
+ return wr.length;
}
/* 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);
/*
diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c
index fb396b9..91a70e5 100644
--- a/ssl/record/rec_layer_s3.c
+++ b/ssl/record/rec_layer_s3.c
@@ -136,7 +136,6 @@ void RECORD_LAYER_init(RECORD_LAYER *rl, SSL *s)
{
rl->s = s;
SSL3_RECORD_clear(rl->rrec, SSL_MAX_PIPELINES);
- SSL3_RECORD_clear(&rl->wrec, 1);
}
void RECORD_LAYER_clear(RECORD_LAYER *rl)
@@ -167,7 +166,6 @@ void RECORD_LAYER_clear(RECORD_LAYER *rl)
SSL3_BUFFER_clear(&rl->wbuf[pipes]);
rl->numwpipes = 0;
SSL3_RECORD_clear(rl->rrec, SSL_MAX_PIPELINES);
- SSL3_RECORD_clear(&rl->wrec, 1);
RECORD_LAYER_reset_read_sequence(rl);
RECORD_LAYER_reset_write_sequence(rl);
@@ -182,7 +180,6 @@ void RECORD_LAYER_release(RECORD_LAYER *rl)
ssl3_release_read_buffer(rl->s);
if (rl->numwpipes > 0)
ssl3_release_write_buffer(rl->s);
- /* TODO: Check why there is no release of wrec here?? */
SSL3_RECORD_release(rl->rrec, SSL_MAX_PIPELINES);
}
diff --git a/ssl/record/record.h b/ssl/record/record.h
index c8c73d8..1b56a6d 100644
--- a/ssl/record/record.h
+++ b/ssl/record/record.h
@@ -265,8 +265,6 @@ typedef struct record_layer_st {
SSL3_BUFFER wbuf[SSL_MAX_PIPELINES];
/* each decoded record goes in here */
SSL3_RECORD rrec[SSL_MAX_PIPELINES];
- /* goes out from here */
- SSL3_RECORD wrec;
/* used internally to point at a raw packet */
unsigned char *packet;
diff --git a/ssl/record/record_locl.h b/ssl/record/record_locl.h
index f1f5bbc..81335fa 100644
--- a/ssl/record/record_locl.h
+++ b/ssl/record/record_locl.h
@@ -121,7 +121,6 @@
#define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf)
#define RECORD_LAYER_get_wbuf(rl) ((rl)->wbuf)
#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_reset_packet_length(rl) ((rl)->packet_length = 0)
#define RECORD_LAYER_get_rstate(rl) ((rl)->rstate)