Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why do I start the word buffers in MD5 with those values specifically? What in the world motivated the decision to use the numbers 1, 1, 2, 3 for the mix columns stagein AES? And what kind of witchcraft is going on in SHA when I call the sigma_x functions?

What kind of math should I be starting with, assuming I only know how to add, subtract, multiply, divide, and mod?

share|improve this question
The designers should explain why they chose these "magic values" in their papers but usually there is no specific reason. Still this depends on the algorithm. Some probability and statistics could also be of help. – rath Mar 24 '13 at 4:15

The Skein family of hash functions (submitted to NIST for the SHA-3 competition, but not selected as the winner) has a really well-written paper that tries to go into detail for how it was designed, how constants were chosen, etc. It might be a good place to start.

share|improve this answer

One of the best avenues for study is to practice breaking existing cyphers. Start small, with classic cyphers such as monoalphabetic substitution, polyalphabetic cyphers, transpositions, etc. Do the daily Cryptoquip in the newspaper! Learn what makes them weak, what makes them exploitable, and what makes them strong. Then move on to stream cyphers, to mechanized cyphers like the Hebern and Enigma machines, and then to modern electronic block cyphers.

With each cypher you attack, you first learn how to attack a simplified or reduced round variant, then apply it to the more complex and complete implementations. Along the way, learn how some of the various protocols and implementations have made cyphers weak, or provided defenses against certain forms of attack. Finally, study some of the advanced attacks, and replicate their results.

To implement these attacks, you'll discover new topics you need to understand in order to pull them off: statistics, modulo arithmetic, algebra, recursion, protocols, zero knowledge proofs, bignum math, game theory, Feistel networks, whatever. These are the same tools you will later use to understand and construct cyphers and protocols of your own.

Once you study attacks on cyphers, protocols, and implementations, you'll better understand why some of the more esoteric design decisions were made, or why certain mechanisms were added. A fascinating case study for the value of this approach can be a found by reading the history of the Lucifer cypher.

Good luck!

share|improve this answer
@PaytonTurnage: this is why this is such an excellent answer; unless you understand how cryptanalysis is done, that is, how cyphers can be broken, you really don't understand cryptography (that is, you won't understand why things are designed the way they are). And, the only way to understand cryptanalysis is to do cryptanalysis. – poncho Mar 25 '13 at 19:49

I have long answer and short,

the short: dont teach your self by your self, look for a teacher. the best book to cover all crypto subject easly (that you have to do at the first) is: Cryptography & Network Security, Behrouz Forouzan

you will face many questions, write them and ask you teacher.

sometime, the design decisions is not published, however this will not trust the cipher.

"1, 1, 2, 3 for the mix columns" is for hardware implementation propose (make less Hw gates) and then for speed, so you can use a different numbers with same function but with slow performance.

share|improve this answer
how can you find a teacher? It's not like you can open the newspaper and look for an ad. Are there other places where you can get crypto training apart from a university? – rath Mar 24 '13 at 20:18
I don't know that your book recommendation is as good as you make it out to be. Personally, I think that "Applied Cryptography: Protocols, Algorithms, and Source Code in C" by Bruce Schneier and "Cryptography Engineering: Design Principles and Practical Applications" by Ferguson, Schneier and Kohno are both superior books in every sense of the word. – Nik Bougalis Mar 25 '13 at 17:20
@Abdullah: no, the AES designers didn't pick 1,1,2,3 for the mix columns solely for hardware implementation. Their first criteria was that they formed an MDS matrix; if you replace those numbers with numbers that don't form an MDS matrix, the security proofs of AES against differential and linear cryptanalysis fall apart. – poncho Mar 25 '13 at 20:05

About teachers

I and others have suggested some teachers. But another approach would of course be to contact companies who work with cryptography (or analysis for that matter). Maybe both. I have no general knowledge about names, except for this award winning company: No, I don't have any economical interest in mentioning them, but two of the founders happened to be my teachers back in the University days – that's how I got acquainted with their projects.

Actually I just wanted to post this as a small comment to @rath up above in Abdullah’s answer, but for some reason I couldn't post anything there. that's why I post here as a new answer in itself. Hope it can do good somehow...?

share|improve this answer

From a mathematicians standpoint the subject of "cryptography" is based on Abstract Algebra.

Abstract algebra is a notoriously difficult field to master, but some parts of it are quite easy to grasp at first (but difficult to master as said).

I would guess that implementing abstract algebra in a computer, then involves a lot of Mathematical Analysis and Statistics as well, because much of what a computer do is emulating (making approximations to) exact calculations. This part of the process has nothing to do with Cryptography as such, but is important for a computer to work in general.

So with this knowledge, it should be clear, that understand Cryptography-programming you should both learn what cryptography is as mathematical discipline AND how computers simulates exact mathematical calculations. It is two very different things and if you mix them up you will get very very confused! This approach holds true, if you wants to understand anything mathematical a computer does.

If you want to find a teacher, I would suggest to contact a teacher in abstract algebra. He could cover you in on the mathematical side of things. A computer scientist could cover you in on how computers emulates real mathematics. Dont expect to understand everything. Not in the first 10 years...good luck :-)

share|improve this answer
Could you clarify "how computers simulates exact mathematical calculations"? Do you mean binary representation to store numbers? Cryptography rarely uses floating-point numbers. – Thomas Mar 25 '13 at 1:55
I mean everything that differs from real math. It would be the subject of another thread. – Electronic Yoga Mar 25 '13 at 10:08
This is a rather poor answer; no, you don't need to spend 10 years studying Abstract Algebra and Computer Science. He probably should have stopped at "I would guess that...". For example, when we're working with a finite group or field, no, we don't make approximations to exact calculations; we perform the operation precisely. – poncho Mar 25 '13 at 17:12
I was using the 10-year-suggestion to emphasize, that this is a huge and deep field and yes if you really wants to know the drill (and dont have a degree) you will need many years of hard work and study. Of course if you just wants to play around you dont. An example: when computers work with statistics and randomness, you would need to know what happens, or you will make mistakes. Computers simulating mathematical operations is not all about floating-points or not. If you want to discuss this specific topic, I recommend you start another thread, because this thread is not about that issue. – Electronic Yoga Mar 25 '13 at 20:53
@poncho Besides, whether you like my original answer or not, you a downright wrong in calling it "poor". It is - quite objectively - a rich answer. There is a lot of keywords to catch up on and I even solved the teacher-problems that other people was just talking about, but didnt answer. You will need to learn to seperate your personal feelings from objective judging. That too is also a hard long journey, some would say it never ends... :-) – Electronic Yoga Mar 25 '13 at 21:03

You might want to give some information about your background - whether you go to school/ college/ graduated in computer science/ work as a programmer/ or something else.

In general, studying computer science or mathematics is a good foundation. However, cryptography will probably be covered in advanced courses at larger universities (in Master and PHD programs). In general, any form of academic course will offer you the "tools of the trade", but in order to really understand the matter you need the according prerequisites in advanced mathematics/computer science (mostly abstract algebra, complexity theory and some probability theory).

I don't expect to understand it, but I want to try. The problem is, I don't even know where to start. What kind of math should I be starting with, assuming I only know how to add, subtract, multiply, divide, and mod?

Well... then you have a couple of years of university courses in mathematics ahead of you. Starting with linear algebra and probability theory, and later you'll have to learn abstract algebra, algebraic number theory and maybe some statistics.

The most important part of this is probably group theory, at least for asymmetric cryptosystems. Symmetric encryption, hash functions, other cryptographic primitives and higher higher functions all apply their own kind of "magic".

share|improve this answer
While it's certainly true that the larger Universities will have courses in cryptography, they may not be good courses. The fact is that few Universities have really good cryptography courses that will provide a solid foundation. Most don't have any at all, and they just skim over the subject. At my University, I personally found that the courses offered by the Mathematics department (particularly, courses in discrete math, Galois theory, etc) were much more in-depth and useful in theory and practice than the course offered by the Computer Science Department. – Nik Bougalis Mar 25 '13 at 17:15
The University of Minnesota has a CSci 5471 course on Modern Cryptography that my son took. One of his assignments was to produce an MD5 collision. I thought it sounded very hands on and useful. They also have a followup course, CSci 8980, where students present recent research papers in the field of cryptography. – John Deters Mar 25 '13 at 20:34

You can find a very illustrative explanation of how not to teach yourself crypto here:

Briefly the exciting field of crypto includes an intersection of computer science, math and engineering. The latter is not required always if you are interested in a scientific path

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.