Handle incompatibility between parameters and unique in TPublic
#41
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.
Summary
This PR addresses an issue where the
t_public.parametersandt_public.uniqueare incompatible by preventing the gem from raising an exception when this happens and just returningnilas result ofTPM:KeyAttestation#key.Why?
We discovered this issue after upgrading
tpm-key_attestationto0.13.1in cedarcode/webauthn-ruby#449. During this upgrade, a test failure in theWebAuthntest suite revealed an unsupported edge case: calling thekeymethod ofKeyAttestationraises an exception whent_public.parametersandt_public.uniqueare incompatible.The exception occurs in the following code:
tpm-key_attestation/lib/tpm/t_public.rb
Lines 82 to 85 in 8ea5976
This issue went unnoticed before because
key_attestation.valid?used to returnfalse(because it failed to validate the signature), preventingkey_attestation.keyfrom being called. However, after changes to the signature validation process in #29,valid?now returnstruefor this scenario, which led the test to fail because thepubAreafor this scenario was set up with incompatibleparametersanduniqueattributes (because the coordinatesxandyare inconsistent with itscurve).Although we haven’t encountered this scenario in real-world applications, the
WebAuthntest suite helped uncover this validation gap.