SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
29.74k stars 3.15k forks source link

LibCrypto: Implement a performant RSA keygen algorithm #23561

Open ADKaster opened 3 months ago

ADKaster commented 3 months ago

The current implementation of Crypto::PK::RSA::generate_key is slow and inefficient. It simply generates random values of the specified modulus length and checks if they are valid key pairs.

For modulus length of 256, or 512, this works ... all right. But when we start asking for 1024, 2048 or 4096 length key pairs, things get out of hand quickly. Tens of seconds quickly.

alimpfard commented 3 months ago

Some more relevant bits: