x509_init_oid() to initalize all necessary OID objects at start.
OK tb@
-/* $OpenBSD: cert.c,v 1.49 2021/12/26 12:32:28 tb Exp $ */
+/* $OpenBSD: cert.c,v 1.50 2022/01/18 13:06:43 claudio Exp $ */
/*
* Copyright (c) 2021 Job Snijders <job@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
const char *fn; /* currently-parsed file */
};
-static ASN1_OBJECT *carepo_oid; /* 1.3.6.1.5.5.7.48.5 (caRepository) */
-static ASN1_OBJECT *mft_oid; /* 1.3.6.1.5.5.7.48.10 (rpkiManifest) */
-static ASN1_OBJECT *notify_oid; /* 1.3.6.1.5.5.7.48.13 (rpkiNotify) */
-
-static void
-cert_init_oid(void)
-{
- if ((carepo_oid = OBJ_txt2obj("1.3.6.1.5.5.7.48.5", 1)) == NULL)
- errx(1, "OBJ_txt2obj for %s failed", "1.3.6.1.5.5.7.48.5");
- if ((mft_oid = OBJ_txt2obj("1.3.6.1.5.5.7.48.10", 1)) == NULL)
- errx(1, "OBJ_txt2obj for %s failed", "1.3.6.1.5.5.7.48.10");
- if ((notify_oid = OBJ_txt2obj("1.3.6.1.5.5.7.48.13", 1)) == NULL)
- errx(1, "OBJ_txt2obj for %s failed", "1.3.6.1.5.5.7.48.13");
-}
+extern ASN1_OBJECT *carepo_oid; /* 1.3.6.1.5.5.7.48.5 (caRepository) */
+extern ASN1_OBJECT *manifest_oid; /* 1.3.6.1.5.5.7.48.10 (rpkiManifest) */
+extern ASN1_OBJECT *notify_oid; /* 1.3.6.1.5.5.7.48.13 (rpkiNotify) */
/*
* Append an IP address structure to our list of results.
if (!ASN1_frame(p->fn, dsz, &d, &plen, &ptag))
goto out;
- if (carepo_oid == NULL)
- cert_init_oid();
-
if (OBJ_cmp(oid, carepo_oid) == 0)
rc = sbgp_sia_resource_carepo(p, d, plen);
- else if (OBJ_cmp(oid, mft_oid) == 0)
+ else if (OBJ_cmp(oid, manifest_oid) == 0)
rc = sbgp_sia_resource_mft(p, d, plen);
else if (OBJ_cmp(oid, notify_oid) == 0)
rc = sbgp_sia_resource_notify(p, d, plen);
-/* $OpenBSD: extern.h,v 1.104 2022/01/14 15:00:23 claudio Exp $ */
+/* $OpenBSD: extern.h,v 1.105 2022/01/18 13:06:43 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
/* X509 helpers. */
+void x509_init_oid(void);
char *x509_get_aia(X509 *, const char *);
char *x509_get_aki(X509 *, int, const char *);
char *x509_get_ski(X509 *, const char *);
-/* $OpenBSD: gbr.c,v 1.11 2021/10/26 10:52:50 claudio Exp $ */
+/* $OpenBSD: gbr.c,v 1.12 2022/01/18 13:06:43 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
*
struct gbr *res; /* results */
};
-static ASN1_OBJECT *gbr_oid;
+extern ASN1_OBJECT *gbr_oid;
/*
* Parse a full RFC 6493 file and signed by the certificate "cacert"
memset(&p, 0, sizeof(struct parse));
p.fn = fn;
- /* OID from section 9.1, RFC 6493. */
- if (gbr_oid == NULL) {
- gbr_oid = OBJ_txt2obj("1.2.840.113549.1.9.16.1.35", 1);
- if (gbr_oid == NULL)
- errx(1, "OBJ_txt2obj for %s failed",
- "1.2.840.113549.1.9.16.1.35");
- }
-
cms = cms_parse_validate(x509, fn, der, len, gbr_oid, &cmsz);
if (cms == NULL)
return NULL;
-/* $OpenBSD: mft.c,v 1.45 2022/01/13 13:46:03 claudio Exp $ */
+/* $OpenBSD: mft.c,v 1.46 2022/01/18 13:06:43 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
struct mft *res; /* result object */
};
-static ASN1_OBJECT *mft_oid;
+extern ASN1_OBJECT *mft_oid;
static const char *
gentime2str(const ASN1_GENERALIZEDTIME *time)
memset(&p, 0, sizeof(struct parse));
p.fn = fn;
- if (mft_oid == NULL) {
- mft_oid = OBJ_txt2obj("1.2.840.113549.1.9.16.1.26", 1);
- if (mft_oid == NULL)
- errx(1, "OBJ_txt2obj for %s failed",
- "1.2.840.113549.1.9.16.1.26");
- }
-
cms = cms_parse_validate(x509, fn, der, len, mft_oid, &cmsz);
if (cms == NULL)
return NULL;
-/* $OpenBSD: parser.c,v 1.37 2022/01/14 15:00:23 claudio Exp $ */
+/* $OpenBSD: parser.c,v 1.38 2022/01/18 13:06:43 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
ERR_load_crypto_strings();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
+ x509_init_oid();
if ((ctx = X509_STORE_CTX_new()) == NULL)
cryptoerrx("X509_STORE_CTX_new");
-/* $OpenBSD: roa.c,v 1.34 2021/12/22 08:44:15 claudio Exp $ */
+/* $OpenBSD: roa.c,v 1.35 2022/01/18 13:06:43 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
struct roa *res; /* results */
};
-static ASN1_OBJECT *roa_oid;
+extern ASN1_OBJECT *roa_oid;
/*
* Parse IP address (ROAIPAddress), RFC 6482, section 3.3.
memset(&p, 0, sizeof(struct parse));
p.fn = fn;
- /* OID from section 2, RFC 6482. */
- if (roa_oid == NULL) {
- roa_oid = OBJ_txt2obj("1.2.840.113549.1.9.16.1.24", 1);
- if (roa_oid == NULL)
- errx(1, "OBJ_txt2obj for %s failed",
- "1.2.840.113549.1.9.16.1.24");
- }
-
cms = cms_parse_validate(x509, fn, der, len, roa_oid, &cmsz);
if (cms == NULL)
return NULL;
-/* $OpenBSD: x509.c,v 1.29 2021/10/28 09:02:19 beck Exp $ */
+/* $OpenBSD: x509.c,v 1.30 2022/01/18 13:06:43 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
#include "extern.h"
-static ASN1_OBJECT *bgpsec_oid; /* id-kp-bgpsec-router */
+ASN1_OBJECT *carepo_oid; /* 1.3.6.1.5.5.7.48.5 (caRepository) */
+ASN1_OBJECT *manifest_oid; /* 1.3.6.1.5.5.7.48.10 (rpkiManifest) */
+ASN1_OBJECT *notify_oid; /* 1.3.6.1.5.5.7.48.13 (rpkiNotify) */
+ASN1_OBJECT *roa_oid; /* id-ct-routeOriginAuthz CMS content type */
+ASN1_OBJECT *mft_oid; /* id-ct-rpkiManifest CMS content type */
+ASN1_OBJECT *gbr_oid; /* id-ct-rpkiGhostbusters CMS content type */
+ASN1_OBJECT *bgpsec_oid; /* id-kp-bgpsec-router Key Purpose */
-static void
-init_oid(void)
+
+void
+x509_init_oid(void)
{
+
+ if ((carepo_oid = OBJ_txt2obj("1.3.6.1.5.5.7.48.5", 1)) == NULL)
+ errx(1, "OBJ_txt2obj for %s failed", "1.3.6.1.5.5.7.48.5");
+ if ((manifest_oid = OBJ_txt2obj("1.3.6.1.5.5.7.48.10", 1)) == NULL)
+ errx(1, "OBJ_txt2obj for %s failed", "1.3.6.1.5.5.7.48.10");
+ if ((notify_oid = OBJ_txt2obj("1.3.6.1.5.5.7.48.13", 1)) == NULL)
+ errx(1, "OBJ_txt2obj for %s failed", "1.3.6.1.5.5.7.48.13");
+ if ((roa_oid = OBJ_txt2obj("1.2.840.113549.1.9.16.1.24", 1)) == NULL)
+ errx(1, "OBJ_txt2obj for %s failed",
+ "1.2.840.113549.1.9.16.1.24");
+ if ((mft_oid = OBJ_txt2obj("1.2.840.113549.1.9.16.1.26", 1)) == NULL)
+ errx(1, "OBJ_txt2obj for %s failed",
+ "1.2.840.113549.1.9.16.1.26");
+ if ((gbr_oid = OBJ_txt2obj("1.2.840.113549.1.9.16.1.35", 1)) == NULL)
+ errx(1, "OBJ_txt2obj for %s failed",
+ "1.2.840.113549.1.9.16.1.35");
if ((bgpsec_oid = OBJ_txt2obj("1.3.6.1.5.5.7.3.30", 1)) == NULL)
errx(1, "OBJ_txt2obj for %s failed", "1.3.6.1.5.5.7.3.30");
}
goto out;
}
- if (bgpsec_oid == NULL)
- init_oid();
-
if (OBJ_cmp(bgpsec_oid, sk_ASN1_OBJECT_value(eku, 0)) == 0) {
purpose = CERT_PURPOSE_BGPSEC_ROUTER;
goto out;