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.
This PR does this by enabling Tokio Tracing to emit logs if no tracing
subscriber is initialized (via the tracing/log feature).
Also fixes guards around costly logging to actually emits log events if no
tracing subscriber is initialized by using the enabled check of the log crate
instead of the enabled check of the tracing crate.
See: https://docs.rs/tracing/0.1.41/tracing/#emitting-log-records
* 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>
* Internal message printer exposed as display_dig_style
* fix clippy lint
* rename MessagePrinter to DigPrinter and use if-let
* document display_dig_style and ZonefileFmt
* Restore 'Display' behaviour for 'SecAlg' etc
The doc comment for 'int_enum_str_decimal' explicitly states that the
'FromStr' impl expects a decimal number and that the 'Display' impl
will also output a decimal number. However, 'Display' was also adding
the mnemonic for the number.
* Print mnemonics for SecAlg etc. in ZonefileFmt comments
---------
Co-authored-by: arya dradjica <arya@nlnetlabs.nl>