Skip to content

Commit

Permalink
Standardise type for epoch
Browse files Browse the repository at this point in the history
The value for epoch was being represented internally via various types:
uint16_t, unsigned short, unsigned int, unsigned long

We standardise on uint16_t

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #18132)
  • Loading branch information
mattcaswell committed Aug 18, 2022
1 parent 9007412 commit 279754d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ssl/record/methods/dtls_meth.c
Expand Up @@ -629,7 +629,7 @@ static int dtls_free(OSSL_RECORD_LAYER *rl)

static int
dtls_new_record_layer(OSSL_LIB_CTX *libctx, const char *propq, int vers,
int role, int direction, int level, unsigned int epoch,
int role, int direction, int level, uint16_t epoch,
unsigned char *key, size_t keylen, unsigned char *iv,
size_t ivlen, unsigned char *mackey, size_t mackeylen,
const EVP_CIPHER *ciph, size_t taglen,
Expand Down
2 changes: 1 addition & 1 deletion ssl/record/methods/ktls_meth.c
Expand Up @@ -481,7 +481,7 @@ static struct record_functions_st ossl_ktls_funcs = {

static int
ktls_new_record_layer(OSSL_LIB_CTX *libctx, const char *propq, int vers,
int role, int direction, int level, unsigned int epoch,
int role, int direction, int level, uint16_t epoch,
unsigned char *key, size_t keylen, unsigned char *iv,
size_t ivlen, unsigned char *mackey, size_t mackeylen,
const EVP_CIPHER *ciph, size_t taglen,
Expand Down
2 changes: 1 addition & 1 deletion ssl/record/methods/recmethod_local.h
Expand Up @@ -68,7 +68,7 @@ struct ossl_record_layer_st
int direction;
int level;
/* DTLS only */
unsigned int epoch;
uint16_t epoch;

/*
* A BIO containing any data read in the previous epoch that was destined
Expand Down
4 changes: 2 additions & 2 deletions ssl/record/methods/tls_common.c
Expand Up @@ -967,7 +967,7 @@ int tls_read_record(OSSL_RECORD_LAYER *rl, void **rechandle, int *rversion,
*data = rec->data + rec->off;
*datalen = rec->length;
if (rl->isdtls) {
*epoch = (uint16_t)rec->epoch;
*epoch = rec->epoch;
memcpy(seq_num, rec->seq_num, sizeof(rec->seq_num));
}

Expand Down Expand Up @@ -1160,7 +1160,7 @@ tls_int_new_record_layer(OSSL_LIB_CTX *libctx, const char *propq, int vers,

static int
tls_new_record_layer(OSSL_LIB_CTX *libctx, const char *propq, int vers,
int role, int direction, int level, unsigned int epoch,
int role, int direction, int level, uint16_t epoch,
unsigned char *key, size_t keylen, unsigned char *iv,
size_t ivlen, unsigned char *mackey, size_t mackeylen,
const EVP_CIPHER *ciph, size_t taglen,
Expand Down
8 changes: 4 additions & 4 deletions ssl/record/record.h
Expand Up @@ -67,7 +67,7 @@ typedef struct ssl3_record_st {
unsigned char *comp;
/* epoch number, needed by DTLS1 */
/* r */
unsigned long epoch;
uint16_t epoch;
/* sequence number, needed by DTLS1 */
/* r */
unsigned char seq_num[SEQ_NUM_SIZE];
Expand Down Expand Up @@ -100,7 +100,7 @@ typedef struct dtls1_bitmap_st {
} DTLS1_BITMAP;

typedef struct record_pqueue_st {
unsigned short epoch;
uint16_t epoch;
struct pqueue_st *q;
} record_pqueue;

Expand All @@ -110,8 +110,8 @@ typedef struct dtls_record_layer_st {
* undefined, and starts at zero once the initial handshake is
* completed
*/
unsigned short r_epoch;
unsigned short w_epoch;
uint16_t r_epoch;
uint16_t w_epoch;

/*
* Buffered application records. Only for records between CCS and
Expand Down
2 changes: 1 addition & 1 deletion ssl/record/recordmethod.h
Expand Up @@ -147,7 +147,7 @@ struct ossl_record_method_st {
const char *propq, int vers,
int role, int direction,
int level,
unsigned int epoch,
uint16_t epoch,
unsigned char *key,
size_t keylen,
unsigned char *iv,
Expand Down
2 changes: 1 addition & 1 deletion ssl/ssl_local.h
Expand Up @@ -1909,7 +1909,7 @@ struct dtls1_retransmit_state {
EVP_MD_CTX *write_hash; /* used for mac generation */
COMP_CTX *compress; /* compression */
SSL_SESSION *session;
unsigned short epoch;
uint16_t epoch;
};

struct hm_header_st {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/ssltestlib.c
Expand Up @@ -263,7 +263,7 @@ static void mempacket_free(MEMPACKET *pkt)

typedef struct mempacket_test_ctx_st {
STACK_OF(MEMPACKET) *pkts;
unsigned int epoch;
uint16_t epoch;
unsigned int currrec;
unsigned int currpkt;
unsigned int lastpkt;
Expand Down

0 comments on commit 279754d

Please sign in to comment.