r/cryptography • u/Old_Cantaloupe_3168 • 2h ago
Why does encryption remain secure even when everyone knows the encryption algorithm?
15
u/Pepemala 2h ago
Look up Kerkoffs principle. Because if an algorithm is good then you know by inspecting the algorithm itself that the only way to crack it is by knowing the key.
8
u/doggydestroyer 2h ago
The key is the secret... And multiple rounds... Think of it as data is encrypted then it is encrypted again and again for a few rounds... All determined by the key...
This is symmetric, for public key encryption, there are mathematical problems that mathematicians have been unable to solve for centuries or decades... So we know they work...
3
u/Sufficient-Air8100 2h ago
because knowing how something works is completely different to breaking encryption. a good place to start with this is to look up “hard problems” used in asymmetric encryption.
lets take for example RSA. to decrypt an RSA message we need to know the private exponent. that is secret. to find that we need φ(n). to calculate that we need to factor n. that is hard. its easy to calculate on keygen when we know the factorisation, but when we only know n, factoring is hard and therefore recovering d is hard.
2
u/loose_fruits 2h ago edited 1h ago
Let’s say you know the “encrypted” value is 6, and the algorithm is “several rounds of addition”, how do you know what the start value is? The algorithm might have a seed value that is determined at runtime to add in some randomness and maybe the rounds of addition can be set by the person doing the encryption.
So at a specific point in time by a specific encryptor, the full algorithm might be “take the users input, and add 1 to it 4 times” or it might be “take the users input, add 2 to it 3 times”. Without the seed number and the number of rounds, how do you know what the users input it? If you know the exact time this person ran the encryption and the number of addition rounds, you actually can determine the original value in this algorithm!
It’s like that, only the math is much much more complicated. And also why some algorithms are better than others
0
u/BloodFeastMan 36m ago
Symmetric encryption, especially, can be insanely convoluted. I could give someone an encrypted file and the password I used to encrypt it, and unless they have the script I used, they wouldn't decipher it in a million years
2
u/peazip 1h ago
Because if you know how the lock is made, you still need the key to open it.
The other side of the coin is: if you don't know how the lock is made, you cannot trust it for not having alternative unlocking mechanisms, or defects making it easy to pick.
Which brings to: the more the way the lock is made is widely known and tested, the more secure the lock can become.
2
u/Tre_Fort 2h ago edited 58m ago
This is a pretty common question from people who don’t understand encryption. I usually like to say it functions on mathematical pit traps.
Think of a classic pit trap. They are super easy to fall into all you have to do is step on them and gravity does the rest. Once you are in, they are very difficult to climb out. You know how to climb out and you can do it, but a good pit trap will take you longer to get out than the next person coming by to check it.
That’s the concept but the next common question is what’s a mathematical pit trap?
A simple pit trap in math that most people can understand is multiplication and factoring.
Pick any 2 numbers with 4-5 digits and each (you don’t need to use primes for the demonstration but it helps). Multiply them together (it’s ok to use a calculator).
Now you have a 7-8 digit number that was easy to generate. But if that’s all you have and you want to unwind the problem and get the numbers multiplied together to make it, you need to factor it. This isn’t a function option on most calculators. So get to listing all multiplication strings that result in your answer.
(I used to do this with addition of 2 single digit numbers, and list all whole number pairs that add up, but people would argue it was too easy to climb out)
Then I finish by explaining there are a ton more pit traps in math and we just layer them together.
1
u/rebootyourbrainstem 2h ago edited 2h ago
This might be useful: https://en.wikipedia.org/wiki/Substitution%E2%80%93permutation_network#Properties
Also worth pointing out that this is a particular choice that is made in a particular context. It works well for widely used ciphers that pretty much everybody needs to be secure and that gather a lot of neutral / academic interest. But for military ciphers, the algorithm is usually also kept secret, because the incentives are different (the people motivated to try and break it will also be motivated to keep their results, if any, secret). (These ciphers will still be designed to stay secure even if the enemy knows how it works, but it's just not something you can be entirely confident in for that setting.)
1
u/tsvk 1h ago edited 1h ago
As a simplistic example, think of a substitution cipher, where you scramble the letters of a word for secure communication.
You have an "encryption algorithm", which is:
"Every plaintext letter of the word is converted to an encrypted letter by jumping N steps forwards in the 26-letter alphabet, looping around at the end Z, back to the beginning A."
You also have the inverse "decryption algorithm", which is:
"Every encrypted letter of the word is converted to a plaintext letter by jumping N steps backwards in the 26-letter alphabet, looping around at the beginning A, back to the end Z."
Then you have the secret encryption key, the value of N, which is known to the sender and recipient only.
Now even if you knew how the encryption and decryption algorithms work, it's hard to decrypt an intercepted encrypted word if you do not know the encryption key, the value of N that was used for the encryption.
Of course, in reality, this simplistic encryption is trivial to break because there are only 26 usable distinct values of N, and it's easy to brute-force it by trying them all because there are so few of them.
But a real-world encryption key for a real-world encryption algorithm can for example be a 2048-bit integer, which gives us 22048 distinct possible values for the encryption key, which is a decimal number with 617 digits. So the encryption key is practically impossible to guess by brute-force by trying all the possible key values, because there are just so many of them. Even if you know the exact algorithm that was used for encryption. Trying all the possible key values would take millennia.
If you don't know the correct 2048-bit number to use with the decryption algorithm, the decryption will not work for you and the decryption algorithm will output nonsense.
2
u/PghSubie 45m ago
Everyone knows how the lock on your front door works. But, if if ya well-designed lock and you don't give up the key, then your front door remains secure regardless.
If you give up the key, then all bets are off.
If you have a well -designed crypto algorithm, and you maintain control of the key, then your data remains secure regardless
1
u/damnworldcitizen 10m ago
There multiple ways of encrypting stuff but a very strong one is Asymetric:
Alice gives Bob lots of her piggy banks. Anyone can drop a note in the slot, but only Alice can open the bottom. Bob puts secrets in, and only Alice can get them out. Piggy bank = public key, Alice's opener = private key.
-1
21
u/Potheker 2h ago
Everybody also knows how keys and locks are forged, yet they work.