Module – 1: Crypto Basics
Module – 1
Crypto Basics
Introduction to Cryptography
🔹 Purpose of the Chapter:
Introduce basic elements of cryptography.
Serve as a foundation for subsequent crypto chapters.
Emphasis on conceptual clarity over mathematical rigor.
🔹 Learning Goals:
Understand what cryptographic techniques are.
Gain an appreciation for why they are used.
🔹 Topics Covered in Future Chapters:
1. Symmetric Key Cryptography
2. Public Key Cryptography
3. Hash Functions
4. Advanced Cryptanalysis
Basic Cryptography Terminology:
Cryptology: The field involving both creating and breaking secret codes.
Cryptography: The art of designing secret codes (encryption).
Cryptanalysis: The practice of breaking or analyzing secret codes.
Crypto: A general term for cryptology, cryptography, or cryptanalysis.
A cipher or cryptosystem is used to encrypt data.
Plaintext: Original, readable data.
Ciphertext: Encrypted (scrambled) version of the plaintext.
Decryption: Reverses encryption to retrieve the original plaintext.
A key configures the cryptosystem for both encryption and decryption.
Types of Cryptosystems:
✅ Symmetric Key Cryptography:
Same key is used for both encryption and decryption.
Key must be kept private and shared securely.
Also called symmetric key, not “secret key” (to avoid ambiguity).
1|Page
Module – 1: Crypto Basics
🔓 Public Key Cryptography (Asymmetric):
Uses two different keys:
o Public Key → used for encryption (can be shared openly).
o Private Key → used for decryption (must be kept secret).
Enables secure communication without exchanging a shared secret.
An ideal cipher makes it computationally infeasible to recover plaintext without the key.
Even if an attacker (e.g., Trudy) knows:
The encryption algorithm…still cannot decrypt the ciphertext without the key.
This is the security goal of cryptographic systems — though real-world ciphers may not always
perfectly meet this ideal.
Kerckhoffs' Principle – Short Notes
Kerckhoffs’ Principle: The security of a cryptosystem should depend only on the secrecy of
the key, not the secrecy of the algorithm.
Named after Auguste Kerckhoffs, who in 1883 outlined six principles of cipher design.
His famous quote: A cipher “must not be required to be secret, and it must be able to fall
into the hands of the enemy without inconvenience.”
Why This Principle Matters:
Secret algorithms are often reverse-engineered or leaked.
History shows many “secret” cryptosystems failed under public scrutiny.
Open cryptosystems allow the crypto community to analyze and verify security over time.
A cryptosystem is “guilty until proven innocent”—it must earn trust through public analysis.
Wider Applications:
Kerckhoffs' Principle applies beyond cryptography to general security design.
Openness encourages more scrutiny, exposing flaws early and strengthening security.
2|Page
Module – 1: Crypto Basics
Despite its wide acceptance, it is often violated in practice, leading to serious vulnerabilities.
Classic Cryptography:
Simple Substitution Cipher: Caesar’s Cipher
A simple substitution cipher where each letter is replaced by one n positions ahead in the
alphabet.
With n = 3, the cipher becomes:
a → D, b → E, ..., z → C
This shift (3) acts as the key.
Plaintext: fourscoreandsevenyearsago
Ciphertext: IRXUVFRUHDAGVHYHABHDUVDIR
(Each letter shifted 3 positions forward)
Decryption:
Reverse the process by shifting each ciphertext letter backward by 3.
Any shift value n ∈ {0, 1, ..., 25} can be used as a key.
The cipher works by shifting each letter in the plaintext forward by n positions.
Brute-Force (Exhaustive Key Search)
An attacker like Trudy can try all 26 possible keys to decrypt the message.
On average, she'll find the correct key after 13 tries.
This method is called an exhaustive key search or brute-force attack.
Keyspace Size Matters
The larger the keyspace, the more secure the cipher:
o 2⁴⁰ keys/sec search rate:
2⁵⁶ keyspace → ~18 hours
2⁶⁴ keyspace → ~6 months
2¹²⁸ keyspace → billions of years
Modern symmetric ciphers use key sizes ≥ 128 bits to prevent brute-force attacks.
Expanding the Keyspace
Instead of just using shifts, we can allow any permutation of the 26 letters.
This creates 26! (factorial) possible keys ≈ 4 × 10²⁶, vastly increasing security.
Example substitution (not a shift):
o plaintext: a b c d e f g h i j k ...
3|Page
Module – 1: Crypto Basics
o ciphertext: Z P B Y J R G K F L X ...
Simple shift ciphers are easy to break due to small keyspace.
Using arbitrary permutations greatly increases the number of keys, making brute-
force attacks less practical—but not necessarily unbreakable using other methods (like
frequency analysis).
Cryptanalysis of Simple Substitution
Ciphertext Assumption:
Trudy intercepts a ciphertext assumed to be encrypted using a simple substitution
cipher.
The key is any permutation of the alphabet (26! possibilities).
A brute-force (exhaustive search) is impractical due to the vast number of possible
keys.
Frequency Analysis Attack:
Instead of guessing all keys, Trudy can analyze letter frequency in the ciphertext.
Assumes that the plaintext is in English, which has well-known letter frequency
patterns:
o Most common letters in English: E, T, A, O, I, N, S, H, R, D, L, U
o Rare letters: Q, Z, X, J, K
Steps for Frequency Analysis:
1. Count how often each letter appears in the ciphertext.
2. Compare this with known English letter frequency (e.g., 'E' is most common).
3. Guess substitutions based on matching frequencies (e.g., if 'Q' appears most, maybe
it maps to 'E').
4. Refine the guesses using patterns in common English words, digrams (e.g., "th",
"he"), and trigrams (e.g., "the", "and").
💡 Key Insight:
Even without the key, a simple substitution cipher is vulnerable to cryptanalysis
when:
o The attacker knows the language.
o The ciphertext is long enough to reflect letter usage patterns.
🎯 Conclusion:
Simple substitution ciphers are not secure.
Frequency analysis is a powerful tool for breaking them.
4|Page
Module – 1: Crypto Basics
Security should rely on large keyspaces and algorithms that resist statistical attacks.
Using Frequency Counts in Cryptanalysis
Trudy observes that "F" is the most frequent letter in the ciphertext.
From known English letter frequencies, "E" is the most common letter in English.
She hypothesizes that "F" → "E" in the substitution cipher.
Step-by-Step Frequency Analysis:
1. Match top-frequency letters in ciphertext to common English letters (e.g., "F" →
"E", "Q" → "T", etc.).
2. Substitute these guesses into the ciphertext.
3. Look for recognizable words or partial words.
4. As more words become clear, refine and expand the substitution guesses.
5. Iteratively decrypt the full message.
Conclusion:
Frequency analysis allows Trudy to crack substitution ciphers without trying every
key.
Once some correct substitutions are made, patterns help reveal the rest.
This method is especially effective when:
5|Page
Module – 1: Crypto Basics
o The message is long enough.
o The plaintext language is known (e.g., English).
Breaking Simple Substitution – Final Steps & Insights
🔓 1. Recognizing Words Like “the”
Trudy doesn't know word boundaries but can guess likely short words.
If the third letter in the decrypted message appears to be "e", and the first two letters
are high-frequency, a logical guess is:
o First word = “the”
Once “the” is identified, those letter mappings (T, H, E) can be applied to the entire
ciphertext.
🔁 2. Progressive Decryption
Each correct guess unlocks more substitutions.
Trudy may make mistakes but will iteratively refine her guesses.
With patience and smart use of statistics, the full message is revealed—much faster
than brute-force (which could take thousands of millennia).
⚠️3. Key Takeaway
A large keyspace alone is not enough for strong security.
A cipher must also be resistant to intelligent attacks like frequency analysis.
🧠 4. The Role of Public Scrutiny
New attacks are always being developed.
Therefore, ciphers must undergo extensive public analysis by skilled cryptographers.
The more experts fail to break a cipher, the more confidence we have in its security.
Definition of a Secure Cipher
✅ 1. Ideal Definition:
A cipher is secure if there is a mathematical proof that no feasible (practical) attack
exists.
However, provably secure ciphers are rare and often impractical for real-world use.
6|Page
Module – 1: Crypto Basics
⚙️2. Practical Definition (Used in This Context):
A cryptosystem is secure if the best-known attack requires as much effort as an
exhaustive key search (brute force).
Meaning: No known shortcut (more efficient) attacks exist.
🧠 3. Key Insights:
Security is judged relative to the key length:
o If the key size is 128 bits, then the best attack should take ~2¹²⁸ operations.
A cipher may be considered insecure if a shortcut attack reduces the effort below
brute-force level.
Key size = Advertised Security
o Any successful shortcut breaks this promise, indicating a design flaw.
🔐 4. Practical Cipher Requirements:
Must satisfy both:
1. No shortcut attack is known (security as defined).
2. Large keyspace to make brute-force attacks impractical.
🎯 Conclusion:
A secure cipher = no better attack than brute force + sufficiently large keyspace.
Double Transposition Cipher
A classic cipher that uses permutations to scramble data. Useful for introducing core
concepts related to permutation and transposition in cryptography.
Encryption Process:
1. Write the plaintext into a grid (array) of a chosen size.
2. First Transposition: Permute (rearrange) the rows according to a key.
3. Second Transposition: Permute the columns using another key.
The version discussed here is a simplified form of the double transposition cipher, used
for easier understanding of key concepts.
Shows how permutation-based ciphers work by rearranging data in structured ways.
Foundation for techniques used in modern block ciphers, such as mixing and diffusion.
For example, suppose we write the plaintext attackatdawn into a 3 x 4 array:
7|Page
Module – 1: Crypto Basics
NADWTKCAATAT
For the double transposition, the key consists of the size of the matrix and the row and
column permutations. Anyone who knows the key can simply put the ciphertext into the
appropriately sized matrix and undo the permutations to recover the plaintext. For
example, to decrypt (2.3), the ciphertext is first put into a 3 x 4 array. Then the columns
are numbered as (4,2,1,3) and rearranged to (1,2,3,4), and the rows are numbered (3,2,1)
and rearranged into (1,2,3),
and we see that we have recovered the plaintext, namely, attackatdawn.
Double Transposition Cipher – Advantages & Limitations
❌ Limitations:
Does not disguise the actual letters in the message.
Same letters appear in ciphertext as in plaintext—no substitution occurs.
✅ Advantages:
Disrupts statistical patterns in the plaintext.
Letter frequencies and common word structures are scattered (or "smeared") across
the ciphertext.
This makes frequency analysis attacks far less effective compared to simple
substitution ciphers.
Security Insight:
Even in its simplified form, this cipher is non-trivial to break.
The concept of diffusing statistical structure is a core idea behind modern block
ciphers like AES.
8|Page
Module – 1: Crypto Basics
While it doesn’t hide letters, double transposition increases confusion and diffusion. A
valuable cryptographic technique still used in more complex forms today.
One-Time Pad (OTP)
The One-Time Pad, also called the Vernam Cipher, is a provably secure
cryptosystem.
Although it has been used historically, it is impractical for most modern
applications.
It is valuable for illustrating important cryptographic concepts.
In the simplified example, an eight-letter alphabet is used, with each letter having a
binary representation (see Table 2.1).
The mapping between letters and bits is not secret, similar to ASCII, which is also
publicly known.
Suppose that Alice, who recently got a job as a spy, wants to use a onetime pad to encrypt the
plaintext message: h e i l h i t l e r .
She first consults Table 2.1 to convert the plaintext letters to the bit string
001 000 010 100 001 010 111 100 000 101.
The one-time pad key is a random bit string of the same length as the message.
Encryption is done by XORing the key with the plaintext.
XOR operation: x ⊕ y, with the useful property that x ⊕ y ⊕ y = x.
Mathematically, this is equivalent to adding the bits modulo 2.
Decryption is done by XORing the ciphertext with the same key.
This XOR property is also widely used in modern symmetric ciphers.
Now suppose that Alice has the key : 111 101 110 101 111 100 000 101 110 000
which is of the proper length to encrypt her message above. Then to encrypt, Alice computes
the ciphertext as
9|Page
Module – 1: Crypto Basics
Converting these ciphertext bits back into letters, the ciphertext message to be transmitted is
srlhssthsr.
When her fellow spy, Bob, receives Alice's message, he decrypts it using the same shared key
and thereby recovers the plaintext:
Let's consider a couple of scenarios. First, suppose that Alice has an enemy, Charlie, within
her spy organization. Charlie claims that the actual key used to encrypt Alice's message is:
101 111 000 101 111 100 000 101 110 000
Bob decrypts the ciphertext using the key given to him by Charlie and obtains
Bob, who doesn't really understand crypto, orders that Alice be brought in for questioning.
Now let's consider a different scenario. Suppose that Alice is captured by her enemies, who
have also intercepted the ciphertext. The captors are eager to read the message and Alice is
"encouraged" to provide the key for this super-secret message. Alice claims that she is
actually a double agent and to prove it she provides the "key":
111 101 000 Oil 101 110 001 011 101 101
When Alice's captors "decrypt" the ciphertext using this "key," they find
Alice's captors, who are not very knowledgeable about crypto, congratulate Alice for her
patriotism and release her.
The One-Time Pad (OTP) is provably secure if:
o The key is truly random
o The key is used only once
o The key is known only to sender and receiver
10 | P a g e
Module – 1: Crypto Basics
With these conditions, the ciphertext reveals no information about the original
message—any plaintext of the same length could match.
However, the OTP is impractical for most uses because:
o The key must be as long as the message.
o It must be securely shared in advance.
o If the key can be securely transmitted, why not just send the message
directly?
Reusing the same pad for multiple messages (a depth) breaks security:
o XORing the two ciphertexts cancels the key, leaving XOR of the two
C1 ⊕ C2 = P1 ⊕ P2
plaintexts:
o This leakage makes cryptanalysis possible.
Danger of Key Reuse in One-Time Pad (Short Note)
If a one-time pad key is reused (a situation known as a depth), the key disappears
C1 ⊕ C2 = P1 ⊕ P2
when ciphertexts are XORed:
This leakage exposes relationships between the plaintexts, giving attackers useful
information.
With just one message, an attacker can't tell if a guessed key is correct.
But with two messages in depth, correct key guesses will produce two meaningful
plaintexts, helping attackers spot the real key.
The more the key is reused, the easier it becomes for an attacker to break the
system.
Let's consider an example of one-time pad encryptions that are in
depth. Using the same bit encoding as in Table, suppose we have
Pi = l i k e = 100010011000 and P2 = k i t e = 011010111000
and both are encrypted with the same key K = 110 011 101 111. Then
11 | P a g e
Module – 1: Crypto Basics
If Trudy knows that two ciphertexts are in depth (encrypted with the same OTP key),
she can:
Detect patterns, such as identical letters at the same positions.
For example, if 2nd and 4th letters of both ciphertexts are the same, she concludes
those plaintext positions match.
More critically, Trudy can guess a likely plaintext (e.g., P₁ = kill = 011010100100)
and XOR it with the ciphertext C₁ to recover a putative key.
She can then XOR that key with C₂ to check if it results in a sensible plaintext P₂.
If P₂ looks plausible, her guess is likely correct — a powerful cryptanalytic technique
made possible only if the pad is reused.
and she can then use this K to "decrypt" C2 and obtain
Since this K does not yield a sensible decryption for P2, Trudy can safely assume that her
guess for Pi was incorrect. When Trudy eventually guesses Pi = like she will obtain the
correct key K and decrypt to find P2 = kite, thereby confirming the correctness of the key
and, therefore, the correctness of both decryptions.
Project VENONA
The VENONA project revealed the Soviet Union's use of one-time pads to securely transmit
encrypted messages from spies in the U.S. during the 1930s and 1940s, particularly involving
atomic bomb secrets. Despite the one-time pad's theoretical security, American
cryptanalysts managed to decrypt many messages due to flawed key generation that led to
key reuse. Notable figures like the Rosenbergs were identified through these decrypts.
Codebook Cipher
12 | P a g e
Module – 1: Crypto Basics
A classic codebook cipher replaces entire words or phrases with preassigned codewords
from a dictionary-like book, offering a more complex form of substitution. Used notably by
Germany in World War I—including for the famous Zimmermann telegram—these ciphers
relied heavily on the physical security of the codebook. The Zimmermann telegram,
intercepted and decrypted by the British using a damaged codebook, influenced the U.S. to
join the war. To improve security and extend codebook life, additive books (random
sequences) were introduced, functioning similarly to a one-time pad when not reused.
However, repeated use allowed for statistical attacks. Modern block ciphers echo this
concept by using keys to define large sets of virtual codebooks, often combined with
initialization vectors (IVs) to enhance security.
Ciphers of the Election of 1876
The U.S. presidential election of 1876 between Rutherford B. Hayes and Samuel J. Tilden was
extremely close, occurring during a time of national division after the Civil War. Although
Tilden won the popular vote, disputed electoral votes in four states led to the formation of a
commission to resolve the issue. The commission awarded all disputed votes to Hayes,
securing his presidency. Tilden's supporters alleged bribery, but no proof emerged.
After the 1876 U.S. election, encrypted messages from Tilden's supporters were discovered,
using a cipher that combined a partial codebook (for key words) with word transposition.
Messages were padded to specific lengths and scrambled using fixed permutations. For
example, a 10-word message used the permutation 9,3,6,1,10,5,2,7,4,8. One decrypted
message revealed criticism of the situation, stating: “Can’t read last telegram. Situation
unchanged. They are all idiots.”
The cipher used by Tilden's supporters after the 1876 election was weak and easily broken.
It reused fixed permutations for messages of the same length, allowing cryptanalysts to
compare messages "in depth" and uncover the pattern. Once the permutations were
discovered, the partial codebook was reconstructed using context and some unencrypted
texts. The decrypted messages revealed attempts to bribe election officials, exposing that
Tilden's side had committed the same misconduct they accused Hayes of. The case highlights
the dangers of key reuse and the importance of key variability in secure cryptographic
systems.
Modern Crypto History
1. 20th Century Importance:
o Cryptography played a crucial role in political, military, and later commercial
affairs.
2. Zimmermann Telegram:
13 | P a g e
Module – 1: Crypto Basics
o An early 20th-century example showcasing the impact of cryptanalysis in
political decisions.
3. Stimson’s Decision (1929):
o U.S. Secretary of State Henry Stimson shut down U.S. cryptanalysis, saying,
"Gentlemen do not read each other's mail."
o This was a costly mistake before Pearl Harbor.
4. World War II – Golden Age of Cryptanalysis:
o Allied forces broke almost all major Axis cryptosystems.
o The intelligence gained was extremely valuable for military strategies.
5. Pacific Theatre:
o Purple Cipher (Japanese government): Broken before Pearl Harbor, but failed
to reveal the planned attack.
o JN-25 Cipher (Japanese Navy): Decrypted by Americans and crucial to
victories at the Coral Sea and Midway.
6. European Theatre:
o Enigma Cipher (Germany): Code-named ULTRA by Allies.
o Provided major intelligence but had to be used carefully to avoid alerting
Germans.
7. Churchill & Coventry Incident:
o Alleged that Churchill didn’t warn Coventry of a German attack to protect the
secret of Enigma being broken (later proven false).
8. Polish Contribution:
o Polish cryptanalysts initially broke Enigma.
o After fleeing occupied Europe, they shared their knowledge with British
experts.
9. Alan Turing’s Role:
o Led the British team that improved Enigma-breaking techniques at Bletchley
Park.
A picture of the Enigma appears in Figure.
14 | P a g e
Module – 1: Crypto Basics
Evolution of Cryptography (Post-World War II to Modern Era)
1. Scientific Shift:
o Post-WWII, cryptography transitioned from a "black art" to a science.
o Key moment: Claude Shannon’s 1949 paper “Communication Theory of
Secrecy Systems”.
2. Shannon’s Contributions:
o Proved the security of the one-time pad.
o Introduced two key principles for cipher design:
Confusion: Obscures relationship between plaintext and ciphertext.
Diffusion: Spreads plaintext influence across ciphertext to hide
patterns.
3. Application of Concepts:
o Confusion-only: One-time pad, substitution ciphers.
o Diffusion-only: Double transposition.
o Effective modern ciphers combine both.
4. Commercial Need Emerges:
o 1970s computer revolution created demand for data protection.
o U.S. government acknowledged the commercial need for secure
cryptography.
5. Birth of DES:
o National Bureau of Standards (NBS) called for a crypto algorithm.
o Result: Data Encryption Standard (DES), a major milestone in cryptographic
history.
6. Impact of DES:
o DES played a foundational role in modern cryptography.
o Spurred academic and public interest in cryptographic research.
7. Public Key Cryptography & Research Growth:
o Public key cryptography emerged shortly after DES.
o The 1980s saw the rise of annual CRYPTO conferences.
8. 1990s Developments:
o Introduction of the Clipper Chip.
15 | P a g e
Module – 1: Crypto Basics
Work began on DES replacements due to its aging design.
o
9. Wider Adoption:
o Governments still fund crypto research.
o However, cryptography is now public, with open academic and commercial
development.
A Taxonomy of Cryptography
Overview of Cryptographic Categories
Three Major Categories:
o Symmetric ciphers
o Public key cryptosystems
o Hash functions
Symmetric Ciphers
Same key is used for both encryption and decryption.
Types:
Stream ciphers: Extend one-time pad idea, prioritize practical key management.
Block ciphers: Work like dynamic codebooks; each key defines a unique mapping.
Trends:
Stream ciphers were more popular post-WWII.
Block ciphers dominate today, especially in software applications.
Stream ciphers remain efficient in hardware environments.
Public Key Cryptography
Two keys: a public key (shared openly) and a private key (kept secret).
Anyone can encrypt a message using your public key, but only you (with the private
key) can decrypt it.
Advantages:
o Solves the key distribution problem faced by symmetric systems.
o No prior key exchange needed.
Historical Flaw in Symmetric Key Distribution:
o Example: Walker family spy ring sold U.S. military keys to the Soviets,
exploiting poor key distribution.
Digital Signatures
Unique Feature of Public Key Systems:
If a message is encrypted with a private key, it can be decrypted by anyone using the
public key.
This serves as a digital signature: verifies authenticity, since only the private key
owner could have signed it.
Symmetric vs Public Key Cryptography
Functionality:
Everything possible with symmetric ciphers can also be done with public key
cryptosystems.
Public key crypto offers additional capabilities, like digital signatures.
16 | P a g e
Module – 1: Crypto Basics
Efficiency Trade-off:
Symmetric cryptography is much faster than public key crypto (often several
orders of magnitude).
Therefore, symmetric crypto is used to encrypt most data in practice.
Role of Public Key Crypto:
Despite being slower, it plays critical roles in secure communications (e.g., key
exchange, authentication).
Cryptographic Hash Functions
Definition:
A function that takes input of any size and produces a fixed-size output (hash).
Essential Properties:
Avalanche effect: Small input changes should result in significant output changes
(around half of bits).
Collision resistance: It should be computationally infeasible to find two different
inputs that hash to the same output.
Utility:
Though not obviously useful at first glance, hash functions are powerful tools in
many cryptographic and data integrity applications.
A Taxonomy of Cryptanalysis
Goal of Cryptanalysis
Objective: Recover the plaintext, the key, or both.
Kerckhoffs’ Principle: Assume the attacker (Trudy) knows everything about the
algorithm, but not the key.
Access Assumption: Trudy always has access to the ciphertext, or else encryption would
be pointless.
Types of Attacks
Ciphertext-Only Attack: Trudy has only ciphertext. Most difficult scenario for the
attacker.
Known Plaintext Attack: Trudy has some plaintext-ciphertext pairs.
Can leverage common data patterns (e.g., headers in emails) to guess key.
Chosen Plaintext Attack:
Trudy can select plaintexts and obtain the corresponding ciphertexts.
Possible in systems that automatically encrypt user input (e.g., protocols,
compromised sessions).
Adaptively Chosen Plaintext Attack:
Trudy adjusts her plaintext selection based on previously obtained ciphertexts.
Offers greater power and efficiency in breaking encryption.
Related Key Attack:
Exploits weaknesses when keys are mathematically related.
Important in certain applications like wireless protocols or embedded systems.
Public Key Specific Attack
17 | P a g e
Module – 1: Crypto Basics
Forward Search Attack: Applicable to public key crypto, not symmetric. Trudy guesses
potential plaintexts (like "yes" or "no"), encrypts them with Alice’s public key, and
matches them with the intercepted ciphertext.
Hash Function Relevance: Forward search techniques can also apply to hash functions in
some cases.
Keyspace and Plaintext Space Requirements
Keyspace Size: Must be large to prevent brute-force key guessing.
Plaintext Space Size (in Public Key Crypto): Must be large enough to prevent trying all
possible plaintexts (like in forward search attacks).
18 | P a g e