Cryptography

Science of securing communication

Mohamed Bilal ⏳ 7 min read
Cryptography

Encryption is an age-old technique that has been written about numerous times but it always intrigues me especially its roots. So let’s start with a brief introduction and discuss its roots which continues to amaze me every time I discuss it.

Encryption

Encryption in modern day cryptography, is a process of converting plaintext into an unreadable form using cryptographic algorithms. Encrypted messages are decrypted using a shared secret key.

Can this not be broken without a key?

While no encryption standard is completely secure, it is not that easy to break modern encryption standards. AES-256 encryption, for example, represents 2^256 which is a mammoth 115.79 quattuorvigintillion combinations. I did not even know what a vigintillion means until I started reading about this topic.

Vigintillion: What is it?

It is 1 followed by 63 zeroes. That is some number isn’t it. While this is an incredibly rare number to encounter it is disputed too. Some references have it at 1 followed by 120 zeroes as well.

It also happens to be the current largest number in the “illion” series.

Quattuorvigintillion: It is an impossibly massive number represented by a 1 followed by 75 zeros.

Scientists estimate approximately 10^78 to 10^82 atoms in the observable universe. The total combinations AES-256 can produce is 10^77 which is nearly as large as the estimate atoms. Because of this sheer cosmic scale it is nearly impossible to guess an AES-256 key using brute force attacks.

Galaxy

Quantum Computers. Can they break it ?

Unlikely, while quantum computing poses a significant risk to asymmetric encryption, they pose a risk to symmetric encryption too but the key length matters a lot. AES-256 is considered quantum safe due to its key length-256 bits. The Grover’s algorithm can be devastating and can cut the effective strength by half. Even at 128 bits though the AES-256 encryption is out of reach as it stands today. This could change in future looking at the pace at which technology is evolving.

Asymmetric encryption is what is securing most of the internet today, hence organizations like NIST are working on and rolling out cryptographic systems known as PQC (Post-Quantum Cryptography). The idea behind PQC is to find new algorithms that are immune to quantum attacks.

Roots

The roots of cryptography can be traced back to ancient Egypt.

Hieroglyphs

The earliest known evidence to cryptography was found in the hieroglyphic text carved in the tomb of an Egyptian nobleman, Khnumhotep II believed to have lived circa 1900 BC. What was mysterious was the use of non-standard symbols in certain places.

Was it encryption the way we know it?

The large consensus is it is not. Historians believe this was a way to create mystery in the writings to make them seem sacred or could be the scribes flexing their intellectual abilities by testing others with such puzzles.

First Recorded Evidence

Fast forward a few centuries and you have what is likely the first recorded usage of cryptography for security reasons. The Spartans wrote a message on a parchment wrapped across a wooden cylinder and this could only be read by someone who had a cylinder of same size.

Cryptography Spartans

Julius Caesar

Julius Caesar invented what is known as Caesar cipher. It is a fairly simple technique which relies on substitution. Basically jumping a fixed set of characters forward/backward. Let’s assume we use a right shift of 4 characters as our substitution cipher.

M O H A M E D  B I L A L
Q S L E Q I H  F M P E P

As you can see F comes 4 positions after B to the right, M is position 4 to the right of I and so on. While this fairly simple cipher was used by Caesar to protect military messages, it is susceptible to simple brute force attacks hence does not find an implementation in modern systems.

Caesar

Al-Kindi

An Arab scholar in the 9th century by the name Al-Kindi developed a frequency analysis technique to break such ciphers including the Caesar cipher. He documented his work in his manuscript Risāla fī Istikhrāj al-Mu’ammā.

Al-Kindi’s work laid the foundation for modern Cryptanalysis - a process of finding weaknesses in cryptographic algorithms that allow access to encrypted content/messages.

Al-Kindi

Indecipherable Cipher

Move forward to the 16th century and we get the Vigenère Cipher. The frequency analysis developed by Al-Kindi reverse engineered substitution ciphers until the Vigenère Cipher made its appearance in the 16th century. Instead of using one Caesar cipher it relies on multiple such ciphers which made it an undisputed champion of cryptography for the next 300 years.

What made it so difficult and the gold standard for centuries?

It is the combination of multiple Caesar ciphers determined by a corresponding key. Let’s assume the plaintext message being encrypted is MOHAMED BILAL and corresponding key is NBAEYIO AZXQT. The position shift is determined by the position each corresponding letter of the key occupies in the alphabetic order.

Technique:

  • M has N as its corresponding letter in the key here. N is the 13th letter of the alphabet (we begin at A=0) hence we shift M by 13 positions in this cipher which gives us Z.
  • O has B as its corresponding letter. B occupies the 1st position in the alphabet hence we shift O by 1 position which gives us P.
M O H A M E D  B I L A L
Z P H E K M R  B H I Q E
Key
N B A E Y I O  A Z X Q T

The German Enigma Machine

With the outbreak of World War I and the widespread use of the electric telegraph, armies needed a way to encrypt messages much faster. Encrypting massive volumes of data by hand using the Vigenère cipher was no longer an option, as it was far too slow and highly prone to human error. The solution was mechanization, leading to the invention of the Enigma Machine. Used extensively throughout World War II, this invention changed the cryptographic landscape entirely.

This machine looked like a standard typewriter but relied on a complex set of electromechanical rotors to scramble the 26 letters of the Latin alphabet. When an operator pressed a letter on the keyboard, an electrical current passed through the shifting rotors and illuminated a corresponding ciphertext letter on a lightboard. Because the circuit was reciprocal, entering the converted ciphertext back into a properly configured machine transformed it directly back into plaintext.

How did it work?

The two machines used for communication needed to be identical in their setup. Shared codebook, exact same rotors, identical plugboard and the exact same 3 letter starting position for both sender and receiver.

Since the mechanics were the same, the rotors on both machines advanced in the exact same sequence. This meant that when the receiver typed the third letter of the ciphertext, their rotors had shifted into the precise mechanical state the sender’s machine was in when the third letter was originally encrypted. This perfect mirroring allowed the message to be decoded seamlessly.

Enigma WW2

Modern Cryptography

Enter the computer age. With this technological leap, cryptography moved away from physical mechanics and entirely into the mathematical realm of binary code (1s and 0s).

Data Encryption Standard (DES):

Developed by IBM in the 1970s, DES used a 56-bit key to scramble data using a block cipher technique. It officially established the framework for modern symmetric encryption standards, where the sender and receiver must use the exact same key.

Public-Key Cryptography - RSA:

Invented by researchers Rivest, Shamir, and Adleman, RSA is recognized as the first practical asymmetric encryption system. Instead of a single shared key, this system relies on a mathematically linked pair: a Public Key and a Private Key.

Public keys are freely shareable with the world, while Private keys are kept strictly secret. This setup allows anyone to encrypt a message using your public key, but only the person possessing the corresponding private key can decrypt it. This elegantly solved the massive logistical problem of secure key distribution, making asymmetric encryption the de facto security standard of the modern internet.

Advanced Encryption Standard (AES):

As computers evolved and their processing power exponentially increased, legacy standards became increasingly vulnerable to brute-force attacks. To counter this sheer computational power, AES was introduced, offering much larger key lengths: 128-bit, 192-bit, and 256-bit. As discussed earlier, AES-256 remains virtually unbreakable by classical computers. Furthermore, it is currently considered highly resistant even to the looming threat of quantum computing. While the landscape of cryptography is always evolving and things may change in the future, AES-256 stands as the gold standard for symmetric encryption today.

What’s Next?

Today, modern cryptographic systems rely on a variety of advanced algorithms and techniques, including Stream and Block ciphers (symmetric), RSA and ECC (asymmetric), and even cutting-edge Lattice-based math (post-quantum).

I intend to deep dive into these subjects in upcoming blogs.