# Introduction to Cryptography

Secret messaging has been in vogue since the times of Julius Caesar. But later, this art of communicating messages in a secret or encoded form has come to be known as cryptography. The word cryptography is derived from Greek and means ‘secret writing’. This article is intended to introduce you to the basics of cryptography and lead you to do some encryption stuff yourselves.

Let us start with some basic terminology. In crypto lingo the message we want to send secretly and securely is called ‘plaintext’ or ‘cleartext’. It is then encoded using various algorithms to produce some undecipherable (or at least hard to decipher) messages known as ‘ciphertext’. This process of encoding ordinary messages or plaintext to ciphertext is called ‘encryption’. And the reverse process of obtaining plaintext from ciphertext is known as ‘decryption’. Encryption and decryption usually make use of a key, and the coding method is such that decryption can be performed only if you know the proper key.

Encryption Decryption
Plaintext ———-> Ciphertext ———-> Plaintext

As we mentioned above, the art of keeping messages secret is called cryptography and those who involve in such an art are called cryptographers. As good and evil exist side by side, there are people who try to break or decipher these secret messages. The art of breaking ciphers is called cryptanalysis and those who practice it are called cryptanalysts. Now that we know the basic terminology, let’s move ahead and look at the various cryptographic algorithms.

There are three different types of cryptographic algorithms. They are

1. Symmetric Key-based algorithms
2. Asymmetric key-based algorithms and
3. Hash algorithms

All these algorithms are based on the ‘Fundamental Tenet of Cryptography':

“If lots of smart people have failed to solve a problem, then it probably won’t be solved (soon).”
– Quote from the book by Radia Perlman, et al.

Let’s discuss each of these algorithms.

1. Symmetric key-based algorithms
These algorithms are also known as Conventional Cryptographic algorithms or Secret key algorithms. They are implemented using two types of ciphers called ‘block ciphers’ or ‘stream ciphers’. Stream ciphers can encrypt a single bit of plaintext at a time, whereas block ciphers take a number of bits (typically 64 bits in modern ciphers), and encrypt them as a single unit.

Using these cipher types, your data is separated into chunks, and those chunks are encrypted and decrypted based on a specific key. Stream ciphers are used more predominantly than block ciphers, as the chunks are encrypted on a bit-by-bit basis. This process is much smaller and faster than encrypting larger chunks or blocks of data. But the important point to note is that there is only one key for encryption and decryption called the ‘Secret’ key. Here is a pictorial description of how it is done.

Encryption
Plaintext ———->Ciphertext
^ Key
|
|
|
Ciphertext ———->Plaintext
Decryption

As we can see from the Figure above, there is only one key used. That is why it’s a secret shared key. Both the sender and the receiver of the message share the secret key.

There are various algorithms developed using this symmetric cryptographic algorithm. I am listing some of them here.

1. DES (Data Encryption Standard)
2. TripleDES (A variation of DES)
4. Blowfish
5. IDEA (International Data Encryption Algorithm)
6. RC4, etc

Note: The details of their implementation are beyond the scope of this article. The readers are suggested to go through the links and textbooks presented in the ‘Resources section below.

2. Asymmetric key-based algorithms
This method uses one key to encrypt data and a different key to decrypt the same data. This algorithm is also called private/public key encryption algorithm. It works like this. Every user has two keys. A public key, which can be distributed to everybody (or published on the web) and a private key, which is kept secret with the owner of the keys. If someone wants to send an encrypted message, he/she uses the public key to encrypt the message. The recipient of the message can decrypt it using only the private key. Note that the message cannot be decrypted using the public key. The private key in this algorithm is similar to the ‘secret’ key in Symmetric key-based algorithms discussed above. Here is a pictorial description of the algorithm.

Encryption
Plaintext ———-> Ciphertext
/  Public key
|
/  Private key
Ciphertext ———-> Plaintext
Decryption

The famous examples of this type of cryptographic algorithms are:

2. Diffie-Hellman algorithm
3. DSS (Digital Signature Standard)
4. LUC
5. XTR
6. ElGamal, etc

3. Cryptographic Hash Algorithms
Cryptographic hash functions are used in various contexts, for example to compute the message digest when making a digital signature. A hash function compresses the bits of a message to a fixed-size hash value in a way that distributes the possible messages evenly among the possible hash values. A cryptographic hash function does this in a way that makes it extremely difficult to come up with a message that would hash to a particular hash value.

There are many hash algorithms in use. Some of them are:
1. SHA (Secure Hash Standard)
2. RIPEMD-160
3. MD5
4. MD2
5. MD4
6. Tiger

I hope that makes a good introduction to the field of cryptography. If you want to learn the details of all the algorithms mentioned above, I suggest you go through some of the books listed in the link below. I may write some follow-up articles on various cryptographic attacks. If you are impatient and want to learn all about cryptography in a hurry, there are some good sites on the web with wealth of information on the subject. I am providing some of them in the Resources section below. Please take a look and have a fun reading …

Jay Fougere is the IT manager for the iEntry network. He also writes occasional articles. If you have any IT questions, please direct them to Jay@ientry.com.

Introduction to Cryptography