This PR changes the CI trigger for pull requests to use the default activity types which – the Internet claims – is “open,” “synchronize,” and “reopen.”
- 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.
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.
* 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.
* [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>
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.
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.
* 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.
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.
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.