0% found this document useful (0 votes)
34 views12 pages

Cryptography Unit 2

Cryptography is the art of securing communication and information through algorithms, ensuring that only intended recipients can access the data. It includes symmetric-key and asymmetric-key cryptography, with applications in secure online transactions, digital signatures, and password protection. Various techniques, including classical ciphers and modern encryption methods like AES and RSA, are employed to protect data integrity and confidentiality.

Uploaded by

aashdeepsingh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views12 pages

Cryptography Unit 2

Cryptography is the art of securing communication and information through algorithms, ensuring that only intended recipients can access the data. It includes symmetric-key and asymmetric-key cryptography, with applications in secure online transactions, digital signatures, and password protection. Various techniques, including classical ciphers and modern encryption methods like AES and RSA, are employed to protect data integrity and confidentiality.

Uploaded by

aashdeepsingh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Cryptography

 From the beginning any era, human being has two natural needs:
 To communicate and share information and
 To communicate selectively.
 These two needs gave rise to the art of coding the messages in such a way that only the
intended people could have access to the information. Unauthorized people could not
extract any information.
 The word “cryptography‟ is the combination of two Greek words, “Krypto” meaning
hidden or secret and “graphene” meaning writing.

Cryptography: Cryptography is a technique of securing information and communications


through the use of some algorithms so that only those persons for whom the information is
intended can understand it and process it.

Cryptography is a technique of locking communication by converting plain text into


impenetrable ciphertext. It involves various algorithms and protocols to ensure data
confidentiality, integrity, authentication, and non-repudiation.

The two primary types of cryptography are symmetric key cryptography and asymmetric key
cryptography and it plays a dynamic role in ensuring the security and privacy of information
in today’s digital world and enables secure online transactions, protects data stored in
databases, and ensures the confidentiality of communication. As technology continues to
advance, cryptography remains a crucial tool in the ongoing battle to keep our information
safe from hackers.

Cryptography including symmetric-key cryptography, asymmetric-key cryptography as well as


Cryptanalysis, Public Key Cryptography and more.
Types of Cryptography:
There are several types of cryptography, each with its own unique features and applications.
Some of the most common types of cryptography include:

1. Symmetric-key cryptography: This type of cryptography involves the use of a single key to
encrypt and decrypt data. Both the sender and receiver use the same key, which must be kept
secret to maintain the security of the communication.

2. Asymmetric-key cryptography: Asymmetric-key cryptography, also known as public-key


cryptography, uses a pair of keys – a public key and a private key – to encrypt and decrypt
data. The public key is available to anyone, while the private key is kept secret by the owner.

3. Hash functions: A hash function is a mathematical algorithm that converts data of any size
into a fixed-size output. Hash functions are often used to verify the integrity of data and
ensure that it has not been tampered with.

Applications of Cryptography:
Cryptography has a wide range of applications in modern-day communication, including:

 Secure online transactions: Cryptography is used to secure online transactions, such


as online banking and e-commerce, by encrypting sensitive data and protecting it from
unauthorized access.

 Digital signatures: Digital signatures are used to verify the authenticity and integrity
of digital documents and ensure that they have not been tampered with.

 Password protection: Passwords are often encrypted using cryptographic algorithms


to protect them from being stolen or intercepted.

Symmetric Cipher Model –


Key Terms

 Plaintext – Original message or Data that is input to the algorithm.


 Encryption Algorithm – The algorithm that generates text by performing substitution
or permutation.
 Secret Key – Key that decides substitution and transformation that is to be applied to
the algorithm.
 Ciphertext – The substituted or permuted message which is produced by inputting
plaintext and key to algorithm.
 Decryption Algorithm –The algorithm takes ciphertext and key as input and generates
plaintext.

For secure communication using encryption following requirements must be


satisfied:

 Strong encryption algorithm - Given the algorithm and one or more ciphertexts

attacker can neither decrypt the ciphertext nor find key.

 The key must be exchanged in secret manner by communicating entities.

Symmetric Encryption Model :

Symmetric Encryption Scheme :

• Input is, Message P and the encryption key K - Algorithm forms the Ciphertext C denoted
as C=E(K,P) .

• The receiver has key K. P = D(K,C)

 Attacker is only interested in particular message so try to get P by estimating


plaintext P’.
 Attacker may try to recover key so that all further messages can be recovered by
estimating key K’

Classical cryptographic algorithms:-


Classical cryptographic algorithms refer to encryption techniques developed before the
modern era of computer-based cryptography. These algorithms primarily rely on
mathematical transformations such as substitution, transposition, and polyalphabetic
techniques. Here are some of the most well-known classical cryptographic algorithms:
1. Substitution Ciphers

These replace characters in plaintext with other characters according to a fixed system.

 Caesar Cipher: Each letter in the plaintext is shifted by a fixed number of positions
in the alphabet.

 Monoalphabetic Cipher: Each letter in the plaintext is replaced with a different


letter according to a predefined mapping.

 Playfair Cipher: Uses a 5x5 grid of letters to encrypt digraphs (pairs of letters)
rather than single characters.

2. Transposition Ciphers

These rearrange the order of letters in the plaintext to create ciphertext.

 Rail Fence Cipher: The message is written in a zigzag pattern and then read row
by row.

 Columnar Transposition Cipher: The plaintext is written in a grid and then read
column-wise according to a key.

 Route Cipher: The text is written in a grid and read in a specific order (spiral,
diagonal, etc.).

3. Polyalphabetic Ciphers

These use multiple substitution alphabets to make frequency analysis more difficult.

 Vigenère Cipher: Uses a keyword to determine shifts in the alphabet for


encryption.

 Beaufort Cipher: A variant of the Vigenère cipher with a different encryption


function.

 Autokey Cipher: Similar to the Vigenère cipher, but part of the plaintext is used as
the key.

4. Hill Cipher

 Uses matrix multiplication to encrypt blocks of letters.

 Involves linear algebra concepts and requires an invertible key matrix.

5. Enigma Machine

 Used during World War II by the Germans.


 A complex system of rotors and electrical circuits to perform polyalphabetic
substitution.

6. Vernam Cipher

 A type of one-time pad that relies on bitwise XOR operations.

 Secure only if the key is truly random and used only once.

These classical ciphers were effective in their time but are now largely obsolete due to
advances in computational power and cryptanalysis techniques. Modern cryptography
relies on more complex algorithms such as AES, RSA, and ECC, which provide much
stronger security.

Monoalphabetic Substitutions such as Caesar Cipher


Caesar Cipher

Definition

The Caesar Cipher is a basic monoalphabetic substitution cipher where each letter in the
plaintext is shifted by a fixed number of positions in the alphabet.

Encryption Process

1. Choose a shift value (k), typically between 1 and 25.

2. Replace each letter in the plaintext with a letter shifted forward by k positions.

3. Wrap around the alphabet if needed (e.g., shifting ‘Z’ by 1 gives ‘A’).

Encryption Formula

C=(P+k)mod 26C = (P + k) \mod 26C=(P+k)mod26

Where:

 C = Ciphertext letter

 P = Plaintext letter (converted to a numerical index: A = 0, B = 1, ..., Z = 25)

 k = Shift value

Decryption Formula

P=(C−k)mod 26P = (C - k) \mod 26P=(C−k)mod26

Where:

 P = Decrypted plaintext letter

 C = Ciphertext letter
Example (Shift = 3)

Encryption

Plaintext: HELLO

 H→K

 E→H

 L→O

 L→O

 O→R

✅ Ciphertext: KHOOR

Decryption (Reverse Shift = 3)

 K→H

 H→E

 O→L

 O→L

 R→O

Decrypted Text: HELLO

Cryptanalysis for Monoalphabetic Ciphers


1. Brute Force Attack

🔹 Applicable to ciphers with a small keyspace, like the Caesar cipher.


🔹 Since the Caesar cipher has only 25 possible shifts, an attacker can simply try all
possible shifts and find the correct one.

Example:
For the ciphertext "KHOOR", trying all 25 shifts would eventually reveal "HELLO" when
the correct shift (3) is used.

2. Frequency Analysis
🔹 Most effective against all monoalphabetic ciphers.
🔹 In any language, some letters appear more frequently than others.
🔹 For example, in English, the most common letters (by frequency) are:

 E, T, A, O, I, N, S, H, R, D, L, U

📌 Steps to Break a Cipher Using Frequency Analysis:

1. Count the frequency of each letter in the ciphertext.

2. Compare with known letter frequency distributions.

3. Substitute high-frequency ciphertext letters with probable plaintext letters.

4. Use context clues to refine the decryption.

Example:
Ciphertext: "ZOLSS"

 If "S" is the most frequent letter, it might correspond to "E" (most common English
letter).

 If "O" appears often, it could be "T" or "O".

 Using logical deduction, we might uncover that "ZOLSS" → "HELLO".

3. Known Plaintext Attack (KPA)

🔹 Used when part of the plaintext is known.


🔹 If an attacker knows or guesses part of the original message, they can determine the
substitution pattern and break the rest of the ciphertext.

Example:

 If we suspect a military message starts with "ATTACK," we can match it with the
ciphertext and uncover the letter mappings.

4. Pattern Recognition & Word Structures

🔹 Used for ciphers preserving spaces or word structures.


🔹 Common words like "THE" or "AND" can be identified by their letter patterns.

Example:
Ciphertext: "XYY XZ YYX"

 If "THE" is a likely word, then X = T, Y = H, Z = E.


Transposition Cipher
A transposition cipher is a type of cipher that encrypts a message by rearranging the
order of the letters in the plaintext, rather than substituting them with different letters.
Unlike substitution ciphers, which replace letters, transposition ciphers maintain the
original plaintext letters but scramble their positions according to a defined rule.

Types of Transposition Ciphers

1. Rail Fence Cipher

🔹 The message is written in a zigzag (rail fence) pattern and then read row by row.

Example (Key = 3 Rails)

Plaintext: HELLO WORLD

Write it in a zigzag pattern:

mathematica

CopyEdit

H L O O L

EL WRD

L O

Read row-wise:
Ciphertext: HLOOL ELWRD LO

Decryption: Reverse the zigzag and reconstruct the original message.

2. Columnar Transposition Cipher

🔹 The message is written in a grid (row-wise), then read column-wise based on a key.

Example (Key = "ZEBRA")

Plaintext: HELLO WORLD

Arrange the text into columns:

mathematica
CopyEdit

Z E B R A (Key)

-----------

HELLO

WORLD

Sort columns by alphabetical order of the key (A, B, E, R, Z):

mathematica

CopyEdit

A B E R Z

O L L L H

D R O W W

Read column-wise: Ciphertext: OHW LRL DLO

Decryption: Rearrange the columns back to their original order.

3. Route Cipher

🔹 The message is written in a grid, then read in a specific order (spiral, diagonal, etc.).

Example (Spiral Order)

Plaintext: ATTACK AT DAWN

Arrange into a 3x5 grid:

css

CopyEdit

ATTAC

KATDA

WNXXX

Read in a spiral pattern: Ciphertext: A T T A C A D T K A X X X N W

Decryption: Reverse the spiral order.

Stream and Block Ciphers in Cryptography


In modern cryptography, encryption algorithms are classified into Stream Ciphers and
Block Ciphers based on how they process data. Both are widely used in secure
communication, but they differ in their approach.

1. Stream Ciphers
Definition

A stream cipher encrypts data one bit or byte at a time, typically using a keystream
generator that produces a pseudo-random sequence of bits. The plaintext is combined
with this keystream using bitwise XOR.

Characteristics of Stream Ciphers


 Encrypts data bit-by-bit or byte-by-byte.
 Uses a keystream (pseudo-random bit sequence).
 Faster than block ciphers.
 Suitable for real-time encryption (e.g., voice and video).
 Vulnerable to key reuse attacks.

Example: Vernam Cipher (One-Time Pad)


 Uses a truly random keystream as long as the message.

 Encryption: C=P⊕KC = P \oplus KC=P⊕K (Ciphertext = Plaintext XOR Key)

 Decryption: P=C⊕KP = C \oplus KP=C⊕K (Reapplying XOR with the same key
restores plaintext)

Example: RC4 (Rivest Cipher 4)


 A widely used stream cipher (though now considered insecure).

 Used in WEP and SSL/TLS (legacy systems).

 Generates a keystream from a seed key using KSA (Key Scheduling Algorithm)
and

Applications of Stream Ciphers


 Wireless networks (WEP, WPA)

 Secure communications (TLS, VoIP)

 Mobile encryption (GSM, LTE)


2. Block Ciphers
Definition

A block cipher encrypts data in fixed-size blocks (e.g., 64-bit or 128-bit blocks). It applies
a series of mathematical transformations based on a secret key.

Characteristics of Block Ciphers


 Encrypts data in fixed-size blocks (e.g., 128-bit).
 Uses Substitution-Permutation Networks (SPN) or Feistel Structure.
 More secure and resistant to attacks than stream ciphers.
 Slower than stream ciphers for small data.

Popular Block Ciphers

1. DES (Data Encryption Standard)

o 64-bit block size, 56-bit key.

o Uses Feistel structure with 16 rounds.

o Now considered insecure due to small key size.

2. AES (Advanced Encryption Standard)

o 128-bit block size, key sizes of 128, 192, or 256 bits.

o Uses Substitution-Permutation Network (SPN).

o Highly secure, used in SSL/TLS, VPNs, and disk encryption.

3. Triple DES (3DES)

o Applies DES three times for improved security.

o Still used in legacy financial systems.

Modes of Operation (For Block Ciphers)

Since block ciphers work on fixed-size blocks, they require modes of operation to handle
variable-length messages.

Mode Description Security Feature

ECB (Electronic Weak, vulnerable to


Encrypts each block independently
Codebook) pattern attacks
Mode Description Security Feature

CBC (Cipher Block XORs each block with the previous Prevents pattern
Chaining) ciphertext block before encryption repetition

CFB (Cipher Converts block cipher into a self- Used for streaming
Feedback Mode) synchronizing stream cipher applications

OFB (Output Uses a keystream like a stream


Resistant to bit errors
Feedback Mode) cipher

CTR (Counter Uses a counter as input to generate High parallelization,


Mode) keystream widely used

Applications of Block Ciphers

 AES for secure communications (TLS, VPNs, SSH)

 Disk encryption (BitLocker, VeraCrypt)

 Database encryption (Oracle Transparent Data Encryption)

Comparison: Stream vs. Block Ciphers

Feature Stream Cipher Block Cipher

Fixed-size blocks (e.g., 128-


Processing Bit-by-bit or byte-by-byte
bit)

Speed Faster Slower (more secure)

Security Weak if keystream is predictable Stronger against brute-force

Example
RC4, Salsa20 AES, DES, 3DES
Ciphers

Real-time encryption (VoIP, video Secure file transfer, disk


Use Cases
streaming) encryption

You might also like