Skip to content

Add SHA-256/SHA-512 TOTP variants (#43) - #96

Merged
sidick merged 1 commit into
mainfrom
issue-43-sha2-totp
Jul 22, 2026
Merged

sidick merged 1 commit into
mainfrom
issue-43-sha2-totp

Conversation

@sidick

@sidick sidick commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • RFC 6238 allows HMAC-SHA256/SHA512 alongside the near-universal SHA-1; the vault format already reserved algorithm ids 1/2 for them (docs/VAULT_FORMAT.md), so this activates them rather than changing the format.
  • Adds portable SHA-256/SHA-512 (src/core/sha256.*, sha512.*) and their HMAC variants, and generalises otp.c around an otp_alg dispatch (hotp()/totp() plus a shared otp_render() every front-end now uses for code formatting).
  • otpauth://'s algorithm= parameter is parsed and validated — an algorithm AmiAuth doesn't implement is rejected outright, rather than silently generating (wrong) SHA-1 codes.
  • Both the CLI and GUI code-rendering paths now go through otp_render().

Test plan

  • make test — 256 host unit tests pass, including RFC 6238 App. B SHA-256/SHA-512 vectors
  • make diff — OpenSSL differential fuzz pass for SHA-256, SHA-512, HMAC-SHA256, HMAC-SHA512 (0 mismatches)
  • make m68k-docker / make gui-docker — plain 68000 baseline cross-builds succeed
  • make gui-smoke — headless Copperline GUI smoke test passes
  • make smoke — CLI smoke test passes
  • Manual CLI run: added SHA-256 and SHA-512 accounts via otpauth:// URIs, confirmed correct codes and that an unsupported algorithm= is rejected
  • userdocs/ updated in this PR (Managing-Accounts.md, Security-Model.md, Troubleshooting-and-FAQ.md); docs/VAULT_FORMAT.md updated for the activated algorithm ids

🤖 Generated with Claude Code

RFC 6238 allows HMAC-SHA256/SHA512 alongside the near-universal SHA-1.
Adds portable SHA-256/SHA-512 (src/core/sha256.*, sha512.*) and their
HMAC variants, generalises otp.c around an otp_alg dispatch (hotp()/totp()
plus an otp_render() every front-end now shares for code formatting),
parses otpauth://'s algorithm= parameter (rejecting anything unimplemented
rather than silently falling back to SHA-1), and activates the vault
format's already-reserved algorithm ids 1/2. Covered by RFC 6238 App. B
vectors and an OpenSSL differential fuzz pass for every new primitive.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sidick sidick mentioned this pull request Jul 22, 2026
7 tasks done
@sidick
sidick merged commit 2986a73 into main Jul 22, 2026
7 checks passed
@sidick
sidick deleted the issue-43-sha2-totp branch July 22, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant