summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls_internal.h
diff options
context:
space:
mode:
authorjsing <>2018-02-10 04:57:35 +0000
committerjsing <>2018-02-10 04:57:35 +0000
commit55d7f5b4e436517c599ae10fb98d503022d8cca3 (patch)
tree220397ac4d651f9ebaa0a028f81a800a6991a0eb /src/lib/libtls/tls_internal.h
parent1ad3c784cb5a6f09eb35a87556f57f9a129ac572 (diff)
downloadopenbsd-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.h20
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,
199int tls_set_string(const char **_dest, const char *_src); 199int tls_set_string(const char **_dest, const char *_src);
200 200
201struct tls_keypair *tls_keypair_new(void); 201struct tls_keypair *tls_keypair_new(void);
202void tls_keypair_clear_key(struct tls_keypair *_keypair); 202void tls_keypair_clear(struct tls_keypair *_keypair);
203void tls_keypair_free(struct tls_keypair *_keypair);
203int tls_keypair_set_cert_file(struct tls_keypair *_keypair, 204int 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);
205int tls_keypair_set_cert_mem(struct tls_keypair *_keypair, const uint8_t *_cert, 206int 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);
207int tls_keypair_set_key_file(struct tls_keypair *_keypair, 208int 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);
209int tls_keypair_set_key_mem(struct tls_keypair *_keypair, const uint8_t *_key, 210int 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);
211int tls_keypair_set_ocsp_staple_file(struct tls_keypair *_keypair, 212int 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);
213int tls_keypair_set_ocsp_staple_mem(struct tls_keypair *_keypair, 214int 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);
215void tls_keypair_clear(struct tls_keypair *_keypair);
216void tls_keypair_free(struct tls_keypair *_keypair);
217int tls_keypair_load_cert(struct tls_keypair *_keypair, 216int tls_keypair_load_cert(struct tls_keypair *_keypair,
218 struct tls_error *_error, X509 **_cert); 217 struct tls_error *_error, X509 **_cert);
219int tls_keypair_pubkey_hash(struct tls_keypair *_keypair,
220 struct tls_error *_error, char **_hash);
221 218
222struct tls_sni_ctx *tls_sni_ctx_new(void); 219struct tls_sni_ctx *tls_sni_ctx_new(void);
223void tls_sni_ctx_free(struct tls_sni_ctx *sni_ctx); 220void 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);
281int tls_hex_string(const unsigned char *_in, size_t _inlen, char **_out, 278int tls_hex_string(const unsigned char *_in, size_t _inlen, char **_out,
282 size_t *_outlen); 279 size_t *_outlen);
283int tls_cert_hash(X509 *_cert, char **_hash); 280int tls_cert_hash(X509 *_cert, char **_hash);
281int tls_cert_pubkey_hash(X509 *_cert, char **_hash);
284 282
285int tls_password_cb(char *_buf, int _size, int _rwflag, void *_u); 283int tls_password_cb(char *_buf, int _size, int _rwflag, void *_u);
286 284