summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2021-12-12 20:34:04 +0000
committertb <>2021-12-12 20:34:04 +0000
commit3f19462ef9f7b14cbdfe731cbd045f86e3e05b24 (patch)
treecf1e6711ef119149af6d753c4f04418e48290d57 /src
parent5b598f42c0c982dd743e932a1f79bd651cd6fda8 (diff)
downloadopenbsd-3f19462ef9f7b14cbdfe731cbd045f86e3e05b24.tar.gz
openbsd-3f19462ef9f7b14cbdfe731cbd045f86e3e05b24.tar.bz2
openbsd-3f19462ef9f7b14cbdfe731cbd045f86e3e05b24.zip
A few more simplifications using get0_pubkey instead of get_pubkey + free.
Diffstat (limited to 'src')
-rw-r--r--src/usr.bin/openssl/x509.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/usr.bin/openssl/x509.c b/src/usr.bin/openssl/x509.c
index 5248c67886..c777ee9b74 100644
--- a/src/usr.bin/openssl/x509.c
+++ b/src/usr.bin/openssl/x509.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509.c,v 1.28 2021/12/12 20:29:15 tb Exp $ */ 1/* $OpenBSD: x509.c,v 1.29 2021/12/12 20:34:04 tb 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 *
@@ -846,12 +846,11 @@ x509_main(int argc, char **argv)
846 ERR_print_errors(bio_err); 846 ERR_print_errors(bio_err);
847 goto end; 847 goto end;
848 } 848 }
849 if ((pkey = X509_REQ_get_pubkey(req)) == NULL) { 849 if ((pkey = X509_REQ_get0_pubkey(req)) == NULL) {
850 BIO_printf(bio_err, "error unpacking public key\n"); 850 BIO_printf(bio_err, "error unpacking public key\n");
851 goto end; 851 goto end;
852 } 852 }
853 i = X509_REQ_verify(req, pkey); 853 i = X509_REQ_verify(req, pkey);
854 EVP_PKEY_free(pkey);
855 if (i < 0) { 854 if (i < 0) {
856 BIO_printf(bio_err, "Signature verification error\n"); 855 BIO_printf(bio_err, "Signature verification error\n");
857 ERR_print_errors(bio_err); 856 ERR_print_errors(bio_err);
@@ -893,13 +892,12 @@ x509_main(int argc, char **argv)
893 NULL) == NULL) 892 NULL) == NULL)
894 goto end; 893 goto end;
895 894
896 if ((pkey = X509_REQ_get_pubkey(req)) == NULL) 895 if ((pkey = X509_REQ_get0_pubkey(req)) == NULL)
897 goto end; 896 goto end;
898 if (!X509_set_pubkey(x, pkey)) { 897 if (!X509_set_pubkey(x, pkey)) {
899 EVP_PKEY_free(pkey); 898 EVP_PKEY_free(pkey);
900 goto end; 899 goto end;
901 } 900 }
902 EVP_PKEY_free(pkey);
903 } else { 901 } else {
904 x = load_cert(bio_err, x509_config.infile, x509_config.informat, 902 x = load_cert(bio_err, x509_config.infile, x509_config.informat,
905 NULL, "Certificate"); 903 NULL, "Certificate");
@@ -1392,11 +1390,10 @@ x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, X509 *x,
1392 X509_STORE_CTX *xsc = NULL; 1390 X509_STORE_CTX *xsc = NULL;
1393 EVP_PKEY *upkey; 1391 EVP_PKEY *upkey;
1394 1392
1395 upkey = X509_get_pubkey(xca); 1393 upkey = X509_get0_pubkey(xca);
1396 if (upkey == NULL) 1394 if (upkey == NULL)
1397 goto end; 1395 goto end;
1398 EVP_PKEY_copy_parameters(upkey, pkey); 1396 EVP_PKEY_copy_parameters(upkey, pkey);
1399 EVP_PKEY_free(upkey);
1400 1397
1401 if ((xsc = X509_STORE_CTX_new()) == NULL) 1398 if ((xsc = X509_STORE_CTX_new()) == NULL)
1402 goto end; 1399 goto end;
@@ -1507,12 +1504,11 @@ sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest,
1507{ 1504{
1508 EVP_PKEY *pktmp; 1505 EVP_PKEY *pktmp;
1509 1506
1510 pktmp = X509_get_pubkey(x); 1507 pktmp = X509_get0_pubkey(x);
1511 if (pktmp == NULL) 1508 if (pktmp == NULL)
1512 goto err; 1509 goto err;
1513 EVP_PKEY_copy_parameters(pktmp, pkey); 1510 EVP_PKEY_copy_parameters(pktmp, pkey);
1514 EVP_PKEY_save_parameters(pktmp, 1); 1511 EVP_PKEY_save_parameters(pktmp, 1);
1515 EVP_PKEY_free(pktmp);
1516 1512
1517 if (!X509_set_issuer_name(x, X509_get_subject_name(x))) 1513 if (!X509_set_issuer_name(x, X509_get_subject_name(x)))
1518 goto err; 1514 goto err;