Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

vcsjones
Copy link
Member

The bypasses a few more defensive copies in PublicKey.

AsnEncodedData(AsnEncodedData) makes a defensive copy of the data for itself, which the constructor of PublicKey uses. However, there are a few factory methods in PublicKey that create an AsnEncodedData solely for the purpose of transferring to PublicKey. In that circumstance, we can bypass the copy since the creation of the AsnEncodedData already made the defensive copy.

Likewise for X509Certificate2.PublicKey. This shaves several hundred bytes in allocation, scaling with the key size.

@ghost ghost added the area-System.Security label Jan 17, 2024
@ghost ghost assigned vcsjones Jan 17, 2024
@ghost
Copy link

ghost commented Jan 17, 2024

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

The bypasses a few more defensive copies in PublicKey.

AsnEncodedData(AsnEncodedData) makes a defensive copy of the data for itself, which the constructor of PublicKey uses. However, there are a few factory methods in PublicKey that create an AsnEncodedData solely for the purpose of transferring to PublicKey. In that circumstance, we can bypass the copy since the creation of the AsnEncodedData already made the defensive copy.

Likewise for X509Certificate2.PublicKey. This shaves several hundred bytes in allocation, scaling with the key size.

Author: vcsjones
Assignees: vcsjones
Labels:

area-System.Security

Milestone: -

@stephentoub stephentoub merged commit 23eaf25 into dotnet:main Jan 20, 2024
tmds pushed a commit to tmds/runtime that referenced this pull request Jan 23, 2024
@vcsjones vcsjones added this to the 9.0.0 milestone Jan 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants