OpenBSD CVS

CVS log for src/usr.sbin/rpki-client/cert.c


[BACK] Up to [local] / src / usr.sbin / rpki-client

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.144 / (download) - annotate - [select for diffs], Sat Jun 8 13:33:49 2024 UTC (2 hours, 16 minutes ago) by tb
Branch: MAIN
CVS Tags: HEAD
Changes since 1.143: +10 -7 lines
Diff to previous 1.143 (colored)

Tigthen cert_parse_ee_cert() and ta_parse()

Require that a cert fed to cert_parse_ee_cert() have an EE cert purpose.
Instead of throwing a warning for BGPsec router certs, check for the TA
purpose in ta_parse() and reject everything else.

ok job

Revision 1.143 / (download) - annotate - [select for diffs], Sat Jun 8 13:31:37 2024 UTC (2 hours, 19 minutes ago) by tb
Branch: MAIN
Changes since 1.142: +7 -3 lines
Diff to previous 1.142 (colored)

Improve x509_get_purpose()

Instead of only differentiating between CA and BGPsec Router certs,
make it recognize TA and EE certs as well. TAs and CAs have the cA
boolean in the basic constraints, while EE and BGPsec router certs
do not.

TAs are self-signed, CAs not self-issued, all other certs with the
cA boolean are invalid. EE certs do not have an extended key usage
and BGPsec certs contain the id-kp-bgpsec-router OID.

Handle the new purposes where needed.
                                                                                                    ok job

Revision 1.142 / (download) - annotate - [select for diffs], Sat Jun 8 13:28:35 2024 UTC (2 hours, 22 minutes ago) by tb
Branch: MAIN
Changes since 1.141: +5 -5 lines
Diff to previous 1.141 (colored)

Add a x509_cache_extensions() helper

This is a simple wrapper around X509_check_policy(cert, -1, 0) that
doesn't need an explanatory comment in the caller.

The reason for having to do this is that various OpenSSL API calls rely
on having extension information cached. As an unsurprising consequence of
OpenSSL's characteristic API misdesign these calls can't report errors,
so they call the extension caching without error checking and the result
is that they may report nonsense.

To work around this, cache the extensions up front so a second call can't
fail and thus API calls such as X509_check_ca(), X509_get_key_usage() and
X509_cmp() work reliably.

ok job

Revision 1.141 / (download) - annotate - [select for diffs], Fri Jun 7 08:36:54 2024 UTC (31 hours, 13 minutes ago) by tb
Branch: MAIN
Changes since 1.140: +5 -1 lines
Diff to previous 1.140 (colored)

Add two related todo items for purpose handling

BGPsec certs are a bit weird and checks for them are all over the place,
some of them in the TA handling, which makes very little sense. We'd be
better off adding another purpose for trust anchors and use that instead.

ok claudio job

Revision 1.140 / (download) - annotate - [select for diffs], Thu Jun 6 12:38:02 2024 UTC (2 days, 3 hours ago) by tb
Branch: MAIN
Changes since 1.139: +5 -1 lines
Diff to previous 1.139 (colored)

Tell my future self why I don't want to change this check

Revision 1.139 / (download) - annotate - [select for diffs], Thu Jun 6 11:53:09 2024 UTC (2 days, 3 hours ago) by tb
Branch: MAIN
Changes since 1.138: +5 -1 lines
Diff to previous 1.138 (colored)

Check that TA certs are correctly signed

We know the pubkey from the TAL, so check that the signature is right
as required by RFC 6487, section 7, additional condition 1, applied to
self-issued certs. Make the error check weird since OpenSSL 3 broke yet
another API (thanks claudio for making me go look).

ok claudio job

Revision 1.138 / (download) - annotate - [select for diffs], Thu Jun 6 07:20:15 2024 UTC (2 days, 8 hours ago) by tb
Branch: MAIN
Changes since 1.137: +4 -4 lines
Diff to previous 1.137 (colored)

rpki-client: fix RFC section references in ta_parse()

ok claudio

Revision 1.137 / (download) - annotate - [select for diffs], Thu Jun 6 03:29:52 2024 UTC (2 days, 12 hours ago) by tb
Branch: MAIN
Changes since 1.136: +4 -14 lines
Diff to previous 1.136 (colored)

rpki-client: simplify ta_parse()

Since this is always called after cert_parse_pre(), notBefore and notAfter
are available in struct cert, so we can use time_t comparison.

ok claudio

Revision 1.136 / (download) - annotate - [select for diffs], Tue Jun 4 14:10:53 2024 UTC (4 days, 1 hour ago) by tb
Branch: MAIN
Changes since 1.135: +7 -0 lines
Diff to previous 1.135 (colored)

rpki-client: reject certs with unexpected SIA accessMethods

RFC 6487, section 4.8.8.1 only lists caRepository and rpkiManifest, and
RFC 8182 added rpkiNotify for RRDP. All other access methods (which would
be children of id-ad), are not allowed and do not really make sense here.

ok claudio

Revision 1.135 / (download) - annotate - [select for diffs], Tue Jun 4 14:07:10 2024 UTC (4 days, 1 hour ago) by tb
Branch: MAIN
Changes since 1.134: +13 -4 lines
Diff to previous 1.134 (colored)

rpki-client: only allow a single rpkiNotify SIA accessMethod

RFC 8182, section 3.2 is not super explicit about it, but there should
only be one rpkiNotify accessMethod, and it should contain a location
with a URI of type https. Check this and reject certs that contain more
than one.

ok claudio

Revision 1.134 / (download) - annotate - [select for diffs], Tue Jun 4 04:17:18 2024 UTC (4 days, 11 hours ago) by tb
Branch: MAIN
Changes since 1.133: +10 -4 lines
Diff to previous 1.133 (colored)

rpki-client: remove proto argument from x509_location()

After recent changes, the rpkiNotify access description became the last
user of it, so this is now a pointless complication.

ok claudio

Revision 1.133 / (download) - annotate - [select for diffs], Mon Jun 3 12:58:39 2024 UTC (5 days, 2 hours ago) by tb
Branch: MAIN
Changes since 1.132: +36 -6 lines
Diff to previous 1.132 (colored)

Rework SIA handling to be less incorrect

Currently we would only accept rsync URIs in caRepository and rpkiManifest.
This is wrong. The specification requires at least one rsync URI to be
resent, but allows for other URI types, ordered by descending CA preference.
With this diff we will still only respect the first rsync address, but we
will no longer reject certificates listing other URIs. Make the warning
conditional on verbose mode.

Also make it clearer that sbgp_sia() (which is poorly named) is for CA
certs while x509_get_sia() is for EE certs.

input/ok claudio

Revision 1.132 / (download) - annotate - [select for diffs], Fri May 31 02:45:15 2024 UTC (8 days, 13 hours ago) by tb
Branch: MAIN
Changes since 1.131: +25 -3 lines
Diff to previous 1.131 (colored)

rpki-client: check issuer for certs and CRLs

Per RFC 6487, the subject and issuer fields of a certificate and the issuer
field of a CRL are subject to the same restrictions: only a commonName and
an optional serialNumber may be present and the commonName must be an ASN.1
printable string.

So far we've only checked the subject of certificates, which covers almost
everything by relying on the verifier to check that the issuer's subject is
identical to the subject's issuer, also for CRLs per X509_V_FLAG_CRL_CHECK.
The only thing missing this way is the TA's issuer.

Since the check is cheap and simple, we're better off doing it ourselves:
Refactor the x509_vaild_subject() helper to take an X509_NAME (which is of
course the appropriate name for a type representing an X.501 distinguished
name). This checks the details of RFC 6487, section 4.4, except that we
still can't check for a printable string since afrinic has ~3000 EE certs
that don't follow the spec, which would knock out ~45% of their ROAs. We're
told that this is going to be fixed this year.

looks good to claudio
ok job

Revision 1.131 / (download) - annotate - [select for diffs], Mon May 20 15:51:43 2024 UTC (2 weeks, 4 days ago) by claudio
Branch: MAIN
Changes since 1.130: +31 -8 lines
Diff to previous 1.130 (colored)

Instead of tracking certificates by SKI track them by an internal identifier.

The certificate SKI is not strictly unique so using it as a unique id is
problematic. It is also not really needed to do that since in theory we
already know the path (but this got lost in the privsep communication).
So add a cert id and pass this id back and forth between main process and
the parser. With this id we can lookup the authentication chain in the
parser and this even works with multiple paths to the same resource.
Since we no longer lookup by SKI the valid_aki_ski function is replaced
by find_issuer() which does the lookup by certid.

The loop protection is now extended to allow each TAL to reach each file
once but still triggers if a file is reaccessed by the tree of a TAL.

In filemode the lookup now uses an AIA uri based lookup tree. Again this
replaces the SKI based lookups from before.

Done together with tb@
OK tb@ job@

Revision 1.130 / (download) - annotate - [select for diffs], Sun Apr 21 19:27:44 2024 UTC (6 weeks, 5 days ago) by claudio
Branch: MAIN
Changes since 1.129: +2 -2 lines
Diff to previous 1.129 (colored)

P-256 support is experimental so require -x to enable it.

Also clean up the externs a little bit by moving experimental and noop
to extern.h.
Reminded by and OK tb@

Revision 1.129 / (download) - annotate - [select for diffs], Fri Mar 22 03:38:12 2024 UTC (2 months, 2 weeks ago) by job
Branch: MAIN
Changes since 1.128: +4 -4 lines
Diff to previous 1.128 (colored)

Replace protocol literal strings and strlen() calls with defined constants

OK tb@ claudio@

Revision 1.128 / (download) - annotate - [select for diffs], Tue Mar 19 05:04:13 2024 UTC (2 months, 2 weeks ago) by tb
Branch: MAIN
Changes since 1.127: +3 -3 lines
Diff to previous 1.127 (colored)

Rename parent to issuer in struct auth

Parent is confusing and issuer is the appropriate terminology. This is
a mechanical diff. The only remaining uses of 'parent' in this code
base now mean 'parent process'.

discussed with beck and job
ok job

Revision 1.127 / (download) - annotate - [select for diffs], Fri Feb 16 14:48:47 2024 UTC (3 months, 3 weeks ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.126: +87 -104 lines
Diff to previous 1.126 (colored)

Remove struct parse from cert.c

This is one of those weird things that metastasized throughout the code
base. job is about to introduce the 9th incompatible copy of it. Enough
is enough. It doesn't help anything.

looks good to claudio
ok clang

Revision 1.126 / (download) - annotate - [select for diffs], Fri Feb 16 11:55:42 2024 UTC (3 months, 3 weeks ago) by tb
Branch: MAIN
Changes since 1.125: +2 -2 lines
Diff to previous 1.125 (colored)

fix whitespace

Revision 1.125 / (download) - annotate - [select for diffs], Sun Feb 4 07:43:27 2024 UTC (4 months ago) by tb
Branch: MAIN
Changes since 1.124: +10 -5 lines
Diff to previous 1.124 (colored)

Split X509_get_ext_count() out of for loop again

The compiler can't know that the count doesn't change, so avoid evaluating
X509_get_ext_count() in each iteration. Also use a separate loop variable
in the ASid non-inheritance check to avoid a silly cast.

ok claudio

Revision 1.124 / (download) - annotate - [select for diffs], Sat Feb 3 14:43:15 2024 UTC (4 months ago) by tb
Branch: MAIN
Changes since 1.123: +4 -8 lines
Diff to previous 1.123 (colored)

Fix X509_get_ext_count() usage

It doesn't return a value < 0. If it did, someone could feed rpki-client
a bad cert that makes it error out, which is bad. There are various checks
that will reject a cert without extensions, so we don't need to check this
explicitly.

ok job

Revision 1.123 / (download) - annotate - [select for diffs], Thu Feb 1 15:11:38 2024 UTC (4 months ago) by tb
Branch: MAIN
Changes since 1.122: +5 -6 lines
Diff to previous 1.122 (colored)

Normalize the nid printing

OBJ_nid2* can return NULL if the gloriously consistent objects.txt
database doesn't specify a long or a short name. So try the long name
first, fall back to the short name, and if both fail, use "unknown".
Always include the nid as a decimal.

ok claudio

Revision 1.122 / (download) - annotate - [select for diffs], Thu Jan 11 11:55:14 2024 UTC (4 months, 3 weeks ago) by job
Branch: MAIN
Changes since 1.121: +4 -3 lines
Diff to previous 1.121 (colored)

Make the -P option work for Trust Anchor certificates as well

OK tb@

Revision 1.121 / (download) - annotate - [select for diffs], Thu Dec 14 07:52:53 2023 UTC (5 months, 3 weeks ago) by tb
Branch: MAIN
Changes since 1.120: +29 -3 lines
Diff to previous 1.120 (colored)

rpki-client: make IP address block checks stricter

There are only two valid AFIs in this context, so check that we have one
or two of them. We only accept the IPv4 and IPv6 AFIs in ip_add_afi_parse()
and reject any SAFI, so enforce that neither AFI is repeated. This doesn't
change things for certificates, where all this is implied by other checks
combined. Making this explicit and match the logic needed for ROAs is a win.

looks good to job
ok claudio

Revision 1.120 / (download) - annotate - [select for diffs], Sun Dec 10 14:18:23 2023 UTC (5 months, 4 weeks ago) by job
Branch: MAIN
Changes since 1.119: +2 -2 lines
Diff to previous 1.119 (colored)

Since errno isn't used here, use warnx() instead of warn()

OK tb@

Revision 1.119 / (download) - annotate - [select for diffs], Thu Oct 19 17:05:54 2023 UTC (7 months, 2 weeks ago) by job
Branch: MAIN
Changes since 1.118: +6 -2 lines
Diff to previous 1.118 (colored)

Add experimental support for secp256r1 aka P-256 aka prime256v1

ECDSA signatures are much smaller than RSA signatures while offering
similar security. Adding support for P-256 now allows CA developers
to test their implementations, and paving the way for signers in the
production environment in the future to take advantage of ECDSA.

OK tb@

Revision 1.118 / (download) - annotate - [select for diffs], Fri Oct 13 12:06:49 2023 UTC (7 months, 3 weeks ago) by job
Branch: MAIN
Changes since 1.117: +12 -7 lines
Diff to previous 1.117 (colored)

Allow imposing constraints on RPKI trust anchors

The ability to constrain a RPKI Trust Anchor's effective signing
authority to a limited set of Internet Number Resources allows
Relying Parties to enjoy the potential benefits of assuming trust,
within a bounded scope.

Some examples: ARIN does not support inter-RIR IPv6 transfers, so
it wouldn't make any sense to see a ROA subordinate to ARIN's trust
anchor covering RIPE-managed IPv6 space. Conversely, it wouldn't
make sense to observe a ROA covering ARIN-managed IPv6 space under
APNIC's, LACNIC's, or RIPE's trust anchor - even if a derived trust
arc (a cryptographically valid certificate path) existed. Along these
same lines, AFRINIC doesn't support inter-RIR transfers of any kind,
and none of the RIRs have authority over private resources like
10.0.0.0/8 and 2001:db8::/32.

For more background see:
https://datatracker.ietf.org/doc/draft-snijders-constraining-rpki-trust-anchors/
https://mailman.nanog.org/pipermail/nanog/2023-September/223354.html

With and OK tb@, OK claudio@

Revision 1.117 / (download) - annotate - [select for diffs], Mon Sep 25 15:33:08 2023 UTC (8 months, 1 week ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.116: +21 -22 lines
Diff to previous 1.116 (colored)

rpki-client: mechanical rename of some variables

The previous commit used suboptimal variable names for ease of review.
Fix this up now.

ok claudio

Revision 1.116 / (download) - annotate - [select for diffs], Mon Sep 25 14:56:20 2023 UTC (8 months, 1 week ago) by tb
Branch: MAIN
Changes since 1.115: +120 -77 lines
Diff to previous 1.115 (colored)

rpki-client: Refactor sbgp_assysnum() and sbgp_addrblk()

An upcoming diff requires the ability to convert ASIdentifiers and
IpAddrBlocks into rpki-client's internal structures.  Accordingly,
split already existing code into dedicated parsing functions . The
original functions now only extract the extension-specific data from
the X509_EXTENSION.

input/ok claudio

Revision 1.115 / (download) - annotate - [select for diffs], Tue Sep 12 09:33:30 2023 UTC (8 months, 3 weeks ago) by job
Branch: MAIN
Changes since 1.114: +9 -4 lines
Diff to previous 1.114 (colored)

Ensure the X.509 Subject only contains commonName and optionally serialNumber

OK tb@

Revision 1.114 / (download) - annotate - [select for diffs], Thu Jun 29 10:28:25 2023 UTC (11 months, 1 week ago) by tb
Branch: MAIN
Changes since 1.113: +17 -17 lines
Diff to previous 1.113 (colored)

Retire log.c

Convert all cryptowarnx() and cryptoerrx() to appropriate versions of
warn() and err{,x}(). Neither users nor developers benefit from them.
If we need better errors, we need to do some thinking. libcrypto won't
do that for us.

suggested by claudio
ok job

Revision 1.113 / (download) - annotate - [select for diffs], Sat Jun 24 04:15:14 2023 UTC (11 months, 2 weeks ago) by tb
Branch: MAIN
Changes since 1.112: +3 -3 lines
Diff to previous 1.112 (colored)

Remove a pair of parens and make one check more consistent with the others

Revision 1.112 / (download) - annotate - [select for diffs], Fri Jun 23 20:05:30 2023 UTC (11 months, 2 weeks ago) by tb
Branch: MAIN
Changes since 1.111: +3 -2 lines
Diff to previous 1.111 (colored)

Fix warning about empty ipAddressesOrRanges

Committed from an older tree.

Revision 1.111 / (download) - annotate - [select for diffs], Fri Jun 23 07:40:28 2023 UTC (11 months, 2 weeks ago) by tb
Branch: MAIN
Changes since 1.110: +33 -8 lines
Diff to previous 1.110 (colored)

rpki-client: check for duplicate certificate extensions

RFC 5280 disallows multiple extensions with the same OID. Since libcrypto
does not check that currently, do this by hand. This only deals with CA
certs for now, EE certs could do that similarly.

Found with BBN test corpora

ok job

Revision 1.110 / (download) - annotate - [select for diffs], Fri Jun 23 07:26:21 2023 UTC (11 months, 2 weeks ago) by tb
Branch: MAIN
Changes since 1.109: +15 -1 lines
Diff to previous 1.109 (colored)

rpki-client: disallow empty sets of IP Addresses or AS numbers

RFC 3779 doesn't say anything about empty lists of IP addresses and AS
numbers. Of course the RFC 3779 code in libcrypto implements a check for
empty lists for AS numbers but fails to do so for IP addresses...

While RFC 6487 is explicit about disallowing empty lists of IP addresses,
it is not explicit about disallowing empty ipAddressesOrRanges, but that
seems to be the intent.

Found with BBN test corpora

ok job

Revision 1.109 / (download) - annotate - [select for diffs], Tue Jun 20 12:28:08 2023 UTC (11 months, 2 weeks ago) by job
Branch: MAIN
Changes since 1.108: +11 -1 lines
Diff to previous 1.108 (colored)

Ensure the X.509 version is V3

OK tb@

Revision 1.108 / (download) - annotate - [select for diffs], Tue May 9 10:34:32 2023 UTC (13 months ago) by tb
Branch: MAIN
Changes since 1.107: +2 -1 lines
Diff to previous 1.107 (colored)

rpki-client: use partial chains in certificate validation

The generally rather poor quality RFC 3779 code in libcrypto also performs
abysmally. Flame graphs show that nearly 20% of the parser process is spent
in addr_contains() alone. There is room for improvement in addr_contains()
itself - the containment check for prefixes could be optimized quite a bit.
We can avoid a lot of the most expensive work for certificates with tons of
resources close to the TA by using the verifier's partial chains flag.

More precisely, in the tree of already validated certs look for the first
one that has no inherited RFC 3779 resources and use that as 'trust anchor'
for our chains via the X509_V_FLAG_PARTIAL_CHAIN flag. This way we can be
sure that a leaf's delegated resources are properly covered and at the same
time significantly shorten most paths validated.

Job's and my testing indicates that this avoids 30-50% of overhead and works
equally well with LibreSSL and OpenSSL >= 1.1. The main bottlenecks in the
parser process now appear to be SHA-2 and RSA/BIGNUM, two well-known pain
points in libcrypto.

This is based on a hint by beck and was discussed extensively with beck,
claudio and job during and after m2k23.

ok claudio job

Revision 1.107 / (download) - annotate - [select for diffs], Sat Apr 15 00:39:08 2023 UTC (13 months, 3 weeks ago) by job
Branch: MAIN
Changes since 1.106: +9 -1 lines
Diff to previous 1.106 (colored)

Disallow issuer and subject unique identifiers

In 1992, the ITU-T - through X.509 version 2 - introduced subject and
issuer unique identifier fields to handle the possibility of reuse
of subject and/or issuer names over time. However, the standing
recommendation is that names not be reused for different entities and
that Internet certificates not make use of unique identifiers.
Conforming RPKI CAs will never issue certificates with unique identifiers.

OK tb@ claudio@

Revision 1.106 / (download) - annotate - [select for diffs], Fri Mar 10 12:44:56 2023 UTC (14 months, 4 weeks ago) by job
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.105: +5 -5 lines
Diff to previous 1.105 (colored)

mechanical change, rename struct members to match the original X509 names

OK tb@

Revision 1.105 / (download) - annotate - [select for diffs], Fri Mar 10 12:02:11 2023 UTC (14 months, 4 weeks ago) by job
Branch: MAIN
Changes since 1.104: +3 -1 lines
Diff to previous 1.104 (colored)

Show the X.509 notBefore in filemode

OK tb@

Revision 1.104 / (download) - annotate - [select for diffs], Mon Mar 6 16:58:41 2023 UTC (15 months ago) by job
Branch: MAIN
Changes since 1.103: +17 -1 lines
Diff to previous 1.103 (colored)

Ensure .cer and .crl outside-TBS signatures are sha256WithRSAEncryption

Note: there is a potential for confusion in RFC 7935, the specification
differentiates between 2 contexts: "in the certificate" and "CMS SignedData".

In the CMS context, either rsaEncryption or sha256WithRSAEncryption can
appear (and both *do* appear in the wild).

However, RFC 7935 section 2 fourth paragraph starting with "In certificates,
CRLs, ..." mandates that sha256WithRSAEncryption is used to sign .cer and
.crl files:

    "The Object Identifier (OID) sha256WithRSAEncryption from RFC4055 MUST
    be used in these products."

The above requirement matches observations on existing RPKI deployments.

OK tb@

Revision 1.103 / (download) - annotate - [select for diffs], Mon Mar 6 16:04:52 2023 UTC (15 months ago) by job
Branch: MAIN
Changes since 1.102: +9 -1 lines
Diff to previous 1.102 (colored)

Add check for RSA key pair modulus & public exponent

Both the SPKI inside a CA's .cer TBS section and Signers wrapped in CMS
must be RSA, with mod 2048 & (e) 0x10001

OK tb@

Revision 1.102 / (download) - annotate - [select for diffs], Tue Feb 21 10:18:47 2023 UTC (15 months, 2 weeks ago) by tb
Branch: MAIN
Changes since 1.101: +14 -8 lines
Diff to previous 1.101 (colored)

rpki-client: ensure there is no trailing garbage in signed objects

The d2i functions are designed in such a way that the caller is responsible
to check if the entire buffer was consumed. Add checks on deserializing a
signed object to ensure the entire file has been consumed. Reject the file
if it has trailing garbage.

found by & ok job, ok claudio

Revision 1.101 / (download) - annotate - [select for diffs], Wed Nov 30 09:12:34 2022 UTC (18 months, 1 week ago) by job
Branch: MAIN
Changes since 1.100: +1 -3 lines
Diff to previous 1.100 (colored)

Remove unused includes

OK claudio@

Revision 1.100 / (download) - annotate - [select for diffs], Wed Nov 30 08:17:21 2022 UTC (18 months, 1 week ago) by job
Branch: MAIN
Changes since 1.99: +1 -3 lines
Diff to previous 1.99 (colored)

Remove unused sys/socket.h include

OK claudio@

Revision 1.99 / (download) - annotate - [select for diffs], Tue Nov 29 20:41:32 2022 UTC (18 months, 1 week ago) by job
Branch: MAIN
Changes since 1.98: +1 -2 lines
Diff to previous 1.98 (colored)

Only include stdarg.h, if we call any of va_{start,end}()

OK tb@

Revision 1.98 / (download) - annotate - [select for diffs], Sat Nov 26 17:14:40 2022 UTC (18 months, 1 week ago) by job
Branch: MAIN
Changes since 1.97: +3 -3 lines
Diff to previous 1.97 (colored)

Make error messages about 'inherit' elements in End-Entity certs consistent

OK tb@

Revision 1.97 / (download) - annotate - [select for diffs], Tue Nov 8 08:15:39 2022 UTC (19 months ago) by tb
Branch: MAIN
Changes since 1.96: +2 -2 lines
Diff to previous 1.96 (colored)

stray space

Revision 1.96 / (download) - annotate - [select for diffs], Mon Nov 7 16:23:32 2022 UTC (19 months ago) by job
Branch: MAIN
Changes since 1.95: +7 -3 lines
Diff to previous 1.95 (colored)

Simplify use of strrchr()

with and OK tb@

Revision 1.95 / (download) - annotate - [select for diffs], Fri Nov 4 12:05:36 2022 UTC (19 months ago) by tb
Branch: MAIN
Changes since 1.94: +2 -2 lines
Diff to previous 1.94 (colored)

whitespace

Revision 1.94 / (download) - annotate - [select for diffs], Fri Nov 4 10:09:09 2022 UTC (19 months ago) by job
Branch: MAIN
Changes since 1.93: +10 -1 lines
Diff to previous 1.93 (colored)

Catch bad characters in rpkiManifest filenames earlier on

This improves the hard-to-read error:

rpki-client: .rrdp/59B96A4C078FDCEDBB776D5BE8DF45EAC0149157547270EA7D4647A76611E145/rpki-rsync.us-east-2.amazonaws.com/volume/220c3ec2-ccf9-4b8a-bf61-fd4d1e151271/LAXNBPgDnLLjagP8++RFIoaMCGo.mft: RFC 6487 section 4.8.6: CRL: bad CRL distribution point extension
rpki-client: rpki-rsync.us-east-2.amazonaws.com/volume/220c3ec2-ccf9-4b8a-bf61-fd4d1e151271/LAXNBPgDnLLjagP8++RFIoaMCGo.mft: no valid mft available

to:

rpki-client: rpki.ripe.net/repository/DEFAULT/ZMvVW3ZpjFaCVe2TtDEqMlyFk3E.cer: SIA: rpkiManifest filename contains invalid characters

OK tb@

Revision 1.93 / (download) - annotate - [select for diffs], Fri Nov 4 09:45:19 2022 UTC (19 months ago) by job
Branch: MAIN
Changes since 1.92: +2 -2 lines
Diff to previous 1.92 (colored)

Don't show CPS URIs when in filemode

OK tb@

Revision 1.92 / (download) - annotate - [select for diffs], Thu Nov 3 10:39:19 2022 UTC (19 months ago) by job
Branch: MAIN
Changes since 1.91: +21 -1 lines
Diff to previous 1.91 (colored)

Constrain KeyUsage and ExtendedKeyUsage on both CA & EE certificates

RFC 6487 section 4.8.4 restricts the KeyUsage extension on EE
certificates to only be digitalSignature.

RFC 6487 section 4.8.5 forbids the ExtendedKeyUsage extension from
appearing on CA certificates. However, this may change in the future
through the standardisation process.

OK tb@

Revision 1.91 / (download) - annotate - [select for diffs], Thu Nov 3 00:00:53 2022 UTC (19 months ago) by job
Branch: MAIN
Changes since 1.90: +6 -1 lines
Diff to previous 1.90 (colored)

Permit only keyCertSign and CRLSign in CA KeyUsage extension

OK tb@

Revision 1.90 / (download) - annotate - [select for diffs], Wed Nov 2 23:20:59 2022 UTC (19 months ago) by job
Branch: MAIN
Changes since 1.89: +9 -4 lines
Diff to previous 1.89 (colored)

Emit warnings when unexpected X.509v3 extensions are encountered

OK tb@

Revision 1.89 / (download) - annotate - [select for diffs], Sat Sep 3 21:24:02 2022 UTC (21 months ago) by job
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.88: +13 -1 lines
Diff to previous 1.88 (colored)

Properly free() crl & auth tree in parser process

OK claudio@

Revision 1.88 / (download) - annotate - [select for diffs], Sat Sep 3 14:40:09 2022 UTC (21 months ago) by job
Branch: MAIN
Changes since 1.87: +5 -1 lines
Diff to previous 1.87 (colored)

Introduce x509_any_inherit() for objects which may not have inherit elements

Unify conformance checking of Trust Anchors, ROAs, ASPAs, RSCs - none of which
may have any 'inherit' elements in the RFC 3779 IP/AS Resources extension of
the X509 certificate.

OK tb@

Revision 1.87 / (download) - annotate - [select for diffs], Sat Sep 3 13:30:27 2022 UTC (21 months ago) by claudio
Branch: MAIN
Changes since 1.86: +3 -1 lines
Diff to previous 1.86 (colored)

Add the repoid of the cert in the cert struct. This way it is possible
to track the parent repository id of a publication point.
Nomenclature is confusing but not much we can do here.
OK tb@ job@

Revision 1.86 / (download) - annotate - [select for diffs], Sat Sep 3 13:01:43 2022 UTC (21 months ago) by tb
Branch: MAIN
Changes since 1.85: +8 -1 lines
Diff to previous 1.85 (colored)

Move non-inheritance check for BGPsec certs into cert_parse_pre()

ok claudio job (as part of a larger diff)

Revision 1.85 / (download) - annotate - [select for diffs], Fri Aug 19 12:45:53 2022 UTC (21 months, 2 weeks ago) by tb
Branch: MAIN
Changes since 1.84: +44 -1 lines
Diff to previous 1.84 (colored)

Check the resources in ROAs and RSCs against EE certs

The resources delegated in the RFC 3779 extensions of the EE cert for
ROAs or RSCs can be a subset of the resources in the auth chain. So far
we compared that the resources of ROAs and RSCs are covered by the auth
chain, which is not entirely correct. Extract the necessary data from
the EE cert into rpki-client's own data structures, then verify that
the EE cert's resources cover the ones claimed in the ROA or RSC.

Do this as part or ROA and RSC parsing, that the EE cert's resources are
covered by the auth chain is checked in valid_x509() later on.

All this is a bit more annoying and intrusive than it should be...

ok claudio job

Revision 1.84 / (download) - annotate - [select for diffs], Tue May 31 18:51:35 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.83: +2 -1 lines
Diff to previous 1.83 (colored)

I made non-trivial contributions to these files.

Revision 1.83 / (download) - annotate - [select for diffs], Tue May 31 18:33:16 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.82: +55 -44 lines
Diff to previous 1.82 (colored)

Prepare rewrite of rsc.c with templated ASN.1

Change signatures of various functions to avoid using struct parse and
expose sbgp_as_{id,range}() and sbgp_addr{,_range}() so they can be used
from rsc.c. This is a mostly mechanical diff.

ok claudio job

Revision 1.82 / (download) - annotate - [select for diffs], Sun May 15 15:00:53 2022 UTC (2 years ago) by deraadt
Branch: MAIN
Changes since 1.81: +4 -4 lines
Diff to previous 1.81 (colored)

whitespace spotted during read-thru

Revision 1.81 / (download) - annotate - [select for diffs], Thu May 12 10:49:22 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.80: +57 -89 lines
Diff to previous 1.80 (colored)

Align parsing of ipAddrBlock with autnomousSysNum

We now do one allocation per address family instead of one per prefix or
range.

ok claudio

Revision 1.80 / (download) - annotate - [select for diffs], Thu May 12 08:53:33 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.79: +44 -26 lines
Diff to previous 1.79 (colored)

Tidy up IP handling

Populate struct ip in the leaf functions instead of handing it through
several layers and copying it along the way. Pass in the afi instead of
letting struct ip carry it.

ok claudio

Revision 1.79 / (download) - annotate - [select for diffs], Thu May 12 07:45:27 2022 UTC (2 years ago) by claudio
Branch: MAIN
Changes since 1.78: +55 -50 lines
Diff to previous 1.78 (colored)

Refactor parsing of autonomousSysNum. Adjust code so that the allocation
needed for append_as() is done upfront.
OK tb@

Revision 1.78 / (download) - annotate - [select for diffs], Wed May 11 16:13:05 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.77: +7 -1 lines
Diff to previous 1.77 (colored)

Cache X509v3 extensions as soon as we have a cert

X509 API functions such as X509_check_ca() or X509_get_extension_flags()
can't be used reliably unless we know that X509v3 extensions are cached.
Otherwise they try to cache the extensions themselves but can't report
possible errors sensibly. They carry on and may return nonsense.

An old trick is to call X509_check_purpose() with a purpose of -1 which
is a wrapper around the internal x509v3_cache_extensions() that allows
error checking. Do this when we have a new cert. This way the API
functions affected by this can be relied upon. Another nice side effect
of doing this is that with LibreSSL we then know that the RFC 3779
extensions are in canonical form.

ok beck claudio

Revision 1.77 / (download) - annotate - [select for diffs], Wed May 11 09:40:00 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.76: +2 -2 lines
Diff to previous 1.76 (colored)

Fix doc comment of sbgp_asrange()

Revision 1.76 / (download) - annotate - [select for diffs], Wed May 11 09:07:04 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.75: +23 -23 lines
Diff to previous 1.75 (colored)

Move sbgp_addr() down to the other sbgp_addr_* functions.

ok claudio job

Revision 1.75 / (download) - annotate - [select for diffs], Wed May 11 08:59:00 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.74: +42 -189 lines
Diff to previous 1.74 (colored)

Deserialize ASIdentifiers in libcrypto

Let the RFC 3779 code in libcrypto do its job: deserialize the ASIdentifiers
extension using X509V3_EXT_d2i() and then simply walk the returned struct.
This replaces quite a bit of low level ASN.1 fiddling with much simpler
reaching into structs with names that have some meaning.

Additionally, RFC 6487, 4.8.10 forbids RDI entries, so throw an error
instead of ignoring them.

ok claudio

Revision 1.74 / (download) - annotate - [select for diffs], Tue May 10 16:43:53 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.73: +6 -7 lines
Diff to previous 1.73 (colored)

Fix a couple of typos in doc comments, bunch of KNF (whitespace) tweaks

Revision 1.73 / (download) - annotate - [select for diffs], Tue May 10 16:17:07 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.72: +38 -177 lines
Diff to previous 1.72 (colored)

Deserialize IPAddrBlocks in libcrypto

Let the RFC 3779 code in libcrypto do its job: deserialize the IPAddrBlocks
extension using X509V3_EXT_d2i() and then simply walk the returned struct.
This replaces quite a bit of low level ASN.1 fiddling with much simpler
reaching into structs with names that have some meaning.

ok claudio

Revision 1.72 / (download) - annotate - [select for diffs], Tue May 10 15:45:04 2022 UTC (2 years ago) by tb
Branch: MAIN
Changes since 1.71: +4 -4 lines
Diff to previous 1.71 (colored)

Fix leaks due to incorrect early returns rather than proper cleanup.

ok claudio job

Revision 1.71 / (download) - annotate - [select for diffs], Thu Apr 21 12:59:03 2022 UTC (2 years, 1 month ago) by claudio
Branch: MAIN
Changes since 1.70: +10 -2 lines
Diff to previous 1.70 (colored)

Further refactor and cleanup filemode.c mainly remove the copies of
proc_parser_cert_validate() and proc_parser_root_cert() adjust
parse_load_certchain() and parse_load_ta() respectivly.
Also cleanup the functions in parser.c and make it possible to call
ta_parse and cert_parse with a NULL cert.
OK tb@

Revision 1.70 / (download) - annotate - [select for diffs], Thu Apr 21 09:53:07 2022 UTC (2 years, 1 month ago) by claudio
Branch: MAIN
Changes since 1.69: +9 -9 lines
Diff to previous 1.69 (colored)

The filemode code is enough different from the regular parser code that it
makes sense to totally split it out. Duplicate proc_parser_cert_validate()
and proc_parser_root_cert() for now.

The valid_x509() plus the required static functions are moved to validate.c.
The crl_tree code moved into crl.c similar to the auth_tree handling in
cert.c. All the proc functions are now tagged with __attribute(noreturn)
which allows to remove the errx() after them.

OK tb@

Revision 1.69 / (download) - annotate - [select for diffs], Tue Apr 12 09:48:23 2022 UTC (2 years, 1 month ago) by tb
Branch: MAIN
Changes since 1.68: +2 -2 lines
Diff to previous 1.68 (colored)

Add a colon to warning for consistency

Revision 1.68 / (download) - annotate - [select for diffs], Tue Apr 12 09:32:23 2022 UTC (2 years, 1 month ago) by tb
Branch: MAIN
Changes since 1.67: +70 -70 lines
Diff to previous 1.67 (colored)

Shuffle sbgp_sia() a bit down to a place where it makes more sense

ok claudio

Revision 1.67 / (download) - annotate - [select for diffs], Tue Apr 12 08:45:34 2022 UTC (2 years, 1 month ago) by tb
Branch: MAIN
Changes since 1.66: +4 -38 lines
Diff to previous 1.66 (colored)

Generalize sbgp_sia_location() to x509_location()

AIA and CRL URIs can reuse the code in sbgp_sia_location and thus get the
same checks as the SIA locations. This eliminates some more duplication
and makes the checks more stringent in that embedded NULs and "./" are no
longer allowed.

ok claudio

Revision 1.66 / (download) - annotate - [select for diffs], Mon Apr 11 10:39:45 2022 UTC (2 years, 1 month ago) by tb
Branch: MAIN
Changes since 1.65: +32 -109 lines
Diff to previous 1.65 (colored)

Simplify SIA extension parsing further

Inline sbgp_sia_resource_entry() into sbgp_sia(). Add sbgp_sia_location()
to deduplicate sbgp_sia_resource_{notify,mft,carepo}(). Pull the GEN_URI
check into sbgp_sia_location() now that it doesn't have to be repeated
three times.

ok claudio

Revision 1.65 / (download) - annotate - [select for diffs], Mon Apr 11 08:28:54 2022 UTC (2 years, 1 month ago) by tb
Branch: MAIN
Changes since 1.64: +19 -35 lines
Diff to previous 1.64 (colored)

Merge sbgp_sia() and sbgp_sia_resource()

These two functions are now short and easy, so there's no need for a split.
Also, pull the .mft extension check out of sbgp_sia_resource_mft() and use
rtype_from_file_extension() instead.

ok claudio

Revision 1.64 / (download) - annotate - [select for diffs], Mon Apr 11 08:04:43 2022 UTC (2 years, 1 month ago) by tb
Branch: MAIN
Changes since 1.63: +14 -15 lines
Diff to previous 1.63 (colored)

Simplify cert_parse_pre()

Remove rc and c and check things the straightforward way. Avoids some
contorted code and shaves off a few lines.

ok claudio

Revision 1.63 / (download) - annotate - [select for diffs], Mon Apr 11 06:47:38 2022 UTC (2 years, 1 month ago) by tb
Branch: MAIN
Changes since 1.62: +47 -123 lines
Diff to previous 1.62 (colored)

Let the templated ASN.1 parse the SIA extension

Instead of using super low level ASN.1 fiddling, let libcrypto's templated
ASN.1 take care of parsing the SIA extension. This trivializes much of this
code.  Resolves one FIXME and adds a missing check for URI type of the SIA
repo resources.

ok claudio

Revision 1.62 / (download) - annotate - [select for diffs], Tue Apr 5 03:56:20 2022 UTC (2 years, 2 months ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.61: +13 -1 lines
Diff to previous 1.61 (colored)

Fix two missing checks in the SIA extension

Make sure that the caRepository and rpkiManifest are present before
calling strstr on them. Also check that the extension is not critical.

ok claudio deraadt

Revision 1.61 / (download) - annotate - [select for diffs], Mon Apr 4 13:15:11 2022 UTC (2 years, 2 months ago) by tb
Branch: MAIN
Changes since 1.60: +1 -5 lines
Diff to previous 1.60 (colored)

Remove two more FIXMEs: to get there, we rely on the OID already.

ok claudio

Revision 1.60 / (download) - annotate - [select for diffs], Sat Apr 2 12:17:53 2022 UTC (2 years, 2 months ago) by claudio
Branch: MAIN
Changes since 1.59: +9 -17 lines
Diff to previous 1.59 (colored)

Split certificate parsing in two steps. cert_parse_pre() which does
the parse and some checks and cert_parse() or ta_parse() to do the
additional checks for regular certs or TAs.
With this adjust the cert parser in -f mode to identify TAs (by checking
if it is self signed) and adjust the validation in that case. Now -f
should be able to parse and show all object correctly.
With and OK tb@

Revision 1.59 / (download) - annotate - [select for diffs], Fri Apr 1 17:22:07 2022 UTC (2 years, 2 months ago) by claudio
Branch: MAIN
Changes since 1.58: +19 -16 lines
Diff to previous 1.58 (colored)

Change x509_get_aki(), x509_get_ski(), x509_get_aia(), and x509_get_crl()
to work more like x509_get_expire(). They will return an error if the
extension extraction failed but not if it was not present. The callers
must now do that check but most did already.
With this cert_parse_inner() no longer cares about TA vs non-TA certs.
Feedback and OK tb@

Revision 1.58 / (download) - annotate - [select for diffs], Fri Apr 1 13:27:38 2022 UTC (2 years, 2 months ago) by claudio
Branch: MAIN
Changes since 1.57: +49 -47 lines
Diff to previous 1.57 (colored)

Move the TA specific checks from cert_parse_inner() to ta_parse() and
the regular cert checks from cert_parse_inner() to cert_parse().
OK tb@

Revision 1.57 / (download) - annotate - [select for diffs], Fri Apr 1 10:00:41 2022 UTC (2 years, 2 months ago) by tb
Branch: MAIN
Changes since 1.56: +2 -2 lines
Diff to previous 1.56 (colored)

Fix error message from d2i_X509_bio() to d2i_X509()

ok claudio

Revision 1.56 / (download) - annotate - [select for diffs], Fri Feb 4 16:50:49 2022 UTC (2 years, 4 months ago) by tb
Branch: MAIN
Changes since 1.55: +4 -4 lines
Diff to previous 1.55 (colored)

More consistency in the return code docs.

Revision 1.55 / (download) - annotate - [select for diffs], Fri Feb 4 16:50:01 2022 UTC (2 years, 4 months ago) by tb
Branch: MAIN
Changes since 1.54: +5 -1 lines
Diff to previous 1.54 (colored)

Document certificate_policies() in a comment.

Revision 1.54 / (download) - annotate - [select for diffs], Fri Feb 4 16:28:20 2022 UTC (2 years, 4 months ago) by tb
Branch: MAIN
Changes since 1.53: +80 -1 lines
Diff to previous 1.53 (colored)

Ensure that certificate policies follow RFC 7318

RFC 7318 makes requirements on the certificate policy extension imposed
by RFC 6487 a bit stricter. It requires that exactly one policy OID is
present and that it be id-cp-ipAddr-asNumber and if there is a policy
qualifier it must be id-qt-cps. These are requirements that the X.509
verifier's policy code can't enforce, so unpack the certificate policy
extension by hand and check that it matches expectations.

ok claudio

Revision 1.53 / (download) - annotate - [select for diffs], Thu Jan 20 16:36:19 2022 UTC (2 years, 4 months ago) by claudio
Branch: MAIN
Changes since 1.52: +36 -15 lines
Diff to previous 1.52 (colored)

Move the notBefore and notAfter checks from proc_parser_root_cert()
to ta_parse(). This fits better there. Also drop extracting and
printing the x509 subject of the TAs. The subject is more or less
the filename anyway which is already printed.
OK tb@

Revision 1.52 / (download) - annotate - [select for diffs], Tue Jan 18 16:52:18 2022 UTC (2 years, 4 months ago) by claudio
Branch: MAIN
Changes since 1.51: +2 -3 lines
Diff to previous 1.51 (colored)

Use X509_get0_pubkey() for opk and remove the EVP_PKEY_free(opk).
Suggested by and OK tb@

Revision 1.51 / (download) - annotate - [select for diffs], Tue Jan 18 16:36:49 2022 UTC (2 years, 4 months ago) by claudio
Branch: MAIN
Changes since 1.50: +9 -21 lines
Diff to previous 1.50 (colored)

Change cert_parse() and ta_parse() to no longer take a x509 handle as
argument. The x509 cert is also inside struct cert and easy to access.
Also switch auth_insert() to a void function since it can't fail.
OK tb@

Revision 1.50 / (download) - annotate - [select for diffs], Tue Jan 18 13:06:43 2022 UTC (2 years, 4 months ago) by claudio
Branch: MAIN
Changes since 1.49: +5 -19 lines
Diff to previous 1.49 (colored)

Cleanup the scattered OBJ_txt2obj() calls and move them into
x509_init_oid() to initalize all necessary OID objects at start.
OK tb@

Revision 1.49 / (download) - annotate - [select for diffs], Sun Dec 26 12:32:28 2021 UTC (2 years, 5 months ago) by tb
Branch: MAIN
Changes since 1.48: +3 -3 lines
Diff to previous 1.48 (colored)

fix spelling of inheritance

Revision 1.48 / (download) - annotate - [select for diffs], Sun Dec 26 12:30:11 2021 UTC (2 years, 5 months ago) by tb
Branch: MAIN
Changes since 1.47: +13 -1 lines
Diff to previous 1.47 (colored)

Check ipAddrBlock and autonomousSysNum for criticality

These extensions MUST be marked critical. Criticality is determined by the
ASN1_BOOLEAN that is extracted and ignored after the FIXME a few lines
below each of the two hunks. Rather than getting the info from there, it's
easier to use an API call that checks what was already parsed by d2i_X509().

ok claudio job

Revision 1.28.2.1 / (download) - annotate - [select for diffs], Tue Nov 9 13:41:19 2021 UTC (2 years, 6 months ago) by benno
Branch: OPENBSD_6_9
Changes since 1.28: +213 -155 lines
Diff to previous 1.28 (colored) next main 1.29 (colored)

rpki-client(8) should handle CA misbehaviours as soft-errors.

This is a merge of usr.sbin/rpki-client and usr.bin/rsync from current
and includes all commits in rpki-client 7.5 up to Tue Nov 9 11:03:40
2021 and to openrsync up to Wed Nov 3 14:42:13 2021, including:

* Make rpki-client more resilient regarding untrusted input:
  - fail repository synchronisation after 15min runtime
  - limit the number of publication points per TAL
  - don't allow DOCTYPE definitions in RRDP XML files
  - fix detection of HTTP redirect loops.
* limit the number of concurrent rsync processes.
* fix CRLF in tal files.

This is patches/6.9/common/021_rpki.patch.sig

Revision 1.32.4.1 / (download) - annotate - [select for diffs], Tue Nov 9 13:40:32 2021 UTC (2 years, 6 months ago) by benno
Branch: OPENBSD_7_0
Changes since 1.32: +186 -118 lines
Diff to previous 1.32 (colored) next main 1.33 (colored)

rpki-client(8) should handle CA misbehaviours as soft-errors.

This is a merge of usr.sbin/rpki-client and usr.bin/rsync from current
and includes all commits in rpki-client 7.5 up to Tue Nov 9 11:03:40
2021 and to openrsync up to Wed Nov 3 14:42:13 2021, including:

* Make rpki-client more resilient regarding untrusted input:
  - fail repository synchronisation after 15min runtime
  - limit the number of publication points per TAL
  - don't allow DOCTYPE definitions in RRDP XML files
  - fix detection of HTTP redirect loops.
* limit the number of concurrent rsync processes.
* fix CRLF in tal files.

This is patches/7.0/common/004_rpki.patch.sig

Revision 1.47 / (download) - annotate - [select for diffs], Fri Nov 5 10:50:41 2021 UTC (2 years, 7 months ago) by claudio
Branch: MAIN
Changes since 1.46: +8 -70 lines
Diff to previous 1.46 (colored)

Simplify how IP addresses and AS numbers are passed between processes.
Since they are stored in an array just blast the full array in and out
of the io buffers at once instead of iterating element by element.
It also allows to remove a lot of extra code.
OK benno@ job@

Revision 1.46 / (download) - annotate - [select for diffs], Thu Nov 4 11:32:55 2021 UTC (2 years, 7 months ago) by claudio
Branch: MAIN
Changes since 1.45: +13 -18 lines
Diff to previous 1.45 (colored)

Instead of passing tal descriptions around just pass a tal id and
use a small lookup table to print the description in the output path.
OK tb@

Revision 1.45 / (download) - annotate - [select for diffs], Tue Nov 2 19:30:30 2021 UTC (2 years, 7 months ago) by claudio
Branch: MAIN
Changes since 1.44: +10 -3 lines
Diff to previous 1.44 (colored)

Only add CA certificates to the auth tree, skip BGPsec certificates.
Also make sure that trust anchors are not BGPsec certs.
While there fix some overly long lines.
OK benno@

Revision 1.44 / (download) - annotate - [select for diffs], Mon Nov 1 17:00:34 2021 UTC (2 years, 7 months ago) by claudio
Branch: MAIN
Changes since 1.43: +19 -3 lines
Diff to previous 1.43 (colored)

Further simplify cert and auth handling. Move common code into auth_insert
and skip this distinction between invalid and failed certificates.
The difference between the to is getting more and more blurry.
OK tb@

Revision 1.43 / (download) - annotate - [select for diffs], Thu Oct 28 09:02:19 2021 UTC (2 years, 7 months ago) by beck
Branch: MAIN
Changes since 1.42: +3 -2 lines
Diff to previous 1.42 (colored)

Don't exit in certain cases on failures to parse x509 objects.

In most cases we already warn and continue if someone sends us malformed
x509 objects. This makes this consistent behaviour in all places
so that if someone passes in bogus X509, We end up failing their entry
and continuing rather than exiting.

We still exit on memory/system failures so that a future run of rpki
client can simply do better when the machine is perhaps less hammered
on

ok job@ claudio@

Revision 1.42 / (download) - annotate - [select for diffs], Wed Oct 27 21:56:58 2021 UTC (2 years, 7 months ago) by beck
Branch: MAIN
Changes since 1.41: +5 -1 lines
Diff to previous 1.41 (colored)

Add limits on size of certain untrusted inputs

ok job@

Revision 1.41 / (download) - annotate - [select for diffs], Tue Oct 26 13:31:05 2021 UTC (2 years, 7 months ago) by claudio
Branch: MAIN
Changes since 1.40: +11 -19 lines
Diff to previous 1.40 (colored)

Also move the cert parser code away from using BIO.
OK beck@

Revision 1.40 / (download) - annotate - [select for diffs], Sat Oct 23 16:06:04 2021 UTC (2 years, 7 months ago) by claudio
Branch: MAIN
Changes since 1.39: +32 -33 lines
Diff to previous 1.39 (colored)

Finnally move away from blocking reads in rpki-client. The code was a
mish mash of poll, non-blocking writes and blocking reads. Using the
introduced ibuf size header in io_buf_new()/io_buf_close() the read
side can be changed to pull in a full ibuf and only start the un-marshal
once all data has been read.
OK benno@

Revision 1.39 / (download) - annotate - [select for diffs], Fri Oct 15 22:30:33 2021 UTC (2 years, 7 months ago) by job
Branch: MAIN
Changes since 1.38: +1 -6 lines
Diff to previous 1.38 (colored)

zap 3 comments

Revision 1.38 / (download) - annotate - [select for diffs], Tue Oct 12 15:16:45 2021 UTC (2 years, 7 months ago) by job
Branch: MAIN
Changes since 1.37: +22 -11 lines
Diff to previous 1.37 (colored)

Emit SKI in the JSON output and improve flow in x509_get_pubkey()

OK claudio@

Revision 1.37 / (download) - annotate - [select for diffs], Mon Oct 11 16:50:03 2021 UTC (2 years, 7 months ago) by job
Branch: MAIN
Changes since 1.36: +116 -24 lines
Diff to previous 1.36 (colored)

Add support for BGPsec Router Certificates (RFC 8209)

BGPsec router keys are extracted from RPKI certificates and
emitted via the JSON output in base64 encoded form.

OK tb@ claudio@

Revision 1.36 / (download) - annotate - [select for diffs], Thu Oct 7 12:59:29 2021 UTC (2 years, 8 months ago) by job
Branch: MAIN
Changes since 1.35: +8 -5 lines
Diff to previous 1.35 (colored)

Make sure BGPsec router certs don't have a SIA

OK claudio@

Revision 1.35 / (download) - annotate - [select for diffs], Thu Oct 7 11:18:54 2021 UTC (2 years, 8 months ago) by job
Branch: MAIN
Changes since 1.34: +2 -2 lines
Diff to previous 1.34 (colored)

Clarify error message

OK benno@

Revision 1.34 / (download) - annotate - [select for diffs], Thu Oct 7 08:30:39 2021 UTC (2 years, 8 months ago) by claudio
Branch: MAIN
Changes since 1.33: +2 -1 lines
Diff to previous 1.33 (colored)

Add x509_get_expire() to extract the not-after time from a certificate
as a epoch time_t. Store the expire time for certs, crls will follow after.
OK tb@

Revision 1.33 / (download) - annotate - [select for diffs], Tue Oct 5 11:20:46 2021 UTC (2 years, 8 months ago) by job
Branch: MAIN
Changes since 1.32: +22 -8 lines
Diff to previous 1.32 (colored)

Add rudimentary support for BGPsec router certificates

OK claudio@

Revision 1.32 / (download) - annotate - [select for diffs], Thu Sep 9 14:15:49 2021 UTC (2 years, 8 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE
Branch point for: OPENBSD_7_0
Changes since 1.31: +24 -13 lines
Diff to previous 1.31 (colored)

Rework how various OIDs are compared in the code.

Instead of converting the ASN1_OBJECT into a string and comparing the
strings, convert the string into an ASN1_OBJECT once and then compare
these objects with OBJ_cmp().

Makes the code a bit easier to read and removes some repetitive conversions.
With input and OK tb@

Revision 1.31 / (download) - annotate - [select for diffs], Tue Jul 13 18:39:39 2021 UTC (2 years, 10 months ago) by job
Branch: MAIN
Changes since 1.30: +3 -24 lines
Diff to previous 1.30 (colored)

Add more checks for eContent 'version' fields.

Input from deraadt@, tb@, claudio@

OK deraadt@ claudio@ tb@

Revision 1.30 / (download) - annotate - [select for diffs], Thu May 27 09:41:02 2021 UTC (3 years ago) by job
Branch: MAIN
Changes since 1.29: +5 -5 lines
Diff to previous 1.29 (colored)

Fix more warnings

OK tb@

Revision 1.29 / (download) - annotate - [select for diffs], Thu May 27 09:01:08 2021 UTC (3 years ago) by job
Branch: MAIN
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

Fix warning

OK tb@

Revision 1.28 / (download) - annotate - [select for diffs], Fri Mar 5 17:15:19 2021 UTC (3 years, 3 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE
Branch point for: OPENBSD_6_9
Changes since 1.27: +15 -51 lines
Diff to previous 1.27 (colored)

Factor out the URI check we do in various places into valid_uri().
RRDP will add a bunch more checks so this makes even more sense.
With and OK tb@

Revision 1.27 / (download) - annotate - [select for diffs], Thu Feb 18 16:23:17 2021 UTC (3 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.26: +16 -11 lines
Diff to previous 1.26 (colored)

Use X509_get_ext_d2i() also for x509_get_aki() and x509_get_ski().
Now x509_get_extensions() is no longer required to loop over all
extensions and the code becomes a lot simpler.
While there cleanup x509_get_crl(), as explained by tb@ X509_get_ext_d2i()
allocates memory so one needs to free the pointer at the end.
For x509_crl_get_aki() use X509_CRL_get_ext_d2i() and more or less
copy the rest over from x509_get_aki().
Warn if extensions are missing or present when not expected and also
check the the extensions are marked non-critical as required.
OK job@ tb@

Revision 1.26 / (download) - annotate - [select for diffs], Tue Feb 16 07:58:30 2021 UTC (3 years, 3 months ago) by job
Branch: MAIN
Changes since 1.25: +9 -1 lines
Diff to previous 1.25 (colored)

get Authority Information Access (AIA) from CA & EE certs

In the context of the RPKI, the AIA extension identifies the publication
point of the certificate of the issuer of the certificate in which the
extension appears. A single reference to the publication point of the
immediate superior certificate MUST be present, except for a
"self-signed" certificate.

Thanks tb@ for review

OK claudio@

Revision 1.25 / (download) - annotate - [select for diffs], Mon Feb 8 09:22:53 2021 UTC (3 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.24: +52 -3 lines
Diff to previous 1.24 (colored)

Extract the 1.3.6.1.5.5.7.48.5 (caRepository) SIA from the certificate.
Make sure that the caRepository matches the start of the URI of rpkiManifest.
The MFT must be a file inside the caRepository.
OK tb@

Revision 1.24 / (download) - annotate - [select for diffs], Thu Feb 4 08:58:19 2021 UTC (3 years, 4 months ago) by claudio
Branch: MAIN
Changes since 1.23: +3 -2 lines
Diff to previous 1.23 (colored)

Eventhough most openssl includes include everything try to be a bit more
explicit about what is used where. Seems to be the least worst solution.

Revision 1.23 / (download) - annotate - [select for diffs], Fri Jan 29 10:13:16 2021 UTC (3 years, 4 months ago) by claudio
Branch: MAIN
Changes since 1.22: +7 -47 lines
Diff to previous 1.22 (colored)

A while ago rpki-client was changed to validate the sha256 hashes of
files referenced in MFT files during the validation of the MFT file.
An MFT is only valid if all files are present and their hashes are valid.
Because of this there is no longer the need to check the hash when
these files are parsed later on. Remove these checks for CRT, ROA and CRL
files. Use the presence of the pkey when parsing cert files to decide
if it is a root cert or not.
OK tb@

Revision 1.22 / (download) - annotate - [select for diffs], Fri Jan 8 08:09:07 2021 UTC (3 years, 5 months ago) by claudio
Branch: MAIN
Changes since 1.21: +24 -29 lines
Diff to previous 1.21 (colored)

Start using the ibuf API (ibuf_dynamic, ibuf_add, ibuf_close) for writing
data between processes. This completely decouples the write side.
rpki-client can't really use the imsg framework but it can use the ibuf
bits wich imsg is built on.
OK benno@ job@

Revision 1.21 / (download) - annotate - [select for diffs], Mon Dec 21 11:35:55 2020 UTC (3 years, 5 months ago) by claudio
Branch: MAIN
Changes since 1.20: +7 -18 lines
Diff to previous 1.20 (colored)

Now that a NULL string is marshalled as NULL again we can drop some
extra has_xyz integers to indicate if the following buffer is present
or not. At the same time sprinkle some asserts for strings which must
be not NULL.
OK tb@

Revision 1.20 / (download) - annotate - [select for diffs], Mon Dec 7 13:23:01 2020 UTC (3 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.19: +21 -2 lines
Diff to previous 1.19 (colored)

Limit the URL embedded in .cer files to only consist out of isalnum or
ispunct characters. Everything else is fishy and so block those early on.
OK millert@ job@

Revision 1.19 / (download) - annotate - [select for diffs], Sat Oct 24 08:09:39 2020 UTC (3 years, 7 months ago) by claudio
Branch: MAIN
Changes since 1.18: +12 -15 lines
Diff to previous 1.18 (colored)

Refactor sbgp_sia_resource_mft() similar to sbgp_sia_resource_notify().
Instead of rsync_uri_parse() check the start of the uri for rsync:// and
also check that the uri ends in .mft.
OK tb@

Revision 1.18 / (download) - annotate - [select for diffs], Sat Sep 12 15:46:48 2020 UTC (3 years, 8 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.17: +1 -2 lines
Diff to previous 1.17 (colored)

Include openssl/x509.h in extern.h since it uses a few of the typedefs from
there in structs and prototypes. Remove the openssl/ssl.h and other strange
openssl includes in the .c files that don't use openssl specific functions.
OK beck@ and tb@

Revision 1.17 / (download) - annotate - [select for diffs], Tue Jul 28 07:35:04 2020 UTC (3 years, 10 months ago) by claudio
Branch: MAIN
Changes since 1.16: +85 -45 lines
Diff to previous 1.16 (colored)

One tiny step towards adding RRDP support in rpki-client.
Extract the notify URL from the cert if it is available and pass it back to
the parent process. The parent process can then use this info to load the
repo via RRDP instead of rsync.
OK benno@ (some long time ago)

Revision 1.15.4.1 / (download) - annotate - [select for diffs], Mon Jul 27 14:30:30 2020 UTC (3 years, 10 months ago) by deraadt
Branch: OPENBSD_6_7
Changes since 1.15: +3 -4 lines
Diff to previous 1.15 (colored) next main 1.16 (colored)

Fix return value check for openssl API. Do not return success if pkey is NULL.

Feedback and ok cladio@
ok patrick@, tb@
this is 6.7/015_rpki.patch

Revision 1.16 / (download) - annotate - [select for diffs], Mon Jul 27 14:29:45 2020 UTC (3 years, 10 months ago) by tobhe
Branch: MAIN
Changes since 1.15: +3 -4 lines
Diff to previous 1.15 (colored)

Fix return value check for openssl API. Do not return success if pkey is NULL.

Feedback and ok cladio@
ok patrick@, tb@

Revision 1.15 / (download) - annotate - [select for diffs], Thu Apr 2 09:16:43 2020 UTC (4 years, 2 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE
Branch point for: OPENBSD_6_7
Changes since 1.14: +8 -2 lines
Diff to previous 1.14 (colored)

Use fopen() and BIO_new_fd() instead of BIO_new_file so that a possible
open error can be better logged to the operator. The cryptowarnx function
logs warnings is a less optimal way (mainly because of OpenSSL error stacks).
OK benno@ deraadt@

Revision 1.14 / (download) - annotate - [select for diffs], Wed Feb 26 02:35:08 2020 UTC (4 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)

ugly spaces offended me

Revision 1.13 / (download) - annotate - [select for diffs], Fri Nov 29 05:11:18 2019 UTC (4 years, 6 months ago) by benno
Branch: MAIN
Changes since 1.12: +8 -8 lines
Diff to previous 1.12 (colored)

commited at minus 21 degC
s/EXIT_FAILURE/1/
ok claudio@

Revision 1.12 / (download) - annotate - [select for diffs], Thu Nov 28 20:36:17 2019 UTC (4 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.11: +21 -1 lines
Diff to previous 1.11 (colored)

Convert the auths array into an RB tree indexed by SKI. For fast lookups
the parent auth struct is stored as a pointer so walking up the certificate
chain remains simple. Doing this replaces a few slow lookups and speeds up
rpki-client by a factor of 2.
OK benno@

Revision 1.11 / (download) - annotate - [select for diffs], Thu Nov 28 20:32:59 2019 UTC (4 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.10: +3 -2 lines
Diff to previous 1.10 (colored)

The root certs do not have a CRL distribution point extension so don't
try to fetch it.
OK benno@ (part of a larger diff)

Revision 1.10 / (download) - annotate - [select for diffs], Thu Nov 28 16:36:50 2019 UTC (4 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.9: +5 -176 lines
Diff to previous 1.9 (colored)

Use x509_get_crl() to get the crl distribution point out of the x509 cert.
Simplifies the code a fair bit.

Revision 1.9 / (download) - annotate - [select for diffs], Thu Nov 28 03:22:59 2019 UTC (4 years, 6 months ago) by benno
Branch: MAIN
Changes since 1.8: +4 -1 lines
Diff to previous 1.8 (colored)

To verify a manifest, a roa, or a certificate, we check its signature
against the CA one layer above it. This check just needs to use the
certificate revocation list published by that CA.

Instead of loading all CRLs we find into the trust store, we create a
STACK_OF(X509_CRL), push the onto it and use it with
X509_STORE_CTX_set0_crls(ctx, crls);

The x509_get_crl() function to retrieve a crl path from an X509 object
is written by claudio@.
ok claudio@

Revision 1.8 / (download) - annotate - [select for diffs], Wed Nov 27 17:08:12 2019 UTC (4 years, 6 months ago) by benno
Branch: MAIN
Changes since 1.7: +3 -1 lines
Diff to previous 1.7 (colored)

Only store ta certs in the trust store and build chains of the
intermediate certificates for use in X509_STORE_CTX_init(). To do that
save the X509 cert in struct cert.
claudio sees > 2x speed increase.

ok claudio@ and feedback from jsing@ and beck@.

Revision 1.7 / (download) - annotate - [select for diffs], Tue Aug 13 13:27:26 2019 UTC (4 years, 9 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.6: +5 -3 lines
Diff to previous 1.6 (colored)

Show the most common warnings only if verbose is set. Most of these warnings
were shown because of an inconsistent rpki database and is no real problem.
OK florian@

Revision 1.6 / (download) - annotate - [select for diffs], Thu Jun 20 13:50:03 2019 UTC (4 years, 11 months ago) by claudio
Branch: MAIN
Changes since 1.5: +44 -25 lines
Diff to previous 1.5 (colored)

Rewrite some if () { } else if () {} chains into multiple independent
if () blocks. Improves readability in my opinion since I skip some
branches to fast when reading.
OK deraadt@

Revision 1.5 / (download) - annotate - [select for diffs], Wed Jun 19 16:30:36 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.4: +1 -1 lines
Diff to previous 1.4 (colored)

use $OpenBSD$ headers

Revision 1.4 / (download) - annotate - [select for diffs], Wed Jun 19 04:21:43 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.3: +178 -191 lines
Diff to previous 1.3 (colored)

indentation adjustments, in particular near warn statements
ok claudio

Revision 1.3 / (download) - annotate - [select for diffs], Wed Jun 19 02:02:28 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.2: +3 -3 lines
Diff to previous 1.2 (colored)

swap comparisons

Revision 1.2 / (download) - annotate - [select for diffs], Mon Jun 17 15:04:59 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.1: +1 -2 lines
Diff to previous 1.1 (colored)

Don't do -portable in base.  It is better done outside the tree.
Imagine if we did it throughout the tree, how many copies of strlcpy
would we have, and how much time would all the configure shell scripts
and includes take?  It would be ludicrous.

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Mon Jun 17 14:31:30 2019 UTC (4 years, 11 months ago) by job
Branch: job
CVS Tags: job_20190617
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

Import Kristaps Dzonsons' RPKI validator into the tree

rpki-client(1) is an implementation of the Resource Public Key
Infrastructure (RPKI), specified by RFC 6480. The client is responsible
for downloading, validating and converting Route Origin Authorisations
(ROAs) into Validated ROA Payloads (VRPs). The client's output (VRPs)
can be used by bgpd(8) to perform BGP Origin Validation (RFC 6811).

The current rpki-client(1) version depends on the CMS functions in
OpenSSL, this of course needs to be addressed urgently.

Thanks to NetNod, IIS.SE, SUNET & 6connect for supporting this effort!

OK deraadt@

Revision 1.1 / (download) - annotate - [select for diffs], Mon Jun 17 14:31:30 2019 UTC (4 years, 11 months ago) by job
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.