Commit Graph
37 Commits
Author SHA1 Message Date
arya dradjica 3dbc814011 [CI] Check required-features of examples in parallel 2025-08-01 17:27:41 +02:00
Martin HoffmannandGitHub a35f0fc733 Trigger CI on default pull-request activity types. (#549)
This PR changes the CI trigger for pull requests to use the default activity types which – the Internet claims – is “open,” “synchronize,” and “reopen.”
2025-06-27 15:18:46 +02:00
arya dradjica 3165d146d3 [CI] Use the right Rust toolchain 2025-06-25 16:44:11 +02:00
arya dradjica e303272e2c [CI] make the 'cache' job actually write to the cache 2025-06-25 16:26:56 +02:00
arya dradjicaandGitHub c6d934038a Rewrite the CI pipeline (#536)
- Automatically determine the MSRV.
- Rebuild 'main' every week to catch environmental changes.
- Run Clippy in a dedicated job to be more parallel.
  - Only run it on Ubuntu.
- Introduce caching of '~/.cargo' and '/target'.
  - Only save it on 'main', but restore it in all other jobs.
- Preserve OpenSSL-excluding behavior for Windows.
2025-06-25 14:23:28 +00:00
arya dradjicaandarya dradjica d2192ea769 Disable OpenSSL for Windows CI 2025-06-25 09:45:26 +00:00
arya dradjicaandGitHub 54886e047b Change the MSRV policy and bump to 1.79.0 (#480)
The MSRV is being bumped so that `domain` can access newer language features.  In particular:

- `<[u8]>::utf8_chunks()` (1.79) is very useful for processing byte strings that will _mostly_ contain valid UTF-8 text.
- `core::net` (1.77) allows us to remove our polyfills of `Ipv4Addr` etc., used when the `std` feature is disabled.
- `async fn` and return-position `impl Trait` in traits (1.75) allow us to define traits using `async fn`, avoiding the overhead of `Box<dyn Future>` for un-nameable future types.
- `Option::is_some_and()` (1.70) simplifies a very common pattern when inspecting optional values.

The MSRV bump policy is also being updated; it sets a maximum MSRV (relative to the latest stable Rust version) and documents the conditions under which a bump will occur.
2025-01-22 11:22:02 +01:00
Ximon EighteenandGitHub 39a04b6f6a Don't run CI checks twice per push to PR branches. (#439) 2024-11-11 12:35:07 +01:00
Ximon EighteenandGitHub b137d5bac6 Add missing required features to Cargo.toml for examples (#432)
* Add missing required features to serve-zone example.

* Fix required-features listed in Cargo.toml for the query-zone example.

* Fix required-features listed in Cargo.toml for the client-transports example.

* Echo all run commands to check examples, and exit immediately on error (also ensures a final success doesn't cause previous failures to be ignored).

* Fix required-features listed in Cargo.toml for the server-transports example.

* Remove unused import except when feature is enabled that needs it.
2024-11-08 14:16:46 +01:00
Ximon EighteenandGitHub 41fef2849a Check example compilation in the CI workflow. (#438) 2024-11-08 12:13:25 +01:00
8e8d616ee2 Loading, storing, and generating DNSSEC keys (#406)
* [sign] Define 'KeyPair' and impl key export

A private key converted into a 'KeyPair' can be exported in the
conventional DNS format.  This is an important step in implementing
'ldns-keygen' using 'domain'.  It is up to the implementation modules
to provide conversion to and from 'KeyPair'; some impls (e.g. for HSMs)
won't support it at all.

* [sign] Define trait 'Sign'

'Sign' is a more generic version of 'sign::key::SigningKey' that does
not provide public key information.  It does not try to abstract over
all the functionality of a keypair, since that can depend on the
underlying cryptographic implementation.

* [sign] Implement parsing from the DNS format

There are probably lots of bugs in this implementation, I'll add some
tests soon.

* [sign] Provide some error information

Also fixes 'cargo clippy' issues, particularly with the MSRV.

* [sign] Move 'KeyPair' to 'generic::SecretKey'

I'm going to add a corresponding 'PublicKey' type, at which point it
becomes important to differentiate from the generic representations and
actual cryptographic implementations.

* [sign/generic] Add 'PublicKey'

* [sign] Rewrite the 'ring' module to use the 'Sign' trait

Key generation, for now, will only be provided by the OpenSSL backend
(coming soon).  However, generic keys (for RSA/SHA-256 or Ed25519) can
be imported into the Ring backend and used freely.

* Implement DNSSEC signing with OpenSSL

The OpenSSL backend supports import from and export to generic secret
keys, making the formatting and parsing machinery for them usable.  The
next step is to implement generation of keys.

* [sign/openssl] Implement key generation

* [sign/openssl] Test key generation and import/export

* [sign/openssl] Add support for ECDSA

* [sign/openssl] satisfy clippy

* [sign/openssl] Implement the 'Sign' trait

* Install OpenSSL in CI builds

* Ensure 'openssl' dep supports 3.x.x

* [workflows/ci] Use 'vcpkg' instead of vendoring OpenSSL

* Ensure 'openssl' dep exposes necessary interfaces

* [workflows/ci] Record location of 'vcpkg'

* [workflows/ci] Use a YAML def for 'VCPKG_ROOT'

* [workflows/ci] Fix a vcpkg triplet to use

* Upgrade openssl to 0.10.57 for bitflags 2.x

* [workflows/ci] Use dynamic linking for vcpkg openssl

* [workflows/ci] Correctly annotate 'vcpkg'

* [sign/openssl] Implement exporting public keys

* [sign/ring] Implement exporting public keys

* [sign/generic] Test (de)serialization for generic secret keys

There were bugs in the Base64 encoding/decoding that are not worth
trying to debug; there's a perfectly usable Base64 implementation in
the crate already.

* [sign] Thoroughly test import/export in both backends

I had to swap out the RSA key since 'ring' found it to be too small.

* [sign] Remove debugging code and satisfy clippy

* [sign] Account for CR LF in tests

* [sign/openssl] Fix bugs in the signing procedure

- RSA signatures were being made with an unspecified padding scheme.
- ECDSA signatures were being output in ASN.1 DER format, instead of
  the fixed-size format required by DNSSEC (and output by 'ring').
- Tests for signature failures are now added for both backends.

* Refactor the 'sign' module

Most functions have been renamed.  The public key types have been moved
to the 'validate' module (which 'sign' now depends on), and they have
been outfitted with conversions (e.g. to and from DNSKEY records).

Importing a generic key into an OpenSSL or Ring key now requires the
public key to also be available.  In both implementations, the pair are
checked for consistency -- this ensures that both are uncorrupted and
that keys have not been mixed up.  This also allows the Ring backend to
support ECDSA keys (although key generation is still difficult).

The 'PublicKey' and 'PrivateKey' enums now store their array data in
'Box'.  This has two benefits: it is easier to securely manage memory
on the heap (since the compiler will not copy it around the stack); and
the smaller sizes of the types is beneficial (although negligibly) to
performance.

* Move 'sign' and 'validate' to unstable feature gates

* [workflows/ci] Document the vcpkg env vars

* Rename public/secret key interfaces to '*Raw*'

This makes space for higher-level interfaces which track DNSKEY flags
information (and possibly key rollover information).

* [sign/ring] Store the RNG in an 'Arc'

* [validate] Enhance 'Signature' API

* [validate] Add high-level 'Key' type

* [sign/openssl] Pad ECDSA keys when exporting

Tests would spuriously fail when generated keys were only 31 bytes in
size.

* [validate] Implement 'Key::key_tag()'

This is more efficient than allocating a DNSKEY record and computing
the key tag there.

* [validate] Correct bit offsets for flags

* [validate] Implement support for digests

The test keys have been rotated and replaced with KSKs since they have
associated DS records I can verify digests against.  I also expanded
Ring's testing to include ECDSA keys.  The validate module tests SHA-1
keys as well, which aren't supported by 'sign'.

* [validate] Enhance BIND format conversion for 'Key'

Public keys in the BIND format can now have multiple lines (even with
comments).  Keys can also be directly written into the BIND format and
round-trips to and from the BIND format are now tested.

* [sign] Introduce 'SigningKey'

* [sign] Handle errors more responsibly

The 'openssl' and 'ring' modules should now follow the contributing
guidelines regarding module layout and formatting.

* [sign] correct doc link

* [sign/openssl] Replace panics with results

* remove 'sign/key'

* [sign] Introduce 'common' for abstracting backends

This is useful for abstracting over OpenSSL and Ring, so that Ring can
be used whenever possible while OpenSSL is used as a fallback.  This is
useful for clients that just wish to support everything.

* [sign/generic] add top-level doc comment

* [validate] debug bind format errors

* [validate] more debug statements

* [validate] format DNSKEYs using 'ZonefileFmt'

The 'Dnskey' impl of 'fmt::Display' was no longer accurate to the zone
file format because 'SecAlg' now prints '<code>(<mnemonic>)'.

* Reorganize crate features in 'Cargo.toml'

* [sign] Add key generation support for Ring

It's a bit hacky because it relies on specific byte indices within the
generated PKCS8 documents (internally, Ring basically just concatenates
bytes to form the documents, and we use the same indices).  However,
any change to the document format should be caught by the tests here.

* [sign] Make OpenSSL support optional

Now that Ring and OpenSSL support all mandatory algorithms, OpenSSL is
no longer required in order to provide signing functionality.

* [sign] Rename 'generic::SecretKey' to 'KeyBytes'

* [sign] Rename 'SecretKey' to 'KeyPair' in all impls

* [sign] Rename 'KeyBytes' to 'SecretKeyBytes'

For consistency with the upcoming 'PublicKeyBytes'.

* [validate] Rename 'RawPublicKey' to 'PublicKeyBytes'

* [sign/ring] Remove redundant imports

* [sign,validate] Add 'display_as_bind()' to key bytes types

* [sign,validate] remove unused imports

* [sign] Document everything

* [lib] Rewrite feature flag documentation

* [workflows/ci] Use 'apt-get' instead of 'apt'

* [sign] Clarify documentation as per @ximon18

* [sign] Use 'secrecy' to protect private keys

* [sign] Improve documentation and examples

---------

Co-authored-by: arya dradjica <arya@nlnetlabs.nl>
2024-11-05 13:57:55 +01:00
Martin HoffmannandGitHub c421dc89f2 Proposal for a MSRV policy. (#330)
This PR proposes a revised policy for dealing with minimum supported Rust
versions.

It suggests to keep the rust-version field in Cargo.toml at the oldest Rust
version that is able to build with minimal dependency versions and all
features enabled. In addition, the Rust version necessary to build with
latest dependencies is provided in the README and as a comment in
Cargo.toml. Both these versions are checked in the CI workflow.

The reasoning behind the proposal is that rust-version sets a hard limit on
the version, so it should be chosen as low as possible. While technically it
could be lower with a subset of the features selected, this feels like a
slippery slope and setting the version with all features selected feels like
an acceptable compromise.

Only documenting the version that is necessary to build with latest
dependencies isn’t ideal but at least provides some guidance as to what to
choose for people who go look for some.
2024-06-20 14:34:15 +02:00
Terts DiepraamandGitHub 30b7b99030 bump to rust 1.78 (#320)
This PR updates the minimum supported Rust version to 1.78.
2024-05-29 16:32:36 +02:00
Martin HoffmannandGitHub 95a7218048 Update dependencies. (#304)
This PR updates all dependencies to their latest major version. This
requires some changes to the examples using tokio-rustls.

This PR also updates the minimum supported Rust version to 1.70.

This is a breaking change.
2024-04-29 17:41:07 +02:00
Martin HoffmannandGitHub 1e25edb277 Fix nightly warnings. (#280)
This PR fixes warnings from lints added to the nightly compiler. It also
changes the CI workflow to error out when there are warnings.
2024-02-27 12:59:19 +01:00
Martin HoffmannandGitHub e63c192ebc Remove interop and ci-test features and set interop tests to ignore. (#254)
* Remove interop and ci-test features and set interop tests to ignore.
* Fix feature selection.
* Clippy-suggested improvements.
* Do things for --all-targets in CI.
2024-01-16 10:29:05 +01:00
HugoandGitHub 642331fdab Upgrade required Rust version to 1.67. (#221)
This commit upgrades the minimum required Rust version to 1.67
and applies a Clippy-suggested fix.
2023-08-23 11:41:42 +02:00
Martin HoffmannandGitHub a2ce078a92 The Great octseq Conversion (#160)
This commit swaps the traits and types defined in `base::octets` for their
equivalent in the `octseq` trait. These are mostly the same except that they
facilitate Generic Associated Types as stabilized in Rust 1.65. This results
in subtly changed trait bounds, though mostly these should be invisible to
the user.

One notable change is that `octseq` makes the error type of the
`OctetsBuilder` generic and uses `Infallible` for those types where
appending data will never fail (which, for most users, is all of them). It
provides methods for either case and we are mirroring these in `domain`.
While this means that converting you code to using the PR will require some
work, that work should mostly be removing unwraps – which is nice.

We’re using the opportunity to clean up a few more things that have crept
into the code over time. A list of which will be added here:

*  The range, slice, and split methods on the domain name types have
   changed. They have been merge into a single method taking ranges – except
   for those on `Dname` that require type changes. The split methods now
   take references and don’t change `self` anymore. This is somewhat
   required by the limitations imposed by the new `Octets` trait but feels
   better, anyway.

*  The `Parse`, `Compose`, and `Scan` traits have been demoted to mere
   extension traits for foreign types (primarily the built-in integers, so
   that you can do things like `u16::parse`). All other types now simply have
   methods matching the patterns. Where generics are necessary, dedicated
   traits have been added. E.g., there now are `ParseRecordData` and
   `ComposeRecordData` traits that are implemented by all record data types.

*  Composing of record data and options has been switched to a scheme where
   the size is predetermined whenever possible instead of composing the data
   and then updating the length after. Since this is not possible for record
   data that uses compressed names when compression is actually in use, the
   old scheme is still used in this particular case.
2023-01-10 12:48:41 +01:00
Martin HoffmannandGitHub cd88889557 Redesign zone file parsing. (#142)
This commit completely redesigns zone file parsing. The primary change is to
convert the scanner into a trait in order to allow multiple zone parser
implementations for different sources and purposes. A number of changes had
to be made in order to make this possible.

The commit also contains an initial implementation of a scanner that modifies
data in-place and can thus returned parsed data with only a minimal amount
of additional allocations. While working, this scanner is more a
proof-of-concept at this point to ensure that the API design is sound.

This commit is based on ideas and code proposed by @not-my-profile in #106.

This commit increases the minimal supported Rust version to 1.59.0.
2022-11-07 15:11:36 +01:00
Martin Hoffmann 23cedfa7dd Only run Clippy on stable Rust. 2022-09-15 12:43:58 +02:00
Martin HoffmannandGitHub 9d937070ed Fix errors in --no-default-features built. (#129)
Also enables the `--tests` flag when building with --no-default-features in the CI.
2022-04-21 14:12:13 +02:00
Martin HoffmannandGitHub 997ad926a9 The minimum support rust version is now 1.56.1. (#128) 2022-04-21 11:52:08 +02:00
Martin Hoffmann 067d1a6874 Fix workflow syntax. 2021-11-24 12:07:12 +01:00
Martin Hoffmann 11a3b34935 CI: Only run Clippy on stable and nightly. 2021-11-24 12:05:41 +01:00
Martin Hoffmann 9b7daf69fd Increase minimum supported Rust version to 1.52. 2021-11-24 10:49:02 +01:00
Martin Hoffmann 257caf0aac Introduce a ci-test feature rather than editing the workflow file. 2021-11-12 17:41:39 +01:00
Martin Hoffmann 7f9eab0f8c Increase minimum supported Rust version to 1.49. 2021-07-29 12:21:31 +02:00
Martin Hoffmann 5439169b56 Disable Clippy on the beta channel. 2021-05-26 11:10:31 +02:00
Martin HoffmannandGitHub 0ddde30e71 Merge pull request #85 from koivunej/do_rustfmt
cargo fmt
2021-01-14 11:14:28 +01:00
Joonas Koivunen f7c4153b4d ci: add minimal-versions check and test 2021-01-13 18:33:37 +02:00
Joonas Koivunen 5d47aa24fc ci: add stable cargo fmt check
run clippy only on ubuntu-latest as it doesn't seem to be installed on
windows. however all code is processed by rustfmt regardless of the
target.
2021-01-13 16:03:44 +02:00
Martin Hoffmann bb46dcc8ae Don’t include the interop feature in Github Actions. 2020-08-27 11:48:35 +02:00
Martin Hoffmann e956ab4732 Fix CI workflow. 2020-08-27 10:44:26 +02:00
Martin Hoffmann 6a8fafed59 Update minimal Rust version to 1.45. 2020-08-25 17:55:11 +02:00
Martin Hoffmann c69e8aae45 No features in test in workspace. 2020-03-24 14:00:40 +01:00
Martin Hoffmann 03769518bd Minimum Rust version is 1.42.0. 2020-03-24 13:44:30 +01:00
Martin Hoffmann 20ec910055 Switch to Github Actions. 2020-03-24 13:43:30 +01:00