hmac

Generic, pure-Rust implementation of Hash-based Message Authentication Code (HMAC)

Library
Cargo
v0.13.0
371stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
51/100Fair
Development Activity52
Maintenance8
Community64
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture86
Code Quality88
Innovation80
Learning Curve75

hmac is RustCrypto’s generic implementation of HMAC (Hash-based Message Authentication Code), the algorithm underlying JWT signing, TLS handshakes, and countless API request-signing schemes. Rather than baking in one hash function, it is generic over any hash implementing the digest crate’s EagerHash trait, so the same Hmac<D> type works with SHA-256, SHA-512, SHA-3, or any other RustCrypto digest by swapping a type parameter.

The crate lives in the RustCrypto/MACs monorepo alongside sibling MAC algorithms (CMAC, PMAC, CBC-MAC, Retail MAC, Belt-MAC), all built on the same shared digest/crypto-common trait foundation that underlies the wider RustCrypto ecosystem. It is #![no_std], making it usable in embedded and constrained environments, and is one of the most widely depended-upon crates in the Rust ecosystem for authenticated message integrity.

What You Get

  • A Hmac<D> type generic over any hash implementing digest::block_api::EagerHash, so switching hash functions is a type-parameter change
  • SimpleHmac and SimpleHmacReset variants for hash functions that don’t implement the EagerHash block-level optimization
  • #![no_std] support for embedded and constrained targets with no heap or OS dependency
  • An optional zeroize feature to securely wipe key material from memory when a Hmac instance is dropped
  • A Reset variant (HmacReset) allowing an HMAC instance to be reused across multiple messages without reallocating state

Common Use Cases

  • Signing and verifying JWTs using the HS256/HS384/HS512 algorithm family
  • Implementing HMAC-based request signing for API authentication (e.g. AWS SigV4-style signing schemes)
  • TLS and other cryptographic protocol implementations that need HMAC as a building block for key derivation (HKDF) or record authentication
  • Embedded firmware needing message authentication without a heap allocator, via the crate’s no_std support

Under The Hood

Architecture - The hmac crate lives in the RustCrypto/MACs workspace (hmac/) alongside sibling crates (cmac/, pmac/, cbc-mac/, retail-mac/, belt-mac/) that share the same digest/crypto-common trait foundation used across all of RustCrypto’s hash and cipher crates. Internally, src/lib.rs defines the public Hmac<D>/HmacReset<D> types via the digest::buffer_fixed! macro, which wires up the generic block-buffering logic once and reuses it for both variants; block_api.rs implements the actual inner/outer-pad HMAC construction at the block level for hashes that support eager block processing, while simple.rs/simple_reset.rs provide a fallback implementation for hashes that don’t.

Tech Stack - Pure Rust, #![no_std], with a single runtime dependency on the digest crate (itself part of the RustCrypto trait ecosystem). Rust edition 2024, MSRV 1.85. Dev-dependencies pull in concrete hash implementations (md-5, sha1, sha2, streebog) purely for testing against known test vectors, not as runtime dependencies of the published crate.

Code Quality - The crate has a dedicated tests/ directory for integration-level test-vector verification in addition to a small, focused src/ implementation (548 total lines across lib.rs, block_api.rs, simple.rs, simple_reset.rs, utils.rs), consistent with RustCrypto’s project-wide convention of validating primitives against published standard test vectors (RFC 2104, FIPS 198-1). Licensed under dual MIT/Apache-2.0, the standard RustCrypto licensing convention, with LICENSE-MIT and LICENSE-APACHE both present in the crate directory.

API Design - The API follows the shared digest/crypto-common trait conventions used across all RustCrypto crates: construct via KeyInit::new_from_slice, feed data via the Mac trait’s update, then finalize via finalize/verify_slice. This trait-based consistency means learning hmac’s API transfers directly to every other RustCrypto MAC or hash crate, at the cost of needing some familiarity with the digest crate’s trait hierarchy up front.

Used by 16 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
51%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,087

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript51%
Rust38%
Updated today
Dart
74%
AGPL 3.0

AppFlowy

Productivity · Project Management · Collaboration

75,729

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
66
Dependency
Built with
Dart74%
Rust24%
Updated 1 weeks ago
TypeScript
75%
GPL 3.0

Bramble

Password Manager · Security · Authentication

315

Local-first, end-to-end encrypted password manager that syncs your vault directly between your own devices over a private peer-to-peer mesh — no server, no account, no cloud in the middle.

View details
73
Repo Health
84
Technical
72
Dependency
Built with
TypeScript75%
Updated today
Swift
64%
GPL 3.0

cmux

Developer Tools · AI Development

26,221

A native, Ghostty-based macOS terminal with vertical tabs, agent-aware notifications, and a scriptable browser built for running many parallel AI coding agent sessions instead of juggling tmux panes.

View details
84
Repo Health
81
Technical
72
Dependency
Built with
Swift64%
Rust14%
Updated today
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,761

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
67
Dependency
Built with
TypeScript75%
Updated today
Rust
50%
Other

hoodik

File Storage · Security

1,446

Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support

View details
74
Repo Health
71
Technical
65
Dependency
Built with
Rust50%
TypeScript33%
Vue15%
Updated 4 days ago
Rust
41%
Other

Hook0

Devops

1,477

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
83
Repo Health
82
Technical
70
Dependency
Built with
Rust41%
TypeScript17%
JavaScript15%
Updated today
TypeScript
75%
Other

Jan

AI Assistants

44,052

Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.

View details
90
Repo Health
81
Technical
66
Dependency
Built with
TypeScript75%
Rust21%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search