- **Fix stale DocC disambiguation hash for PrivateKey init**
- **Fix documentation errors, typos, and a bug in
CertificateStore.appending**
- **code example fixes within the existing articles:**
- **Lots of smaller fixes across the board - some copy/pasta errors,
consistency in usage, typos and grammar issues - added documentation
comments where missing to get all public types covered - applied
internal style guidelines for representing the types**
---------
Co-authored-by: David Nadoba <dnadoba@gmail.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: Raphael <josephnoir@users.noreply.github.com>
## Summary
- Fixed typo in `SignatureAlgorithm.swift:180`: "unsupprted" →
"unsupported"
## Details
The error message thrown when an unsupported signature algorithm value
is encountered contained a spelling error. This has been corrected.
## Test plan
- Existing tests continue to pass
- The error message is only shown when an invalid algorithm is used, so
no new tests are needed
### Motivation:
When loading a private key from disk as a `Certificate.PrivateKey` there
is no straight forward way to query the supported signature algorithms.
For signature algorithm negotiation, the raw values defined in RFC are
useful as well.
### Modifications:
Add a new property to query the supported signature algorithms for a
given key. Add a new property that translates a signature algorithm to
the respective value defined in RFC 8446.
### Results:
Working with certificate private keys and signature algorithms gets
easier.
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.
Most of the time, the signature algorithm that should be used is
dictated by the type of the private key.
* Ed25519 keys support only one signature algorithm.
* RFC 5753 section 8 recommends that "[the P-256 curve] be used with
SHA-256; the P-384 curve be used with SHA-384; and the P-521 curve be
used with SHA-512".
* RSA keys support 4 signature algorithms. But most people use RSA with
SHA-256 and nobody should use RSA with SHA-1 anymore.
More over, Certificate.PrivateKey is opaque to the user, who may not
know what type of private key they're using and what the appropriate
signature algorithm is.
For those reasons, we add convenience wrappers around methods with a
signature algorithm to provide a reasonable default value.
---------
Co-authored-by: Cory Benfield <lukasa@apple.com>
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
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.