Skip to main content

A tool to compute NSEC3 hashes for DNS labels

Project description

NSEC3 Hash Utility

This project provides a Python CLI tool to compute the NSEC3 hash for a Fully-Qualified Domain Name (FQDN). The NSEC3 hash is commonly used in DNSSEC deployments to provide authenticated denial of existence without leaking zone contents.

Features

  • Converts a domain name into its canonical DNS wire format.
  • Hashes the name using SHA-1 with optional salt and iterations, as defined by the NSEC3 specification.
  • Outputs the hash as an NSEC3-compliant Base32hex string (without padding, using characters 0-9 and A-V).

Usage

  1. Ensure your input is a Fully-Qualified Domain Name (FQDN):

    • The name must end with a dot (e.g., www.example.com.).
    • The trailing dot denotes the root of the DNS tree; omitting it will canonicalize the name by appending a dot automatically, but for correctness and standard compliance, always provide FQDN.
  2. Running from the command line:

    python3 hash_nsec3.py <name> [--salt SALT] [--iterations N]
    
    • <name>: The domain name to hash, e.g., host.example.com.
    • --salt SALT: (Optional) Hexadecimal salt string, e.g., AABBCCDD (default is no salt).
    • --iterations N: (Optional) Number of additional hash iterations (default: 0).

    Examples

    python3 hash_nsec3.py www.example.com.
    python3 hash_nsec3.py www.example.com. --salt AABBCC
    python3 hash_nsec3.py www.example.com. --salt AABBCC --iterations 5
    

About NSEC3 Hashing

  • Canonicalization: The tool converts domain names to the DNS wire format (length-prefixed labels, lowercased).
  • Hashing: It applies SHA-1, followed by the specified number of additional iterations, salting each hash.
  • Base32hex Encoding: The raw 20-byte SHA-1 digest is encoded according to RFC 4648 section 7, without padding and using the restricted alphabet.

For example, the hash of www.example.com. with no salt and zero iterations will be a 32-character Base32-encoded string, MIFDNDT3NFF3OD53O7TLA1HRFF95JKUK

References

Alternatives

ISC have a similar command, called nsec3hash written in C as part of BIND

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_nsec3hash-1.0.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_nsec3hash-1.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file py_nsec3hash-1.0.2.tar.gz.

File metadata

  • Download URL: py_nsec3hash-1.0.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for py_nsec3hash-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2749a993d947c79f69116cf9b0a3c1d9b805cc32047aa9df8617d0a903c66b92
MD5 f5b9ac32e0e2fdd21eaf72b0a0134362
BLAKE2b-256 8478d37e4718eb3ca551f2ecbab097cbb446f245dfa49fc8353d9ca928db4f26

See more details on using hashes here.

File details

Details for the file py_nsec3hash-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for py_nsec3hash-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fab7899fae417d2794e61e69a31add66d2c1d66e114c65ef3585f659e338fa25
MD5 79756eda0db7f6e4de6ce8abc2a3c6ac
BLAKE2b-256 ecfb1478f8fe7387769ff210a1a8157d99228a64f8e36da37d662132b0bec60f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page