Define SEQ_NUM_SIZE

Replace the hard coded value 8 (the size of the sequence number) with a
constant defined in a macro.

Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
Matt Caswell 2015-03-26 13:12:24 +00:00
parent 3497ac5d33
commit e5bf62f716
3 changed files with 9 additions and 7 deletions

View File

@ -209,7 +209,7 @@ void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap)
bitmap->map <<= shift, bitmap->map |= 1UL;
else
bitmap->map = 1UL;
memcpy(bitmap->max_seq_num, seq, 8);
memcpy(bitmap->max_seq_num, seq, SEQ_NUM_SIZE);
} else {
shift = -cmp;
if (shift < sizeof(bitmap->map) * 8)

View File

@ -127,6 +127,8 @@ typedef struct ssl3_buffer_st {
int left;
} SSL3_BUFFER;
#define SEQ_NUM_SIZE 8
typedef struct ssl3_record_st {
/* type of record */
/*
@ -166,15 +168,15 @@ typedef struct ssl3_record_st {
/* sequence number, needed by DTLS1 */
/*
* r
*/ unsigned char seq_num[8];
*/ unsigned char seq_num[SEQ_NUM_SIZE];
} SSL3_RECORD;
typedef struct dtls1_bitmap_st {
unsigned long map; /* track 32 packets on 32-bit systems and 64
* - on 64-bit systems */
/* Track 32 packets on 32-bit systems and 64 - on 64-bit systems */
unsigned long map;
unsigned char max_seq_num[8]; /* max record number seen so far, 64-bit
* value in big-endian encoding */
/* Max record number seen so far, 64-bit value in big-endian encoding */
unsigned char max_seq_num[SEQ_NUM_SIZE];
} DTLS1_BITMAP;
typedef struct record_pqueue_st {

View File

@ -156,7 +156,7 @@ int SSL3_RECORD_setup(SSL3_RECORD *r)
void SSL3_RECORD_set_seq_num(SSL3_RECORD *r, const unsigned char *seq_num)
{
memcpy(r->seq_num, seq_num, 8);
memcpy(r->seq_num, seq_num, SEQ_NUM_SIZE);
}
/*