# Introduction to cryptography

CRYPTOGRAPHY is not just an area of study but is a mandatory requirement in today’s digital world. It is an essential tool for keeping digital information safe both in the system and during its transmission. If we look carefully, cryptography can be seen everywhere, from secure communication over the Internet to user authentication and to encrypting files on our disks. Cryptography resides at the heart of every system or network that needs security and privacy. Cryptography existed for thousands of years and will continue to be the basis for developing security mechanisms. This chapter covers the basic concepts related to cryptography. It briefly discusses both traditional and modern cryptography as well as the journey from conventional to modern cryptography. It describes cryptographic principles and key terms in detail to build a strong foundation.

## Introduction To Cryptography

Cryptography [1]—[5] is the science of writing secrets to hide information from unintended recipients. Cryptography can do much more than establish a secret key for secure communication between different parties. Like physical signatures in our world, cryptography offers analogous, digital signatures in the digital world. The purpose of the digital signature is the same as the physical signature: it will authenticate your identity. But, unlike a physical signature, we cannot use the same digital signature to sign all the documents as we do in the physical world because in the digital world, anyone can quite easily cut and paste the digital signature to some material that we might not want to sign. Therefore, cryptography helps us to develop a digital signature which authenticates our identity while at the same time it ensures that no one can copy and paste it. It does this by making the digital signature a function of the contents of the data we want to sign. Recently, the application of cryptography has been seen in the most popular blockchain technology of the century, where one can anonymously communicate over the network. Cryptography is ancient; roughly 2078 years ago, Julius Caesar first used a very simple substitution cipher in his military commands where each letter was shifted to make the message meaningless. Later, this cipher was named after him and called the Caesar cipher. Another widespread use of cryptography in history is the Enigma machine developed by the Germans at the end of World War I and heavily used in World War II to transmit messages securely. In the next section, we will briefly discuss and categorize the famous traditional ciphers.

## Classification Of Ciphers

Cipher is the outcome of the conversion process from something meaningful to something scrambled and hard to understand. We expect from the reader that basic terminologies like ciphertext, plaintext, encryption, decryption, etc. are already known, and we will move directly to the different categories of ciphers and discuss them categorically as shown in Figure 2.1.

### Based On The Type Of Operations

The ciphers under this category care called the classical ciphers and play an important role in understanding modern ciphers.

#### Substitution cipher

In a substitution cipher each character in plaintext is substituted with a ciphertext character. The substitution can either be monoalphabetic, where each plaintext character is substituted with same ciphertext character, or polyalphabetic, where each plaintext character is substituted with different ciphertext characters. Examples of substitution ciphers which we will discuss include the Caesar cipher, Vigenere cipher and one-time pad.

*Figure 2.1* Classification of ciphers.

- • Caesar cipher: This is an example of a shift cipher with the shift value fixed to three. A more flexible version of the Caesar cipher permits the shift value to be any integer. Even though an arbitrary value is allowed for the shift, there are only 25 different shift ciphers possible for any given plaintext. Since each plaintext character is always substituted with the same ciphertext character, this is an example of a monoalphabetic cipher.
- • Vigenere cipher: This cipher is based on multiple interwoven shift ciphers based on the length of a keyword. The keyword is repeated until it becomes equal to the length of the plaintext. It is a type of polyalpha- betic cipher.
- • One-time pad (OTP): This cipher was designed by Vernam in 1917. It is an extension of Vigenere cipher with the following rules: i) the length of the keyword (key) is the same as the length of the plaintext, ii) the keyword is a randomly generated string of alphabets, iii) the keyword is used only once. OTP is known to have perfect secrecy, i.e., by looking at the ciphertext, absolutely nothing is revealed about the plaintext. Further, it is impossible to break using the brute force method. We can get the idea of the complexity of breaking OTP by this simple example: consider a message with five characters encrypted using OTP. To break the ciphertext by brute force, we need to try all possibilities of keys and conduct computation for 26
^{s}, i.e., 11 881 376 combinations, and this is just for a message with five characters. Thus, for a longer message, the calculation grows exponentially with every new alphabet. However, OTP is hard to use in practice because of the long keys.

#### Transposition cipher

In the transposition cipher, instead of substituting different characters in plaintext, we change the location of elements to generate the ciphertext. Various types of transposition ciphers include the rail fence cipher, the row transposition cipher and the columnar transposition cipher.