unsigned long header_length;
unsigned char seq64be[8];
struct dtls1_retransmit_state saved_state;
- unsigned char save_write_sequence[8];
/*-
OPENSSL_assert(s->init_num == 0);
s->write_hash = frag->msg_header.saved_retransmit_state.write_hash;
s->compress = frag->msg_header.saved_retransmit_state.compress;
s->session = frag->msg_header.saved_retransmit_state.session;
- DTLS_RECORD_LAYER_set_w_epoch(&s->rlayer,
+ DTLS_RECORD_LAYER_set_saved_w_epoch(&s->rlayer,
frag->msg_header.saved_retransmit_state.epoch);
- if (frag->msg_header.saved_retransmit_state.epoch ==
- saved_state.epoch - 1) {
-
- memcpy(save_write_sequence, RECORD_LAYER_get_write_sequence(&s->rlayer),
- sizeof(save_write_sequence));
- RECORD_LAYER_set_write_sequence(&s->rlayer, s->d1->last_write_sequence);
- }
-
ret = dtls1_do_write(s, frag->msg_header.is_ccs ?
SSL3_RT_CHANGE_CIPHER_SPEC : SSL3_RT_HANDSHAKE);
s->write_hash = saved_state.write_hash;
s->compress = saved_state.compress;
s->session = saved_state.session;
- DTLS_RECORD_LAYER_set_w_epoch(&s->rlayer, saved_state.epoch);
-
- if (frag->msg_header.saved_retransmit_state.epoch ==
- saved_state.epoch - 1) {
- memcpy(s->d1->last_write_sequence,
- RECORD_LAYER_get_write_sequence(&s->rlayer),
- sizeof(s->d1->last_write_sequence));
- RECORD_LAYER_set_write_sequence(&s->rlayer, save_write_sequence);
- }
+ DTLS_RECORD_LAYER_set_saved_w_epoch(&s->rlayer, saved_state.epoch);
s->d1->retransmitting = 0;
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);
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++;
}
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 {
#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) \
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,
#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);
unsigned short handshake_write_seq;
unsigned short next_handshake_write_seq;
unsigned short handshake_read_seq;
- /* save last sequence number for retransmissions */
- unsigned char last_write_sequence[8];
+
/* Buffered handshake messages */
pqueue buffered_messages;
/* Buffered (sent) handshake records */