Keep retransmit window size architecture-independent.

Parameters like these should not change between 32-bit and 64-bit. 64 is also
the value recommended in RFC 6347, section 4.1.2.6. Document those fields while
I'm here.

Change-Id: I8481ee0765ff3d261a96a2e1a53b6ad6695b2d42
Reviewed-on: https://boringssl-review.googlesource.com/2222
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2014-11-07 02:49:34 -05:00 committed by Adam Langley
parent 60e7992764
commit d8138e91d0
2 changed files with 8 additions and 7 deletions

View File

@ -103,11 +103,12 @@ typedef struct timeval OPENSSL_timeval;
typedef struct dtls1_bitmap_st
{
unsigned long map; /* track 32 packets on 32-bit systems
and 64 - on 64-bit systems */
unsigned char max_seq_num[8]; /* max record number seen so far,
64-bit value in big-endian
encoding */
/* map is a bit mask of the last 64 sequence numbers. Bit
* |1<<i| corresponds to |max_seq_num - i|. */
uint64_t map;
/* max_seq_num is the largest sequence number seen so far. It
* is a 64-bit value in big-endian encoding. */
uint8_t max_seq_num[8];
} DTLS1_BITMAP;
struct dtls1_retransmit_state

View File

@ -1452,7 +1452,7 @@ static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap)
shift = -cmp;
if (shift >= sizeof(bitmap->map)*8)
return 0; /* stale, outside the window */
else if (bitmap->map & (1UL<<shift))
else if (bitmap->map & (((uint64_t) 1) << shift))
return 0; /* record previously received */
memcpy (s->s3->rrec.seq_num,seq,8);
@ -1479,7 +1479,7 @@ static void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap)
else {
shift = -cmp;
if (shift < sizeof(bitmap->map)*8)
bitmap->map |= 1UL<<shift;
bitmap->map |= ((uint64_t) 1) << shift;
}
}