Skip to content
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

Use output size helpers for cryptographic primitives #82800

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

vcsjones
Copy link
Member

This updates a few places that can use algorithm output size helpers.

Closes #67059

@ghost
Copy link

ghost commented Feb 28, 2023

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

Issue Details

This updates a few places that can use algorithm output size helpers.

Closes #67059

Author: vcsjones
Assignees: -
Labels:

area-System.Security

Milestone: -

@vcsjones vcsjones marked this pull request as ready for review February 28, 2023 23:54
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Since it isn't a fatal error to miscalculate the estimatedSize, don't throw an exception. Just truck along.
_ => KeySize / 4,
};
int estimatedSize = GetMaxSignatureSize(DSASignatureFormat.IeeeP1363FixedFieldConcatenation);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this more expensive? The implementation of the method isn't trivial, but maybe it doesn't matter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in a micro-benchmark, but ECDSA signing and verifying is going to dominate. For IeeeP1363FixedFieldConcatenation it basically boils down to AsymmetricAlgorithmHelpers.BitsToBytes(KeySize) * 2; Where BitsToBytes just does the "ceiling then divide by 8". I wouldn't be surprised if the JIT inlined BitsToBytes.

@jozkee
Copy link
Member

jozkee commented Mar 6, 2023

System.Net.Http.Json failure is #82918.
System.Net[.Http] failures are most likely instability.
System.Runtime.Tests failure on MacCatalystc says:

[15:00:42] fail: Application test run crashed
                 No test log file was produced

@jozkee jozkee merged commit ef71bb7 into dotnet:main Mar 6, 2023
@vcsjones vcsjones deleted the fix-67059 branch March 6, 2023 21:12
@ghost ghost locked as resolved and limited conversation to collaborators Apr 6, 2023
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.

Estimated signature size calculation for ECDsa and RSA may be incorrect
5 participants