This article outlines cryptographic operations and best practices you should follow to make your applications or systems secure.
Cryptography has been around as long as the written history of mankind. This is because of human nature - we always have something to hide. The full story is perfectly explained in Wikipedia. The point is, this is a never-ending competition between people inventing ciphers and people breaking ciphers. Computers intensified the competition. Computers make ciphers incredibly strong, on the other hand, computers help to break the ciphers. It is like a sword vs. a shield. It is very important to use a proper shield.
Before the 1970s, cryptography was only used to keep secrets. This all changed when asymmetric cryptography was invented. Deeply theoretical ideas were implemented - all possible thanks to computers. These include:
The topics above are explained well in any book about cryptography. My point is, that these two functions (asymmetric cryptography and hashes) gave us digital signatures, key exchange and many other things we can’t do very well with traditional symmetric cryptosystems. Yes, you can digitally sign data using a symmetric cipher via an ugly over-complicated method, but it’s very hard to implement.
Computers continue to become more and more powerful. Now we are in the early stages of quantum computers (Maybe we will have super-string computers soon). Consequently, ciphers we use today will be too weak tomorrow. During my practice MD5, SHA-1 were cracked, RSA-512 became too weak. However, many systems and applications still use MD5!!
Indeed, there are additional obstacles. I am talking about the theory. We are progressing in the cryptographic theory. Most of the algorithms we use are an implementation of the Feistel network - Twofish, DES, even Russian GOST. This network is explored very well - and all ciphers mentioned seem to be reliable enough (if key size, round count are chosen properly).
It could be argued that AES (or Rijndael) is still a dark horse. On one hand, it was developed by highly experienced professionals and well-tested by thousands of researchers around the Globe. On the other hand, the Titanic was also developed by professionals :) Joking aside, at one point in time, somebody (maybe a student or enthusiast) may find some internal AES symmetry, making AES very weak or easily decrypted. No guarantee. Generally speaking, only ONE cipher can be guaranteed - the Vernam cipher.
The situation with asymmetric ciphers is that the theory is not well developed, due to deep mathematical reasons. Asymmetric cryptography offers the term “computational complexity”. This means we can't decrypt the cipher because we don't currently have an efficient attack on the computationally-complex problem and/ or we don’t have a computer powerful enough yet. This is a reason why armies don't like or ignore asymmetric ciphers.
The lack of proof produces lot of speculations. Americans may suspect that Russians know a FAST factorization algorithm enabling them to break American asymmetric encryption and may disadvice to use them. Russians may think (I guarantee) in similar terms.
Normal users have no choice but need to trust the experts. As users we should always ask them questions:
Do we have such professionals we could (and may) ask? Yes. We do. It's NIST. They accumulate best practices, knowledge and experience in our industry.
NIST provide you a some very useful recommendations about:
All those matters are important and will help you very much to avoid stupid mistakes and, more important, unauthorized information disclosure. Cryptography is a deep water - many hidden rocks are inside. Any cryptographic protocol exposes some vulnerability. Please read the following NIST topics:
Hopefully, most cryptographic libraries follow NIST recommendations and will not permit you do really bad things. However, still keep the recommendation in mind.
Do not follow NIST recommendations blindly - think for yourself. Obviously, NIST does not know about your specific use-cases and sensitivities. Remember, NIST gives you general recommendations, helping you avoid stupid mistakes or reinventing the wheel. Follow them, but not too formally and blindly. Cryptography is your closest friend, so use it properly, according the logic and knowledge. Think!
In summary, NIST recommendations are good in typical cases. The real world is a bit wider, however. So - think for yourself!