Commit Graph
49 Commits
Author SHA1 Message Date
Rick Newton-Rogers d016643222 Migrate to GitHub Actions reusable workflows (2) (#74)
* Prepare repo for new GHA checks

Motivation:

Migrate to GitHub Actions reusable workflows (2)

Modifications:

* Add GHA PR label checks
* Add GHA benchmarks checks
* Satisfy soundness checks

Result:

New soundness checks should be green and ready for adoption

* review comments
2024-10-15 13:04:58 +01:00
Peter AdamsandCory Benfield aeb9c927fd More Sendability annotiations (#72)
Motivation:

Completing annotations helps with coverage for consuming projects.

Modifications:

Mark more things and Sendable or not.

Result:

Consuming libraries more likely to get correct usage.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-10-14 10:49:11 +00:00
aryan-25 a6cdd4d974 Add support for CRLF line endings to PEMDocument (#68)
* Add support for CRLF line endings to `PEMDocument`

* Remove `lineEnding` as an argument and instead detect line ending automatically.

* Fix description

* Refactor
2024-10-09 10:38:02 +01:00
Paul SeligmanandPaul Seligman dd8cacc283 Update code to compile without issue when ExistentialAny enabled (#63)
Motivation:

We should feel confident that we compile clean when built in an environment
that has enabled upcoming Swift features.

When compiling swift-asn1 specifying `.enableUpcomingFeature("ExistentialAny")`
there are some minor warnings emitted by ASN1.swift.

Modifications:

Minor code changes to address surfaced warnings

Result:

Better confidence that we don't break downstreams that compile this code with
these upcoming features enabled.

Co-authored-by: Paul Seligman <pseligman@apple.com>
2024-09-13 23:59:52 -07:00
Clinton Nkwocha 41bee14cff Add rawFractionalSeconds property to GeneralizedTime (#53)
Motivation:

There is a possible overflow when computing a `Double` value for `fractionalSeconds` from an `ArraySlice` of bytes. Hence, access to this original `ArraySlice` is necessary.

Modifications:

- Add `rawFractionalSeconds` property to `GeneralizedTime`.
- Add a new `internal init` to `GeneralizedTime` that accepts `rawFractionalSeconds` instead of `fractionalSeconds` and generates the later from the former.
- Adjust the algorithm for computing `fractionalSeconds`, from a mathematical to a `String` computation. This is due to the precision mismatch between the mathematical computation and the native `Double` computation. This issue, which previously did not surface, now does, due to the newly included round-trip conversion from `fractionalSeconds` to `rawFractionalSeconds`.

Result:

- The `rawFractionalSeconds` property now provides the original `ArraySlice` from which `fractionalSeconds` was computed.
- `GeneralizedTime` can now compute `fractionalSeconds` from the provided `rawFractionalSeconds`.
2024-06-19 08:26:50 -07:00
aryan-25andCory Benfield e61ef9579a Add initializers for ASN1ObjectIdentifier (#56)
* Add initializers for ASN1ObjectIdentifier

* Added comments to public symbols. Updated error name.

* Add new Substring initializer. Refactor UInt Collection initializer.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-06-18 06:18:58 -07:00
David Zech 28d0e0717f Add support for parsing BER (#42) 2023-10-02 14:42:33 +01:00
David Nadoba 12c24ff59d Support multi PEM parsing and speed up PEM parsing in general (#39)
* Multi PEM support

* Multi PEM support

* swift-format

* Apply review feedback
2023-09-18 03:20:51 -07:00
David Nadoba 49557d7f0a Fix docs: constructed is no longer part of ASN1Identifier (#40) 2023-09-15 18:11:12 +01:00
David Nadoba d5636be054 remove outdated TODO (#38) 2023-08-25 10:50:10 +01:00
David Nadoba ef712c4268 Remove deprecated API (#37) 2023-08-22 11:08:52 +01:00
David Nadoba ce1faa434b Make ASN1ObjectIdentifiers internal representation be the encoded form (#36)
* Make `ASN1ObjectIdentifier`s internal representation be the encoded form

* validate during initialisation

* swift-format

* formatting
2023-08-17 15:53:25 +01:00
David Nadoba 43e0170e65 Adopt apple/swift-format (#35)
* default swift-format configuration

* Adopt `apple/swift-format`

* Fix soundness.sh

* Fix linting warnings

* update license header

* Apply review comments
2023-08-11 09:42:48 +01:00
David Nadoba 4758353894 Support macOS 10.14.x/iOS 12.x and older again (#34)
* Support macOS 10.14.x/iOS 12.x and older again

* Revert "Support macOS 10.14.x/iOS 12.x and older again"

This reverts commit 6eeba0327f.

* Erase concrete type manually
2023-07-03 10:25:35 +01:00
David Nadoba 0c33f188a8 Make IntegerBytesCollection conditionally Sendable (#33) 2023-06-30 12:09:52 +01:00
David Nadoba 8dd3d3192f Add method to lazily parse a SET from a ASN1Node (#32)
### Motiviation
We want reduce allocations in swift-certificates and need a way to parse without allocating an intermediate `Array`.

### Modifications
add `DER.lazySet(of:identifier:rootNode)` which returns its result without allocating.

### Result
We can eliminate allocations during parsing
2023-06-29 14:08:10 +01:00
Cory Benfield 748ece52a8 Avoid using stride(from:to:by:).reversed() (#31)
While this is a nice clear construction, it also has to allocate a temporary
Array, as the StrideTo type is not a BidirectionalCollection but a Sequence.
2023-05-24 09:32:27 +01:00
Cory Benfield 0700d170e8 Fix bug in comparing Generalized and UTC Time (#30)
The prior time comparison did not correctly handle wildly different
times. This patch resolves the issue.
2023-05-18 09:53:54 +01:00
Cory Benfield 1c5387a7ff Make GeneralizedTime and UTCTime Comparable. (#29)
In many cases it's useful to be able to place these into a total order.
This patch adds support for ordering them.
2023-05-18 07:31:59 +01:00
David Nadoba c43fef6dc0 Make PEMDocument Hashable (#28)
* Make `PEMDocument` `Hashable`

* Add `Sendable`
2023-04-21 10:36:29 +01:00
David Nadoba a53d9f676c Add PEM support through PEMRepresentable (#26)
* Add proper PEM support through `PEMRepresentable`

* Fix review comment and add more documentation

* Fix review comments

* Remove `allowedPEMDiscriminators`
2023-04-19 09:55:17 +01:00
Joey b3aaa046fa Documentation - Typos (#24) 2023-04-11 00:39:26 -07:00
Dave Poirier 155b8acdb2 Changed scope of PEMDocument to public (#22) 2023-03-23 10:30:15 +00:00
Cory Benfield 8fb2cd7edc Add support for serializing raw bytes.
In rare cases it's necessary for users to be able to do an end-run
around the serializer. This is most common in cases where some bytes
have had a signature calculated over them, and they are being
re-encoded. Even though DER is unambiguous, the ASN.1 objects themselves
may not be, and may permit multiple valid encodings. Allowing the bytes
to be re-serialized as they were preserves the integrity of the
signature.
2023-03-08 09:06:29 +00:00
Saleem Abdulrasool eb470005ae build: add in dispatch search (#18)
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.
2023-03-02 20:25:25 -08:00
David Nadoba 9d9a8a0c35 Fix review comments 2023-02-10 10:34:13 +01:00
David Nadoba 3794ff4734 Add < again 2023-02-09 06:59:35 +01:00
David Nadoba 321a1076ac Fix review comments 2023-02-08 18:09:17 +01:00
David Nadoba e5ebc6fcb6 rename ASN1BytesComparable to ASN1SetElement 2023-02-08 15:45:29 +01:00
David Nadoba 70d18b6847 SET OF de/serialization 2023-02-07 14:19:10 +01:00
Cory Benfield 658011c966 Further code review 2023-02-06 10:41:39 +00:00
Cory Benfield 85d12f6c3b Code review feedback 2023-02-06 10:24:04 +00:00
Cory Benfield 0fa1d76282 Move to struct-backed error pattern 2023-02-03 10:37:10 +00:00
David Nadoba 4363483e72 Add support for implicitly tagged optional fields 2023-02-02 14:49:58 +01:00
Yim Lee 4009d67f25 Add license header check for cmake files 2023-01-25 15:56:37 -08:00
Yim Lee 0f873377cd Set up CMake build 2023-01-25 13:49:19 -08:00
David Nadoba cfeb75ac80 Fix soundness
File extension of the CONTRIBUTORS file is `.txt` not `.md`
2022-11-30 11:17:30 +01:00
David Nadoba 080ce9bdc8 Use correct project name in license header
And add missing header in one file
2022-11-24 22:52:31 +01:00
Cory Benfield eb11d30c1d Remove constructed/primitive from the tag type
Constructed/primitive is an artefact of the encoder, not of the tag, so
we should remove it from the tag type itself.
2022-11-18 15:33:46 +00:00
Cory Benfield 8fb2002b4f Clarify unexpectedFieldType 2022-11-18 14:43:36 +00:00
Cory Benfield d52b14f90f Tolerate single-component OIDs 2022-11-18 14:42:26 +00:00
Cory Benfield a8bcd18f13 Simpler OID decoder 2022-11-17 18:42:47 +00:00
Cory Benfield e30f8d297d Move testing types to tests 2022-11-17 17:53:20 +00:00
Cory Benfield 10327060c5 Miscellaneous cleanups 2022-11-17 17:30:23 +00:00
Cory Benfield 5d785ab44a Clean up some typos 2022-11-17 17:25:02 +00:00
Cory Benfield 099c2574e3 Remove the ASN1 namespace 2022-11-17 17:20:09 +00:00
Cory Benfield 87aa5246b2 Better ASN1Any printed representation 2022-11-17 09:47:55 +00:00
Cory Benfield 11f0617fac Better OID string representation 2022-11-16 16:41:23 +00:00
Cory Benfield 81b7d4dc72 Initial commit 2022-11-15 10:31:11 +01:00