Repository navigation
Require 112-bit OTP secrets and update illustrative examples - #205
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.