diff options
author | tb <> | 2024-05-27 16:11:16 +0000 |
---|---|---|
committer | tb <> | 2024-05-27 16:11:16 +0000 |
commit | 912c6385e2bea73681bdd41aed095d1a80a13cd3 (patch) | |
tree | 2d4692b0c4687249a96e6b0a0fd80856ca5bc8d6 | |
parent | 8d78f6625f014d794fde6e4b4190bb6d7c2410f0 (diff) | |
download | openbsd-912c6385e2bea73681bdd41aed095d1a80a13cd3.tar.gz openbsd-912c6385e2bea73681bdd41aed095d1a80a13cd3.tar.bz2 openbsd-912c6385e2bea73681bdd41aed095d1a80a13cd3.zip |
openssl: avoid shadowed pkeys in x509.c
ok job jsing
-rw-r--r-- | src/usr.bin/openssl/x509.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/usr.bin/openssl/x509.c b/src/usr.bin/openssl/x509.c index 0d5cf5d033..5f27b3ae6f 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.37 2024/01/26 11:58:37 job Exp $ */ | 1 | /* $OpenBSD: x509.c,v 1.38 2024/05/27 16:11:16 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 | * |
@@ -1142,24 +1142,23 @@ x509_main(int argc, char **argv) | |||
1142 | purpose_print(STDout, x, ptmp); | 1142 | purpose_print(STDout, x, ptmp); |
1143 | } | 1143 | } |
1144 | } else if (cfg.modulus == i) { | 1144 | } else if (cfg.modulus == i) { |
1145 | EVP_PKEY *pkey; | 1145 | EVP_PKEY *pubkey; |
1146 | 1146 | ||
1147 | pkey = X509_get0_pubkey(x); | 1147 | if ((pubkey = X509_get0_pubkey(x)) == NULL) { |
1148 | if (pkey == NULL) { | ||
1149 | BIO_printf(bio_err, | 1148 | BIO_printf(bio_err, |
1150 | "Modulus=unavailable\n"); | 1149 | "Modulus=unavailable\n"); |
1151 | ERR_print_errors(bio_err); | 1150 | ERR_print_errors(bio_err); |
1152 | goto end; | 1151 | goto end; |
1153 | } | 1152 | } |
1154 | BIO_printf(STDout, "Modulus="); | 1153 | BIO_printf(STDout, "Modulus="); |
1155 | if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA) { | 1154 | if (EVP_PKEY_id(pubkey) == EVP_PKEY_RSA) { |
1156 | RSA *rsa = EVP_PKEY_get0_RSA(pkey); | 1155 | RSA *rsa = EVP_PKEY_get0_RSA(pubkey); |
1157 | const BIGNUM *n = NULL; | 1156 | const BIGNUM *n = NULL; |
1158 | 1157 | ||
1159 | RSA_get0_key(rsa, &n, NULL, NULL); | 1158 | RSA_get0_key(rsa, &n, NULL, NULL); |
1160 | BN_print(STDout, n); | 1159 | BN_print(STDout, n); |
1161 | } else if (EVP_PKEY_id(pkey) == EVP_PKEY_DSA) { | 1160 | } else if (EVP_PKEY_id(pubkey) == EVP_PKEY_DSA) { |
1162 | DSA *dsa = EVP_PKEY_get0_DSA(pkey); | 1161 | DSA *dsa = EVP_PKEY_get0_DSA(pubkey); |
1163 | const BIGNUM *pub_key = NULL; | 1162 | const BIGNUM *pub_key = NULL; |
1164 | 1163 | ||
1165 | DSA_get0_key(dsa, &pub_key, NULL); | 1164 | DSA_get0_key(dsa, &pub_key, NULL); |
@@ -1170,16 +1169,15 @@ x509_main(int argc, char **argv) | |||
1170 | "Wrong Algorithm type"); | 1169 | "Wrong Algorithm type"); |
1171 | BIO_printf(STDout, "\n"); | 1170 | BIO_printf(STDout, "\n"); |
1172 | } else if (cfg.pubkey == i) { | 1171 | } else if (cfg.pubkey == i) { |
1173 | EVP_PKEY *pkey; | 1172 | EVP_PKEY *pubkey; |
1174 | 1173 | ||
1175 | pkey = X509_get0_pubkey(x); | 1174 | if ((pubkey = X509_get0_pubkey(x)) == NULL) { |
1176 | if (pkey == NULL) { | ||
1177 | BIO_printf(bio_err, | 1175 | BIO_printf(bio_err, |
1178 | "Error getting public key\n"); | 1176 | "Error getting public key\n"); |
1179 | ERR_print_errors(bio_err); | 1177 | ERR_print_errors(bio_err); |
1180 | goto end; | 1178 | goto end; |
1181 | } | 1179 | } |
1182 | PEM_write_bio_PUBKEY(STDout, pkey); | 1180 | PEM_write_bio_PUBKEY(STDout, pubkey); |
1183 | } else if (cfg.C == i) { | 1181 | } else if (cfg.C == i) { |
1184 | unsigned char *d; | 1182 | unsigned char *d; |
1185 | char *m; | 1183 | char *m; |