Commit Graph
1133 Commits
Author SHA1 Message Date
Philip-NLnetLabsandGitHub bcb4e8553f Fix clippy errors for 1.85.0. (#490)
* Fix clippy errors for 1.85.0.

* Also fix nightly clippies.

* Restore comment.

* Remove redundant ok()
2025-02-26 15:21:59 +01:00
Ximon EighteenandGitHub 2d17c29aa1 Update Changelog. 2025-02-08 11:13:08 +01:00
Ximon EighteenandGitHub 2d6b6eec42 Use base16 for Ds (de)serialization. (#423) 2025-02-08 11:08:00 +01:00
Ben BeasleyandGitHub c1a5e86233 Update to rstest 0.23.0, the current release (#442) 2025-02-06 09:51:12 +01:00
Alex BandandGitHub c6a7967d94 Merge pull request #483 from NLnetLabs/license-update
Update license text to match OSI
2025-01-28 14:31:31 +01:00
Alex Band 4310eb14ce Update license text to match OSI 2025-01-28 14:06:18 +01: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
Philip Homburg f5deabdf9f Fix clippy::question_mark issues. 2025-01-13 16:24:54 +01:00
arya dradjica a5df033b3c Update 'Cargo.lock'
Running 'cargo check' will automatically bring 'Cargo.lock' to this
state.  Apparently some dependencies were missing.
2025-01-08 13:23:46 +01:00
Alex BandandGitHub ec53b8e7b9 Update article link 2025-01-08 11:57:48 +01:00
Ximon EighteenandGitHub f826b82b6d RustDoc typo correction. 2025-01-07 16:12:26 +01:00
Ximon EighteenandGitHub 1d534b72af Simplify the crate intro in the docs. (#476) 2025-01-07 15:27:27 +01:00
Ximon Eighteen ea528fff81 Typo correction in the first paragraph of the crate RustDoc main page. 2025-01-07 14:31:03 +01:00
Philip Homburg 6ae24ae038 Update Changelog. 2024-12-19 14:52:49 +01:00
Philip Homburg 69f1dc520b Add key lifecycle management (PR #459) 2024-12-19 14:49:14 +01:00
Ximon EighteenandGitHub b69b2cda4c Support client crates that use the standard Rust log framework instead of Tokio Tracing. (#465)
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
2024-12-18 17:17:18 +01:00
Martin Hoffmann f02b559ba3 Update changelog. 2024-12-18 14:58:11 +01:00
arya dradjicaandGitHub 3011d4c1a7 [zonefile/inplace] Handle backslashes in quoted strings (#472)
This PR fixes an issue when parsing the first backslash of a quoted
string introduced by #470.
2024-12-18 14:54:55 +01:00
Ximon EighteenandGitHub d9f3983317 Update changelog. 2024-12-16 13:24:46 +01:00
Ximon EighteenandGitHub 51fc72b217 Handle quoted octets. (#470) 2024-12-16 13:22:06 +01:00
Ximon Eighteen e586123000 Update changelog. 2024-12-06 15:27:19 +01:00
Ximon EighteenandGitHub 245f2cfcba Add a tab before the RDATA as well as within it, to match LDNS tabbed output format. (#463) 2024-12-06 14:22:03 +01:00
Ximon EighteenandGitHub e51de81a30 Update changelog. 2024-12-05 13:21:58 +01:00
Terts DiepraamandGitHub 92ed95184b Add TabbedWriter for ZonefileFmt (#446)
* add AlignedWriter for ZonefileFmt

* Rename AlignedWriter to TabbedWriter
2024-12-05 13:03:09 +01:00
93a0053596 Apply fixes for new issues found by Clippy 1.83.0 (#460)
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
2024-11-29 15:33:18 +01:00
Philip Homburg fd519f0bf8 Update changelog. 2024-11-26 14:14:26 +01:00
Philip Homburg c2619838c0 A load balancer client transport (PR #425). 2024-11-26 14:11:37 +01:00
Philip Homburg 2e3a141f5f Update changelog. 2024-11-26 13:36:23 +01:00
Philip Homburg a26927039a Improvements to multi_stream and redundant (PR #424). 2024-11-26 13:33:03 +01:00
Ximon Eighteen 8f6e44385a Update changelog. 2024-11-14 15:40:23 +01:00
arya dradjicaandGitHub 7c1667739d [resolver/stub] Allow adding connections dynamically (#440)
This can be used to side-step 'ResolvConf' and the underlying default
'multi_stream' connection type with a custom one, e.g. for testing.
2024-11-14 15:39:58 +01:00
Ximon Eighteen 0feda10d0b Update changelog. 2024-11-14 15:20:16 +01:00
Ximon EighteenandGitHub 6b842a7d10 Derive Arbitrary for some types via a new Cargo feature, to enable fuzz testing in downstream projects that use those types. (#441) 2024-11-14 15:11:56 +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
arya dradjicaandGitHub a23a5fd21e Key sizes for DNSSEC keys (#435)
* [validate] Implement 'key_size()'
* [validate] Ensure that RSA public keys don't have leading zeros when parsing DNSKEY records.
2024-11-08 13:10:40 +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
Ximon EighteenandGitHub 24ecebeff1 Update changelog. 2024-11-04 09:58:32 +01:00
Ximon EighteenandGitHub f974bee834 Update changelog. 2024-11-04 09:57:54 +01:00
WeilenceandGitHub 196c5f5fe1 Add support for NAPTR record type (#427) 2024-11-04 09:54:21 +01:00
Ximon EighteenandGitHub da4faef85d Update changelog. 2024-10-31 22:06:36 +01:00
Ximon EighteenandGitHub bf95f3737d FIX: NSEC records should include themselves in the generated bitmap. (#417) 2024-10-31 22:04:49 +01:00
Terts DiepraamandGitHub 9a9624150d Internal message printer exposed as display_dig_style (#420)
* 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
2024-10-31 12:28:37 +01:00
Philip Homburg 984d16b6d8 Fix ReplyMessage (#429) 2024-10-29 14:10:30 +01:00
Philip Homburg b6d50d9a90 Fix bug where using UnknownRecord data fails when compressed names are present. 2024-10-29 13:35:20 +01:00
ed9824894d Restore 'Display' behaviour for 'SecAlg' etc (#428)
* 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>
2024-10-29 13:26:15 +01:00
Terts Diepraam 01938907fd update changelog 2024-10-28 14:29:06 +01:00
Philip Homburg f7d25de16d Changelog. 2024-10-28 13:58:28 +01:00
Philip Homburg f13016e299 Qname router (#353) 2024-10-28 13:51:57 +01:00