Check signing algo in COSE attached verify#7476
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds algorithm verification to the COSE Sign1 verification process by checking that the algorithm specified in the COSE message header matches the algorithm supported by the verification key.
Key Changes
- Extracts the algorithm identifier from the COSE message's protected header
- Derives the expected algorithm identifier from the public key's curve type
- Validates that both algorithms match before proceeding with signature verification
- Returns early with an error if algorithms are incompatible or cannot be determined
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
|
Looks like we do the same prefix of checks in |
Member
Author
|
Ok, adding this apparently benign check has uncovered the following problems:
|
achamayou
commented
Nov 21, 2025
cjen1-msft
approved these changes
Nov 21, 2025
eddyashton
reviewed
Nov 21, 2025
eddyashton
reviewed
Nov 21, 2025
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.
Prompted by #7468, and includes #7468 after further further checks.
This change uncovered what was effectively an abuse of the
ECPublicKey_OpenSSLclass to cover both EC and RSA verification. The following changes have been made:PublicKey_OpenSSLhas been added, to wrap either kind/all kinds of EVP_PKEY. This works well with t_cose, which also does.ECPublicKey_OpenSSLconstruction now fails if the input is an RSA key, matchingRSAPublicKey_OpenSSLECPublicKey_OpenSSLandRSAPublicKey_OpenSSLnow inherit fromPublicKey_OpenSSLto reduce code duplication. This may or may not be a good thing, as discussed with @maxtropets, but is an internal implementation choice that is not exposed in the public headers and can be adjusted at a later time if desired.