hkdf
HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
What it is and what it does
HKDF is a cryptographic key derivation function that implements the HMAC-based Extract-and-Expand Key Derivation Function as specified in the draft RFC. It takes input key material (typically a password or shared secret) and derives one or more cryptographically strong keys suitable for use in encryption, authentication, or other cryptographic operations. The package provides both a functional interface (separate `hkdf_extract()` and `hkdf_expand()` functions) and a wrapper class (`Hkdf`) for convenience.
The functional interface defaults to SHA-512 for hashing, while the wrapper class defaults to SHA-256. Both allow you to specify a custom hash function. The extract phase produces a pseudorandom key (PRK) from input material and an optional salt; the expand phase then generates output key material of a specified length, optionally parameterized by context information. This is useful when you need to derive multiple independent keys from a single source or when you need to convert weak input into strong cryptographic material.
Use it for:
- Derive encryption keys from a user password in a password-based key derivation workflow.
- Generate multiple independent session keys from a single shared secret in a protocol handshake.
- Expand a master key into subkeys for different purposes (e.g., encryption, authentication, integrity).
- Implement cryptographic protocols that require HKDF-based key material generation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements HMAC-based Key Derivation Function (HKDF) with extract-and-expand operations for deriving cryptographic keys from input key material.
No. The package is dormant (last release 2015-06-16, classifiers list only Python 2.6–3.4, all end-of-life), has high install friction (source-only), and offers no runtime dependencies to ease integration. Install only if you are maintaining legacy Python 2 code that already depends on it.
Install
hkdf on PyPI
pip
pip install hkdfuv
uv add hkdfpoetry
poetry add hkdfInstalling hkdf
Before you install
High install friction due to source-only distribution (hkdf-0.0.3.tar.gz). Maintenance is dormant—last release was 2015-06-16 and last commit 2024-01-17, with no recent activity. Classifiers indicate support only for Python 2.6, 2.7, 3.3, 3.4, all of which are end-of-life.
License in practice
Licensed under BSD (permissive), which permits commercial and private use with minimal restrictions. No notable licensing constraints for most use cases.
Quickstart
from hkdf import hkdf_extract, hkdf_expand
from binascii import unhexlify
prk = hkdf_extract(unhexlify(b"8e94ef805b93e683ff18"), b"asecretpassword")
key = hkdf_expand(prk, b"context1", 16)
No runtime dependencies, but package is source-only and classifiers list only Python 2.6–3.4, all end-of-life versions. Compatibility with modern Python versions is unverified.
Verify before relying
- Whether the package actually works on Python 3.5 or later despite classifiers listing only 2.6–3.4.
- Whether any security review or audit has been performed on the HKDF implementation since 2015.
- Current maintenance status and whether the author is accepting pull requests or bug reports.
Package facts
| License | UNKNOWN (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | dormant — 4,077 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 101,992/month — #12,900 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: hkdf-0.0.3.tar.gz
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
pyscryptA pure-Python implementation of the scrypt…
permissive · top 15,000 on PyPI
aws-cryptographic-material-providersProvides cryptographic material management and…
unclear · top 15,000 on PyPI
eth-keyfileLoads, creates, and decrypts Ethereum…
permissive · top 5,000 on PyPI
diffiehellmanlibGenerates Diffie-Hellman key exchange…
permissive · top 15,000 on PyPI
keyrings.cryptfileA keyring backend that stores passwords in an…
permissive · top 15,000 on PyPI
altchaCreates and verifies ALTCHA proof-of-work…
permissive · top 15,000 on PyPI
scryptPython bindings for the scrypt key derivation…
permissive · top 15,000 on PyPI
spake2Implements SPAKE2, a password-authenticated key…
permissive · top 15,000 on PyPI
bip32Implements BIP 32 hierarchical deterministic…
permissive · top 15,000 on PyPI
bcryptbcrypt provides modern password hashing using…
permissive · top 1,000 on PyPI