diff options
| author | jsing <> | 2020-05-10 16:56:11 +0000 |
|---|---|---|
| committer | jsing <> | 2020-05-10 16:56:11 +0000 |
| commit | b31d318d829815c32911ba41253883a36be79792 (patch) | |
| tree | c31ffbaae4cfd09bf31b64685c65004c13420403 /src/lib/libssl/tls13_server.c | |
| parent | de23b97501f6e54572fa507f71060d59df83240e (diff) | |
| download | openbsd-b31d318d829815c32911ba41253883a36be79792.tar.gz openbsd-b31d318d829815c32911ba41253883a36be79792.tar.bz2 openbsd-b31d318d829815c32911ba41253883a36be79792.zip | |
Provide alert defines for TLSv1.3 and use in the TLSv1.3 code.
Rather than using a mess of SSL_AL_*, SSL_AD_*, SSL3_AD_* and TLS1_AD_*
defines, provide our own TLS13_ALERT_* defines and use those. This also
provides the alerts that are new to TLSv1.3.
ok beck@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/tls13_server.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c index 0b040fb51d..9dfb4a7227 100644 --- a/src/lib/libssl/tls13_server.c +++ b/src/lib/libssl/tls13_server.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_server.c,v 1.40 2020/05/09 20:38:19 tb Exp $ */ | 1 | /* $OpenBSD: tls13_server.c,v 1.41 2020/05/10 16:56:11 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> |
| 4 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 4 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
| @@ -129,13 +129,13 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
| 129 | * TLS 1.3 or later. This requires the legacy version be set to 0x0303. | 129 | * TLS 1.3 or later. This requires the legacy version be set to 0x0303. |
| 130 | */ | 130 | */ |
| 131 | if (legacy_version != TLS1_2_VERSION) { | 131 | if (legacy_version != TLS1_2_VERSION) { |
| 132 | ctx->alert = SSL_AD_PROTOCOL_VERSION; | 132 | ctx->alert = TLS13_ALERT_PROTOCOL_VERSION; |
| 133 | goto err; | 133 | goto err; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | /* Store legacy session identifier so we can echo it. */ | 136 | /* Store legacy session identifier so we can echo it. */ |
| 137 | if (CBS_len(&session_id) > sizeof(ctx->hs->legacy_session_id)) { | 137 | if (CBS_len(&session_id) > sizeof(ctx->hs->legacy_session_id)) { |
| 138 | ctx->alert = SSL_AD_ILLEGAL_PARAMETER; | 138 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
| 139 | goto err; | 139 | goto err; |
| 140 | } | 140 | } |
| 141 | if (!CBS_write_bytes(&session_id, ctx->hs->legacy_session_id, | 141 | if (!CBS_write_bytes(&session_id, ctx->hs->legacy_session_id, |
| @@ -144,14 +144,14 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
| 144 | 144 | ||
| 145 | /* Parse cipher suites list and select preferred cipher. */ | 145 | /* Parse cipher suites list and select preferred cipher. */ |
| 146 | if ((ciphers = ssl_bytes_to_cipher_list(s, &cipher_suites)) == NULL) { | 146 | if ((ciphers = ssl_bytes_to_cipher_list(s, &cipher_suites)) == NULL) { |
| 147 | ctx->alert = SSL_AD_ILLEGAL_PARAMETER; | 147 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
| 148 | goto err; | 148 | goto err; |
| 149 | } | 149 | } |
| 150 | cipher = ssl3_choose_cipher(s, ciphers, SSL_get_ciphers(s)); | 150 | cipher = ssl3_choose_cipher(s, ciphers, SSL_get_ciphers(s)); |
| 151 | if (cipher == NULL) { | 151 | if (cipher == NULL) { |
| 152 | tls13_set_errorx(ctx, TLS13_ERR_NO_SHARED_CIPHER, 0, | 152 | tls13_set_errorx(ctx, TLS13_ERR_NO_SHARED_CIPHER, 0, |
| 153 | "no shared cipher found", NULL); | 153 | "no shared cipher found", NULL); |
| 154 | ctx->alert = SSL_AD_HANDSHAKE_FAILURE; | 154 | ctx->alert = TLS13_ALERT_HANDSHAKE_FAILURE; |
| 155 | goto err; | 155 | goto err; |
| 156 | } | 156 | } |
| 157 | S3I(s)->hs.new_cipher = cipher; | 157 | S3I(s)->hs.new_cipher = cipher; |
| @@ -159,7 +159,7 @@ tls13_client_hello_process(struct tls13_ctx *ctx, CBS *cbs) | |||
| 159 | /* Ensure only the NULL compression method is advertised. */ | 159 | /* Ensure only the NULL compression method is advertised. */ |
| 160 | if (!CBS_mem_equal(&compression_methods, tls13_compression_null_only, | 160 | if (!CBS_mem_equal(&compression_methods, tls13_compression_null_only, |
| 161 | sizeof(tls13_compression_null_only))) { | 161 | sizeof(tls13_compression_null_only))) { |
| 162 | ctx->alert = SSL_AD_ILLEGAL_PARAMETER; | 162 | ctx->alert = TLS13_ALERT_ILLEGAL_PARAMETER; |
| 163 | goto err; | 163 | goto err; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| @@ -517,7 +517,7 @@ tls13_server_certificate_verify_send(struct tls13_ctx *ctx, CBB *cbb) | |||
| 517 | 517 | ||
| 518 | err: | 518 | err: |
| 519 | if (!ret && ctx->alert == 0) | 519 | if (!ret && ctx->alert == 0) |
| 520 | ctx->alert = TLS1_AD_INTERNAL_ERROR; | 520 | ctx->alert = TLS13_ALERT_INTERNAL_ERROR; |
| 521 | 521 | ||
| 522 | CBB_cleanup(&sig_cbb); | 522 | CBB_cleanup(&sig_cbb); |
| 523 | EVP_MD_CTX_free(mdctx); | 523 | EVP_MD_CTX_free(mdctx); |
| @@ -757,12 +757,12 @@ tls13_client_certificate_verify_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
| 757 | goto err; | 757 | goto err; |
| 758 | } | 758 | } |
| 759 | if (!EVP_DigestVerifyUpdate(mdctx, sig_content, sig_content_len)) { | 759 | if (!EVP_DigestVerifyUpdate(mdctx, sig_content, sig_content_len)) { |
| 760 | ctx->alert = TLS1_AD_DECRYPT_ERROR; | 760 | ctx->alert = TLS13_ALERT_DECRYPT_ERROR; |
| 761 | goto err; | 761 | goto err; |
| 762 | } | 762 | } |
| 763 | if (EVP_DigestVerifyFinal(mdctx, CBS_data(&signature), | 763 | if (EVP_DigestVerifyFinal(mdctx, CBS_data(&signature), |
| 764 | CBS_len(&signature)) <= 0) { | 764 | CBS_len(&signature)) <= 0) { |
| 765 | ctx->alert = TLS1_AD_DECRYPT_ERROR; | 765 | ctx->alert = TLS13_ALERT_DECRYPT_ERROR; |
| 766 | goto err; | 766 | goto err; |
| 767 | } | 767 | } |
| 768 | 768 | ||
| @@ -770,7 +770,7 @@ tls13_client_certificate_verify_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
| 770 | 770 | ||
| 771 | err: | 771 | err: |
| 772 | if (!ret && ctx->alert == 0) { | 772 | if (!ret && ctx->alert == 0) { |
| 773 | ctx->alert = TLS1_AD_DECODE_ERROR; | 773 | ctx->alert = TLS13_ALERT_DECODE_ERROR; |
| 774 | } | 774 | } |
| 775 | CBB_cleanup(&cbb); | 775 | CBB_cleanup(&cbb); |
| 776 | EVP_MD_CTX_free(mdctx); | 776 | EVP_MD_CTX_free(mdctx); |
| @@ -826,7 +826,7 @@ tls13_client_finished_recv(struct tls13_ctx *ctx, CBS *cbs) | |||
| 826 | goto err; | 826 | goto err; |
| 827 | 827 | ||
| 828 | if (!CBS_mem_equal(cbs, verify_data, verify_data_len)) { | 828 | if (!CBS_mem_equal(cbs, verify_data, verify_data_len)) { |
| 829 | ctx->alert = TLS1_AD_DECRYPT_ERROR; | 829 | ctx->alert = TLS13_ALERT_DECRYPT_ERROR; |
| 830 | goto err; | 830 | goto err; |
| 831 | } | 831 | } |
| 832 | 832 | ||
