mirror of
https://github.com/NLnetLabs/dnst.git
synced 2026-08-17 21:25:51 +02:00
Add nsec3-hash command. (#6)
Co-authored-by: Jannik <jannik@nlnetlabs.nl> Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
This commit is contained in:
co-authored by
Jannik
Terts Diepraam
parent
18dd6e7ebc
commit
9744d9e1ca
Generated
+590
-17
@@ -1,6 +1,21 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
@@ -57,12 +72,61 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-lock"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18"
|
||||
dependencies = [
|
||||
"event-listener",
|
||||
"event-listener-strategy",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
@@ -77,9 +141,9 @@ checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
|
||||
checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
@@ -92,9 +156,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.20"
|
||||
version = "4.5.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
|
||||
checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -102,9 +166,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.20"
|
||||
version = "4.5.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
|
||||
checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -126,9 +190,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.2"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
||||
checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
@@ -136,6 +200,39 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "concurrent-queue"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.11"
|
||||
@@ -152,23 +249,26 @@ dependencies = [
|
||||
"clap",
|
||||
"domain",
|
||||
"lexopt",
|
||||
"octseq",
|
||||
"ring",
|
||||
"tempfile",
|
||||
"test_bin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "domain"
|
||||
version = "0.10.3"
|
||||
source = "git+https://github.com/NLnetLabs/domain.git#39a04b6f6af9496a2ec91b6e5707ecf255fe0c38"
|
||||
source = "git+https://github.com/NLnetLabs/domain.git?branch=initial-nsec3-generation#e1c1db8e4103eed5f69d77d7b88581298cc00818"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"hashbrown",
|
||||
"moka",
|
||||
"octseq",
|
||||
"rand",
|
||||
"ring",
|
||||
"serde",
|
||||
"time",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -181,12 +281,70 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "5.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba"
|
||||
dependencies = [
|
||||
"concurrent-queue",
|
||||
"parking",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "event-listener-strategy"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1"
|
||||
dependencies = [
|
||||
"event-listener",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4"
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-macro",
|
||||
"futures-task",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.15"
|
||||
@@ -198,6 +356,12 @@ dependencies = [
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
@@ -213,12 +377,27 @@ version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexopt"
|
||||
version = "0.3.0"
|
||||
@@ -227,9 +406,9 @@ checksum = "baff4b617f7df3d896f97fe922b64817f6cd9a756bb81d40f8883f2f66dcb401"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.162"
|
||||
version = "0.2.164"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398"
|
||||
checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
@@ -237,12 +416,88 @@ version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"wasi",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "moka"
|
||||
version = "0.12.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32cf62eb4dd975d2dde76432fb1075c49e3ee2331cf36f1f8fd4b66550d32b6f"
|
||||
dependencies = [
|
||||
"async-lock",
|
||||
"async-trait",
|
||||
"crossbeam-channel",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
"event-listener",
|
||||
"futures-util",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"quanta",
|
||||
"rustc_version",
|
||||
"smallvec",
|
||||
"tagptr",
|
||||
"thiserror",
|
||||
"triomphe",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "octseq"
|
||||
version = "0.5.2"
|
||||
@@ -259,6 +514,47 @@ version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "parking"
|
||||
version = "2.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
@@ -283,6 +579,21 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quanta"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"raw-cpuid",
|
||||
"wasi",
|
||||
"web-sys",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
@@ -322,6 +633,24 @@ dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raw-cpuid"
|
||||
version = "11.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.8"
|
||||
@@ -338,10 +667,25 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.40"
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
@@ -350,6 +694,18 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.215"
|
||||
@@ -376,6 +732,31 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
@@ -399,6 +780,12 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tagptr"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.14.0"
|
||||
@@ -412,6 +799,32 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "test_bin"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e7a7de15468c6e65dd7db81cf3822c1ec94c71b2a3c1a976ea8e4696c91115c"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.36"
|
||||
@@ -431,6 +844,70 @@ version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.41.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
|
||||
dependencies = [
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "triomphe"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.13"
|
||||
@@ -449,12 +926,108 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
|
||||
+2
-9
@@ -10,16 +10,9 @@ path = "src/bin/ldns.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.3.4", features = ["derive"] }
|
||||
domain = { version = "0.10.3", git = "https://github.com/NLnetLabs/domain.git", features = [
|
||||
"zonefile",
|
||||
"bytes",
|
||||
"unstable-validate",
|
||||
] }
|
||||
domain = { version = "0.10.3", git = "https://github.com/NLnetLabs/domain.git", branch = "initial-nsec3-generation", features = ["unstable-validator", "zonefile"] }
|
||||
lexopt = "0.3.0"
|
||||
|
||||
# for implementation of nsec3 hash until domain has it stabilized
|
||||
octseq = { version = "0.5.2", features = ["std"] }
|
||||
ring = { version = "0.17" }
|
||||
|
||||
[dev-dependencies]
|
||||
test_bin = "0.4.0"
|
||||
tempfile = "3.14.0"
|
||||
|
||||
@@ -22,7 +22,7 @@ Options
|
||||
.. option:: -i <NUMBER>, -t <NUMBER>, --iterations <NUMBER>
|
||||
|
||||
Use the given number of additional iterations for the hash
|
||||
calculation. Defaults to 1.
|
||||
calculation. Defaults to 0.
|
||||
|
||||
.. option:: -s <HEX STRING>, --salt <HEX STRING>
|
||||
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
//! The command of _dnst_.
|
||||
|
||||
pub mod help;
|
||||
pub mod key2ds;
|
||||
pub mod nsec3hash;
|
||||
@@ -17,7 +16,7 @@ use super::error::Error;
|
||||
|
||||
#[derive(Clone, Debug, clap::Subcommand)]
|
||||
pub enum Command {
|
||||
/// Print the NSEC3 hash of a given domain name
|
||||
/// Prints the NSEC3 hash of a given domain name
|
||||
#[command(name = "nsec3-hash")]
|
||||
Nsec3Hash(self::nsec3hash::Nsec3Hash),
|
||||
|
||||
|
||||
+288
-72
@@ -1,16 +1,15 @@
|
||||
use crate::env::Env;
|
||||
use crate::error::Error;
|
||||
use std::ffi::OsString;
|
||||
use std::str::FromStr;
|
||||
|
||||
use clap::builder::ValueParser;
|
||||
use domain::base::iana::nsec3::Nsec3HashAlg;
|
||||
use domain::base::name::{self, Name};
|
||||
use domain::base::ToName;
|
||||
use domain::rdata::nsec3::{Nsec3Salt, OwnerHash};
|
||||
use domain::rdata::nsec3::Nsec3Salt;
|
||||
use domain::validate::nsec3_hash;
|
||||
use lexopt::Arg;
|
||||
// use domain::validator::nsec::nsec3_hash;
|
||||
use octseq::OctetsBuilder;
|
||||
use ring::digest;
|
||||
use std::ffi::OsString;
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::env::Env;
|
||||
use crate::error::Error;
|
||||
|
||||
use super::{parse_os, parse_os_with, LdnsCommand};
|
||||
|
||||
@@ -18,40 +17,45 @@ use super::{parse_os, parse_os_with, LdnsCommand};
|
||||
pub struct Nsec3Hash {
|
||||
/// The hashing algorithm to use
|
||||
#[arg(
|
||||
long,
|
||||
long = "algorithm",
|
||||
short = 'a',
|
||||
value_name = "NUMBER_OR_MNEMONIC",
|
||||
default_value_t = Nsec3HashAlg::SHA1,
|
||||
value_parser = ValueParser::new(Nsec3Hash::parse_nsec_alg)
|
||||
value_name = "NUMBER OR MNEMONIC",
|
||||
default_value = "SHA-1",
|
||||
value_parser = ValueParser::new(Nsec3Hash::parse_nsec3_alg)
|
||||
)]
|
||||
algorithm: Nsec3HashAlg,
|
||||
|
||||
/// The number of hash iterations
|
||||
#[arg(
|
||||
long,
|
||||
long = "iterations",
|
||||
short = 'i',
|
||||
visible_short_alias = 't',
|
||||
value_name = "NUMBER",
|
||||
default_value_t = 1
|
||||
default_value_t = 0
|
||||
)]
|
||||
iterations: u16,
|
||||
|
||||
/// The salt in hex representation
|
||||
#[arg(short = 's', long, value_name = "HEX_STRING", default_value_t = Nsec3Salt::empty())]
|
||||
#[arg(
|
||||
long = "salt",
|
||||
short = 's',
|
||||
value_name = "HEX STRING",
|
||||
default_value_t = Nsec3Salt::empty(),
|
||||
value_parser = ValueParser::new(Nsec3Hash::parse_salt)
|
||||
)]
|
||||
salt: Nsec3Salt<Vec<u8>>,
|
||||
|
||||
/// The domain name to hash
|
||||
#[arg(value_name = "DOMAIN_NAME", value_parser = ValueParser::new(Nsec3Hash::parse_name))]
|
||||
#[arg(value_name = "DOMAIN NAME", value_parser = ValueParser::new(Nsec3Hash::parse_name))]
|
||||
name: Name<Vec<u8>>,
|
||||
}
|
||||
|
||||
const LDNS_HELP: &str = "\
|
||||
ldns-nsec3-hash [OPTIONS] <domain name>
|
||||
prints the NSEC3 hash of the given domain name
|
||||
|
||||
-a <algorithm> hashing algorithm number
|
||||
-t <number> iterations
|
||||
-s <string> salt in hex\
|
||||
-a [algorithm] hashing algorithm
|
||||
-t [number] number of hash iterations
|
||||
-s [string] salt
|
||||
";
|
||||
|
||||
impl LdnsCommand for Nsec3Hash {
|
||||
@@ -69,11 +73,12 @@ impl LdnsCommand for Nsec3Hash {
|
||||
match arg {
|
||||
Arg::Short('a') => {
|
||||
let val = parser.value()?;
|
||||
algorithm = parse_os_with("algorithm (-a)", &val, Nsec3Hash::parse_nsec_alg)?;
|
||||
algorithm =
|
||||
parse_os_with("algorithm (-a)", &val, Nsec3Hash::parse_nsec3_alg_as_num)?;
|
||||
}
|
||||
Arg::Short('s') => {
|
||||
let val = parser.value()?;
|
||||
salt = parse_os("salt (-s)", &val)?;
|
||||
salt = parse_os_with("salt (-s)", &val, Nsec3Hash::parse_salt)?;
|
||||
}
|
||||
Arg::Short('t') => {
|
||||
let val = parser.value()?;
|
||||
@@ -112,75 +117,286 @@ impl Nsec3Hash {
|
||||
Name::from_str(&arg.to_lowercase())
|
||||
}
|
||||
|
||||
pub fn parse_nsec_alg(arg: &str) -> Result<Nsec3HashAlg, &'static str> {
|
||||
// Note: This function is only necessary until
|
||||
// https://github.com/NLnetLabs/domain/pull/431 is merged.
|
||||
pub fn parse_salt(arg: &str) -> Result<Nsec3Salt<Vec<u8>>, Error> {
|
||||
if arg.len() >= 512 {
|
||||
Err(Error::from("Salt too long"))
|
||||
} else {
|
||||
Nsec3Salt::<Vec<u8>>::from_str(arg).map_err(|err| Error::from(err.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_nsec3_alg(arg: &str) -> Result<Nsec3HashAlg, &'static str> {
|
||||
if let Ok(num) = arg.parse() {
|
||||
let alg = Nsec3HashAlg::from_int(num);
|
||||
// check for valid algorithm here, to be consistent with error messages
|
||||
// if domain::validator::nsec::supported_nsec3_hash(alg) {
|
||||
if alg.to_mnemonic().is_some() {
|
||||
Ok(alg)
|
||||
} else {
|
||||
Err("unknown algorithm number")
|
||||
}
|
||||
Self::num_to_nsec3_alg(num)
|
||||
} else {
|
||||
Nsec3HashAlg::from_mnemonic(arg.as_bytes()).ok_or("unknown algorithm mnemonic")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_nsec3_alg_as_num(arg: &str) -> Result<Nsec3HashAlg, &'static str> {
|
||||
match arg.parse() {
|
||||
Ok(num) => Self::num_to_nsec3_alg(num),
|
||||
Err(_) => Err("malformed algorithm number"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn num_to_nsec3_alg(num: u8) -> Result<Nsec3HashAlg, &'static str> {
|
||||
let alg = Nsec3HashAlg::from_int(num);
|
||||
match alg.to_mnemonic() {
|
||||
Some(_) => Ok(alg),
|
||||
None => Err("unknown algorithm number"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Nsec3Hash {
|
||||
pub fn execute(self, env: impl Env) -> Result<(), Error> {
|
||||
let hash = nsec3_hash(&self.name, self.algorithm, self.iterations, &self.salt)
|
||||
.to_string()
|
||||
.to_lowercase();
|
||||
let hash =
|
||||
nsec3_hash::<_, _, Vec<u8>>(&self.name, self.algorithm, self.iterations, &self.salt)
|
||||
.map_err(|err| format!("Error creating NSEC3 hash: {err}"))?
|
||||
.to_string()
|
||||
.to_lowercase();
|
||||
|
||||
let mut out = env.stdout();
|
||||
writeln!(out, "{}.", hash);
|
||||
writeln!(env.stdout(), "{}.", hash);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: This is a verbatim copy of the nsec3_hash function from domain::validator::nsec.
|
||||
// TODO: when exposed/available, replace with implementation from domain::validator::nsec
|
||||
fn nsec3_hash<N, HashOcts>(
|
||||
owner: N,
|
||||
algorithm: Nsec3HashAlg,
|
||||
iterations: u16,
|
||||
salt: &Nsec3Salt<HashOcts>,
|
||||
) -> OwnerHash<Vec<u8>>
|
||||
where
|
||||
N: ToName,
|
||||
HashOcts: AsRef<[u8]>,
|
||||
{
|
||||
let mut buf = Vec::new();
|
||||
// These are just basic tests as there is very little code in this module, the
|
||||
// actual NSEC3 generation should be tested as part of the domain crate.
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
mod without_cli {
|
||||
use core::str::FromStr;
|
||||
|
||||
owner.compose_canonical(&mut buf).expect("infallible");
|
||||
buf.append_slice(salt.as_slice()).expect("infallible");
|
||||
use domain::base::iana::Nsec3HashAlg;
|
||||
use domain::base::Name;
|
||||
use domain::rdata::nsec3::Nsec3Salt;
|
||||
|
||||
let digest_type = if algorithm == Nsec3HashAlg::SHA1 {
|
||||
&digest::SHA1_FOR_LEGACY_USE_ONLY
|
||||
} else {
|
||||
// totest, unsupported NSEC3 hash algorithm
|
||||
// Unsupported.
|
||||
panic!("should not be called with an unsupported algorithm");
|
||||
};
|
||||
use crate::commands::nsec3hash::Nsec3Hash;
|
||||
use crate::env::fake::{FakeCmd, FakeEnv, FakeStream};
|
||||
|
||||
let mut ctx = digest::Context::new(digest_type);
|
||||
ctx.update(&buf);
|
||||
let mut h = ctx.finish();
|
||||
// Note: For the types we use that are provided by the domain crate,
|
||||
// construction of them from bad inputs should be tested in that
|
||||
// crate, not here. This test exercises the just the actual
|
||||
// functionalty of this module without the outer layer of CLI argument
|
||||
// parsing which is independent of whether we are invoked as `dnst
|
||||
// nsec3-hash`` or as `ldns-nsec3-hash`.
|
||||
#[test]
|
||||
fn execute() {
|
||||
let env = FakeEnv {
|
||||
cmd: FakeCmd::new(["unused"]),
|
||||
stdout: FakeStream::default(),
|
||||
stderr: FakeStream::default(),
|
||||
};
|
||||
|
||||
for _ in 0..iterations {
|
||||
buf.truncate(0);
|
||||
buf.append_slice(h.as_ref()).expect("infallible");
|
||||
buf.append_slice(salt.as_slice()).expect("infallible");
|
||||
// We don't test all permutations as that would take too long (~20 seconds)
|
||||
#[allow(clippy::single_element_loop)]
|
||||
for algorithm in ["SHA-1"] {
|
||||
let algorithm = Nsec3HashAlg::from_mnemonic(algorithm.as_bytes())
|
||||
.unwrap_or_else(|| panic!("Algorithm '{algorithm}' was expected to be okay"));
|
||||
let nsec3_hash = Nsec3Hash {
|
||||
algorithm,
|
||||
iterations: 0,
|
||||
salt: Nsec3Salt::empty(),
|
||||
name: Name::root(),
|
||||
};
|
||||
nsec3_hash.execute(&env).unwrap();
|
||||
}
|
||||
|
||||
let mut ctx = digest::Context::new(digest_type);
|
||||
ctx.update(&buf);
|
||||
h = ctx.finish();
|
||||
for iterations in [0, 1, u16::MAX - 1, u16::MAX] {
|
||||
let nsec3_hash = Nsec3Hash {
|
||||
algorithm: Nsec3HashAlg::SHA1,
|
||||
iterations,
|
||||
salt: Nsec3Salt::empty(),
|
||||
name: Name::root(),
|
||||
};
|
||||
nsec3_hash.execute(&env).unwrap();
|
||||
}
|
||||
|
||||
for salt in ["", "-", "aa", "aabb", "aa".repeat(255).as_str()] {
|
||||
let salt = Nsec3Salt::from_str(salt)
|
||||
.unwrap_or_else(|err| panic!("Salt '{salt}' was expected to be okay: {err}"));
|
||||
let nsec3_hash = Nsec3Hash {
|
||||
algorithm: Nsec3HashAlg::SHA1,
|
||||
iterations: 0,
|
||||
salt,
|
||||
name: Name::root(),
|
||||
};
|
||||
nsec3_hash.execute(&env).unwrap();
|
||||
}
|
||||
|
||||
for name in [
|
||||
".", "a", "a.", "ab", "ab.", "a.ab", "a.ab.", "ab.ab", "ab.ab.", "a.ab.ab",
|
||||
"a.ab.ab.",
|
||||
] {
|
||||
let name = Name::from_str(name)
|
||||
.unwrap_or_else(|err| panic!("Name '{name}' was expected to be okay: {err}"));
|
||||
let nsec3_hash = Nsec3Hash {
|
||||
algorithm: Nsec3HashAlg::SHA1,
|
||||
iterations: 0,
|
||||
salt: Nsec3Salt::empty(),
|
||||
name,
|
||||
};
|
||||
nsec3_hash.execute(&env).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For normal hash algorithms this should not fail.
|
||||
OwnerHash::from_octets(h.as_ref().to_vec()).expect("should not fail")
|
||||
mod with_dnst_cli {
|
||||
use core::str;
|
||||
|
||||
use crate::env::fake::FakeCmd;
|
||||
use crate::error::Error;
|
||||
use crate::Args;
|
||||
|
||||
#[test]
|
||||
fn accept_good_cli_args() {
|
||||
assert_cmd_eq(&["nlnetlabs.nl"], "asqe4ap6479d7085ljcs10a2fpb2do94.\n");
|
||||
assert_cmd_eq(
|
||||
&["-a", "1", "nlnetlabs.nl"],
|
||||
"asqe4ap6479d7085ljcs10a2fpb2do94.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-a", "SHA-1", "nlnetlabs.nl"],
|
||||
"asqe4ap6479d7085ljcs10a2fpb2do94.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-i", "0", "nlnetlabs.nl"],
|
||||
"asqe4ap6479d7085ljcs10a2fpb2do94.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-i", "1", "nlnetlabs.nl"],
|
||||
"e3dbcbo05tvq0u7po4emvbu79c8vpcgk.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-s", "", "nlnetlabs.nl"],
|
||||
"asqe4ap6479d7085ljcs10a2fpb2do94.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-s", "DEADBEEF", "nlnetlabs.nl"],
|
||||
"dfucs7bmmtsil9gij77k1kmocclg5d8a.\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reject_bad_cli_args() {
|
||||
assert!(parse_cmd_line(&[]).is_err());
|
||||
assert!(parse_cmd_line(&[""]).is_err());
|
||||
|
||||
assert!(parse_cmd_line(&["-a"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "2", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "SHA1", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "SHA-256", "nlnetlabs.nl"]).is_err());
|
||||
|
||||
assert!(parse_cmd_line(&["-i"]).is_err());
|
||||
assert!(parse_cmd_line(&["-i", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-i", "", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-i", "-1", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-i", "abc", "nlnetlabs.nl"]).is_err());
|
||||
assert!(
|
||||
parse_cmd_line(&["-i", &((u16::MAX as u32) + 1).to_string(), "nlnetlabs.nl"])
|
||||
.is_err()
|
||||
);
|
||||
|
||||
assert!(parse_cmd_line(&["-s"]).is_err());
|
||||
assert!(parse_cmd_line(&["-s", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-s", "NOTHEX", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-s", &"aa".repeat(256), "nlnetlabs.nl"]).is_err());
|
||||
}
|
||||
|
||||
//------------ Helper functions ------------------------------------------
|
||||
|
||||
fn parse_cmd_line(args: &[&str]) -> Result<Args, Error> {
|
||||
FakeCmd::new(["dnst", "nsec3-hash"]).args(args).parse()
|
||||
}
|
||||
|
||||
fn assert_cmd_eq(args: &[&str], expected_output: &str) {
|
||||
let result = FakeCmd::new(["dnst", "nsec3-hash"]).args(args).run();
|
||||
assert_eq!(result.exit_code, 0);
|
||||
assert_eq!(result.stdout, expected_output);
|
||||
assert_eq!(result.stderr, "");
|
||||
}
|
||||
}
|
||||
|
||||
mod with_ldns_cli {
|
||||
use core::str;
|
||||
|
||||
use crate::env::fake::FakeCmd;
|
||||
use crate::error::Error;
|
||||
use crate::Args;
|
||||
|
||||
#[test]
|
||||
fn accept_good_cli_args() {
|
||||
assert_cmd_eq(&["nlnetlabs.nl"], "e3dbcbo05tvq0u7po4emvbu79c8vpcgk.\n");
|
||||
assert_cmd_eq(
|
||||
&["-a", "1", "nlnetlabs.nl"],
|
||||
"e3dbcbo05tvq0u7po4emvbu79c8vpcgk.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-t", "0", "nlnetlabs.nl"],
|
||||
"asqe4ap6479d7085ljcs10a2fpb2do94.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-t", "1", "nlnetlabs.nl"],
|
||||
"e3dbcbo05tvq0u7po4emvbu79c8vpcgk.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-s", "", "nlnetlabs.nl"],
|
||||
"e3dbcbo05tvq0u7po4emvbu79c8vpcgk.\n",
|
||||
);
|
||||
assert_cmd_eq(
|
||||
&["-s", "DEADBEEF", "nlnetlabs.nl"],
|
||||
"2h8rboqdrq0ard25vrmc4hjg7m56hnhd.\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reject_bad_cli_args() {
|
||||
assert!(parse_cmd_line(&[]).is_err());
|
||||
assert!(parse_cmd_line(&[""]).is_err());
|
||||
|
||||
assert!(parse_cmd_line(&["-a"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "2", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "SHA1", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "SHA-1", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-a", "SHA-256", "nlnetlabs.nl"]).is_err());
|
||||
|
||||
assert!(parse_cmd_line(&["-t"]).is_err());
|
||||
assert!(parse_cmd_line(&["-t", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-t", "", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-t", "-1", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-t", "abc", "nlnetlabs.nl"]).is_err());
|
||||
assert!(
|
||||
parse_cmd_line(&["-t", &((u16::MAX as u32) + 1).to_string(), "nlnetlabs.nl"])
|
||||
.is_err()
|
||||
);
|
||||
|
||||
assert!(parse_cmd_line(&["-s"]).is_err());
|
||||
assert!(parse_cmd_line(&["-s", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-s", "NOTHEX", "nlnetlabs.nl"]).is_err());
|
||||
assert!(parse_cmd_line(&["-s", &"aa".repeat(256), "nlnetlabs.nl"]).is_err());
|
||||
}
|
||||
|
||||
//------------ Helper functions ------------------------------------------
|
||||
|
||||
fn parse_cmd_line(args: &[&str]) -> Result<Args, Error> {
|
||||
FakeCmd::new(["ldns-nsec3-hash"]).args(args).parse()
|
||||
}
|
||||
|
||||
fn assert_cmd_eq(args: &[&str], expected_output: &str) {
|
||||
let result = FakeCmd::new(["ldns-nsec3-hash"]).args(args).run();
|
||||
assert_eq!(result.exit_code, 0);
|
||||
assert_eq!(result.stdout, expected_output);
|
||||
assert_eq!(result.stderr, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -204,7 +420,7 @@ mod test {
|
||||
|
||||
let res = cmd.args(["example.test"]).run();
|
||||
assert_eq!(res.exit_code, 0);
|
||||
assert_eq!(res.stdout, "o09614ibh1cq1rcc86289olr22ea0fso.\n")
|
||||
assert_eq!(res.stdout, "jbas736chung3bb701jkjdhqkqlhvug7.\n")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
use std::process::Command;
|
||||
|
||||
const TEST_ZONE_NAME: &str = "nlnetlabs.nl";
|
||||
const LDNS_NSEC3_CMD: &str = "ldns-nsec3-hash";
|
||||
const DNST_NSEC3_SUBCMD: &str = "nsec3-hash";
|
||||
|
||||
#[ignore = "should only be run if ldns command line tools are installed"]
|
||||
#[test]
|
||||
fn nsec3_hash() {
|
||||
// Note: ldns-nsec3-hash defaults NSEC3 iterations to 1, while dnst
|
||||
// nsec-hash defaults NSEC3 iterations to 0.
|
||||
assert_cmds_eq(
|
||||
&[LDNS_NSEC3_CMD, TEST_ZONE_NAME],
|
||||
&[DNST_NSEC3_SUBCMD, "--iterations", "1", TEST_ZONE_NAME],
|
||||
);
|
||||
assert_cmds_eq(
|
||||
&[LDNS_NSEC3_CMD, TEST_ZONE_NAME, "-t", "0"],
|
||||
&[DNST_NSEC3_SUBCMD, TEST_ZONE_NAME],
|
||||
);
|
||||
assert_cmds_eq(
|
||||
&[LDNS_NSEC3_CMD, "-a", "1", TEST_ZONE_NAME],
|
||||
&[
|
||||
DNST_NSEC3_SUBCMD,
|
||||
"--iterations",
|
||||
"1",
|
||||
"--algorithm",
|
||||
"1",
|
||||
TEST_ZONE_NAME,
|
||||
],
|
||||
);
|
||||
assert_cmds_eq(
|
||||
&[LDNS_NSEC3_CMD, "-s", "", TEST_ZONE_NAME],
|
||||
&[
|
||||
DNST_NSEC3_SUBCMD,
|
||||
"--iterations",
|
||||
"1",
|
||||
"--salt",
|
||||
"",
|
||||
TEST_ZONE_NAME,
|
||||
],
|
||||
);
|
||||
assert_cmds_eq(
|
||||
&[LDNS_NSEC3_CMD, "-s", "DEADBEEF", TEST_ZONE_NAME],
|
||||
&[
|
||||
DNST_NSEC3_SUBCMD,
|
||||
"--iterations",
|
||||
"1",
|
||||
"--salt",
|
||||
"DEADBEEF",
|
||||
TEST_ZONE_NAME,
|
||||
],
|
||||
);
|
||||
|
||||
for iterations in 0..10 {
|
||||
assert_cmds_eq(
|
||||
&[
|
||||
LDNS_NSEC3_CMD,
|
||||
"-t",
|
||||
&iterations.to_string(),
|
||||
TEST_ZONE_NAME,
|
||||
],
|
||||
&[
|
||||
DNST_NSEC3_SUBCMD,
|
||||
"-i",
|
||||
&iterations.to_string(),
|
||||
TEST_ZONE_NAME,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_cmds_eq(cmd1: &[&str], cmd2: &[&str]) {
|
||||
let cmd1_output = Command::new(cmd1[0]).args(&cmd1[1..]).output().unwrap();
|
||||
|
||||
let cmd2_output = test_bin::get_test_bin("dnst").args(cmd2).output().unwrap();
|
||||
|
||||
assert_eq!(
|
||||
std::str::from_utf8(&cmd1_output.stderr),
|
||||
Ok(""),
|
||||
"Unexpected stderr content for command: {}",
|
||||
cmd1.join(" ")
|
||||
);
|
||||
assert_eq!(
|
||||
std::str::from_utf8(&cmd2_output.stderr),
|
||||
Ok(""),
|
||||
"Unexpected stderr content for command: {}",
|
||||
cmd2.join(" ")
|
||||
);
|
||||
assert!(
|
||||
!cmd1_output.stdout.is_empty(),
|
||||
"Expected stdout content for command: {}: {:?}",
|
||||
cmd1.join(" "),
|
||||
std::str::from_utf8(&cmd1_output.stdout)
|
||||
);
|
||||
assert!(
|
||||
!cmd2_output.stdout.is_empty(),
|
||||
"Expected stdout content for command: {}: {:?}",
|
||||
cmd2.join(" "),
|
||||
std::str::from_utf8(&cmd2_output.stdout)
|
||||
);
|
||||
assert_eq!(
|
||||
cmd1_output.status.code(),
|
||||
cmd2_output.status.code(),
|
||||
"Exit code mismatch for command: {}",
|
||||
cmd1.join(" ")
|
||||
);
|
||||
|
||||
// This will only work for LDNS commands whose output we are able to
|
||||
// replicate exactly.
|
||||
assert_eq!(
|
||||
std::str::from_utf8(&cmd1_output.stdout),
|
||||
std::str::from_utf8(&cmd2_output.stdout),
|
||||
"Stdout content mismatch for command: {}",
|
||||
cmd1.join(" ")
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user