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

Change RSA.LegalKeySizes for Apple platforms to return 8192 #110591

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vcsjones
Copy link
Member

This changes RSA.LegalKeySizes to return a maximum of 8192 on Apple platforms, as opposed to 16384. At least on macOS Sequoia and Sonoma, the limit is 8192-bit.

While we are here, memoize the KeySizes instance. They are immutable. The returned array is not - so we only memoize the interior KeySizes instance, not the returned array.

Closes #110588.

@teo-tsirpanis
Copy link
Contributor

Should we add a test that keys with the max size can be created?

@vcsjones
Copy link
Member Author

vcsjones commented Dec 10, 2024

Should we add a test that keys with the max size can be created?

We do here

[ConditionalFact(typeof(TestEnvironment), nameof(TestEnvironment.IsStressModeEnabled))]
public static void GenerateMaxKey()
{
GenerateKey(rsa => GetMax(rsa.LegalKeySizes));
}

But it's (effectively) a manual-only because it takes about ~30 seconds for macOS to generate an RSA 8K key. It can take several minutes for platforms that support 16K keys. Even for Outerloop that's too long, in my opinion.

This manual-only test fails without the fix, which is what prompted me to make the change.

@teo-tsirpanis
Copy link
Contributor

Makes sense, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS: RSA.Create and Import fails with > 8192-bit keys
2 participants