* Add `Certificate.PrivateKey` description
and update `Certificate.PublicKey` description to disambiguate from private keys.
* secure enclave is only a thing on darwin
* update tests
Motivation:
PublicKey doesn't conform to DERImplicitlyTaggable which was an oversight during development.
Modifications:
Add conformance to DERImplicitlyTaggable, PEMSerializable, and PEMParsable.
Result:
PublicKey is DERImplicitlyTaggable.
Co-authored-by: David Nadoba <d_nadoba@apple.com>
Motivation
We prefer issuers that have a subject key identifier that matches the authority key identifier of the certificate for which were are searching for an issuer. However, currently we have flipped this sort order.
Modifications
Flip preference order
update test
add test which would previously fail
Result
We actually prefer certificates in the order described above.
Note that this is just a performance improvement.
Co-authored-by: Cory Benfield <lukasa@apple.com>
### Motivation
We have used `ASN1ObjectIdentifier` with just one component in tests but they need at least two components. `swift-asn1` has recently changed the initialiser to enforce this during initialisation time if initialised from a literal. Therefore our tests currently crash.
### Modifications
This PR changes all of our test `ASN1ObjectIdentifier`s to have at least two components.
### Results
Tests no longer crash
Only non-self-issued certificates count against the maxPathLength limit.
RFC Section 4.2.1.9. Basic Constraints:
> [...]
> The pathLenConstraint field is meaningful only if the cA boolean is
> asserted and the key usage extension, if present, asserts the
> keyCertSign bit (Section 4.2.1.3). In this case, it gives the
> maximum number of non-self-issued intermediate certificates that may
> follow this certificate in a valid certification path. (Note: The
> last certificate in the certification path is not an intermediate
> certificate, and is not included in this limit. Usually, the last
> certificate is an end entity certificate, but it can be a CA
> certificate.) A pathLenConstraint of zero indicates that no non-
> self-issued intermediate CA certificates may follow in a valid
> certification path. Where it appears, the pathLenConstraint field
> MUST be greater than or equal to zero. Where pathLenConstraint does
> not appear, no limit is imposed.
> [...]
> https://www.rfc-editor.org/rfc/rfc5280#section-4.2.1.9
Co-authored-by: Cory Benfield <lukasa@apple.com>
* `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
### Motivation
`debugDescription` name and documentation is confusing and should be changed but it is today expected to be suitable to be used as part of a structured display e.g. to be printed as part of `struct` or `enum` with associated values. Therefore it should have no unpaired parentheses, no unescaped quotes and no top-level commas.
### Modifications
- let `debugDescription` simply contain the same contents as `description` but suitable for structural display as described above.
- add a new `multilineDescription` which contains the same contents as the `description` but breaded down on multiple lines for better readability.
* Support hard failures from OCSPRequester
* rename error result methods to nonTerminalError and terminalError from softFailure and harFailure
* rename query result in tests as well
* Update Sources/X509/OCSP/OCSPPolicy.swift
Co-authored-by: Franz Busch <privat@franz-busch.de>
* Add warning
---------
Co-authored-by: Franz Busch <privat@franz-busch.de>
* Store `String` in `RelativeDistinguishedName.Attribute` instead of `ASN1Any` if possible
* Add Equatable and Hashable test
* fix typo
* remove trys
* Apply review feedback
* update allocation numbers
* Setup allocation test framework
* Add allocation test that decodes all WebPKI Roots
* Replace _WebPKI with inline PEM strings
* Fix test
* implement `TinyArray`
* save progress with local ASN.1 dependency
465 allocs
* Implement lazySet in swift-certificates
* test on all WebPKI roots
* Revert "test on all WebPKI roots"
This reverts commit 4af11bb087.
* remove PerformanceTests
* Add tests for TinyArray
* revert changes
* delete unused test
* Implement TinyArray
* update cmake
* “Hide” enum and support storing arrays of exactly one element in `.arbitrary`
* Add allocation tests for TinyArray
* make arrays of different sizes
* Remove array optimisation
* run append in a loop
* Move _TinyArray into a separate module
and apply review feedback
* update cmake files
* remove unused Foundation import
* Allocations are lower by “1” on Linux
* import new module
* Add loop
* update allocation numbers for Linux
* replace with do/catch with try!
* Fix copyright
* update allocations
* Move lazySet to swift-asn1
* update allocation counters
* Fix `update-alloc-limits-to-last-completed-ci-build`
* Use concrete type
* 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
* Setup allocation test framework
* Add allocation test that decodes all WebPKI Roots
* Replace _WebPKI with inline PEM strings
* Fix test
* revert changes
* delete unused test
* Add loop
* update allocation numbers for Linux
* replace with do/catch with try!
* Implement TinyArray
* update cmake
* “Hide” enum and support storing arrays of exactly one element in `.arbitrary`
* Add allocation tests for TinyArray
* make arrays of different sizes
* Remove array optimisation
* run append in a loop
* Move _TinyArray into a separate module
and apply review feedback
* update cmake files
* remove unused Foundation import
* Allocations are lower by “1” on Linux
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.
* We don’t need to maintain uniqueness
* Police uniqueness of `ExtendedKeyUsage`
* use new error case
* call `insert` from `append`
* refactor duplication finding algorithm into reusable method
* 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
The "from parts" Certificate constructor has existed for a while. As noted
in the docstring, it was originally added for testing and validation
purposes. However, it's not very useful for that purpose.
For one thing, many of the constitutuent parts are not actually directly
constructible. For example, one cannot create a Signature type directly.
For another thing, invalid Certificate handling tests probably want to be
able to construct Certificates that are invalid in a number of interesting
ways, and so will want to use the DER representation to do so.
As a result, this intializer is not broadly useful: even this library
doesn't use it for testing. Let's remove it.
* 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