diff options
author | Matt Caswell <matt@openssl.org> | 2022-10-17 15:07:47 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2022-10-20 14:39:33 +0100 |
commit | 43dfa5a9319f67cd652fdc3a8711fc53859cd11e (patch) | |
tree | 1abc273bb20fc385bfd464f3d9591a95cdbc717c /ssl | |
parent | 421386e392151c267ac7d3de6a2dd23c0ab62aed (diff) |
Remove dtls_write_records
The dtls_write_records function, after the previous series of commits,
was functionally equivalent to tls_write_records_default - so it can be
removed completely.
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)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/record/methods/dtls_meth.c | 100 | ||||
-rw-r--r-- | ssl/record/methods/recmethod_local.h | 2 | ||||
-rw-r--r-- | ssl/record/methods/tls1_meth.c | 2 | ||||
-rw-r--r-- | ssl/record/methods/tlsany_meth.c | 2 |
4 files changed, 2 insertions, 104 deletions
diff --git a/ssl/record/methods/dtls_meth.c b/ssl/record/methods/dtls_meth.c index 9a24d5f8ad..e867adc382 100644 --- a/ssl/record/methods/dtls_meth.c +++ b/ssl/record/methods/dtls_meth.c @@ -735,106 +735,6 @@ int dtls_post_encryption_processing(OSSL_RECORD_LAYER *rl, return tls_increment_sequence_ctr(rl); } -int dtls_write_records(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates, - size_t numtempl) -{ - int mac_size = 0; - SSL3_RECORD wr; - SSL3_BUFFER *wb; - WPACKET pkt, *thispkt = &pkt; - size_t wpinited = 0; - int ret = 0; - unsigned char *compressdata = NULL; - - if (rl->md_ctx != NULL && EVP_MD_CTX_get0_md(rl->md_ctx) != NULL) { - mac_size = EVP_MD_CTX_get_size(rl->md_ctx); - if (mac_size < 0) { - RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - } - - if (numtempl != 1) { - /* Should not happen */ - RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - - if (!rl->funcs->allocate_write_buffers(rl, templates, numtempl, NULL)) { - /* RLAYERfatal() already called */ - return 0; - } - - if (!rl->funcs->initialise_write_packets(rl, templates, numtempl, - NULL, thispkt, rl->wbuf, - &wpinited)) { - /* RLAYERfatal() already called */ - return 0; - } - - wb = rl->wbuf; - - SSL3_RECORD_set_type(&wr, templates->type); - SSL3_RECORD_set_rec_version(&wr, templates->version); - - if (!rl->funcs->prepare_record_header(rl, thispkt, templates, - templates->type, &compressdata)) { - /* RLAYERfatal() already called */ - goto err; - } - - /* lets setup the record stuff. */ - SSL3_RECORD_set_data(&wr, compressdata); - SSL3_RECORD_set_length(&wr, templates->buflen); - SSL3_RECORD_set_input(&wr, (unsigned char *)templates->buf); - - /* - * we now 'read' from wr.input, wr.length bytes into wr.data - */ - - /* first we compress */ - if (rl->compctx != NULL) { - if (!tls_do_compress(rl, &wr) - || !WPACKET_allocate_bytes(thispkt, wr.length, NULL)) { - RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, SSL_R_COMPRESSION_FAILURE); - goto err; - } - } else if (compressdata != NULL) { - if (!WPACKET_memcpy(thispkt, wr.input, wr.length)) { - RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - goto err; - } - SSL3_RECORD_reset_input(&wr); - } - - if (!rl->funcs->prepare_for_encryption(rl, mac_size, thispkt, &wr)) { - /* RLAYERfatal() already called */ - goto err; - } - - if (rl->funcs->cipher(rl, &wr, 1, 1, NULL, mac_size) < 1) { - if (rl->alert == SSL_AD_NO_ALERT) { - RLAYERfatal(rl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - } - goto err; - } - - if (!rl->funcs->post_encryption_processing(rl, mac_size, templates, - thispkt, &wr)) { - /* RLAYERfatal() already called */ - goto err; - } - - /* now let's set up wb */ - SSL3_BUFFER_set_left(wb, SSL3_RECORD_get_length(&wr)); - - ret = 1; - err: - if (wpinited > 0) - WPACKET_cleanup(thispkt); - return ret; -} - static size_t dtls_get_max_record_overhead(OSSL_RECORD_LAYER *rl) { size_t blocksize, mac_size; diff --git a/ssl/record/methods/recmethod_local.h b/ssl/record/methods/recmethod_local.h index a25dd9d70f..2552a8c0ac 100644 --- a/ssl/record/methods/recmethod_local.h +++ b/ssl/record/methods/recmethod_local.h @@ -361,8 +361,6 @@ int dtls_post_encryption_processing(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *thistempl, WPACKET *thispkt, SSL3_RECORD *thiswr); -int dtls_write_records(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates, - size_t numtempl); int tls_default_set_protocol_version(OSSL_RECORD_LAYER *rl, int version); int tls_default_validate_record_header(OSSL_RECORD_LAYER *rl, SSL3_RECORD *re); diff --git a/ssl/record/methods/tls1_meth.c b/ssl/record/methods/tls1_meth.c index 232f055c52..1007efc57a 100644 --- a/ssl/record/methods/tls1_meth.c +++ b/ssl/record/methods/tls1_meth.c @@ -669,7 +669,7 @@ struct record_functions_st dtls_1_funcs = { NULL, NULL, NULL, - dtls_write_records, + tls_write_records_default, /* * Don't use tls1_allocate_write_buffers since that handles empty fragment * records which aren't needed in DTLS. We just use the default allocation diff --git a/ssl/record/methods/tlsany_meth.c b/ssl/record/methods/tlsany_meth.c index c2a1e0d090..e52bebfba0 100644 --- a/ssl/record/methods/tlsany_meth.c +++ b/ssl/record/methods/tlsany_meth.c @@ -183,7 +183,7 @@ struct record_functions_st dtls_any_funcs = { NULL, NULL, NULL, - dtls_write_records, + tls_write_records_default, tls_allocate_write_buffers_default, tls_initialise_write_packets_default, NULL, |