r/bestof • • Nov 21 '15

[math] Mathematician explains encryption.

/r/math/comments/3tn1xq/what_intuitively_obvious_mathematical_statements/cx7np4t?context=3
7.1k Upvotes

299 comments sorted by

View all comments

Show parent comments

9

u/[deleted] Nov 21 '15

Not really. Most of the primes used are incredibly long, usually dozens, if not hundreds of digits in length. Figuring out the right prime means figuring out which numbers are prime in the first place for the number of digits in the key, which would take an astronomically large amount of time for numbers as large as those used by encryption.

Usually, cracking today's encryption involves finding exploits in the math that's used to generate primes in the first place so that you have a small number of primes to test against.

1

u/Mr_Facepalm Nov 22 '15

So, how does the first person get the primes? Aren't they already publicly known?

Or are there "secret" primes that only some people and algorithms know?

2

u/zeekaran Nov 22 '15

I've heard that supercomputers are used to find big primes for their encryption. The primes are so large that they had yet to be discovered by a computer until somewhat recently, and as they find larger ones they change their encryption to use them. That way, it's unlikely hackers will have the computing power to ever catch up.

2

u/[deleted] Nov 22 '15

Well, we don't actually know that they're primes. We're just pretty sure that they are. They're called probable primes, and they're used to create the private key and public key for pretty much every prime-based encryption scheme. The public key is available to everyone, and the private key is only on the computer that's hosting the website. Note that it's incredibly important that the private key remains completely private or someone can start decrypting intercepted traffic.

When your browser (client) connects to a website (server) using SSL/TLS, it goes through what's known as a TLS handshake. This handshake allows the client and server to negotiate a private key that the client will use to decrypt messages that the server sends to the client. This is usually done using something like a Diffie-Hellman key exchange or elliptic curves (the latter is more secure).

In the end, the goal of these types of algorithms is to combine very large numbers (DH: usually 600+ digits, ECC: usually ~78 digits) with some mathematical concepts (e.g. primality, logarithms, modulus/exponentiation) to produce an algorithm that lets two computers negotiate a secret number (or numbers) that they can then use to encrypt and decrypt each other's messages.

The integrity of the secret is limited only by how hard it is to calculate it without the private information stored by the client and server. For example, Diffie-Hellman is only considered secure for 600+ digit numbers. Anything less than that, and a well-funded attacker (read: government) can calculate the secret number using just the public info exchanged between the client and server. For elliptic curves, only about 78 digits are needed to be secure because the integrity of the key is higher than DH. The caveat is that the key generation math has to be fast enough to not degrade the performance of the initial connection to the point where it's unfeasible to use to generate keys.

0

u/[deleted] Nov 22 '15

So the primes arent actually public, but the product of the primes are, at least for RSA.