-/* $OpenBSD: x509type.c,v 1.23 2023/11/13 15:44:15 tb Exp $ */
+/* $OpenBSD: x509type.c,v 1.24 2023/11/13 16:16:14 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
int ret = 0;
if (x == NULL)
- return (0);
+ goto done;
- if (pk == NULL) {
- if ((pk = X509_get0_pubkey(x)) == NULL)
- return (0);
- }
+ if (pk == NULL)
+ pk = X509_get0_pubkey(x);
+ if (pk == NULL)
+ goto done;
switch (pk->type) {
case EVP_PKEY_RSA:
break;
}
- nid = X509_get_signature_nid(x);
- if (nid && OBJ_find_sigid_algs(nid, NULL, &nid)) {
- switch (nid) {
- case NID_rsaEncryption:
- case NID_rsa:
- ret |= EVP_PKS_RSA;
- break;
- case NID_dsa:
- case NID_dsa_2:
- ret |= EVP_PKS_DSA;
- break;
- case NID_X9_62_id_ecPublicKey:
- ret |= EVP_PKS_EC;
- break;
- default:
- break;
- }
+ if ((nid = X509_get_signature_nid(x)) == NID_undef)
+ goto done;
+
+ if (!OBJ_find_sigid_algs(nid, NULL, &nid))
+ goto done;
+
+ switch (nid) {
+ case NID_rsaEncryption:
+ case NID_rsa:
+ ret |= EVP_PKS_RSA;
+ break;
+ case NID_dsa:
+ case NID_dsa_2:
+ ret |= EVP_PKS_DSA;
+ break;
+ case NID_X9_62_id_ecPublicKey:
+ ret |= EVP_PKS_EC;
+ break;
+ default:
+ break;
}
- return (ret);
+ done:
+
+ return ret;
}
LCRYPTO_ALIAS(X509_certificate_type);