0% found this document useful (0 votes)
5 views

cryptography

Cryptography is the process of converting plain text into unintelligible text to protect data and ensure secure communication. It encompasses various techniques including private key ciphers, public key cryptography, and hash functions, and addresses security requirements like authentication, confidentiality, and integrity. The document also discusses classical ciphers such as the Caesar cipher and Vigenère cipher, as well as modern applications and cryptanalysis methods.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

cryptography

Cryptography is the process of converting plain text into unintelligible text to protect data and ensure secure communication. It encompasses various techniques including private key ciphers, public key cryptography, and hash functions, and addresses security requirements like authentication, confidentiality, and integrity. The document also discusses classical ciphers such as the Caesar cipher and Vigenère cipher, as well as modern applications and cryptanalysis methods.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 65

Introduction to Cryptography

Cryptography is associated with the process of


converting ordinary plain text into unintelligible text
and vice-versa. It is a method of storing and
transmitting data in a particular form so that only
those for whom it is intended can read and process it.
Cryptography not only protects data from theft or
alteration, but can also be used for user authentication.
Why Study cryptology(1)

A B

Intruder

Communications security

CSE2500 System
2
Why Study cryptology(2)

Customer Merchant

TTP

Electronic Commerce Security

CSE2500 System
3
Why Study cryptology(3)

A B

LEA

Law enforcement

CSE2500 System
4
The Basic Problem
 We consider the confidentiality goal:
 Alice and Bob are Friends
 Marvin is a rival
 Alice wants to send secret messages (M1,M2,…)
to Bob over the Internet
 Rival Marvin wants to read the messages (M1,M2,
…) - Alice and Bob want to prevent this!
 Assumption: The network is OPEN: Marvin is
able to eavesdrop and read all data sent from
Alice to Bob.
 Consequence: Alice must not send messages
(M1,M2,…) directly – they must be “scrambled” or
CSE2500 encrypted
System using a ‘secret code’ unknown to
Marvin but known to Bob. 5
Cryptography

plaintext (data file or messages)

encryption

ciphertext (stored or transmitted safely)

decryption

plaintext (original data or messages)

CSE2500 System
6
Private key cipher

Encryptio Encrypted message Decryptio


n n
(ciphertext)

Alice E
D Bob

key
Message Message
(cleartext,plaintext (cleartext, plaintext)
)

CSE2500 System
7
Basic terms
 Cryptology (to be very precise)
 Cryptography --- code designing
 Cryptanalysis --- code breaking
 Cryptologist:
 Cryptographer & cryptanalyst
 Encryption/encipherment
 Scrambling data into unintelligible to
unauthorised parties
 Decryption/decipherment
 Un-scrambling

CSE2500 System
8
Following are some specific
security requirment
 Authentication
 Confidentiallity
 Integrity
 Non-repudiation
three types of algorithm are used
 Secret key cryptography—same key used
 Public key cryptography----two diffrent key
used
 Hash function - H(m)
CSE2500 System
9
method

CSE2500 System
10
CSE2500 System
11
Examples of “Messages”

 Types of secret “Messages” Alice


might want to send Bob (in increasing
length):
Decision (yes/no), eg. as answer to the
question “Are we meeting tomorrow?”
Numerical Value, eg. as answer to the
question “at what hour are we meeting?”
Document
Software,
Images etc.
CSE2500 System
12
Concepts

 A private key cipher is composed of


two algorithms
encryption algorithm E
decryption algorithm D
 The same key K is used for encryption
& decryption
 K has to be distributed beforehand

CSE2500 System
13
Notations

 Encrypt a plaintext P using a key K &


an encryption algorithm E
C = E(K,P)
 Decrypt a ciphertext C using the same
key K and the matching decryption
algorithm D
P = D(K,C)

 Note: P = D(K,C) = D(K, E(K,P))


CSE2500 System
14
The Caesar cipher (e.g)

 The Caesar cipher is a substitution


cipher, named after Julius Caesar.
 Operation principle:
each letter is translated into the letter
a fixed number of positions after
it in the alphabet table.
 The fixed number of positions is a key
both for encryption and decryption.

CSE2500 System
15
The Caesar cipher (cnt’d)

K=3
Outer: plaintext
Inner: ciphertext

CSE2500 System
16
An example

 For a key K=3,


plaintext letter: ABCDEF...UVWXYZ
ciphtertext letter: DEF...UVWXYZABC
 Hence
TREATY IMPOSSIBLE
is translated into
WUHDWB LPSRVVLEOH

CSE2500 System
17
Breaking classic ciphers

 With the help of fast computers,


99.99% ciphers used before 1976 are
breakable by using one of the 4 types
of attacks (described later).
 Modern cluster computers and future
quantum computers can break several
existing ciphers due to the power of
such computers.

CSE2500 System
18
Breaking the Caesar cipher

 By trial-and error
 By using statistics on letters
frequency distributions of letters
letter percent
A 7.49%
B 1.29%
C 3.54%
D 3.62%
E 14.00%
..................................
CSE2500 System
19
Morden Cryptography applications

 Not just about confidentiality!


 Integrity
 Digital signatures
 Hash functions
 Fair exchange
 Contract signing
 Anonymity
 Electronic cash
 Electronic voting
 Etc.
CSE2500 System
20
4 types of cryptanalysis

 Depending on what a cryptanalyst has


to work with, attacks can be classified
into
ciphertext only attack
known plaintext attack
chosen plaintext attack
chosen ciphertext attack (most severe)

CSE2500 System
21
4 types of attacks

 Ciphertext only attack


the only data available is a target
ciphertext

 Known plaintext attack


a target ciphertext
pairs of other ciphertext and plaintext
(say, previously broken or guessing)

CSE2500 System
22
4 types of attacks

 Chosen plaintext attacks


a target ciphertext
can feed encryption algorithm with
plaintexts and obtain the matching
ciphertexts
 Chosen ciphertext attack
a target ciphertext
can feed decryption algorithm with
ciphertexts and obtain the matching
plaintexts
CSE2500 System
23
Hill Cipher
• The Hill Cipher uses matrix
multiplication to encrypt a message.
First, you need to assign two numbers
to each letter in the alphabet and also
assign numbers to space, . , and ? or !.
The key space is the set of all
invertible matrices over Z26. 26 was
chosen because there are 26
characters, which solves some
problems later on.
Hill Cipher example
Encryption:
Use the table and 00 for spaces:

A B C D E F G H I J K L M N O P Q R S
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
T U VW X Y Z
20 21 22 23 24 25 26

Consider the following message:

Herbert Yardley wrote The American Black Chamber


Hill Cipher example
Break the message into:
he rb er ty ar dl ey wr ot et he am er ic an bl ac kc
ha mb er

Now convert letters into number-pair:


8 5 18 2 5 18 20 25 1 18 4 12 5 25 23 18 15 20

5 20 8 5 1 13 5 18 9 3 1 14 2 12 1 3
11 3 8 1 13 2 5 18  03 07 
K  
 05 12 
Now using the matrix (key)
Hill Cipher example
Make the first pair a column vector (h (8) e (5)),
and multiply that matrix by the key.
 3 7   8   59 
 5 12   5  100 
    

Of course, we need our result to be mod 26


 59   7 
 100   22  mod 26
   

The ciphertext is G (7) V (22).


Hill Cipher example

For the next pair r (18) b (2),


 3 7   18  16 
 5 12   2   10  mod 26
    

and 16 corresponds to P and 10 corresponds to J.

Do this for every pair and obtain


GVPJKGAJYMRHHMMSCCYEGVPEKGVCWQLXXOBMEZAKKG
Hill Cipher Decryption:
Polyalphabetic Ciphers

• polyalphabetic substitution ciphers


• improve security using multiple cipher
alphabets
• make cryptanalysis harder with more
alphabets to guess and flatter frequency
distribution
• use a key to select which alphabet is used for
each letter of the message
• use each alphabet in turn
• repeat from start after end of key is reached
Vigenère Cipher

• simplest polyalphabetic substitution cipher


• effectively multiple caesar ciphers
• key is multiple letters long K = k1 k2 ... kd
• ith letter specifies ith alphabet to use
• use each alphabet in turn
• repeat from start after d letters in message
• decryption simply works in reverse
Example of Vigenère Cipher

• write the plaintext out


• write the keyword repeated above it
• use each key letter as a caesar cipher
key
• encrypt the corresponding plaintext
letter
Plaintext THISPROCESSCANALSOBEEXPRESSED
Keyword CIPHERCIPHERCIPHERCIPHERCIPHE
Ciphertext VPXZTIQKTZWTCVPSWFDMTETIGAHLH

based on a Vigenère Table shown next


Vigenère Cipher
ABCDEFGHIJKLMNOPQRSTUVWXYZ
A ABCDEFGHIJKLMNOPQRSTUVWXYZ
B BCDEFGHIJKLMNOPQRSTUVWXYZA
C CDEFGHIJKLMNOPQRSTUVWXYZAB
D DEFGHIJKLMNOPQRSTUVWXYZABC
E EFGHIJKLMNOPQRSTUVWXYZABCD
F FGHIJKLMNOPQRSTUVWXYZABCDE
G GHIJKLMNOPQRSTUVWXYZABCDEF
H HIJKLMNOPQRSTUVWXYZABCDEFG
I IJKLMNOPQRSTUVWXYZABCDEFGH
J JKLMNOPQRSTUVWXYZABCDEFGHI
K KLMNOPQRSTUVWXYZABCDEFGHIJ
L LMNOPQRSTUVWXYZABCDEFGHIJK
M MNOPQRSTUVWXYZABCDEFGHIJKL
N NOPQRSTUVWXYZABCDEFGHIJKLM
O OPQRSTUVWXYZABCDEFGHIJKLMN
P PQRSTUVWXYZABCDEFGHIJKLMNO
Q QRSTUVWXYZABCDEFGHIJKLMNOP
R RSTUVWXYZABCDEFGHIJKLMNOPQ
S STUVWXYZABCDEFGHIJKLMNOPQR
T TUVWXYZABCDEFGHIJKLMNOPQRS
U UVWXYZABCDEFGHIJKLMNOPQRST
V VWXYZABCDEFGHIJKLMNOPQRSTU
W WXYZABCDEFGHIJKLMNOPQRSTUV
X XYZABCDEFGHIJKLMNOPQRSTUVW
Y YZABCDEFGHIJKLMNOPQRSTUVWX
Z ZABCDEFGHIJKLMNOPQRSTUVWXY
Vigenère Cipher
• By using math. Equation:

C= E(p) = (p+ki) mod (26)


Plaintext THISPROCESSCANALSOBEEXPRESSED
Keyword CIPHERCIPHERCIPHERCIPHERCIPHE
Ciphertext VPXZTIQKTZWTCVPSWFDMTETIGAHLH
Security of Vigenère Ciphers

• have multiple ciphertext letters for each


plaintext letter
• hence letter frequencies are obscured
• but not totally lost
• start with letter frequencies
– see if look monoalphabetic or not
• if not, then need to determine number of
alphabets, since then can attach each
Kasiski Method

• method developed by Babbage / Kasiski


• repetitions in ciphertext give clues to period
• so find same plaintext an exact period apart
• which results in the same ciphertext
• of course, could also be random fluke
• eg repeated “VTW” in previous example
• suggests size of 3 or 9
• then attack each monoalphabetic cipher
individually using same techniques as
before
Autokey Cipher
• ideally want a key as long as the message
• Vigenère proposed the autokey cipher
• with keyword is prefixed to message as key
• knowing keyword can recover the first few
letters
• use these in turn on the rest of the message
• but still have frequency characteristics to attack
• eg. given key deceptive
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
Another Classical Substitution Ciphers
• Keyword mixed

Example:

keyword= AHMAD becomes AHMD


K= 3
ABCD E FGHI J K LMNO PQRST UVWXYZ

XYZA HMDBCE FG I J K LNOPQRST UVW

M= BE OR NOT TO BE
C= YH KO J KQ QKYH
Another Classical Substitution Ciphers
Transposed keyword mixed

Example:

1- keyword= AHMAD becomes AHMD


2- A H M D
B C E F
G I J K
L N O P
Q R S T
U V W X
Y Z

3- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
ABGLQUYHCINR VZMEJ OSWDF KPTX
4- M= BE OR NOT TO BE
C= BQ JO ZMW WM BQ
One-Time Pad
• This technique was introduced by army
signal officer Joseph Mauborgne. Which is
also called Vernam.
• He suggested using a random key that is as
long as the message.
• A message encrypted using a one-time pad
cannot be broken because the encryption
key is a random number and because the
key is used only once

• problems in generation & safe distribution


of key
One-Time Pad (OTP)
• Step 1: Create the key...
• You need to create a random key.
HLMSEZRBHPSJOTDW
• You need a method for converting
alphabet characters into numbers.

A B C D E F G H I J K L M N O P Q R S
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
T U VW X Y Z
20 21 22 23 24 25 26
One-Time Pad (OTP)
• Step 1: HLMSEZRBHPSJOTDW
· To make the key easier to work with, break it into blocks of
two characters each, thus
HL MS EZ RB HP SJ OT DW

• Now use the conversion table shown above to convert the


alphabet characters into numbers. For example H=08 and
L=12, so the first block HL becomes 0812.
The result is 0812 1319 0526 1802 0816 1910 1520 0423.
(The key)
One-Time Pad (OTP)
• Step 2: Format your message...

· Message  MY SECRET.  1325 1905


0318 0520
Key  HL MS EZ RB HP SJ OT DW 
0812 1319 0526 1802 0816 1910 1520 0423
One-Time Pad (OTP)
• Guidelines...
Rule 1 – Numbers. Spell out all numbers in full in your
plaintext. For example, 365 becomes THREE SIX FIVE.
Rule 2 – Negatives. Always add emphasis to the word
NOT in your plaintext. For example, you would write AGENT
ALPHA NOT RPT NOT AVAILABLE FOR MEETING
TUESDAY, where RPT stands for REPEAT.
Rule 3 – Punctuation. Use an X for each period in your
plaintext. For example, MESSAGE RECEIVEDX SEND
MORE INFOX. All other punctuation must be written out in
full. For example, COMMA.
Rule 4 – Termination. End your plaintext with XX. If
necessary, add dummy characters after XX in order to pad
out the message to frustrate cryptanalysis and to conclude
on a doublet (ensuring the numeric string ends with four
digits).
One-Time Pad (OTP)
• Step 3: Encrypt your message...

· We need some way to indicate to our recipient where the


key begins, otherwise he/she won't be able to
decrypt. Remember in our earlier example, we created a key
and stroked off (in gray) the blocks we'd already used.
Here's what our key looked like.
0812 1319 0526 1802 0816 1910 1520 0423

The starting position in the key is at block 1319. So we'll


place the string 1319 at the beginning of our message so
the recipient will know how to decrypt. The plaintext
message of 1325 1905 0318 0520 becomes 1319 1325 1905
0318 0520 because we place the pointer 1319 at the
beginning of the string.
One-Time Pad (OTP)
• Step 3: Encrypt your message...

· First we write out the plaintext. Then directly below it we


write out the key. Then we add the key to the plaintext
using Fibonicci addition. This means we do no carrying.
For example, 9 + 2 would yield 1 not 11. And 7 plus 6 would
yield 3 not 13. Here's how the spy's working sheet would
look.
Plaintext 1319 1325 1905 0318 0520
Key ----- 0526 1802 0816 1910
Ciphertext 1319 1841 2707 0124 1430

Encrypted message  1319 1841 2707 0124 1430


One-Time Pad (OTP)
• Step 3: Decrypting the message...
– We subtract the key from the ciphertext using
Fibonicci subtraction .
– We allow no negative numbers.
– For example, 2 - 9 would yield 3 (because we
add 10 so that we're able to subtract 9 from 12).

· Ciphertext 1319 1841 2707 0124 1430


Key 1319 0526 1802 0816 1910
Plaintext ---- 1325 1905 0318 0520
Transposition Ciphers

• now consider classical transposition


or permutation ciphers
• these hide the message by rearranging
the letter order
• without altering the actual letters used
• can recognise these since have the
same frequency distribution as the
original text
Rail Fence cipher

• write message letters out diagonally over a


number of rows
• then read off cipher row by row
• eg. write message out as:
m e m a t r h t g p r y
e t e f e t e o a a t
• giving ciphertext
MEMATRHTGPRYETEFETEOAAT
Columnar Transposition
Ciphers
a more complex transposition
columnar transposition: is rearrangement of characters of plain text
into coulmns.

• Write plaintext in a rectangle row by row.


• Permute the order of the columns
• Read the message off, column by column
Key: 4 3 1 2 5 6 7
Plaintext: a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
Product Ciphers
• ciphers using substitutions or transpositions
are not secure because of language
characteristics
• hence consider using several ciphers in
succession to make harder, but:
– two substitutions make a more complex substitution
– two transpositions make more complex
transposition
– but a substitution followed by a transposition makes
a new much harder cipher
• this is bridge from classical to modern ciphers
Rotor Machines

• before modern ciphers, rotor machines were


most common complex ciphers in use
• widely used in WW2(World War II)
– German Enigma, Allied Hagelin, Japanese Purple
• implemented a very complex, varying
substitution cipher
• used a series of cylinders, each giving one
substitution, which rotated and changed
after each letter was encrypted
• with 3 cylinders have 263=17576 alphabets
Hagelin Rotor Machine
 Confusion and Diffusion
 A substitution is said to add confusion to the
encryption process whereas a transposition is said to
add diffusion.
 Confusion is intended to make the relationship between
the key and ciphertext as complex as possible.
Diffusion refers to rearranging or spreading out the
characters in the message
 Most modern block cipher systems apply a number of
rounds in succession to encrypt plaintext.
 A round then can be said to add both confusion and
diffusion to the encryption
Steganography

• an alternative to encryption
• hides existence of message
– using only a subset of letters/words in a
longer message marked in some way
– using invisible ink
– hiding in LSB in graphic image or sound
file
• has drawbacks
– high overhead to hide relatively few info
bits
Popular sites for Popular sites for Steganography information

http://www.ise.gmu.edu/~njohnson/Steganography

http://www.rhetoric.umn.edu/Rhetoric/misc/dfrank/ste
gsoft.html

http://www.topology.org/crypto.html
Data Encryption Standard

The Data Encryption Standard (DES) is a symmetric-key


block cipher published by the National Institute of Standards
and Technology (NIST).
DES is an implementation of a Feistel Cipher. It uses 16
round Feistel structure. The block size is 64-bit. Though, key
length is 64-bit, DES has an effective key length of 56 bits,
since 8 of the 64 bits of the key are not used by the
encryption algorithm (function as check bits only). General
Structure of DES is depicted in the following illustration −
Since DES is based on the Feistel Cipher, all that is required to specify
DES is −
1.Round function
2.Key schedule
3.Any additional processing − Initial and final permutation
Initial and Final Permutation

The initial and final permutations are straight Permutation boxes


(P-boxes) that are inverses of each other. They have no cryptography
significance in DES
Round Function
The heart of this cipher is the DES function, f. The DES function applies
a 48-bit key to the rightmost 32 bits to produce a 32-bit output.

Expansion Permutation Box − Since right input is 32-bit and round key
is a 48-bit, we first need to expand right input to 48 bits.

XOR (Whitener). − After the expansion permutation, DES does XOR


operation on the expanded right section and the round key. The round
key is used only in this operation.

Substitution Boxes. − The S-boxes carry out the real mixing


(confusion). DES uses 8 S-boxes, each with a 6-bit input and a 4-bit
output. R
Key Generation
The round-key generator creates sixteen 48-bit keys out of a 56-bit
cipher key.
Triple DES

The speed of exhaustive key searches against DES after 1990


began to cause discomfort amongst users of DES. However,
users did not want to replace DES as it takes an enormous
amount of time and money to change encryption algorithms
that are widely adopted and embedded in large security
architectures.
The pragmatic approach was not to abandon the DES
completely, but to change the manner in which DES is used.
This led to the modified schemes of Triple DES (sometimes
known as 3DES).
Incidentally, there are two variants of Triple
3-KEY Triple DES
Before using 3TDES, user first generate and distribute a 3TDES key K, which consists
of three different DES keys K1, K2 and K3. This means that the actual 3TDES key has
length 3×56 = 168 bits
The encryption-decryption process is as follows −

1.Encrypt the plaintext blocks using single DES with key K 1.

2.Now decrypt the output of step 1 using single DES with key
K2.
3.Finally, encrypt the output of step 2 using single DES with
key K3.
4.The output of step 3 is the ciphertext.

5.Decryption of a ciphertext is a reverse process. User first


decrypt using K3, then encrypt with K2, and finally decrypt
with K1.

You might also like