diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libtls/tls.c | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c index 95fdb8bc4b..fdf4a981a8 100644 --- a/src/lib/libtls/tls.c +++ b/src/lib/libtls/tls.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls.c,v 1.72 2018/02/08 08:04:12 jsing Exp $ */ | 1 | /* $OpenBSD: tls.c,v 1.73 2018/02/08 08:09:10 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -290,46 +290,6 @@ tls_cert_hash(X509 *cert, char **hash) | |||
| 290 | return (rv); | 290 | return (rv); |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | static int | ||
| 294 | tls_keypair_pubkey_hash(struct tls_keypair *keypair, char **hash) | ||
| 295 | { | ||
| 296 | BIO *membio = NULL; | ||
| 297 | X509 *cert = NULL; | ||
| 298 | char d[EVP_MAX_MD_SIZE], *dhex = NULL; | ||
| 299 | int dlen, rv = -1; | ||
| 300 | |||
| 301 | free(*hash); | ||
| 302 | *hash = NULL; | ||
| 303 | |||
| 304 | if ((membio = BIO_new_mem_buf(keypair->cert_mem, | ||
| 305 | keypair->cert_len)) == NULL) | ||
| 306 | goto err; | ||
| 307 | if ((cert = PEM_read_bio_X509_AUX(membio, NULL, tls_password_cb, | ||
| 308 | NULL)) == NULL) | ||
| 309 | goto err; | ||
| 310 | |||
| 311 | if (X509_pubkey_digest(cert, EVP_sha256(), d, &dlen) != 1) | ||
| 312 | goto err; | ||
| 313 | |||
| 314 | if (tls_hex_string(d, dlen, &dhex, NULL) != 0) | ||
| 315 | goto err; | ||
| 316 | |||
| 317 | if (asprintf(hash, "SHA256:%s", dhex) == -1) { | ||
| 318 | *hash = NULL; | ||
| 319 | goto err; | ||
| 320 | } | ||
| 321 | |||
| 322 | rv = 0; | ||
| 323 | |||
| 324 | err: | ||
| 325 | free(dhex); | ||
| 326 | X509_free(cert); | ||
| 327 | BIO_free(membio); | ||
| 328 | |||
| 329 | return (rv); | ||
| 330 | } | ||
| 331 | |||
| 332 | |||
| 333 | int | 293 | int |
| 334 | tls_configure_ssl_keypair(struct tls *ctx, SSL_CTX *ssl_ctx, | 294 | tls_configure_ssl_keypair(struct tls *ctx, SSL_CTX *ssl_ctx, |
| 335 | struct tls_keypair *keypair, int required) | 295 | struct tls_keypair *keypair, int required) |
