-
Notifications
You must be signed in to change notification settings - Fork 5.1k
SignedCms add tests and reduce allocations #116400
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
SignedCms add tests and reduce allocations #116400
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces additional tests for the SignedCms functionality with a particular focus on verifying behavior when a certificate with an unknown SPKI is supplied while also refactoring internal methods to reduce allocations.
- Added tests to validate the NoSignature behavior with an unknown algorithm certificate
- Updated several internal methods in SignerInfo.cs to use generic state parameters and optimized memory usage with stackalloc/arraypool techniques
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.cs | Added tests for NoSignature behavior and default digest computation |
src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfo.cs | Updated verify callback methods and optimized allocation using stackalloc and arraypool |
Comments suppressed due to low confidence (2)
src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfo.cs:680
- The use of the magic number 0x31 here could be clarified by either defining it as a named constant or adding a comment explaining its significance in the encoding process.
encoded[0] = 0x31;
src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfo.cs:928
- [nitpick] Consider renaming the tuple element '@this' to a more descriptive name (e.g., 'signerInfo') to improve code clarity in the callback methods.
static (state, contentToVerify) => state.signatureProcessor.VerifySignature(
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
...raries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfo.cs
Show resolved
Hide resolved
{ | ||
return VerifyHashedMessage( | ||
compatMode, | ||
(@this: this, signatureProcessor, certificate), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@this: this, signatureProcessor, certificate), | |
(info: this, signatureProcessor, certificate), |
@this
always looks icky.
TState
to a couple of sites to reduce allocationsContributes to #115578