feat(xmldsig): resolve ECKeyValue keys#70
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughXMLDSig 1.1 ChangesECKeyValue Parsing and Resolution
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/xmldsig/keys.rs`:
- Around line 285-296: The EC curve OIDs in the key resolver are duplicated as
string literals, which can drift from the parser contract. Update the match in
the key resolution logic to reuse the shared EC OID constants instead of
hardcoded values, ideally by importing the constants used by the parser or
moving them into a common module; keep the existing behavior in the resolver
around the p256::PublicKey and p384::PublicKey branches unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7bd984fb-f24f-4ab5-8b54-52ea39f22419
📒 Files selected for processing (6)
README.mdsrc/xmldsig/keys.rssrc/xmldsig/parse.rstests/fixtures/xmldsig/xmldsig11-interop-2012/signature-enveloping-p256_sha256.xmltests/fixtures/xmldsig/xmldsig11-interop-2012/signature-enveloping-p384_sha384.xmltests/fixtures_smoke.rs
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/xmldsig/parse.rs (1)
2370-2374: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the decoded EC point bytes, not only the length.
This positive P-384 case would still pass if the parser returned any 97-byte point. Compare
public_keyto the expected SEC1 bytes to cover the “preserve exact point bytes” contract for this fixture.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/xmldsig/parse.rs` around lines 2370 - 2374, The P-384 assertion in the EC key parsing test only checks the point length, so it can miss regressions in the decoded bytes. Update the test around the `assert!(matches!(...))` for `KeyInfoSource::KeyValue(KeyValueInfo::Ec { curve_oid, public_key })` to compare `public_key` against the expected SEC1-encoded bytes for this fixture, while still verifying `EC_P384_OID`, so the exact point-preservation contract is tested.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/xmldsig/keys.rs`:
- Around line 641-689: Add a regression test around the key resolution path in
VerifyContext/DefaultKeyResolver that exercises a document containing only an
invalid or curve-mismatched dsig11:ECKeyValue and no later fallback source. The
test should assert that verification returns the deferred typed error from
ECKeyValue handling, specifically InvalidPublicKey or AlgorithmMismatch, rather
than KeyNotFound or a silent ignore. Reuse the existing helpers and symbols like
replace_key_info, KeyResolverConfig, VerificationKey,
SignatureAlgorithm::EcdsaP256Sha256, and verify to locate and cover the
no-fallback branch.
---
Outside diff comments:
In `@src/xmldsig/parse.rs`:
- Around line 2370-2374: The P-384 assertion in the EC key parsing test only
checks the point length, so it can miss regressions in the decoded bytes. Update
the test around the `assert!(matches!(...))` for
`KeyInfoSource::KeyValue(KeyValueInfo::Ec { curve_oid, public_key })` to compare
`public_key` against the expected SEC1-encoded bytes for this fixture, while
still verifying `EC_P384_OID`, so the exact point-preservation contract is
tested.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d9adde8c-5f87-4058-827d-f3fd48b3169c
📒 Files selected for processing (2)
src/xmldsig/keys.rssrc/xmldsig/parse.rs
|
@coderabbitai Fixed the outside-diff P-384 parser test item. |
|
Tip For best results, initiate chat on the files or code changes.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/xmldsig/parse.rs`:
- Around line 627-633: The `public_key` parsing in `parse.rs` currently treats
all failures from `decode_crypto_binary` and `validate_ec_public_key_point` as
`KeyValueInfo::InvalidEcPublicKey`, which incorrectly makes malformed
`PublicKey` payloads fallback-eligible. Update the `public_key` match so only
successfully decoded values that fail `validate_ec_public_key_point` map to
`InvalidEcPublicKey`, while decode/structure/base64 errors from
`decode_crypto_binary` are returned as real parse failures. Use the `public_key`
decode block, `decode_crypto_binary`, and `validate_ec_public_key_point` to
separate fatal decode errors from non-fatal invalid EC-point cases.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 008a43bf-daf3-430b-b9a6-cd14100fb211
📒 Files selected for processing (2)
src/xmldsig/keys.rssrc/xmldsig/parse.rs
Summary
dsig11:ECKeyValueinto curve OID plus uncompressed SEC1 public pointTesting
cargo fmt -- --checkcargo check --workspacecargo clippy --all-targets --all-features -- -D warningscargo build --workspace --all-featurescargo nextest run --workspace(494 passed)cargo test --doc --workspace(3 passed)git diff --checkCloses #69