diff options
author | jsing <> | 2020-01-20 13:10:37 +0000 |
---|---|---|
committer | jsing <> | 2020-01-20 13:10:37 +0000 |
commit | b9ba33b0c7f77fc7b3e33c32ded38da7ee4c7c55 (patch) | |
tree | cfa7f8e8231dba5be24e1ea4325ed5f91b57cb43 /src/lib/libssl/tls13_lib.c | |
parent | 101a098151714705f06800dd03668b1d84167aa1 (diff) | |
download | openbsd-b9ba33b0c7f77fc7b3e33c32ded38da7ee4c7c55.tar.gz openbsd-b9ba33b0c7f77fc7b3e33c32ded38da7ee4c7c55.tar.bz2 openbsd-b9ba33b0c7f77fc7b3e33c32ded38da7ee4c7c55.zip |
Provide an error framework for use with the TLSv1.3 code.
This is based on the libtls error handling code, but adds machine readable
codes and subcodes. We then map these codes back to libssl error codes.
ok beck@ inoguchi@
Diffstat (limited to 'src/lib/libssl/tls13_lib.c')
-rw-r--r-- | src/lib/libssl/tls13_lib.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index 6876528f50..d30d28c45f 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.13 2019/11/26 23:46:18 beck Exp $ */ | 1 | /* $OpenBSD: tls13_lib.c,v 1.14 2020/01/20 13:10:37 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 | * Copyright (c) 2019 Bob Beck <beck@openbsd.org> | 4 | * Copyright (c) 2019 Bob Beck <beck@openbsd.org> |
@@ -263,6 +263,7 @@ tls13_ctx_free(struct tls13_ctx *ctx) | |||
263 | if (ctx == NULL) | 263 | if (ctx == NULL) |
264 | return; | 264 | return; |
265 | 265 | ||
266 | tls13_error_clear(&ctx->error); | ||
266 | tls13_record_layer_free(ctx->rl); | 267 | tls13_record_layer_free(ctx->rl); |
267 | 268 | ||
268 | freezero(ctx, sizeof(struct tls13_ctx)); | 269 | freezero(ctx, sizeof(struct tls13_ctx)); |
@@ -340,6 +341,22 @@ tls13_legacy_wire_write_cb(const void *buf, size_t n, void *arg) | |||
340 | return tls13_legacy_wire_write(ctx->ssl, buf, n); | 341 | return tls13_legacy_wire_write(ctx->ssl, buf, n); |
341 | } | 342 | } |
342 | 343 | ||
344 | static void | ||
345 | tls13_legacy_error(SSL *ssl) | ||
346 | { | ||
347 | struct tls13_ctx *ctx = ssl->internal->tls13; | ||
348 | int reason = ERR_R_INTERNAL_ERROR; | ||
349 | |||
350 | switch (ctx->error.code) { | ||
351 | case TLS13_ERR_VERIFY_FAILED: | ||
352 | reason = SSL_R_CERTIFICATE_VERIFY_FAILED; | ||
353 | break; | ||
354 | } | ||
355 | |||
356 | ERR_put_error(ERR_LIB_SSL, (0xfff), reason, ctx->error.file, | ||
357 | ctx->error.line); | ||
358 | } | ||
359 | |||
343 | int | 360 | int |
344 | tls13_legacy_return_code(SSL *ssl, ssize_t ret) | 361 | tls13_legacy_return_code(SSL *ssl, ssize_t ret) |
345 | { | 362 | { |
@@ -359,9 +376,7 @@ tls13_legacy_return_code(SSL *ssl, ssize_t ret) | |||
359 | return 0; | 376 | return 0; |
360 | 377 | ||
361 | case TLS13_IO_FAILURE: | 378 | case TLS13_IO_FAILURE: |
362 | /* XXX - we need to record/map internal errors. */ | 379 | tls13_legacy_error(ssl); |
363 | if (ERR_peek_error() == 0) | ||
364 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); | ||
365 | return -1; | 380 | return -1; |
366 | 381 | ||
367 | case TLS13_IO_WANT_POLLIN: | 382 | case TLS13_IO_WANT_POLLIN: |