-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECDsa support in System.Security.Cryptography.Xml.SignedXml #36103
Comments
I believe it is possible to get this working today if you are able to implementing the formatters and are able to ensure its correctness. If you set the signature method URI before signing, it will attempt to resolve a CryptoConfig.AddAlgorithm(typeof(ECDsaP256SHA256SignatureDescription), "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256");
XmlDocument doc = GetDocument();
SignedXml sxml = new SignedXml(doc);
sxml.SignedInfo.SignatureMethod = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256";
using var ecdsa = ECDsa.Create(ECCurve.NamedCurves.nistP256);
sxml.SigningKey = ecdsa; The trick then is to create and implement the I threw together a gist that implements a bare-bones example here: https://gist.github.com/vcsjones/07460cd1a0adf03ade27151efdf266e2. It bears repeating that this code is a quickly thrown together example to explore the feasibility of it. |
@vcsjones thanks for sharing. Example code in you gist looks to be working correctly. On https://gist.github.com/olljanat/848c51c141634c7306712fe1bbb20727 I combined it with HLKX package signing code and hardware submission portal looks to be detecting it as correctly signed file. However as far I see, there is not way to define |
This feature request is related to the following problem:
When I'm using
System.Security.Cryptography.Xml.SignedXml
, if the type ofSigningKey
isECDsa
,ComputeSignature
will throwCryptographicException
.The exception was thrown at this line:
runtime/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs
Line 401 in 3011955
If I set
SignedInfo.SignatureMethod
to"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"
by setting protected fields through a subclass, another exception will be thrown at:runtime/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs
Line 408 in 3011955
Description of what API need to be added or changed
System.Security.Cryptography.Xml.SignedXml
should be able to create and verifyECDsa
xml signatures.The text was updated successfully, but these errors were encountered: