-/* $OpenBSD: aspa.c,v 1.22 2023/07/10 12:02:37 job Exp $ */
+/* $OpenBSD: aspa.c,v 1.23 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2022 Job Snijders <job@fastly.com>
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Returns the payload or NULL if the file was malformed.
*/
struct aspa *
-aspa_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
+aspa_parse(X509 **x509, const char *fn, int talid, const unsigned char *der,
+ size_t len)
{
struct parse p;
size_t cmsz;
-/* $OpenBSD: extern.h,v 1.190 2023/09/25 08:48:14 job Exp $ */
+/* $OpenBSD: extern.h,v 1.191 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
enum rtype rtype_from_file_extension(const char *);
void mft_buffer(struct ibuf *, const struct mft *);
void mft_free(struct mft *);
-struct mft *mft_parse(X509 **, const char *, const unsigned char *,
+struct mft *mft_parse(X509 **, const char *, int, const unsigned char *,
size_t);
struct mft *mft_read(struct ibuf *);
int mft_compare(const struct mft *, const struct mft *);
void roa_buffer(struct ibuf *, const struct roa *);
void roa_free(struct roa *);
-struct roa *roa_parse(X509 **, const char *, const unsigned char *,
+struct roa *roa_parse(X509 **, const char *, int, const unsigned char *,
size_t);
struct roa *roa_read(struct ibuf *);
void roa_insert_vrps(struct vrp_tree *, struct roa *,
struct repo *);
void gbr_free(struct gbr *);
-struct gbr *gbr_parse(X509 **, const char *, const unsigned char *,
+struct gbr *gbr_parse(X509 **, const char *, int, const unsigned char *,
size_t);
void geofeed_free(struct geofeed *);
-struct geofeed *geofeed_parse(X509 **, const char *, char *, size_t);
+struct geofeed *geofeed_parse(X509 **, const char *, int, char *, size_t);
void rsc_free(struct rsc *);
-struct rsc *rsc_parse(X509 **, const char *, const unsigned char *,
+struct rsc *rsc_parse(X509 **, const char *, int, const unsigned char *,
size_t);
void takey_free(struct takey *);
void tak_free(struct tak *);
-struct tak *tak_parse(X509 **, const char *, const unsigned char *,
+struct tak *tak_parse(X509 **, const char *, int, const unsigned char *,
size_t);
struct tak *tak_read(struct ibuf *);
void aspa_free(struct aspa *);
void aspa_insert_vaps(struct vap_tree *, struct aspa *,
struct repo *);
-struct aspa *aspa_parse(X509 **, const char *, const unsigned char *,
+struct aspa *aspa_parse(X509 **, const char *, int, const unsigned char *,
size_t);
struct aspa *aspa_read(struct ibuf *);
-/* $OpenBSD: filemode.c,v 1.34 2023/06/29 10:28:25 tb Exp $ */
+/* $OpenBSD: filemode.c,v 1.35 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
switch (type) {
case RTYPE_ASPA:
- aspa = aspa_parse(&x509, file, buf, len);
+ aspa = aspa_parse(&x509, file, -1, buf, len);
if (aspa == NULL)
break;
aia = aspa->aia;
crl_print(crl);
break;
case RTYPE_MFT:
- mft = mft_parse(&x509, file, buf, len);
+ mft = mft_parse(&x509, file, -1, buf, len);
if (mft == NULL)
break;
aia = mft->aia;
notafter = &mft->nextupdate;
break;
case RTYPE_GBR:
- gbr = gbr_parse(&x509, file, buf, len);
+ gbr = gbr_parse(&x509, file, -1, buf, len);
if (gbr == NULL)
break;
aia = gbr->aia;
notafter = &gbr->notafter;
break;
case RTYPE_GEOFEED:
- geofeed = geofeed_parse(&x509, file, buf, len);
+ geofeed = geofeed_parse(&x509, file, -1, buf, len);
if (geofeed == NULL)
break;
aia = geofeed->aia;
notafter = &geofeed->notafter;
break;
case RTYPE_ROA:
- roa = roa_parse(&x509, file, buf, len);
+ roa = roa_parse(&x509, file, -1, buf, len);
if (roa == NULL)
break;
aia = roa->aia;
notafter = &roa->notafter;
break;
case RTYPE_RSC:
- rsc = rsc_parse(&x509, file, buf, len);
+ rsc = rsc_parse(&x509, file, -1, buf, len);
if (rsc == NULL)
break;
aia = rsc->aia;
notafter = &rsc->notafter;
break;
case RTYPE_TAK:
- tak = tak_parse(&x509, file, buf, len);
+ tak = tak_parse(&x509, file, -1, buf, len);
if (tak == NULL)
break;
aia = tak->aia;
-/* $OpenBSD: gbr.c,v 1.27 2023/06/20 12:39:50 job Exp $ */
+/* $OpenBSD: gbr.c,v 1.28 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
*
* Returns the payload or NULL if the document was malformed.
*/
struct gbr *
-gbr_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
+gbr_parse(X509 **x509, const char *fn, int talid, const unsigned char *der,
+ size_t len)
{
struct parse p;
struct cert *cert = NULL;
-/* $OpenBSD: geofeed.c,v 1.13 2023/03/10 12:44:56 job Exp $ */
+/* $OpenBSD: geofeed.c,v 1.14 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2022 Job Snijders <job@fastly.com>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* Returns the Geofeed, or NULL if the object was malformed.
*/
struct geofeed *
-geofeed_parse(X509 **x509, const char *fn, char *buf, size_t len)
+geofeed_parse(X509 **x509, const char *fn, int talid, char *buf, size_t len)
{
struct parse p;
char *delim, *line, *loc, *nl;
-/* $OpenBSD: mft.c,v 1.97 2023/09/03 10:48:50 job Exp $ */
+/* $OpenBSD: mft.c,v 1.98 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* The MFT content is otherwise returned.
*/
struct mft *
-mft_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
+mft_parse(X509 **x509, const char *fn, int talid, const unsigned char *der,
+ size_t len)
{
struct parse p;
struct cert *cert = NULL;
-/* $OpenBSD: parser.c,v 1.98 2023/08/30 10:01:52 job Exp $ */
+/* $OpenBSD: parser.c,v 1.99 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*/
static struct roa *
proc_parser_roa(char *file, const unsigned char *der, size_t len,
- const char *mftaki)
+ const struct entity *entp)
{
struct roa *roa;
struct auth *a;
X509 *x509;
const char *errstr;
- if ((roa = roa_parse(&x509, file, der, len)) == NULL)
+ if ((roa = roa_parse(&x509, file, entp->talid, der, len)) == NULL)
return NULL;
- a = valid_ski_aki(file, &auths, roa->ski, roa->aki, mftaki);
+ a = valid_ski_aki(file, &auths, roa->ski, roa->aki, entp->mftaki);
crl = crl_get(&crlt, a);
if (!valid_x509(file, ctx, x509, a, crl, &errstr)) {
if (der == NULL && errno != ENOENT)
warn("parse file %s", *file);
- if ((mft = mft_parse(&x509, *file, der, len)) == NULL) {
+ if ((mft = mft_parse(&x509, *file, entp->talid, der, len)) == NULL) {
free(der);
return NULL;
}
*/
static struct gbr *
proc_parser_gbr(char *file, const unsigned char *der, size_t len,
- const char *mftaki)
+ const struct entity *entp)
{
struct gbr *gbr;
X509 *x509;
struct auth *a;
const char *errstr;
- if ((gbr = gbr_parse(&x509, file, der, len)) == NULL)
+ if ((gbr = gbr_parse(&x509, file, entp->talid, der, len)) == NULL)
return NULL;
- a = valid_ski_aki(file, &auths, gbr->ski, gbr->aki, mftaki);
+ a = valid_ski_aki(file, &auths, gbr->ski, gbr->aki, entp->mftaki);
crl = crl_get(&crlt, a);
/* return value can be ignored since nothing happens here */
*/
static struct aspa *
proc_parser_aspa(char *file, const unsigned char *der, size_t len,
- const char *mftaki)
+ const struct entity *entp)
{
struct aspa *aspa;
struct auth *a;
X509 *x509;
const char *errstr;
- if ((aspa = aspa_parse(&x509, file, der, len)) == NULL)
+ if ((aspa = aspa_parse(&x509, file, entp->talid, der, len)) == NULL)
return NULL;
- a = valid_ski_aki(file, &auths, aspa->ski, aspa->aki, mftaki);
+ a = valid_ski_aki(file, &auths, aspa->ski, aspa->aki, entp->mftaki);
crl = crl_get(&crlt, a);
if (!valid_x509(file, ctx, x509, a, crl, &errstr)) {
*/
static struct tak *
proc_parser_tak(char *file, const unsigned char *der, size_t len,
- const char *mftaki)
+ const struct entity *entp)
{
struct tak *tak;
X509 *x509;
const char *errstr;
int rc = 0;
- if ((tak = tak_parse(&x509, file, der, len)) == NULL)
+ if ((tak = tak_parse(&x509, file, entp->talid, der, len)) == NULL)
return NULL;
- a = valid_ski_aki(file, &auths, tak->ski, tak->aki, mftaki);
+ a = valid_ski_aki(file, &auths, tak->ski, tak->aki, entp->mftaki);
crl = crl_get(&crlt, a);
if (!valid_x509(file, ctx, x509, a, crl, &errstr)) {
case RTYPE_ROA:
file = parse_load_file(entp, &f, &flen);
io_str_buffer(b, file);
- roa = proc_parser_roa(file, f, flen, entp->mftaki);
+ roa = proc_parser_roa(file, f, flen, entp);
if (roa != NULL)
mtime = roa->signtime;
io_simple_buffer(b, &mtime, sizeof(mtime));
case RTYPE_GBR:
file = parse_load_file(entp, &f, &flen);
io_str_buffer(b, file);
- gbr = proc_parser_gbr(file, f, flen, entp->mftaki);
+ gbr = proc_parser_gbr(file, f, flen, entp);
if (gbr != NULL)
mtime = gbr->signtime;
io_simple_buffer(b, &mtime, sizeof(mtime));
case RTYPE_ASPA:
file = parse_load_file(entp, &f, &flen);
io_str_buffer(b, file);
- aspa = proc_parser_aspa(file, f, flen, entp->mftaki);
+ aspa = proc_parser_aspa(file, f, flen, entp);
if (aspa != NULL)
mtime = aspa->signtime;
io_simple_buffer(b, &mtime, sizeof(mtime));
case RTYPE_TAK:
file = parse_load_file(entp, &f, &flen);
io_str_buffer(b, file);
- tak = proc_parser_tak(file, f, flen, entp->mftaki);
+ tak = proc_parser_tak(file, f, flen, entp);
if (tak != NULL)
mtime = tak->signtime;
io_simple_buffer(b, &mtime, sizeof(mtime));
-/* $OpenBSD: roa.c,v 1.69 2023/06/29 10:28:25 tb Exp $ */
+/* $OpenBSD: roa.c,v 1.70 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* Returns the ROA or NULL if the document was malformed.
*/
struct roa *
-roa_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
+roa_parse(X509 **x509, const char *fn, int talid, const unsigned char *der,
+ size_t len)
{
struct parse p;
size_t cmsz;
-/* $OpenBSD: rsc.c,v 1.27 2023/06/29 10:28:25 tb Exp $ */
+/* $OpenBSD: rsc.c,v 1.28 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2022 Job Snijders <job@fastly.com>
* Returns the RSC or NULL if the object was malformed.
*/
struct rsc *
-rsc_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
+rsc_parse(X509 **x509, const char *fn, int talid, const unsigned char *der,
+ size_t len)
{
struct parse p;
unsigned char *cms;
-/* $OpenBSD: tak.c,v 1.11 2023/06/29 10:28:25 tb Exp $ */
+/* $OpenBSD: tak.c,v 1.12 2023/09/25 11:08:45 tb Exp $ */
/*
* Copyright (c) 2022 Job Snijders <job@fastly.com>
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Returns the TAK or NULL if the object was malformed.
*/
struct tak *
-tak_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len)
+tak_parse(X509 **x509, const char *fn, int talid, const unsigned char *der,
+ size_t len)
{
struct parse p;
struct cert *cert = NULL;