Standardise type for epoch
authorMatt Caswell <matt@openssl.org>
Wed, 27 Jul 2022 13:37:27 +0000 (14:37 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 18 Aug 2022 15:38:14 +0000 (16:38 +0100)
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 https://github.com/openssl/openssl/pull/18132)

ssl/record/methods/dtls_meth.c
ssl/record/methods/ktls_meth.c
ssl/record/methods/recmethod_local.h
ssl/record/methods/tls_common.c
ssl/record/record.h
ssl/record/recordmethod.h
ssl/ssl_local.h
test/helpers/ssltestlib.c

index 05bfa6e2d7c9b31030763f93e8cd87745600959c..e24614a1bdfd9707c3d2bb3811a5b331274d73a4 100644 (file)
@@ -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,
index 51127e41d7e1299d885c4972544f8240d0f5e4da..340356ca5e5d255cf372a62ed725229c9d901027 100644 (file)
@@ -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,
index 2fb100d5a998deb1d3ee8e05a3396f56e1de8dbc..69cb77938b86c4543e0fbd4c41875ebc60958aeb 100644 (file)
@@ -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
index 13efb82c6125d65141c6cdb5b125a3d79f20a21d..00454b43c82dad765a20cd17d60267e5cc7f310e 100644 (file)
@@ -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,
index d3984195afdb651b395d781c314b28ebaf8e2bad..d6f46efa520ee6923e778fc7f24ae8dd6159d2fd 100644 (file)
@@ -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
index bbd633ffbba9394833e66cf644f8e631e82565f5..537091db8a19190eb0aa32133cb84a229f2f5814 100644 (file)
@@ -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,
index ea081815a5949c1614e6fc497c09823a789d122c..7f5c8a0ba5409a4232365dd8d663e8e7dfe03f74 100644 (file)
@@ -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 {
index d95cfef6c574177b9a02cd9f3783a9c9d977fffb..94ea1c53d82f294e678ff559a239ad4745a408df 100644 (file)
@@ -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;