Crypto: add HMAC-SHA1 and PBKDF2-HMAC-SHA256 #41

Closed
opened 2026-12-03 10:24:26 +00:00 by faumaray · 1 comment
Owner

Context: Forge needs HOTP/TOTP and password-hash compatibility (Gitea pbkdf2_sha256) for M04 identity. Forge currently ships temporary RFC-verified implementations and tracks this as VL-CRYPTO-01 and VL-CRYPTO-02.

Need:

  • HMAC-SHA1 (RFC 2104) for HOTP (RFC 4226) and TOTP (RFC 6238).
  • PBKDF2-HMAC-SHA256 (RFC 8018) with checked iteration/salt/output bounds.

Both should be constant-time where they compare or process secrets, wipe intermediate key material, and never log inputs.

Tests/gate: RFC 2202 and RFC 4231 vectors for HMAC, RFC 4226/6238 vectors for the OTP consumers, and RFC 7914 PBKDF2 vectors plus boundary and overflow cases. Forge M04 swaps its temporary implementation for these.

Context: Forge needs HOTP/TOTP and password-hash compatibility (Gitea pbkdf2_sha256) for M04 identity. Forge currently ships temporary RFC-verified implementations and tracks this as VL-CRYPTO-01 and VL-CRYPTO-02. Need: - HMAC-SHA1 (RFC 2104) for HOTP (RFC 4226) and TOTP (RFC 6238). - PBKDF2-HMAC-SHA256 (RFC 8018) with checked iteration/salt/output bounds. Both should be constant-time where they compare or process secrets, wipe intermediate key material, and never log inputs. Tests/gate: RFC 2202 and RFC 4231 vectors for HMAC, RFC 4226/6238 vectors for the OTP consumers, and RFC 7914 PBKDF2 vectors plus boundary and overflow cases. Forge M04 swaps its temporary implementation for these.
Author
Owner

Implemented on branch issue-41-hmac-pbkdf2 (commit 74bd01a): hmac_sha1(_into) and pbkdf2_hmac_sha256(_into) with checked bounds, constant-time handling, wiped intermediates, and a built-in backend when OpenSSL is absent. Merged into main. RFC 2202/4226/6238/7914 vectors and boundary/overlap/fault tests pass on both backends. Closing as done.

Implemented on branch `issue-41-hmac-pbkdf2` (commit `74bd01a`): `hmac_sha1(_into)` and `pbkdf2_hmac_sha256(_into)` with checked bounds, constant-time handling, wiped intermediates, and a built-in backend when OpenSSL is absent. Merged into `main`. RFC 2202/4226/6238/7914 vectors and boundary/overlap/fault tests pass on both backends. Closing as done.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Void/Library#41