* Add support for policing critical extensions
We are required to ensure that we do not validate chains that contain
certificates with extensions marked critical that we do not understand.
Because we allow pluggable policies which can handle arbitrary
extensions, we need a way to ask verifier policy objects what extensions
they can handle.
This patch adds support for policies to express that set, as well as for
the verifier to ensure that certificates that have critical extensions
we cannot understand are not used for chain building. This is integrated
early into chain building to reject unsatisfiable chains, and works
transparently.
This PR also updates the tests to meet this new standard, including
applying the RFC 5280 policy liberally throughout the test suite.
* Don't forget the leaf!
* Rename property
* Remove Sendable
This patch ties together the various checks we have already written into
a single NameConstraintsPolicy, and attaches it to the RFC5280Policy.
This includes defining the logic for traversing names, as well as for
managing the excluded and permitted subtrees.
Unfortunately, this patch is giant. I wish I could do more about it, but
fundamentally the majority of the code it adds is tests, and those tests
are all necessary.
Just to round things out we can add directory name constraints. There's
nominally a fairly complex algorithm for validating directory name
constraints, but most implementations don't bother, instead falling back
to direct matches.
This is the last of the major constraint types we intend to support
initially in name constraints. Mostly URIs leverage the domain name
support, but we do have a need to parse URIs in order to extract their
host component.
`Certificate.SerialNumber.init()` could produce a number where the first byte(s) could be zero(s). We strip them during encoding and will not and can’t reconstruct them after decoding. Therefore a serial number might no longer be equal to itself after a de/serialisation roundtrip. We have observed this behaviour to cause problems in the OCSP test suite with random test failures. This fixes it.
This updates Swift Crypto to 2.4.0 and fixes RSA key serialization on
all platforms. It also adds a defensive check that we only accept
appropriately-formatted RSA keys, and some regression tests.
This PR adds support for handling domain name constraints. Specifically,
it adds the infrastructure for doing so, but doesn't wire it up into a
useful policy. This will follow in a later PR.
When we decode a certificate, we produce an in-memory representation.
This representation is something we are capable of encoding. If we
re-encode that directly, we can produce an output that is different to
the one we injested. This happens when there are objects that can be
canonicalised, such as replacing an explicit ASN1 NULL with an absent
field where both are considered equivalent.
This patch rewrites the code to ensure that we preserve the bytes of the
certificate that we deserialized. This allows us to write them back
unchanged, ensuring that certificates can round-trip through this
library without modification.
A side-effect of this change is that we need to essentially encode the
certificate on construction whenever we build them in memory. That's not
a big deal, but it is a bit of an annoyance.
This is the first of a series of PRs that adds support for RFC 5280
policies as a single verifier policy. For now we take the low hanging
fruit, expiry.
This patch adds support for basic CMS operations. We aren't sure that
the API surface here is right, so for now we're going to provide this
under an SPI guard so that we can make any amendments we might need.
When building against a build tree artifact for Foundation, we need to add the build tree artifacts of dispatch as that is an exposed dependency for Foundation.
Motivation
We omitted RSA signing in the initial implementation. We should support
it.
As part of this, we need to decouple the idea that we know what the
digest algorithm is based solely on the key type. There's no particular
reason not to support ECDSA with SHA256 when using a P521 key, so we
need to tolerate that as well.
Modifications
- Explicitly pass the signature algorithm to our various cryptographic
operations.
- Add a Digest type to handle the various digest types we create.
- Add tests for the various cross products.
Results
RSA signing works, as do weirder flavours of ECDSA.