diff options
author | tb <> | 2021-02-03 07:06:14 +0000 |
---|---|---|
committer | tb <> | 2021-02-03 07:06:14 +0000 |
commit | 70029edfad38276befdaee62f4fe7e084070c0cd (patch) | |
tree | 9f524641600313fef6d235a1c7bfeced27fbe075 /src/lib/libssl/tls13_lib.c | |
parent | 7708b34c3988d3cd2e01b8bd5d4f1a64461e6464 (diff) | |
download | openbsd-70029edfad38276befdaee62f4fe7e084070c0cd.tar.gz openbsd-70029edfad38276befdaee62f4fe7e084070c0cd.tar.bz2 openbsd-70029edfad38276befdaee62f4fe7e084070c0cd.zip |
This is errata/6.8/013_libressl.patch.siglibressl-v3.2.4
Various interoperability issues and memory leaks were discovered in
libcrypto and libssl.
The new verifier is not bug compatible with the old verifier and caused
many issues by failing to propagate errors correctly, returning different
error codes than some software was trained to expect and otherwise failing
when it shouldn't. While much of this is fixed in -current, it's still not
perfect, so switching back to the legacy verifier is preferable at this
point.
Other included fixes:
* Unbreak DTLS retransmissions for flights that include a CCS
* Only check BIO_should_read() on read and BIO_should_write() on write
* Implement autochain for the TLSv1.3 server
* Use the legacy verifier for AUTO_CHAIN
* Implement exporter for TLSv1.3
* Free alert_data and phh_data in tls13_record_layer_free()
* Plug leak in x509_verify_chain_dup()
* Free the policy tree in x509_vfy_check_policy()
Original commits by jsing and tb
ok inoguchi jsing
Diffstat (limited to 'src/lib/libssl/tls13_lib.c')
-rw-r--r-- | src/lib/libssl/tls13_lib.c | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index 590426ad8a..af3de58f93 100644 --- a/src/lib/libssl/tls13_lib.c +++ b/src/lib/libssl/tls13_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_lib.c,v 1.54 2020/09/11 15:03:36 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_lib.c,v 1.54.4.1 2021/02/03 07:06:14 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2019 Bob Beck <beck@openbsd.org> | 4 | * Copyright (c) 2019 Bob Beck <beck@openbsd.org> |
@@ -579,3 +579,75 @@ tls13_clienthello_hash_validate(struct tls13_ctx *ctx) | |||
579 | return 1; | 579 | return 1; |
580 | } | 580 | } |
581 | 581 | ||
582 | int | ||
583 | tls13_exporter(struct tls13_ctx *ctx, const uint8_t *label, size_t label_len, | ||
584 | const uint8_t *context_value, size_t context_value_len, uint8_t *out, | ||
585 | size_t out_len) | ||
586 | { | ||
587 | struct tls13_secret context, export_out, export_secret; | ||
588 | struct tls13_secrets *secrets = ctx->hs->secrets; | ||
589 | EVP_MD_CTX *md_ctx = NULL; | ||
590 | unsigned int md_out_len; | ||
591 | int md_len; | ||
592 | int ret = 0; | ||
593 | |||
594 | /* | ||
595 | * RFC 8446 Section 7.5. | ||
596 | */ | ||
597 | |||
598 | memset(&context, 0, sizeof(context)); | ||
599 | memset(&export_secret, 0, sizeof(export_secret)); | ||
600 | |||
601 | export_out.data = out; | ||
602 | export_out.len = out_len; | ||
603 | |||
604 | if (!ctx->handshake_completed) | ||
605 | return 0; | ||
606 | |||
607 | md_len = EVP_MD_size(secrets->digest); | ||
608 | if (md_len <= 0 || md_len > EVP_MAX_MD_SIZE) | ||
609 | goto err; | ||
610 | |||
611 | if ((export_secret.data = calloc(1, md_len)) == NULL) | ||
612 | goto err; | ||
613 | export_secret.len = md_len; | ||
614 | |||
615 | if ((context.data = calloc(1, md_len)) == NULL) | ||
616 | goto err; | ||
617 | context.len = md_len; | ||
618 | |||
619 | /* In TLSv1.3 no context is equivalent to an empty context. */ | ||
620 | if (context_value == NULL) { | ||
621 | context_value = ""; | ||
622 | context_value_len = 0; | ||
623 | } | ||
624 | |||
625 | if ((md_ctx = EVP_MD_CTX_new()) == NULL) | ||
626 | goto err; | ||
627 | if (!EVP_DigestInit_ex(md_ctx, secrets->digest, NULL)) | ||
628 | goto err; | ||
629 | if (!EVP_DigestUpdate(md_ctx, context_value, context_value_len)) | ||
630 | goto err; | ||
631 | if (!EVP_DigestFinal_ex(md_ctx, context.data, &md_out_len)) | ||
632 | goto err; | ||
633 | if (md_len != md_out_len) | ||
634 | goto err; | ||
635 | |||
636 | if (!tls13_derive_secret_with_label_length(&export_secret, | ||
637 | secrets->digest, &secrets->exporter_master, label, label_len, | ||
638 | &secrets->empty_hash)) | ||
639 | goto err; | ||
640 | |||
641 | if (!tls13_hkdf_expand_label(&export_out, secrets->digest, | ||
642 | &export_secret, "exporter", &context)) | ||
643 | goto err; | ||
644 | |||
645 | ret = 1; | ||
646 | |||
647 | err: | ||
648 | EVP_MD_CTX_free(md_ctx); | ||
649 | freezero(context.data, context.len); | ||
650 | freezero(export_secret.data, export_secret.len); | ||
651 | |||
652 | return ret; | ||
653 | } | ||