From: Matt Caswell Date: Wed, 27 Jul 2022 13:37:27 +0000 (+0100) Subject: Standardise type for epoch X-Git-Tag: openssl-3.2.0-alpha1~2201 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=279754d4199f6e80e17b3e08fa261fbfd3e646c5;p=thirdparty%2Fopenssl.git Standardise type for epoch 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 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/18132) --- diff --git a/ssl/record/methods/dtls_meth.c b/ssl/record/methods/dtls_meth.c index 05bfa6e2d7c..e24614a1bdf 100644 --- a/ssl/record/methods/dtls_meth.c +++ b/ssl/record/methods/dtls_meth.c @@ -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, diff --git a/ssl/record/methods/ktls_meth.c b/ssl/record/methods/ktls_meth.c index 51127e41d7e..340356ca5e5 100644 --- a/ssl/record/methods/ktls_meth.c +++ b/ssl/record/methods/ktls_meth.c @@ -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, diff --git a/ssl/record/methods/recmethod_local.h b/ssl/record/methods/recmethod_local.h index 2fb100d5a99..69cb77938b8 100644 --- a/ssl/record/methods/recmethod_local.h +++ b/ssl/record/methods/recmethod_local.h @@ -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 diff --git a/ssl/record/methods/tls_common.c b/ssl/record/methods/tls_common.c index 13efb82c612..00454b43c82 100644 --- a/ssl/record/methods/tls_common.c +++ b/ssl/record/methods/tls_common.c @@ -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)); } @@ -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, diff --git a/ssl/record/record.h b/ssl/record/record.h index d3984195afd..d6f46efa520 100644 --- a/ssl/record/record.h +++ b/ssl/record/record.h @@ -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]; @@ -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; @@ -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 diff --git a/ssl/record/recordmethod.h b/ssl/record/recordmethod.h index bbd633ffbba..537091db8a1 100644 --- a/ssl/record/recordmethod.h +++ b/ssl/record/recordmethod.h @@ -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, diff --git a/ssl/ssl_local.h b/ssl/ssl_local.h index ea081815a59..7f5c8a0ba54 100644 --- a/ssl/ssl_local.h +++ b/ssl/ssl_local.h @@ -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 { diff --git a/test/helpers/ssltestlib.c b/test/helpers/ssltestlib.c index d95cfef6c57..94ea1c53d82 100644 --- a/test/helpers/ssltestlib.c +++ b/test/helpers/ssltestlib.c @@ -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;