fix: support parsing SM2 certificates in X.509 operation#2630
Open
mansiverma897993 wants to merge 1 commit into
Open
fix: support parsing SM2 certificates in X.509 operation#2630mansiverma897993 wants to merge 1 commit into
mansiverma897993 wants to merge 1 commit into
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.
Description
Resolves the "unsupported curve name" error when parsing certificates signed with SM2 public keys.
The
jsrsasignlibrary used by CyberChef lacks native mappings for the SM2 curve OID (1.2.156.10197.1.301) and the SM2-with-SM3 signature algorithm OID (1.2.156.10197.1.501). This caused the parser to throw a hard exception during public key name resolution and fail to parse the certificate.This PR implements the following:
sm2p256v1) inr.crypto.ECParameterDBand registers the OID mappings insideParseX509Certificate.mjsruntime context.r.crypto.ECDSA.getNameto return"sm2p256v1"when resolving the SM2 OIDs.cert.getPublicKey()in a try-catch block to prevent hard crashes on other unrecognized curves, gracefully falling back to displaying the Raw SPKI Hex and the associated error message.Existing Issue
Fixes #2629
Screenshots
None (non-visual parser backend change).
AI disclosure
This code was created with the assistance of Antigravity, an AI assistant powered by Google DeepMind.
Test Coverage
Added automated test cases covering RSA, EC, and SM2 parsing in
tests/operations/tests/ParseX509Certificate.mjs. All 2,062 tests pass successfully.