diff options
author | eric <> | 2022-01-25 21:51:24 +0000 |
---|---|---|
committer | eric <> | 2022-01-25 21:51:24 +0000 |
commit | 5bc45eb57d3df492a992eb97f4f9efadef0b060c (patch) | |
tree | f7e1f8bcb82bc7a21b3720f212d7fbf3f1d02872 /src/lib/libtls/tls.h | |
parent | c8578f33457bc1465ca08176ebca6e8aac53fcd3 (diff) | |
download | openbsd-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.h | 18 |
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); |
80 | typedef ssize_t (*tls_write_cb)(struct tls *_ctx, const void *_buf, | 80 | typedef 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); |
82 | typedef 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 | ||
83 | int tls_init(void); | 86 | int tls_init(void); |
84 | 87 | ||
@@ -135,6 +138,8 @@ int tls_config_set_ocsp_staple_file(struct tls_config *_config, | |||
135 | int tls_config_set_protocols(struct tls_config *_config, uint32_t _protocols); | 138 | int tls_config_set_protocols(struct tls_config *_config, uint32_t _protocols); |
136 | int tls_config_set_session_fd(struct tls_config *_config, int _session_fd); | 139 | int tls_config_set_session_fd(struct tls_config *_config, int _session_fd); |
137 | int tls_config_set_verify_depth(struct tls_config *_config, int _verify_depth); | 140 | int tls_config_set_verify_depth(struct tls_config *_config, int _verify_depth); |
141 | int tls_config_set_sign_cb(struct tls_config *_config, tls_sign_cb _cb, | ||
142 | void *_cb_arg); | ||
138 | 143 | ||
139 | void tls_config_prefer_ciphers_client(struct tls_config *_config); | 144 | void tls_config_prefer_ciphers_client(struct tls_config *_config); |
140 | void tls_config_prefer_ciphers_server(struct tls_config *_config); | 145 | void tls_config_prefer_ciphers_server(struct tls_config *_config); |
@@ -212,6 +217,17 @@ time_t tls_peer_ocsp_revocation_time(struct tls *_ctx); | |||
212 | time_t tls_peer_ocsp_this_update(struct tls *_ctx); | 217 | time_t tls_peer_ocsp_this_update(struct tls *_ctx); |
213 | const char *tls_peer_ocsp_url(struct tls *_ctx); | 218 | const char *tls_peer_ocsp_url(struct tls *_ctx); |
214 | 219 | ||
220 | struct tls_signer* tls_signer_new(void); | ||
221 | void tls_signer_free(struct tls_signer * _signer); | ||
222 | const char *tls_signer_error(struct tls_signer * _signer); | ||
223 | int tls_signer_add_keypair_file(struct tls_signer *_signer, | ||
224 | const char *_cert_file, const char *_key_file); | ||
225 | int 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); | ||
227 | int 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 |