diff options
author | jsing <> | 2018-02-10 04:57:35 +0000 |
---|---|---|
committer | jsing <> | 2018-02-10 04:57:35 +0000 |
commit | 55d7f5b4e436517c599ae10fb98d503022d8cca3 (patch) | |
tree | 220397ac4d651f9ebaa0a028f81a800a6991a0eb /src/lib/libtls/tls_internal.h | |
parent | 1ad3c784cb5a6f09eb35a87556f57f9a129ac572 (diff) | |
download | openbsd-55d7f5b4e436517c599ae10fb98d503022d8cca3.tar.gz openbsd-55d7f5b4e436517c599ae10fb98d503022d8cca3.tar.bz2 openbsd-55d7f5b4e436517c599ae10fb98d503022d8cca3.zip |
Move the keypair pubkey hash handling code to during config.
The keypair pubkey hash was being generated and set in the keypair when the
TLS context was being configured. This code should not be messing around
with the keypair contents, since it is part of the config (and not the
context).
Instead, generate the pubkey hash and store it in the keypair when the
certificate is configured. This means that we are guaranteed to have the
pubkey hash and as a side benefit, we identify bad certificate content
when it is provided, instead of during the context configuration.
ok beck@
Diffstat (limited to 'src/lib/libtls/tls_internal.h')
-rw-r--r-- | src/lib/libtls/tls_internal.h | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/lib/libtls/tls_internal.h b/src/lib/libtls/tls_internal.h index 14265037eb..f8b9e6118e 100644 --- a/src/lib/libtls/tls_internal.h +++ b/src/lib/libtls/tls_internal.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls_internal.h,v 1.69 2018/02/10 04:41:24 jsing Exp $ */ | 1 | /* $OpenBSD: tls_internal.h,v 1.70 2018/02/10 04:57:35 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> | 3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> |
4 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 4 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
@@ -199,25 +199,22 @@ int tls_set_mem(char **_dest, size_t *_destlen, const void *_src, | |||
199 | int tls_set_string(const char **_dest, const char *_src); | 199 | int tls_set_string(const char **_dest, const char *_src); |
200 | 200 | ||
201 | struct tls_keypair *tls_keypair_new(void); | 201 | struct tls_keypair *tls_keypair_new(void); |
202 | void tls_keypair_clear_key(struct tls_keypair *_keypair); | 202 | void tls_keypair_clear(struct tls_keypair *_keypair); |
203 | void tls_keypair_free(struct tls_keypair *_keypair); | ||
203 | int tls_keypair_set_cert_file(struct tls_keypair *_keypair, | 204 | int tls_keypair_set_cert_file(struct tls_keypair *_keypair, |
204 | struct tls_error *_error, const char *_cert_file); | 205 | struct tls_error *_error, const char *_cert_file); |
205 | int tls_keypair_set_cert_mem(struct tls_keypair *_keypair, const uint8_t *_cert, | 206 | int tls_keypair_set_cert_mem(struct tls_keypair *_keypair, |
206 | size_t _len); | 207 | struct tls_error *_error, const uint8_t *_cert, size_t _len); |
207 | int tls_keypair_set_key_file(struct tls_keypair *_keypair, | 208 | int tls_keypair_set_key_file(struct tls_keypair *_keypair, |
208 | struct tls_error *_error, const char *_key_file); | 209 | struct tls_error *_error, const char *_key_file); |
209 | int tls_keypair_set_key_mem(struct tls_keypair *_keypair, const uint8_t *_key, | 210 | int tls_keypair_set_key_mem(struct tls_keypair *_keypair, |
210 | size_t _len); | 211 | struct tls_error *_error, const uint8_t *_key, size_t _len); |
211 | int tls_keypair_set_ocsp_staple_file(struct tls_keypair *_keypair, | 212 | int tls_keypair_set_ocsp_staple_file(struct tls_keypair *_keypair, |
212 | struct tls_error *_error, const char *_ocsp_file); | 213 | struct tls_error *_error, const char *_ocsp_file); |
213 | int tls_keypair_set_ocsp_staple_mem(struct tls_keypair *_keypair, | 214 | int tls_keypair_set_ocsp_staple_mem(struct tls_keypair *_keypair, |
214 | const uint8_t *_staple, size_t _len); | 215 | struct tls_error *_error, const uint8_t *_staple, size_t _len); |
215 | void tls_keypair_clear(struct tls_keypair *_keypair); | ||
216 | void tls_keypair_free(struct tls_keypair *_keypair); | ||
217 | int tls_keypair_load_cert(struct tls_keypair *_keypair, | 216 | int tls_keypair_load_cert(struct tls_keypair *_keypair, |
218 | struct tls_error *_error, X509 **_cert); | 217 | struct tls_error *_error, X509 **_cert); |
219 | int tls_keypair_pubkey_hash(struct tls_keypair *_keypair, | ||
220 | struct tls_error *_error, char **_hash); | ||
221 | 218 | ||
222 | struct tls_sni_ctx *tls_sni_ctx_new(void); | 219 | struct tls_sni_ctx *tls_sni_ctx_new(void); |
223 | void tls_sni_ctx_free(struct tls_sni_ctx *sni_ctx); | 220 | void tls_sni_ctx_free(struct tls_sni_ctx *sni_ctx); |
@@ -281,6 +278,7 @@ struct tls_ocsp *tls_ocsp_setup_from_peer(struct tls *ctx); | |||
281 | int tls_hex_string(const unsigned char *_in, size_t _inlen, char **_out, | 278 | int tls_hex_string(const unsigned char *_in, size_t _inlen, char **_out, |
282 | size_t *_outlen); | 279 | size_t *_outlen); |
283 | int tls_cert_hash(X509 *_cert, char **_hash); | 280 | int tls_cert_hash(X509 *_cert, char **_hash); |
281 | int tls_cert_pubkey_hash(X509 *_cert, char **_hash); | ||
284 | 282 | ||
285 | int tls_password_cb(char *_buf, int _size, int _rwflag, void *_u); | 283 | int tls_password_cb(char *_buf, int _size, int _rwflag, void *_u); |
286 | 284 | ||