Skip to content

Require 112-bit OTP secrets and update illustrative examples - #205

Merged
kislyuk merged 4 commits into
mainfrom
codex/nist-minimum-secret
Nov 15, 2026
Merged

kislyuk merged 4 commits into
mainfrom
codex/nist-minimum-secret

Conversation

@kislyuk

@kislyuk kislyuk commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Raise the decoded OTP secret minimum from 80 to 112 bits (14 bytes), as required by NIST SP 800-63B-4 section 3.1.4.1 and SP 800-131A Rev. 2 section 10. Section 3.1.4.2 supplies the related verifier requirements. OTP, HOTP, TOTP, and Steam validate Base32 encoding and decoded key length during construction. URI parsing inherits these checks. Generation and verification also revalidate the secret if it is changed after construction.

Extend the README's recognizable teaching seeds, recalculate the displayed OTPs, and update provisioning URIs and the QR payload. Use a fixed timestamp for reproducible TOTP outputs.

Fixture audit: the RFC 4226 and RFC 6238 vectors use 160-, 256-, or 512-bit keys and have no non-conformant key lengths or hash choices under these references. Their seeds and expected outputs are unchanged. Preserve the legacy 80-bit Google Authenticator and Steam vectors as rejection cases, and extend the non-RFC successful fixtures with recalculated outputs. Replace malformed or short URI-only placeholders with valid seeds; add explicit rejection tests for constructors and URI parsing.

Hash audit: SHA-1, SHA-256, and SHA-512 are allowed for HMAC under SP 800-131A Rev. 2 sections 9 and 10. See NIST's SHA-1 transition. BLAKE2b, BLAKE2s, SM3, RIPEMD-160, and MD5-SHA1 are outside the approved hash list, even where compatible implementations can be supplied through the open-ended digest argument. This PR enforces key length, not a digest allowlist or a claim of full NIST conformance.

Validation: 58 unit tests; strict mypy; Ruff lint and formatting; strict Twine checks for wheel and sdist; fixed outputs, URI strings, and QR seed checked; RFC vectors compared with their original ASTs. Also merged locally with the separate interval-limit branch: all 61 combined tests and the Sphinx build pass.

@kislyuk
kislyuk merged commit 0445a06 into main Nov 15, 2026
38 checks passed
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