diff options
author | joshua <> | 2024-03-26 08:54:48 +0000 |
---|---|---|
committer | joshua <> | 2024-03-26 08:54:48 +0000 |
commit | fd23854bc7a3f24b804341870d0979d7a3643d3e (patch) | |
tree | 556c8b71628c259ac6c0e3e66c7165a9860ba4a7 | |
parent | b708bfbe4ecac1e6024ff2b0f7f7aeab1b8c0068 (diff) | |
download | openbsd-fd23854bc7a3f24b804341870d0979d7a3643d3e.tar.gz openbsd-fd23854bc7a3f24b804341870d0979d7a3643d3e.tar.bz2 openbsd-fd23854bc7a3f24b804341870d0979d7a3643d3e.zip |
Add TLS_ERROR_INVALID_CONTEXT error code to libtls
ok jsing@ beck@
-rw-r--r-- | src/lib/libtls/tls.c | 6 | ||||
-rw-r--r-- | src/lib/libtls/tls.h | 3 | ||||
-rw-r--r-- | src/lib/libtls/tls_client.c | 11 | ||||
-rw-r--r-- | src/lib/libtls/tls_server.c | 7 |
4 files changed, 16 insertions, 11 deletions
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 @@ | |||
1 | /* $OpenBSD: tls.c,v 1.101 2024/03/26 06:24:52 joshua Exp $ */ | 1 | /* $OpenBSD: tls.c,v 1.102 2024/03/26 08:54:48 joshua Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -821,7 +821,7 @@ tls_handshake(struct tls *ctx) | |||
821 | tls_error_clear(&ctx->error); | 821 | tls_error_clear(&ctx->error); |
822 | 822 | ||
823 | if ((ctx->flags & (TLS_CLIENT | TLS_SERVER_CONN)) == 0) { | 823 | if ((ctx->flags & (TLS_CLIENT | TLS_SERVER_CONN)) == 0) { |
824 | tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, | 824 | tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, |
825 | "invalid operation for context"); | 825 | "invalid operation for context"); |
826 | goto out; | 826 | goto out; |
827 | } | 827 | } |
@@ -924,7 +924,7 @@ tls_close(struct tls *ctx) | |||
924 | tls_error_clear(&ctx->error); | 924 | tls_error_clear(&ctx->error); |
925 | 925 | ||
926 | if ((ctx->flags & (TLS_CLIENT | TLS_SERVER_CONN)) == 0) { | 926 | if ((ctx->flags & (TLS_CLIENT | TLS_SERVER_CONN)) == 0) { |
927 | tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, | 927 | tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, |
928 | "invalid operation for context"); | 928 | "invalid operation for context"); |
929 | rv = -1; | 929 | rv = -1; |
930 | goto out; | 930 | 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 @@ | |||
1 | /* $OpenBSD: tls.h,v 1.64 2024/03/26 06:24:52 joshua Exp $ */ | 1 | /* $OpenBSD: tls.h,v 1.65 2024/03/26 08:54:48 joshua Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -80,6 +80,7 @@ extern "C" { | |||
80 | #if defined(LIBRESSL_NEXT_API) || defined(LIBRESSL_INTERNAL) | 80 | #if defined(LIBRESSL_NEXT_API) || defined(LIBRESSL_INTERNAL) |
81 | #define TLS_ERROR_UNKNOWN 0x0000 | 81 | #define TLS_ERROR_UNKNOWN 0x0000 |
82 | #define TLS_ERROR_OUT_OF_MEMORY 0x1000 | 82 | #define TLS_ERROR_OUT_OF_MEMORY 0x1000 |
83 | #define TLS_ERROR_INVALID_CONTEXT 0x2000 | ||
83 | #endif | 84 | #endif |
84 | 85 | ||
85 | struct tls; | 86 | 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 @@ | |||
1 | /* $OpenBSD: tls_client.c,v 1.50 2024/03/26 06:24:52 joshua Exp $ */ | 1 | /* $OpenBSD: tls_client.c,v 1.51 2024/03/26 08:54:48 joshua Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -66,7 +66,8 @@ tls_connect_servername(struct tls *ctx, const char *host, const char *port, | |||
66 | int rv = -1, s = -1, ret; | 66 | int rv = -1, s = -1, ret; |
67 | 67 | ||
68 | if ((ctx->flags & TLS_CLIENT) == 0) { | 68 | if ((ctx->flags & TLS_CLIENT) == 0) { |
69 | tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, "not a client context"); | 69 | tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, |
70 | "not a client context"); | ||
70 | goto err; | 71 | goto err; |
71 | } | 72 | } |
72 | 73 | ||
@@ -292,7 +293,8 @@ tls_connect_common(struct tls *ctx, const char *servername) | |||
292 | int rv = -1; | 293 | int rv = -1; |
293 | 294 | ||
294 | if ((ctx->flags & TLS_CLIENT) == 0) { | 295 | if ((ctx->flags & TLS_CLIENT) == 0) { |
295 | tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, "not a client context"); | 296 | tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, |
297 | "not a client context"); | ||
296 | goto err; | 298 | goto err; |
297 | } | 299 | } |
298 | 300 | ||
@@ -456,7 +458,8 @@ tls_handshake_client(struct tls *ctx) | |||
456 | int rv = -1; | 458 | int rv = -1; |
457 | 459 | ||
458 | if ((ctx->flags & TLS_CLIENT) == 0) { | 460 | if ((ctx->flags & TLS_CLIENT) == 0) { |
459 | tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, "not a client context"); | 461 | tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, |
462 | "not a client context"); | ||
460 | goto err; | 463 | goto err; |
461 | } | 464 | } |
462 | 465 | ||
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 @@ | |||
1 | /* $OpenBSD: tls_server.c,v 1.50 2024/03/26 06:24:52 joshua Exp $ */ | 1 | /* $OpenBSD: tls_server.c,v 1.51 2024/03/26 08:54:48 joshua Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -372,7 +372,8 @@ tls_accept_common(struct tls *ctx) | |||
372 | struct tls *conn_ctx = NULL; | 372 | struct tls *conn_ctx = NULL; |
373 | 373 | ||
374 | if ((ctx->flags & TLS_SERVER) == 0) { | 374 | if ((ctx->flags & TLS_SERVER) == 0) { |
375 | tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, "not a server context"); | 375 | tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, |
376 | "not a server context"); | ||
376 | goto err; | 377 | goto err; |
377 | } | 378 | } |
378 | 379 | ||
@@ -461,7 +462,7 @@ tls_handshake_server(struct tls *ctx) | |||
461 | int rv = -1; | 462 | int rv = -1; |
462 | 463 | ||
463 | if ((ctx->flags & TLS_SERVER_CONN) == 0) { | 464 | if ((ctx->flags & TLS_SERVER_CONN) == 0) { |
464 | tls_set_errorx(ctx, TLS_ERROR_UNKNOWN, | 465 | tls_set_errorx(ctx, TLS_ERROR_INVALID_CONTEXT, |
465 | "not a server connection context"); | 466 | "not a server connection context"); |
466 | goto err; | 467 | goto err; |
467 | } | 468 | } |