summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls13_internal.h
diff options
context:
space:
mode:
authorjsing <>2020-01-20 13:10:37 +0000
committerjsing <>2020-01-20 13:10:37 +0000
commitb9ba33b0c7f77fc7b3e33c32ded38da7ee4c7c55 (patch)
treecfa7f8e8231dba5be24e1ea4325ed5f91b57cb43 /src/lib/libssl/tls13_internal.h
parent101a098151714705f06800dd03668b1d84167aa1 (diff)
downloadopenbsd-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_internal.h')
-rw-r--r--src/lib/libssl/tls13_internal.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h
index b33e4818af..41833f233f 100644
--- a/src/lib/libssl/tls13_internal.h
+++ b/src/lib/libssl/tls13_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_internal.h,v 1.36 2019/11/26 23:46:18 beck Exp $ */ 1/* $OpenBSD: tls13_internal.h,v 1.37 2020/01/20 13:10:37 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
@@ -37,6 +37,8 @@ __BEGIN_HIDDEN_DECLS
37#define TLS13_IO_WANT_POLLOUT -3 37#define TLS13_IO_WANT_POLLOUT -3
38#define TLS13_IO_USE_LEGACY -4 38#define TLS13_IO_USE_LEGACY -4
39 39
40#define TLS13_ERR_VERIFY_FAILED 16
41
40typedef void (*tls13_alert_cb)(uint8_t _alert_desc, void *_cb_arg); 42typedef void (*tls13_alert_cb)(uint8_t _alert_desc, void *_cb_arg);
41typedef ssize_t (*tls13_phh_recv_cb)(void *_cb_arg, CBS *cbs); 43typedef ssize_t (*tls13_phh_recv_cb)(void *_cb_arg, CBS *cbs);
42typedef void (*tls13_phh_sent_cb)(void *_cb_arg); 44typedef void (*tls13_phh_sent_cb)(void *_cb_arg);
@@ -160,7 +162,18 @@ struct tls13_handshake_stage {
160 162
161struct ssl_handshake_tls13_st; 163struct ssl_handshake_tls13_st;
162 164
165struct tls13_error {
166 int code;
167 int subcode;
168 int errnum;
169 const char *file;
170 int line;
171 char *msg;
172};
173
163struct tls13_ctx { 174struct tls13_ctx {
175 struct tls13_error error;
176
164 SSL *ssl; 177 SSL *ssl;
165 struct ssl_handshake_tls13_st *hs; 178 struct ssl_handshake_tls13_st *hs;
166 uint8_t mode; 179 uint8_t mode;
@@ -261,6 +274,20 @@ int tls13_server_certificate_verify_recv(struct tls13_ctx *ctx);
261int tls13_server_finished_recv(struct tls13_ctx *ctx); 274int tls13_server_finished_recv(struct tls13_ctx *ctx);
262int tls13_server_finished_send(struct tls13_ctx *ctx); 275int tls13_server_finished_send(struct tls13_ctx *ctx);
263 276
277void tls13_error_clear(struct tls13_error *error);
278
279int tls13_error_set(struct tls13_error *error, int code, int subcode,
280 const char *file, int line, const char *fmt, ...);
281int tls13_error_setx(struct tls13_error *error, int code, int subcode,
282 const char *file, int line, const char *fmt, ...);
283
284#define tls13_set_error(ctx, code, subcode, fmt, ...) \
285 tls13_error_set(&(ctx)->error, (code), (subcode), __FILE__, __LINE__, \
286 (fmt), __VA_ARGS__)
287#define tls13_set_errorx(ctx, code, subcode, fmt, ...) \
288 tls13_error_setx(&(ctx)->error, (code), (subcode), __FILE__, __LINE__, \
289 (fmt), __VA_ARGS__)
290
264__END_HIDDEN_DECLS 291__END_HIDDEN_DECLS
265 292
266#endif 293#endif