14 Commits
Author SHA1 Message Date
eaa10d47d1 documentation updates (#296)
- **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>
2026-06-15 13:04:58 -07:00
LamTrinh.Dev e9312a35a3 Fix typo in SignatureAlgorithm error message. (#295)
## 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
2026-04-17 19:59:50 +00:00
Raphael 23b6a15b5d Expose supported signature algorithms for private keys (#281)
### 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.
2025-11-18 14:16:22 +00:00
Gus Cairo 9ad2ac038e Add visionOS support (#244) 2025-04-08 13:35:11 +00:00
Gus Cairo 4c305e3205 Add macCatalyst to available platforms (#242) 2025-04-08 13:25:54 +01:00
Gus Cairo bd5987524c Replace platforms from Package manifest with availability guards (#232)
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.
2025-03-10 14:31:15 +00:00
Nicolas BachschmidtandCory Benfield eaed0355dc Add default value for signature algorithm (#221)
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>
2025-01-27 11:03:56 +00:00
Cory Benfield 27c6b0fcfa Add support for Ed25519 certificates (#205)
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
2024-10-30 13:30:13 +00:00
Mark SchallandFranz Busch abe0f0b248 Fixing SHA512 in comment (#196)
Co-authored-by: Franz Busch <f.busch@apple.com>
2024-09-11 05:37:44 -07:00
David Nadoba 45ad9935c7 Adopt apple/swift-format (#121)
* Adopt `apple/swift-format`

* install swift-format

* set `UseSynthesizedInitializer` to `false` until bug is fixed https://github.com/apple/swift-format/issues/591

* fix license header

* Fix license header
2023-08-16 11:17:34 +01:00
Cory Benfield 8458a4ff72 Enable RSA signing support.
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.
2023-02-10 16:55:39 +00:00
David Nadoba 4feb081b42 Fix soundness
File extension of the CONTRIBUTORS file is `.txt` not `.md`.
Add missing license header to some files.
2022-11-30 11:28:42 +01:00
David Nadoba 763ea6435a Add docker compose files and scripts for CI
and use correct license header name
2022-11-28 11:38:15 +01:00
Cory Benfield 42be2505cc Initial commit 2022-11-16 15:50:52 +01:00