diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/tls13_lib.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index 3860ddefef..f9505fa438 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.3 2019/01/21 13:45:57 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_lib.c,v 1.4 2019/02/21 17:15:00 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -61,6 +61,35 @@ tls13_cipher_hash(const SSL_CIPHER *cipher) | |||
| 61 | return NULL; | 61 | return NULL; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static void | ||
| 65 | tls13_alert_received_cb(uint8_t alert_level, uint8_t alert_desc, void *arg) | ||
| 66 | { | ||
| 67 | struct tls13_ctx *ctx = arg; | ||
| 68 | SSL *s = ctx->ssl; | ||
| 69 | |||
| 70 | if (alert_desc == SSL_AD_CLOSE_NOTIFY) { | ||
| 71 | ctx->ssl->internal->shutdown |= SSL_RECEIVED_SHUTDOWN; | ||
| 72 | S3I(ctx->ssl)->warn_alert = alert_desc; | ||
| 73 | return; | ||
| 74 | } | ||
| 75 | |||
| 76 | if (alert_desc == SSL_AD_USER_CANCELLED) { | ||
| 77 | /* | ||
| 78 | * We treat this as advisory, since a close_notify alert | ||
| 79 | * SHOULD follow this alert (RFC 8446 section 6.1). | ||
| 80 | */ | ||
| 81 | return; | ||
| 82 | } | ||
| 83 | |||
| 84 | /* All other alerts are treated as fatal in TLSv1.3. */ | ||
| 85 | S3I(ctx->ssl)->fatal_alert = alert_desc; | ||
| 86 | |||
| 87 | SSLerror(ctx->ssl, SSL_AD_REASON_OFFSET + alert_desc); | ||
| 88 | ERR_asprintf_error_data("SSL alert number %d", alert_desc); | ||
| 89 | |||
| 90 | SSL_CTX_remove_session(s->ctx, s->session); | ||
| 91 | } | ||
| 92 | |||
| 64 | struct tls13_ctx * | 93 | struct tls13_ctx * |
| 65 | tls13_ctx_new(int mode) | 94 | tls13_ctx_new(int mode) |
| 66 | { | 95 | { |
| @@ -72,7 +101,8 @@ tls13_ctx_new(int mode) | |||
| 72 | ctx->mode = mode; | 101 | ctx->mode = mode; |
| 73 | 102 | ||
| 74 | if ((ctx->rl = tls13_record_layer_new(tls13_legacy_wire_read_cb, | 103 | if ((ctx->rl = tls13_record_layer_new(tls13_legacy_wire_read_cb, |
| 75 | tls13_legacy_wire_write_cb, NULL, NULL, ctx)) == NULL) | 104 | tls13_legacy_wire_write_cb, tls13_alert_received_cb, NULL, |
| 105 | ctx)) == NULL) | ||
| 76 | goto err; | 106 | goto err; |
| 77 | 107 | ||
| 78 | return ctx; | 108 | return ctx; |
