From fd23854bc7a3f24b804341870d0979d7a3643d3e Mon Sep 17 00:00:00 2001 From: joshua <> Date: Tue, 26 Mar 2024 08:54:48 +0000 Subject: Add TLS_ERROR_INVALID_CONTEXT error code to libtls ok jsing@ beck@ --- src/lib/libtls/tls.c | 6 +++--- src/lib/libtls/tls.h | 3 ++- src/lib/libtls/tls_client.c | 11 +++++++---- src/lib/libtls/tls_server.c | 7 ++++--- 4 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c index 8433f556bf..a8b03f0d4a 100644 --- a/src/lib/libtls/tls.c +++ b/src/lib/libtls/tls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls.c,v 1.101 2024/03/26 06:24:52 joshua Exp $ */ +/* $OpenBSD: tls.c,v 1.102 2024/03/26 08:54:48 joshua Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -821,7 +821,7 @@ tls_handshake(struct tls *ctx) tls_error_clear(&ctx->error); if ((ctx->flags & (TLS_CLIENT | TLS_SERVER_CONN)) == 0) { - tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, + tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, "invalid operation for context"); goto out; } @@ -924,7 +924,7 @@ tls_close(struct tls *ctx) tls_error_clear(&ctx->error); if ((ctx->flags & (TLS_CLIENT | TLS_SERVER_CONN)) == 0) { - tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, + tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, "invalid operation for context"); rv = -1; goto out; diff --git a/src/lib/libtls/tls.h b/src/lib/libtls/tls.h index 0113c1c67f..b69c4af58c 100644 --- a/src/lib/libtls/tls.h +++ b/src/lib/libtls/tls.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tls.h,v 1.64 2024/03/26 06:24:52 joshua Exp $ */ +/* $OpenBSD: tls.h,v 1.65 2024/03/26 08:54:48 joshua Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -80,6 +80,7 @@ extern "C" { #if defined(LIBRESSL_NEXT_API) || defined(LIBRESSL_INTERNAL) #define TLS_ERROR_UNKNOWN 0x0000 #define TLS_ERROR_OUT_OF_MEMORY 0x1000 +#define TLS_ERROR_INVALID_CONTEXT 0x2000 #endif struct tls; diff --git a/src/lib/libtls/tls_client.c b/src/lib/libtls/tls_client.c index 40ef9a02e2..97e1d40210 100644 --- a/src/lib/libtls/tls_client.c +++ b/src/lib/libtls/tls_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_client.c,v 1.50 2024/03/26 06:24:52 joshua Exp $ */ +/* $OpenBSD: tls_client.c,v 1.51 2024/03/26 08:54:48 joshua Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -66,7 +66,8 @@ tls_connect_servername(struct tls *ctx, const char *host, const char *port, int rv = -1, s = -1, ret; if ((ctx->flags & TLS_CLIENT) == 0) { - tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, "not a client context"); + tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, + "not a client context"); goto err; } @@ -292,7 +293,8 @@ tls_connect_common(struct tls *ctx, const char *servername) int rv = -1; if ((ctx->flags & TLS_CLIENT) == 0) { - tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, "not a client context"); + tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, + "not a client context"); goto err; } @@ -456,7 +458,8 @@ tls_handshake_client(struct tls *ctx) int rv = -1; if ((ctx->flags & TLS_CLIENT) == 0) { - tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, "not a client context"); + tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, + "not a client context"); goto err; } diff --git a/src/lib/libtls/tls_server.c b/src/lib/libtls/tls_server.c index a42985744b..a94b4221ed 100644 --- a/src/lib/libtls/tls_server.c +++ b/src/lib/libtls/tls_server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_server.c,v 1.50 2024/03/26 06:24:52 joshua Exp $ */ +/* $OpenBSD: tls_server.c,v 1.51 2024/03/26 08:54:48 joshua Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -372,7 +372,8 @@ tls_accept_common(struct tls *ctx) struct tls *conn_ctx = NULL; if ((ctx->flags & TLS_SERVER) == 0) { - tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, "not a server context"); + tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, + "not a server context"); goto err; } @@ -461,7 +462,7 @@ tls_handshake_server(struct tls *ctx) int rv = -1; if ((ctx->flags & TLS_SERVER_CONN) == 0) { - tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, + tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, "not a server connection context"); goto err; } -- cgit v1.2.3-55-g6feb