Cryptography & encryption

Kapitoly: Cryptography, Frequency analysis

Cryptography is the science dealing with encryption. The goal of encryption is to send a message to someone in such a way that only the receiver of the message, and no one else besides the sender, can understand the message.

Cryptography, coding, steganography

We'll explain what cryptography is by example, along with the main differences between the related sciences of steganography and encryption.

For the sake of example, we can imagine that we have a beautiful wife, but an even more beautiful mistress, with whom we want to arrange a very romantic trip to the Blue Lagoon Hotel.

  • We first agree with our mistress that we will send her messages by replacing each letter in the message with the next letter in the alphabet. So instead of "a" we'll write "b", instead of "b" we'll write "c", ..., instead of "z" we'll write "a". So instead of "hello", we'd write "bipk". We could send a message to the lover

    bipk lpdlp tfkefnf tf wfdfs b wzalpvtjnf qpmpiv nmflb b wpez

    and the wife would have no idea what we were actually sending, while the mistress would - she would shift each letter back one letter, so instead of "bipk lpdlp..." she would read "hello cat..." At the moment we're using cryptography (encryption). Trouble is, if you're sending your lovely work colleague strange clusters of letters every other day, your wife will probably get nervous and pack your bags in no time. Encryption won't be the right choice in this case.

  • In the case of a mistress, you're better off with steganography. The goal of steganography is to send someone a message that will look like an ordinary harmless message, but at the same time there will be another, secret, message hidden in it. So we could send our beautiful lover this message:

    It remains to add that how many times
    ...even cheap things are good,
    so there's no point in buying on price.
    Better read some reviews
    and make your decision based on them.

    The latter looks quite harmless, however, if you always read only the first letter on the line, you will get the word "tomorrow". That's a word hidden in a paragraph of text.

    So the main difference with cryptography is that the output of steganography is usually a text/image/sound recording/... that contains some, typically much smaller, hidden message. With ciphertext, it is clear at a glance that it is not plain text. So you use the cipher when you don't need to hide that you are communicating with someone, but only need to hide the content. You use steganography when you need to conceal the very fact that you are communicating with someone.

  • Encryption is not about secrecy at all, it's just about transcribing the message into a different form that suits you. For example, we could transcribe a message into Morse code so that we could send a message to a lover ... by flashing a torch. Unobtrusiveness itself. The point of Morse code is not to "hide" the message, just to transcribe it into another form. Another code might be the binary code that computers use - for example, each letter is first encoded into a number in the computer, and that number is then converted to binary and stored on disk in this way. The word "hello" would be stored in the computer as the binary notation of the numbers "097 104 111 106" (see ASCII table). Again, this is not a secrecy issue, just a different way of writing.

Cryptanalysis

Of course, no cipher is completely secure, and every cipher will eventually be broken. It's just a matter of time, and if you use a cipher, you have to hope that the time will be long enough that you don't mind anymore if someone breaks your message. If your ex-wife breaks the ciphers you wrote with your mistress, it probably doesn't matter since she's an ex-wife anyway.

The science that studies how to break a given cipher is called cryptanalysis. Cryptography deals with how to crack a cipher and cryptanalysis is the evil little brother. Both of these disciplines are covered by cryptology. So cryptology = cryptography + cryptanalysis. But often cryptography is simply used instead of cryptology.

The basic concepts of cryptography

  • Open text is text that we want to encrypt and then send to someone. So an open text could be "Meet me tonight".
  • Ciphertext (or ciphertext) is the resulting text that is produced after encrypting the plaintext.
  • A key is some piece of information that is exchanged between the communicating parties over some passwordless channel. The key specifies how the cipher behaves. For example, instead of always moving a letter one letter further, i.e. "a" -> "b", "b" -> "c", we can move it three letters further, i.e. "a" -> "d", "b" -> "d". The key is then the number of letters by which we move. The key can also have some steganographic algorithm. We don't have to take the first letter on each line, but we can read, for example, only the fifth letter on the line. The key would then be the number five.
  • A cipher is an algorithm that takes the plaintext and the key as input and returns the ciphertext as output.