-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Fix dispose pattern in PQC types #117096
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
Fix dispose pattern in PQC types #117096
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 ensures that the dispose pattern in several PQC implementations follows the correct guidelines by calling managed dispose methods only when disposing is true and by invoking the base.Dispose method consistently. Key changes include:
- Adding base.Dispose(disposing) in multiple Dispose methods.
- Wrapping managed dispose calls with the disposing check in some implementations.
- Standardizing the dispose pattern across different cryptographic types.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/SlhDsaImplementation.OpenSsl.cs | Added base.Dispose(disposing) but still missing the disposing check when calling _key?.Dispose(). |
src/libraries/Common/src/System/Security/Cryptography/MLKemCng.Windows.cs | Added base.Dispose(disposing) but did not wrap _key.Dispose() with an if (disposing) check. |
src/libraries/Common/src/System/Security/Cryptography/MLDsaImplementation.Windows.cs | Added an explicit if (disposing) check before disposing _key and then calling base.Dispose(disposing). |
src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs | Added an explicit if (disposing) check before disposing _key and then calling base.Dispose(disposing). |
...ystem.Security.Cryptography/src/System/Security/Cryptography/SlhDsaImplementation.OpenSsl.cs
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/MLKemCng.Windows.cs
Show resolved
Hide resolved
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
I don't think we have been following the dispose pattern correctly for a few of the PQC implementations. We should only call managed dispose methods if
disposing
is true.Technically we should also be calling the base implementation, even though they do nothing right now.
This makes the dispose pattern usage more consistent with other cryptographic algorithms.