summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls.h
diff options
context:
space:
mode:
authoreric <>2022-01-25 21:51:24 +0000
committereric <>2022-01-25 21:51:24 +0000
commit5bc45eb57d3df492a992eb97f4f9efadef0b060c (patch)
treef7e1f8bcb82bc7a21b3720f212d7fbf3f1d02872 /src/lib/libtls/tls.h
parentc8578f33457bc1465ca08176ebca6e8aac53fcd3 (diff)
downloadopenbsd-5bc45eb57d3df492a992eb97f4f9efadef0b060c.tar.gz
openbsd-5bc45eb57d3df492a992eb97f4f9efadef0b060c.tar.bz2
openbsd-5bc45eb57d3df492a992eb97f4f9efadef0b060c.zip
Introduce a signer interface intented to make TLS privsep simpler
to implement. Add a tls_config_set_sign_cb() function that allows to register a callback for the signing operation on a tls_config. When used, the context installs fake pivate keys internally, and the callback receives the hash of the public key. Add a tls_signer_*() set of functions to manage tls_signer objects. A tls_signer is an opaque structure on which keys are added. It is used to compute signatures with private keys identified by their associated public key hash. Discussed with and ok jsing@ tb@
Diffstat (limited to 'src/lib/libtls/tls.h')
-rw-r--r--src/lib/libtls/tls.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/libtls/tls.h b/src/lib/libtls/tls.h
index 20f55dcabd..22f04f4023 100644
--- a/src/lib/libtls/tls.h
+++ b/src/lib/libtls/tls.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls.h,v 1.58 2020/01/22 06:44:02 beck Exp $ */ 1/* $OpenBSD: tls.h,v 1.59 2022/01/25 21:51:24 eric Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -79,6 +79,9 @@ typedef ssize_t (*tls_read_cb)(struct tls *_ctx, void *_buf, size_t _buflen,
79 void *_cb_arg); 79 void *_cb_arg);
80typedef ssize_t (*tls_write_cb)(struct tls *_ctx, const void *_buf, 80typedef ssize_t (*tls_write_cb)(struct tls *_ctx, const void *_buf,
81 size_t _buflen, void *_cb_arg); 81 size_t _buflen, void *_cb_arg);
82typedef int (*tls_sign_cb)(void *_cb_arg, const char *_hash,
83 const uint8_t *_dgst, size_t _dgstlen, uint8_t *_psig, size_t *_psiglen,
84 int _padding);
82 85
83int tls_init(void); 86int tls_init(void);
84 87
@@ -135,6 +138,8 @@ int tls_config_set_ocsp_staple_file(struct tls_config *_config,
135int tls_config_set_protocols(struct tls_config *_config, uint32_t _protocols); 138int tls_config_set_protocols(struct tls_config *_config, uint32_t _protocols);
136int tls_config_set_session_fd(struct tls_config *_config, int _session_fd); 139int tls_config_set_session_fd(struct tls_config *_config, int _session_fd);
137int tls_config_set_verify_depth(struct tls_config *_config, int _verify_depth); 140int tls_config_set_verify_depth(struct tls_config *_config, int _verify_depth);
141int tls_config_set_sign_cb(struct tls_config *_config, tls_sign_cb _cb,
142 void *_cb_arg);
138 143
139void tls_config_prefer_ciphers_client(struct tls_config *_config); 144void tls_config_prefer_ciphers_client(struct tls_config *_config);
140void tls_config_prefer_ciphers_server(struct tls_config *_config); 145void tls_config_prefer_ciphers_server(struct tls_config *_config);
@@ -212,6 +217,17 @@ time_t tls_peer_ocsp_revocation_time(struct tls *_ctx);
212time_t tls_peer_ocsp_this_update(struct tls *_ctx); 217time_t tls_peer_ocsp_this_update(struct tls *_ctx);
213const char *tls_peer_ocsp_url(struct tls *_ctx); 218const char *tls_peer_ocsp_url(struct tls *_ctx);
214 219
220struct tls_signer* tls_signer_new(void);
221void tls_signer_free(struct tls_signer * _signer);
222const char *tls_signer_error(struct tls_signer * _signer);
223int tls_signer_add_keypair_file(struct tls_signer *_signer,
224 const char *_cert_file, const char *_key_file);
225int tls_signer_add_keypair_mem(struct tls_signer *_signer, const uint8_t *_cert,
226 size_t _cert_len, const uint8_t *_key, size_t _key_len);
227int tls_signer_sign(struct tls_signer *_signer, const char *_hash,
228 const uint8_t *_dgst, size_t _dgstlen, uint8_t **_psig, size_t *_psiglen,
229 int _padding);
230
215#ifdef __cplusplus 231#ifdef __cplusplus
216} 232}
217#endif 233#endif