Minimum deployment versions in package manifests can be problematic for
libraries, because changing them or adding them to an existing package
that doesn't already use them forces SemVer breaking majors.
Furthermore, depending on a new library that specifies minimum
deployment targets would force the adopting library to also have to add
these platforms to its manifest (which would in turn force a major).
This PR removes the platforms stanza from the package manifest and
replaces it with availability guards where necessary.
`swift-certificates` needed the platforms stanza because `swift-crypto`
forced it onto its adopters. After
https://github.com/apple/swift-crypto/pull/331, this isn't needed
anymore.
Motivation
While Ed25519 is not available in the WebPKI, there
are a number of contexts where it's an appropriate
signature algorithm for X.509. In those contexts,
we should allow the signature algorithm.
Modifications
Add support for Ed25519 keys and signatures.
Add unit tests
Result
Ed25519 support in the X509 certs
DistinguishedName was incorrectly marked DERImplicitlyTaggable,
but it isn't. DistinguishedName is our name for Name, which is
an untagged choice type. Untagged choice types can never be
implicitly tagged.
* `Custom[String|DebugString]Convertible` conformance
* save progress
* Apply new learned rules
debugDescription should be usable in structural display
* remove unused init
* remove unused properties
* Some fixups before review
* change description a bit around and respect RFC 2253
* add addition test
* fix license header and tests
* update allocation counters
* Add integer initialisers on `Certificate.SerialNumber`
`Certificate.SerialNumber` can now be constructed from any `FixedWidthInteger` and also from `StaticBigInt`
* `StaticBigInt` is only available in Swift 5.8
* Do not realloc storage if we trim leading zeros
RSA PSS isn't really deployed in the WebPKI, and with the recent
interest in post-quantum crypto it seems unlikely a new RSA padding
mode will be specified. Let's not allude to trying to support it.
* Police uniqueness of `Certificate.Extensions`
* use array storage
* Use linear scan to find duplicates
* Improve linear scan and remove `update(_:insertAt:)`
* fix tests
* remove `for` argument label and add test
* Make constructing Dates cheaper
Translating between Date and Time is expensive when we use
DateComponents, because we jump through ICU unnecessarily. We can
move over to standard UTC date math instead, which makes this
process vastly cheaper.
* CMakelists
* Code review
Currently, certificate verification is severely bottlenecked on
expiry checking. This bottleneck is almost entirely caused by converting
Time objects into Date objects via DateComponents.
We can reduce the cost of this by doing fewer transformations. Instead
of converting all the Time objects to Dates, we can convert a Date to
a GeneralizedTime and then do all comparisons in GeneralizedTime space.
This vastly reduces the cost of cert validation.
This patch fixes up an issue where a signature produced from raw form
will have a different in-memory representation from the same one
deserialized from the network.
* Support PEM serialisation and parsing for `Certificate`, `Certificate.PublicKey` and `Certificate.PrivateKey`
* Fix Linux build
* Fix tests on Linux
and required watchOS version
* run ./scripts/update_cmakelists.sh
* add proper support for private RSA keys
* Fix review comments
* replace `as Any` with `String(describing:)`
This patch modifies the ECDSA signature representation internally to
avoid eagerly creating the Crypto type. This is necessary because we
can't actually know what key created the signature when we parse it.
As a result we have to defer actually doing that until we actually get a
key type, at which point we can create the underlying key type.
This is a bit less efficient for us overall, but it solves a long-tail
problem in the WebPKI that is more likely to increase in frequency over
time.
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.
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.