summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2021-06-27 19:16:59 +0000
committerjsing <>2021-06-27 19:16:59 +0000
commitfe2e9ea28e886fa3dae7e2d6035a86fae494be20 (patch)
tree824ba9a04d617f76b5150c7a989186b84311ebc7 /src
parentb109677d03c0eb1062f19ab300b485b90c0c2ad7 (diff)
downloadopenbsd-fe2e9ea28e886fa3dae7e2d6035a86fae494be20.tar.gz
openbsd-fe2e9ea28e886fa3dae7e2d6035a86fae494be20.tar.bz2
openbsd-fe2e9ea28e886fa3dae7e2d6035a86fae494be20.zip
Have ssl3_send_client_verify() pass *pkey to called functions.
ssl3_send_client_verify() already has a pointer to the EVP_PKEY for the certificate - pass this as an argument to the functions that it calls, rather than duplicating code/variable declarations.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/ssl_clnt.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/lib/libssl/ssl_clnt.c b/src/lib/libssl/ssl_clnt.c
index fac30b26aa..261bf426cc 100644
--- a/src/lib/libssl/ssl_clnt.c
+++ b/src/lib/libssl/ssl_clnt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_clnt.c,v 1.101 2021/06/27 18:15:35 jsing Exp $ */ 1/* $OpenBSD: ssl_clnt.c,v 1.102 2021/06/27 19:16:59 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -2338,12 +2338,11 @@ ssl3_send_client_key_exchange(SSL *s)
2338} 2338}
2339 2339
2340static int 2340static int
2341ssl3_send_client_verify_sigalgs(SSL *s, CBB *cert_verify) 2341ssl3_send_client_verify_sigalgs(SSL *s, EVP_PKEY *pkey, CBB *cert_verify)
2342{ 2342{
2343 const struct ssl_sigalg *sigalg; 2343 const struct ssl_sigalg *sigalg;
2344 CBB cbb_signature; 2344 CBB cbb_signature;
2345 EVP_PKEY_CTX *pctx = NULL; 2345 EVP_PKEY_CTX *pctx = NULL;
2346 EVP_PKEY *pkey;
2347 EVP_MD_CTX mctx; 2346 EVP_MD_CTX mctx;
2348 const EVP_MD *md; 2347 const EVP_MD *md;
2349 const unsigned char *hdata; 2348 const unsigned char *hdata;
@@ -2353,7 +2352,6 @@ ssl3_send_client_verify_sigalgs(SSL *s, CBB *cert_verify)
2353 2352
2354 EVP_MD_CTX_init(&mctx); 2353 EVP_MD_CTX_init(&mctx);
2355 2354
2356 pkey = s->cert->key->privatekey;
2357 if ((sigalg = ssl_sigalg_select(s, pkey)) == NULL) { 2355 if ((sigalg = ssl_sigalg_select(s, pkey)) == NULL) {
2358 SSLerror(s, SSL_R_SIGNATURE_ALGORITHMS_ERROR); 2356 SSLerror(s, SSL_R_SIGNATURE_ALGORITHMS_ERROR);
2359 goto err; 2357 goto err;
@@ -2419,18 +2417,15 @@ ssl3_send_client_verify_sigalgs(SSL *s, CBB *cert_verify)
2419} 2417}
2420 2418
2421static int 2419static int
2422ssl3_send_client_verify_rsa(SSL *s, CBB *cert_verify) 2420ssl3_send_client_verify_rsa(SSL *s, EVP_PKEY *pkey, CBB *cert_verify)
2423{ 2421{
2424 CBB cbb_signature; 2422 CBB cbb_signature;
2425 EVP_PKEY *pkey;
2426 unsigned char data[EVP_MAX_MD_SIZE]; 2423 unsigned char data[EVP_MAX_MD_SIZE];
2427 unsigned char *signature = NULL; 2424 unsigned char *signature = NULL;
2428 unsigned int signature_len; 2425 unsigned int signature_len;
2429 size_t data_len; 2426 size_t data_len;
2430 int ret = 0; 2427 int ret = 0;
2431 2428
2432 pkey = s->cert->key->privatekey;
2433
2434 if (!tls1_transcript_hash_value(s, data, sizeof(data), &data_len)) 2429 if (!tls1_transcript_hash_value(s, data, sizeof(data), &data_len))
2435 goto err; 2430 goto err;
2436 if ((signature = calloc(1, EVP_PKEY_size(pkey))) == NULL) 2431 if ((signature = calloc(1, EVP_PKEY_size(pkey))) == NULL)
@@ -2455,17 +2450,14 @@ ssl3_send_client_verify_rsa(SSL *s, CBB *cert_verify)
2455} 2450}
2456 2451
2457static int 2452static int
2458ssl3_send_client_verify_ec(SSL *s, CBB *cert_verify) 2453ssl3_send_client_verify_ec(SSL *s, EVP_PKEY *pkey, CBB *cert_verify)
2459{ 2454{
2460 CBB cbb_signature; 2455 CBB cbb_signature;
2461 EVP_PKEY *pkey;
2462 unsigned char data[EVP_MAX_MD_SIZE]; 2456 unsigned char data[EVP_MAX_MD_SIZE];
2463 unsigned char *signature = NULL; 2457 unsigned char *signature = NULL;
2464 unsigned int signature_len; 2458 unsigned int signature_len;
2465 int ret = 0; 2459 int ret = 0;
2466 2460
2467 pkey = s->cert->key->privatekey;
2468
2469 if (!tls1_transcript_hash_value(s, data, sizeof(data), NULL)) 2461 if (!tls1_transcript_hash_value(s, data, sizeof(data), NULL))
2470 goto err; 2462 goto err;
2471 if ((signature = calloc(1, EVP_PKEY_size(pkey))) == NULL) 2463 if ((signature = calloc(1, EVP_PKEY_size(pkey))) == NULL)
@@ -2491,12 +2483,11 @@ ssl3_send_client_verify_ec(SSL *s, CBB *cert_verify)
2491 2483
2492#ifndef OPENSSL_NO_GOST 2484#ifndef OPENSSL_NO_GOST
2493static int 2485static int
2494ssl3_send_client_verify_gost(SSL *s, CBB *cert_verify) 2486ssl3_send_client_verify_gost(SSL *s, EVP_PKEY *pkey, CBB *cert_verify)
2495{ 2487{
2496 CBB cbb_signature; 2488 CBB cbb_signature;
2497 EVP_MD_CTX mctx; 2489 EVP_MD_CTX mctx;
2498 EVP_PKEY_CTX *pctx; 2490 EVP_PKEY_CTX *pctx;
2499 EVP_PKEY *pkey;
2500 const EVP_MD *md; 2491 const EVP_MD *md;
2501 const unsigned char *hdata; 2492 const unsigned char *hdata;
2502 unsigned char *signature = NULL; 2493 unsigned char *signature = NULL;
@@ -2507,8 +2498,6 @@ ssl3_send_client_verify_gost(SSL *s, CBB *cert_verify)
2507 2498
2508 EVP_MD_CTX_init(&mctx); 2499 EVP_MD_CTX_init(&mctx);
2509 2500
2510 pkey = s->cert->key->privatekey;
2511
2512 if (!tls1_transcript_data(s, &hdata, &hdata_len)) { 2501 if (!tls1_transcript_data(s, &hdata, &hdata_len)) {
2513 SSLerror(s, ERR_R_INTERNAL_ERROR); 2502 SSLerror(s, ERR_R_INTERNAL_ERROR);
2514 goto err; 2503 goto err;
@@ -2576,22 +2565,22 @@ ssl3_send_client_verify(SSL *s)
2576 pkey = s->cert->key->privatekey; 2565 pkey = s->cert->key->privatekey;
2577 2566
2578 /* 2567 /*
2579 * For TLS v1.2 send signature algorithm and signature 2568 * For TLS v1.2 send signature algorithm and signature using
2580 * using agreed digest and cached handshake records. 2569 * agreed digest and cached handshake records.
2581 */ 2570 */
2582 if (SSL_USE_SIGALGS(s)) { 2571 if (SSL_USE_SIGALGS(s)) {
2583 if (!ssl3_send_client_verify_sigalgs(s, &cert_verify)) 2572 if (!ssl3_send_client_verify_sigalgs(s, pkey, &cert_verify))
2584 goto err; 2573 goto err;
2585 } else if (pkey->type == EVP_PKEY_RSA) { 2574 } else if (pkey->type == EVP_PKEY_RSA) {
2586 if (!ssl3_send_client_verify_rsa(s, &cert_verify)) 2575 if (!ssl3_send_client_verify_rsa(s, pkey, &cert_verify))
2587 goto err; 2576 goto err;
2588 } else if (pkey->type == EVP_PKEY_EC) { 2577 } else if (pkey->type == EVP_PKEY_EC) {
2589 if (!ssl3_send_client_verify_ec(s, &cert_verify)) 2578 if (!ssl3_send_client_verify_ec(s, pkey, &cert_verify))
2590 goto err; 2579 goto err;
2591#ifndef OPENSSL_NO_GOST 2580#ifndef OPENSSL_NO_GOST
2592 } else if (pkey->type == NID_id_GostR3410_94 || 2581 } else if (pkey->type == NID_id_GostR3410_94 ||
2593 pkey->type == NID_id_GostR3410_2001) { 2582 pkey->type == NID_id_GostR3410_2001) {
2594 if (!ssl3_send_client_verify_gost(s, &cert_verify)) 2583 if (!ssl3_send_client_verify_gost(s, pkey, &cert_verify))
2595 goto err; 2584 goto err;
2596#endif 2585#endif
2597 } else { 2586 } else {