]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Move sequence increment to post encryption processing
authorMatt Caswell <matt@openssl.org>
Mon, 17 Oct 2022 13:42:09 +0000 (14:42 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 20 Oct 2022 13:39:33 +0000 (14:39 +0100)
This change make dtls_write_records virtuall the same as
tls_write_records_default, which will enable us to merge them in a
subsequent commit.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19424)

ssl/record/methods/dtls_meth.c
ssl/record/methods/recmethod_local.h
ssl/record/methods/tls1_meth.c
ssl/record/methods/tlsany_meth.c

index d810ed7a28ff7ab14db6f30171b04b3fb1a62c50..9a24d5f8ad5e1497d169873954753d2e540e7fad 100644 (file)
@@ -720,6 +720,21 @@ int dtls_prepare_record_header(OSSL_RECORD_LAYER *rl,
     return 1;
 }
 
+int dtls_post_encryption_processing(OSSL_RECORD_LAYER *rl,
+                                    size_t mac_size,
+                                    OSSL_RECORD_TEMPLATE *thistempl,
+                                    WPACKET *thispkt,
+                                    SSL3_RECORD *thiswr)
+{
+    if (!tls_post_encryption_processing_default(rl, mac_size, thistempl,
+                                                thispkt, thiswr)) {
+        /* RLAYERfatal() already called */
+        return 0;
+    }
+
+    return tls_increment_sequence_ctr(rl);
+}
+
 int dtls_write_records(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates,
                        size_t numtempl)
 {
@@ -810,11 +825,6 @@ int dtls_write_records(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates,
         goto err;
     }
 
-    if (!tls_increment_sequence_ctr(rl)) {
-        /* RLAYERfatal() already called */
-        goto err;
-    }
-
     /* now let's set up wb */
     SSL3_BUFFER_set_left(wb, SSL3_RECORD_get_length(&wr));
 
index e1267500cff369177d6ff52c577064f59845e160..a25dd9d70fbc535b890b640e310d658f65df687c 100644 (file)
@@ -356,6 +356,11 @@ int dtls_prepare_record_header(OSSL_RECORD_LAYER *rl,
                                OSSL_RECORD_TEMPLATE *templ,
                                unsigned int rectype,
                                unsigned char **recdata);
+int dtls_post_encryption_processing(OSSL_RECORD_LAYER *rl,
+                                    size_t mac_size,
+                                    OSSL_RECORD_TEMPLATE *thistempl,
+                                    WPACKET *thispkt,
+                                    SSL3_RECORD *thiswr);
 int dtls_write_records(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates,
                        size_t numtempl);
 
index 6917fd897b2262940026b873883bbc9e7ea43e0c..232f055c52007877da435ab1fa5368fa04ed4d72 100644 (file)
@@ -682,6 +682,6 @@ struct record_functions_st dtls_1_funcs = {
     dtls_prepare_record_header,
     NULL,
     tls_prepare_for_encryption_default,
-    tls_post_encryption_processing_default,
+    dtls_post_encryption_processing,
     NULL
 };
index ff08c11d0dd8eacf9ade7f481697cda44bc18795..c2a1e0d09021b15042a528c72a5cbaea4cee9719 100644 (file)
@@ -190,6 +190,6 @@ struct record_functions_st dtls_any_funcs = {
     dtls_prepare_record_header,
     NULL,
     tls_prepare_for_encryption_default,
-    tls_post_encryption_processing_default,
+    dtls_post_encryption_processing,
     NULL
 };