Repository navigation
Conversation
Callers configuring verification keys had no way to validate them except by verifying a dummy signature. Add constructors that check key material when the key is configured: - VerifyingKey::es256_spki parses the SPKI DER P-256 key. - VerifyingKey::ps256_spki (ps256 feature) parses the SPKI DER RSA key and enforces the existing 2048-bit minimum. - VerifyingKey::hmac_sha256 requires at least 32 bytes, per RFC 7518 §3.2 (key at least as long as the hash output). All return Error::InvalidKey. The enum variants remain available for unchecked construction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
VerifyingKey's variants accept any bytes. A malformed or undersized key only surfaces as a failure on the first token it's used for. Callers who want to validate configured keys have to verify a dummy signature.Change
New constructors validate key material and return
Error::InvalidKey:VerifyingKey::es256_spki(der)parses the SPKI DER P-256 public key.VerifyingKey::ps256_spki(der)parses the SPKI DER RSA public key and enforces the existing 2048-bit minimum. It requires theps256feature.VerifyingKey::hmac_sha256(secret)requires at least 32 bytes. RFC 7518 §3.2 requires an HMAC key at least as long as the hash output.The enum variants remain available for unchecked construction.
Tests
cargo testpasses with default features (63 unit tests, 74 doctests) and with--no-default-features(56 unit tests, 74 doctests). Clippy is clean in both configurations.🤖 Generated with Claude Code