-/* $OpenBSD: cert.c,v 1.122 2024/01/11 11:55:14 job Exp $ */
+/* $OpenBSD: cert.c,v 1.123 2024/02/01 15:11:38 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2021 Job Snijders <job@openbsd.org>
if ((nid = OBJ_obj2nid(qualifier->pqualid)) != NID_id_qt_cps) {
warnx("%s: RFC 7318 section 2: certificatePolicies: "
- "want CPS, got %d (%s)", p->fn, nid, OBJ_nid2sn(nid));
+ "want CPS, got %s", p->fn, nid2str(nid));
goto out;
}
warnx("%s: P-256 support is experimental", fn);
} else if (nid != NID_sha256WithRSAEncryption) {
warnx("%s: RFC 7935: wrong signature algorithm %s, want %s",
- fn, OBJ_nid2ln(nid),
- OBJ_nid2ln(NID_sha256WithRSAEncryption));
+ fn, nid2str(nid), LN_sha256WithRSAEncryption);
goto out;
}
return p.res;
dup:
- warnx("%s: RFC 5280 section 4.2: duplicate %s extension", fn,
- OBJ_nid2sn(nid));
+ warnx("%s: RFC 5280 section 4.2: duplicate extension: %s", fn,
+ nid2str(nid));
out:
cert_free(p.res);
X509_free(x);
-/* $OpenBSD: cms.c,v 1.41 2023/12/10 14:18:23 job Exp $ */
+/* $OpenBSD: cms.c,v 1.42 2024/02/01 15:11:38 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
nid = OBJ_obj2nid(obj);
if (nid != NID_sha256) {
warnx("%s: RFC 6488: wrong digest %s, want %s", fn,
- OBJ_nid2ln(nid), OBJ_nid2ln(NID_sha256));
+ nid2str(nid), LN_sha256);
goto out;
}
X509_ALGOR_get0(&obj, NULL, NULL, psig);
} else if (nid != NID_rsaEncryption &&
nid != NID_sha256WithRSAEncryption) {
warnx("%s: RFC 6488: wrong signature algorithm %s, want %s",
- fn, OBJ_nid2ln(nid), OBJ_nid2ln(NID_rsaEncryption));
+ fn, nid2str(nid), LN_rsaEncryption);
goto out;
}
-/* $OpenBSD: crl.c,v 1.31 2024/01/18 14:34:26 job Exp $ */
+/* $OpenBSD: crl.c,v 1.32 2024/02/01 15:11:38 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
warnx("%s: P-256 support is experimental", fn);
} else if (nid != NID_sha256WithRSAEncryption) {
warnx("%s: RFC 7935: wrong signature algorithm %s, want %s",
- fn, OBJ_nid2ln(nid),
- OBJ_nid2ln(NID_sha256WithRSAEncryption));
+ fn, nid2str(nid), LN_sha256WithRSAEncryption);
goto out;
}
-/* $OpenBSD: extern.h,v 1.201 2024/01/31 06:57:21 tb Exp $ */
+/* $OpenBSD: extern.h,v 1.202 2024/02/01 15:11:38 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
time_t x509_find_expires(time_t, struct auth *, struct crl_tree *);
/* printers */
+char *nid2str(int);
char *time2str(time_t);
void x509_print(const X509 *);
void tal_print(const struct tal *);
-/* $OpenBSD: print.c,v 1.45 2024/01/18 14:34:26 job Exp $ */
+/* $OpenBSD: print.c,v 1.46 2024/02/01 15:11:38 tb Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
return buf;
}
+char *
+nid2str(int nid)
+{
+ static char buf[128];
+ const char *name;
+
+ if ((name = OBJ_nid2ln(nid)) == NULL)
+ name = OBJ_nid2sn(nid);
+ if (name == NULL)
+ name = "unknown";
+
+ snprintf(buf, sizeof(buf), "nid %d (%s)", nid, name);
+
+ return buf;
+}
+
char *
time2str(time_t t)
{
-/* $OpenBSD: validate.c,v 1.70 2024/01/07 09:48:03 tb Exp $ */
+/* $OpenBSD: validate.c,v 1.71 2024/02/01 15:11:38 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
nid = EC_GROUP_get_curve_name(group);
if (nid != NID_X9_62_prime256v1) {
if ((cname = EC_curve_nid2nist(nid)) == NULL)
- cname = OBJ_nid2sn(nid);
+ cname = nid2str(nid);
warnx("%s: Expected P-256, got %s", fn, cname);
return 0;
}
-/* $OpenBSD: x509.c,v 1.76 2024/01/31 15:01:13 job Exp $ */
+/* $OpenBSD: x509.c,v 1.77 2024/02/01 15:11:38 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(eckey));
if (nid != NID_X9_62_prime256v1) {
if ((cname = EC_curve_nid2nist(nid)) == NULL)
- cname = OBJ_nid2sn(nid);
+ cname = nid2str(nid);
warnx("%s: Expected P-256, got %s", fn, cname);
goto out;
}
warnx("%s: OBJ_obj2nid failed", fn);
return 0;
default:
- warnx("%s: RFC 6487 section 4.5: unexpected attribute "
- "%d (%s)", fn, nid, OBJ_nid2ln(nid));
+ warnx("%s: RFC 6487 section 4.5: unexpected attribute"
+ " %s", fn, nid2str(nid));
return 0;
}
}