diff options
author | Matt Caswell <matt@openssl.org> | 2015-02-04 11:57:34 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-03-26 15:02:00 +0000 |
commit | 3bb8f87d2d9aa1ab51703a725759d440785685e3 (patch) | |
tree | ea65c9d8c0a6723cac561b945639a8fb96bef60c /ssl/record | |
parent | 14daae5a625b38b43229eed0cf750f44d5881c0b (diff) |
Move last_write_sequence from s->d1 to s->rlayer.d.
Also push some usage of last_write_sequence out of dtls1_retransmit_message
and into the record layer.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'ssl/record')
-rw-r--r-- | ssl/record/d1_pkt.c | 22 | ||||
-rw-r--r-- | ssl/record/rec_layer.h | 8 |
2 files changed, 27 insertions, 3 deletions
diff --git a/ssl/record/d1_pkt.c b/ssl/record/d1_pkt.c index 76bea7a29b..b23a9e8d06 100644 --- a/ssl/record/d1_pkt.c +++ b/ssl/record/d1_pkt.c @@ -211,6 +211,26 @@ void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl) d->buffered_app_data.q = buffered_app_data; } +void DTLS_RECORD_LAYER_set_saved_w_epoch(RECORD_LAYER *rl, unsigned short e) +{ + if (e == rl->d->w_epoch - 1) { + memcpy(rl->d->curr_write_sequence, + rl->write_sequence, + sizeof(rl->write_sequence)); + memcpy(rl->write_sequence, + rl->d->last_write_sequence, + sizeof(rl->write_sequence)); + } else if (e == rl->d->w_epoch + 1) { + memcpy(rl->d->last_write_sequence, + rl->write_sequence, + sizeof(unsigned char[8])); + memcpy(rl->write_sequence, + rl->d->curr_write_sequence, + sizeof(rl->write_sequence)); + } + rl->d->w_epoch = e; +} + static int have_handshake_fragment(SSL *s, int type, unsigned char *buf, int len, int peek); @@ -1289,7 +1309,7 @@ void dtls1_reset_seq_numbers(SSL *s, int rw) memset(&(s->rlayer.d->next_bitmap), 0x00, sizeof(DTLS1_BITMAP)); } else { seq = s->rlayer.write_sequence; - memcpy(s->d1->last_write_sequence, seq, + memcpy(s->rlayer.d->last_write_sequence, seq, sizeof(s->rlayer.write_sequence)); s->rlayer.d->w_epoch++; } diff --git a/ssl/record/rec_layer.h b/ssl/record/rec_layer.h index e50bb79873..048cf19487 100644 --- a/ssl/record/rec_layer.h +++ b/ssl/record/rec_layer.h @@ -165,6 +165,10 @@ typedef struct dtls_record_layer_st { unsigned int alert_fragment_len; unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH]; unsigned int handshake_fragment_len; + + /* save last and current sequence numbers for retransmissions */ + unsigned char last_write_sequence[8]; + unsigned char curr_write_sequence[8]; } DTLS_RECORD_LAYER; typedef struct record_layer_st { @@ -231,9 +235,7 @@ typedef struct record_layer_st { #define RECORD_LAYER_get_packet_length(rl) ((rl)->packet_length) #define RECORD_LAYER_add_packet_length(rl, inc) ((rl)->packet_length += (inc)) #define RECORD_LAYER_get_read_sequence(rl) ((rl)->read_sequence) -#define RECORD_LAYER_get_write_sequence(rl) ((rl)->write_sequence) #define DTLS_RECORD_LAYER_get_w_epoch(rl) ((rl)->d->w_epoch) -#define DTLS_RECORD_LAYER_set_w_epoch(rl, e) ((rl)->d->w_epoch = (e)) #define DTLS_RECORD_LAYER_get_processed_rcds(rl) \ ((rl)->d->processed_rcds) #define DTLS_RECORD_LAYER_get_unprocessed_rcds(rl) \ @@ -259,6 +261,7 @@ __owur int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int pe int DTLS_RECORD_LAYER_new(RECORD_LAYER *rl); void DTLS_RECORD_LAYER_free(RECORD_LAYER *rl); void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl); +void DTLS_RECORD_LAYER_set_saved_w_epoch(RECORD_LAYER *rl, unsigned short e); __owur int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); __owur int dtls1_write_bytes(SSL *s, int type, const void *buf, int len); __owur int do_dtls1_write(SSL *s, int type, const unsigned char *buf, @@ -281,6 +284,7 @@ void dtls1_reset_seq_numbers(SSL *s, int rw); #define RECORD_LAYER_reset_packet_length(rl) ((rl)->packet_length = 0) #define RECORD_LAYER_get_rstate(rl) ((rl)->rstate) #define RECORD_LAYER_set_rstate(rl, st) ((rl)->rstate = (st)) +#define RECORD_LAYER_get_write_sequence(rl) ((rl)->write_sequence) #define DTLS_RECORD_LAYER_get_r_epoch(rl) ((rl)->d->r_epoch) __owur int ssl3_read_n(SSL *s, int n, int max, int extend); |