logoalt Hacker News

pants2 • today at 7:36 PM • 3 replies • view on HN

Can't RSA be implemented in only 7 lines of code? Not sure how that computes with your statement


Replies

cvwright • today at 8:07 PM

The connection to the parent post is that the 7-line “textbook” version of RSA is the one that’s vulnerable to all kinds of things that aren’t obvious when you sit down to type in those 7 lines.

mswphd • today at 8:01 PM

Not in the slightest. Getting

1. Constant time bigint arithmetic, and

2. The padding scheme (which has had MANY issues over the years)

Done correctly is relatively complicated. But a shitty insecure version of RSA is easy to write.

stouset • today at 10:10 PM

Not even close.

First, that seven lines of code includes a bignum arithmetic library, but the ones shipped with your language are not constant-time and not suitable in any way, shape, or form for use in cryptographic code.

Then it’s a pain in the ass and slow to encrypt large messages so literally nobody uses RSA to do so. They generate a symmetric key and use that to encrypt the message then use RSA to encrypt the symmetric key.

With both of those you’ve managed to get to a minimally useful but still laughably insecure RSA implementation.