-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
Add a Cryptography Chapter #278
Conversation
I resolved the merge conflict. |
I think the headings "General principles of Cryptography", "Symmetric Cryptography", "Asymmetric Cryptography" should be |
Thanks for the chapter submission! It looks like there is a good amount of text here to review, so give me some time there. As a quick question: will you be adding an initial algorithm with this too? Also: the redirect is probably not necessary in this case. EDIT: Would you be able to separate all sentences into new lines? This will allow me to review individual sentences instead of entire paragraphs and will make the process easier on my end. It also makes it easier with version control (git). Sorry for the inconvenience. |
Yeah I would gladly add an algorithm as well. I wanted to do a sub chapter for every "group" of algorithm. So one for older ones (i.e. caeser or substitution cipher), one for DES/AES one for blowfish (maybe i'll look into twofish as well) and one for RSA EDIT: Also sorry for the merge commit I pulled from the wrong remote and though I pulled everything |
Ooh, nice. To be clear: those will be additional PR's on top of this one? I can hopefully get to review this on Sunday my time, but if you want to add to the PR, I'll wait. |
Depends on what you prefer i think :D If it's to much work to review several PRs I can add everything here. If not I think just for organizational purposes I would do a PR for every sub chapter. |
It's the same amount of work to review one PR or multiple ones. I think you are right that multiple PR's are better for organization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking so long with this. I was working on this review off and on for the past few weeks.
It's a pretty good start, but kinda clunky at times. I added things that I thought would make it an easier read, but it;s sometimes personal opinion.
I think it is missing a lot of information now (mathematical underpinnings, talk of future directions, etc), but I think that information will come with the algorithms as they come in.
# Cryptography | ||
|
||
For a long time humans wanted to send secret messages that only the reciever understands. | ||
The first encryption algorithms go back to the ancient greeks and romans. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit clunky. Maybe something like:
Humans have almost always been interested in sending secret messages that only the sender and receiver understand.
The reason for this is obvious: secret messages should remain secret.
The easiest way for this to happen is to talk behind closed doors, but that simply doesn't work if the the sender and receiver are separated by a significant distance.
In this case, they need to rely on a messenger or mailman to send the message.
For simplicity, let's assume they are sending a written letter for the purpose of negotiating war tactics in ancient Greece or Rome.
Obviously, the message can remain secret if both the sender and receiver also trust the messenger; however, what if the messenger is actually an evil spy?
What if the messenger is killed and the letter is stolen?
What if (in an elaborate ruse), some third party slips into the messenger's tent in the dead-of-night and replaces the letter with another one entirely different?
These are all important questions cryptography addresses.
The idea is simple: we procedurally scramble the message we are sending and only provide the unscrambling procedure to trusted parties.
In this way, the message would seem like utter gobbledygook to anyone other than the sender and receiver.
It doesn't matter if the messenger is evil.
They cannot read the message anyway.
It's also fine if the message is replaced, because then the receiver won't be able to properly decode the message and can just ask for another message to be sent (probably on another path with a different messenger).
|
||
For a long time humans wanted to send secret messages that only the reciever understands. | ||
The first encryption algorithms go back to the ancient greeks and romans. | ||
One of the most well known encryptions is the so called "Caeser Cipher" which was supposedly used by Julius Caeser. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsurprisingly, one of the first methods of encryption was supposedly developed by Julius Caeser and called the "Caesar Cipher."
Here, every character in the message is replaced by another character based on some pre-defined table or chart that only the sender and receiver have.
The table is created by simply rotating the alphabet by$$n$$ spaces, where$$n$$ is chosen in a discussion between the sender and receiver before-hand.
It is certainly not the most complicated scheme out there, but it is generally the first encryption scheme people come up with when trying to encode secret messages to one another.
Honestly, I remember sending messages back and forth to friends in elementary school, but we would never provide the necessary table to decode the message.
Instead, we would provide enough text that they could find the table themselves from context.
If a bunch of elementary school kids can figure out how to break this encryption scheme, it cannot be too robust.
In fact, it's interesting to see how the field of cryptography has grown since the Caesar cipher was developed.
The Caesar cipher obviously needs it's own chapter, so we'll link to that when it exists.
For a long time humans wanted to send secret messages that only the reciever understands. | ||
The first encryption algorithms go back to the ancient greeks and romans. | ||
One of the most well known encryptions is the so called "Caeser Cipher" which was supposedly used by Julius Caeser. | ||
In general there are two different principle of encryption, symmetric and asymmetric encryption. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence seems out of place. You mention these two methods, but don't talk about what they are until later. It' might be better to move this to the bottom.
To explain the two principles I have to introduce you to two people. Enter Alice and Bob. | ||
These two names are very common when reading about cryptography. | ||
A third and (usually) evil person is also needed and that person is called Charlie. | ||
The way these three people are set up are so that Alice and Bob want to exchange messages without Charlie knowing what they said. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph is rather long. Maybe something like:
In the cryptographic literature, there is always a sender, receiver, and eavesdropper.
For some reason beyond my own comprehension, these three people are almost always given the names Alice (sender), Bob (receiver), and Charlie (attacker or eavesdropper).
These names are consistent even with quantum cryptography, so they are here to stay.
These two names are very common when reading about cryptography. | ||
A third and (usually) evil person is also needed and that person is called Charlie. | ||
The way these three people are set up are so that Alice and Bob want to exchange messages without Charlie knowing what they said. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to connect to the next section. I think it flows better to talk about the different types of encryption before talking about the general principles... Simply because the the general principles section also provides advice.
I would maybe add the sentence from above here:
In general, there are two different types of encryption: symmetric and asymmetric.
Both of which are described in the following sections.
For that Alice encrypts the message with her private key. | ||
This is *NOT* so that Charlie can't read the message, since both Bob and Charlie have Alices private key. | ||
What both of them don't have is the private key. | ||
So Charlie can't decrypt, alter and encrypt the message again without Bob noticing it, because it wouldn't decrypt anymore with Alices public key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, if Alice wants to send a message to Bob and Bob wants to make sure the message from Alice was not altered, Alice can encrypt the message with her private key.
If the message is altered (possibly by Charlie), then the message can no longer be decrypted with Alice's public key.
Asymmetric Cryptography is sometimes called "Public key cryptography" because Bob and Alice both need a public and a private key of which they only share the public key. | ||
This makes these algorithms asymmetric because what is encrypted with the public key can only be decrypted with the private key and vice versa. | ||
This has numerous fields of application. It is not only used for encrypting messages, but also for digital signing. | ||
Digital signing is used to make sure that the recieved message actually originates from the person who claims to have written it and you can also make sure nothing got altered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can probably be removed?
So Charlie can't decrypt, alter and encrypt the message again without Bob noticing it, because it wouldn't decrypt anymore with Alices public key. | ||
Some examples for public key cryptography: | ||
* RSA. This algorithm calculates a public and a private key from two very large primes. It is (hopefully) near impossible to factor the product of two such primes in a feasable amount of time. | ||
* ECC or Elliptic-curve cryptography. Here you calulate the private and public key from two points on an elliptic curve. This has the positive side effect that you need smaller numbers than non-ECC algorithms like RSA to achieve the same level of security. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these should be changed to the other format:
RSA: This algorithm calculates a public and a private key from two very large primes. It is (hopefully) near impossible to factor the product of two such primes in a feasable amount of time.
At the end of this section, we need to mention the same thing as above:
This section is currently a work-in-progress. These methods will also have corresponding chapters in the near future.
A third and (usually) evil person is also needed and that person is called Charlie. | ||
The way these three people are set up are so that Alice and Bob want to exchange messages without Charlie knowing what they said. | ||
|
||
## General principles of Cryptography |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if I understand this section. It seems to be talking about implementation details for creating your own cryptographic system, but that is beyond the scope of the AAA. We care about the algorithms, but not about protecting someone from an attack.
Maybe we should say something like:
Cryptographic systems are a cornerstone to modern information technology and lie at the heart of everything from WiFi passwords to bank passwords.
If an attacker manages to crack modern cryptographic algorithms, they could cause serious damage.
For this reason, it is important to keep a few things in mind:
From here, I don't know what to add, though. I kinda feel this section should be removed, as none of the following points seem relevant.
* Adding complications don't necessarily make the algorithm better or safer. | ||
* Always account for wrong design, implementation and usage of cryptosystems. | ||
A good example for a wrong implementation is WPA2 (the algorithm which encrypts WiFi traffic). This algorithm was mathematically proven to be safe yet an error in the implementaion allowed for the "Krack" attack. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhere in this article, we need to mention quantum computing. One of the major reasons it is such a big deal is because it has a heck of a lot of raw power that will completely blow modern cryptographic systems out of the water. This is why quantum cryptography is such a hot topic.
I don't know if it should be added here or with the asymmetric stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably be with the asymmetric stuff, since quantum computing only really affects that because it's good against the descrete logarithm which asymmetric crypto relies on. Symmetric crypto and hashing stays relatively untouched by it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leios There are also several basic assumptions that modern cryptography relies on (if you multiply two large primes, it's hard to get the original primes back out) which other quantum computing techniques (carefully sculpted waveforms + observation) could invalidate, but it's unknown if they will yet. That's... probably too much detail for an introductory thing on crypto in general, though; maybe a linked chapter on quantum-resistant crypto?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would settle for a small post quantum
crypto chapter in which we explain the problems and how they are delt with. Though I agree that this would exceed the "Intro to crypto" part of the chapter
It doesn't matter if the messenger is evil. | ||
They cannot read the message anyway. | ||
It's also fine if the message is replaced, because then the receiver won't be able to properly decode the message and can just ask for another message to be sent (probably on another path with a different messenger). | ||
Unsurprisingly, one of the first methods of encryption was supposedly developed by Julius Caeser and called the "Caesar Cipher." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People have been using ciphers since well before 44BC. Substitution ciphers, in particular, have been around almost as long as writing -- there are Mesopotamian tablets which use it. And, naturally, it was to protect someone's trade secrets. See this. That said, the Caesar cipher is a good introductory example of a cipher; I think it can and should stay, just... don't call it the first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point
* Adding complications don't necessarily make the algorithm better or safer. | ||
* Always account for wrong design, implementation and usage of cryptosystems. | ||
A good example for a wrong implementation is WPA2 (the algorithm which encrypts WiFi traffic). This algorithm was mathematically proven to be safe yet an error in the implementaion allowed for the "Krack" attack. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leios There are also several basic assumptions that modern cryptography relies on (if you multiply two large primes, it's hard to get the original primes back out) which other quantum computing techniques (carefully sculpted waveforms + observation) could invalidate, but it's unknown if they will yet. That's... probably too much detail for an introductory thing on crypto in general, though; maybe a linked chapter on quantum-resistant crypto?
In general, there are two different types of encryption: symmetric and asymmetric. | ||
Both of which are described in the following sections. | ||
|
||
Cryptographic systems are a cornerstone to modern information technology and lie at the heart of everything from WiFi passwords to bank passwords. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This phrasing is... odd. They're not at the heart of passwords. Maybe more like:
Encryption algorithms are a cornerstone to modern information technology and keep everything from cat pictures to bank information safe.
Though the "information technology" bit is still awkward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well i guess you are right. I'll be taking out the password
If an attacker manages to crack modern cryptographic algorithms, they could cause serious damage. | ||
For this reason, it is important to keep a few things in mind: | ||
* Because crypto has become such an advanced field cryptosystems should be analyzed by trained professionals. | ||
Meaning whenever possible use a widely accepted cryptography library instead of writing your own cypher. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent by four spaces to continue the previous bullet point instead of dropping a random paragraph between points.
Cryptographic systems are a cornerstone to modern information technology and lie at the heart of everything from WiFi passwords to bank passwords. | ||
If an attacker manages to crack modern cryptographic algorithms, they could cause serious damage. | ||
For this reason, it is important to keep a few things in mind: | ||
* Because crypto has become such an advanced field cryptosystems should be analyzed by trained professionals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make clear that both algorithms and implementations need to be vetted?
Meaning whenever possible use a widely accepted cryptography library instead of writing your own cypher. | ||
* Kerckhoffs's principle says that when determing the robustness of a cryptosystem it should be assumed that the attacker knows the encryption and decryption algorithm. | ||
This does not include any pre-shared or secret keys. | ||
* With the advances in technology cryptography often hits it's limits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*its
Also, not all that often -- modern crypto typically stays well ahead of the technological curve, and modern crypto is designed with configurable strength. See, for example, bcrypt, which has a configurable number of rounds, to scale the work done without changing the algorithm. That'll probably stay relevant for decades, unless someone finds a fundamental flaw in the algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant here that we always had to scale the algorithms and are looking for better and better algorithms (i.e. ec instead of rsa, md5 being utter garbo for crypto,...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Liikt Ahh gotcha. Maybe rephrase it a little, then? Something like:
Cryptography is always improving as old algorithms get weaker and technology gets more powerful.
Either way works, though, I just misunderstood it the first time.
* **Rot13**: This is a special case of the Caeser Cipher where the alphabet is rotated by 13, hence the name "Rot13." | ||
* **Permutation Cipher**: Here you choose a permutation $$\pi$$ (i.e. $$\pi=(3,1,2,4)$$) and reorder the the letters according to that $$\pi$$ which is the key. | ||
* **XOR encryption**: This method works on bitstrings and combines the message with a second message of equal length with a XOR operator. | ||
To decrypt, simply XOR again with the same second message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"second message" should probably be "key", for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
Some examples for symmetric cryptography are: | ||
* **Ceasar Cipher**: Alice and Bob rotate the alphabet by $$n$$ characters and use that as a table to encode and decode their message. | ||
* **Rot13**: This is a special case of the Caeser Cipher where the alphabet is rotated by 13, hence the name "Rot13." | ||
* **Permutation Cipher**: Here you choose a permutation $$\pi$$ (i.e. $$\pi=(3,1,2,4)$$) and reorder the the letters according to that $$\pi$$ which is the key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pi may well be the variable typically used for the permutation, but for clarity's sake, we should probably call it p
or something less likely to be confused for 3.14159...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was going with what i learned at uni and since the AAA is a pretty scientific collection in general i'd say pi is fine here
This makes these algorithms asymmetric because what is encrypted with the public key can only be decrypted with the private key and vice versa. | ||
This can be used for a number of different applications, like digital signing, encrypted communication or secretly sharing keys. | ||
For example, if Alice wants to send a message to Bob and Bob wants to make sure the message from Alice was not altered, Alice can encrypt the message with her private key. | ||
If the message is altered (possibly by Charlie), then the message can no longer be decrypted with Alice's public key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a sentence about how, without Alice's private key, Eve can't make a message which could be decrypted with Alice's public key.
@leios How do you feel about reviewing this chapter submission again? |
I don't mind helping. But you can also feel free to push into PR as you see fit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text here is pretty good. I made a few suggestions (feel free to ignore some of them). Also: it would be nice to have at least one image or something.
Like with XOR or DES you generate a bit string (depending on which AES you use 128/192 or 256 bit long) which is your key. | ||
* **Blowfish**: This algorithm also was a good contender for the AES but lost to Rijndael. | ||
|
||
This section is currently a work-in-progress, and all of these methods will have corresponding chapters in the near future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to also add some citations here? just add {{ "thing" | cite}}
and
### Bibliography
{% references %} {% endreferences %}
at the end. Be sure to add the citations to literature.bib
It is (hopefully) near impossible to factor the product of two such primes in a feasible amount of time. | ||
* **ECC or Elliptic-curve cryptography**: Here you calculate the private and public key from two points on an elliptic curve. | ||
This has the positive side effect that you need smaller numbers than non-ECC algorithms like RSA to achieve the same level of security. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like before, a few references would be nice
There are a few small changes here, would you mind if I just committed the changes myself to merge this? |
This was finalized in #988 |
I want to add a chapter on cryptography.
This is a general overview of what's to come. In the future i want to also write a sub chapter on most of the algorithms and concepts I mentioned here with the occasional code example.