Encryption Tech Chap
Encryption Tech Chap
2
Basic terminology
• Plaintext: original message to be
encrypted
• Ciphertext: the encrypted message
• Enciphering or encryption: the process of
converting plaintext into ciphertext
• Encryption algorithm: performs encryption
– Two inputs: a plaintext and a secret key
3
Symmetric Cipher Model
4
• Deciphering or decryption: recovering
plaintext from ciphertext
• Decryption algorithm: performs decryption
– Two inputs: ciphertext and secret key
5
• Cipher or cryptographic system : a scheme
for encryption and decryption
• Cryptography: science of studying ciphers
• Cryptanalysis: science of studying attacks
against cryptographic systems
• Cryptology: cryptography + cryptanalysis
6
Ciphers
• Symmetric cipher: same key used for
encryption and decryption
– Block cipher: encrypts a block of plaintext at a
time (typically 64 or 128 bits)
– Stream cipher: encrypts data one bit or one byte
at a time
• Asymmetric cipher: different keys used for
encryption and decryption
7
Symmetric Encryption
• or conventional / secret-key / single-key
• sender and recipient share a common key
• all classical encryption algorithms are
symmetric
8
Symmetric Encryption
• Mathematically:
Y = EK(X) or Y = E(K, X)
X = DK(Y) or X = D(K, Y)
• X = plaintext
• Y = ciphertext
• K = secret key
• E = encryption algorithm
• D = decryption algorithm
• Both E and D are known to public
9
Classical Ciphers
• Plaintext is viewed as a sequence of
elements (e.g., bits or characters)
• Substitution cipher: replacing each
element of the plaintext with another
element.
• Transposition (or permutation) cipher:
rearranging the order of the elements of
the plaintext.
10
Caesar Cipher
• Earliest known substitution cipher
• Invented by Julius Caesar
• Ciphertext is derived from the plaintext alphabet by
shifting each letter a certain number of spaces.
• Each letter is replaced by the letter three positions
further down the alphabet.
• Plain: 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
Cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
• Example: Meet me after the tea party phhw ph
diwhu wkh sduwb
11
Caesar Cipher
• Mathematically, map letters to numbers:
a, b, c, ..., x, y, z
p = DK(c) = (c – k) mod 26
• Can be generalized with any alphabet.
12
Monoalphabetic Substitution Cipher
13
Playfair Cipher
•
14
Playfair Cipher
• Rules:
– If pair letters are same, add an X (uncommon
letter) after the first letter.
• Balloon will be (ba lx lo on).
– If the letter appear in same row / column of the
table, replace them with the letter to immediate
right respectively.
– If the letters are not on same row or column ,
replace with letter in the corners of rectangle.
Playfair Key Matrix
• Use a 5 x 5 matrix.
• Fill in letters of the key (w/o duplicates).
• Fill the rest of matrix with other letters.
• E.g., key = MONARCHY.
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
16
Encrypting and Decrypting
Plaintext is encrypted two letters at a time.
1. If a pair is a repeated letter, insert filler like 'X’.
2. If both letters fall in the same row, replace
each with the letter to its right (circularly).
3. If both letters fall in the same column, replace
each with the the letter below it (circularly).
4. Otherwise, each letter is replaced by the letter
in the same row but in the column of the other
letter of the pair.
17
Hill Cipher
• The algo takes n x n matrix.
• The cipher C of P derived by multiplying P by K.
• When decrypt the message the inverse of K is
used.
• C=(KP) mod (26)
• P= K-1 C mod (26)
Hill Cipher
• Example :-
– Plaintext is “paymoremoney” and key is
– K= |17 17 5 |
|21 18 21|
|2 2 19|
– 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
– ABCDEFGHIJ K L M N O P Q R S T
– 20 21 22 23 24 25
– U VW X Y Z
– KEY PAY MOR EMO NEY
Hill Cipher
• PAY = |15 0 24|, P = 15
• C = (KP) mod 26 0
24
C = 17 17 5 15
21 18 21 X 0 mod 26
2 2 19 24
C= 255+0+120
315+0+504 mod 26
30+0+456
Hill Cipher
• C= 375
819 mod 26
486
C= 11 L
13 N
18 S
PAY = LNS
Polyalphabetic Substitution Ciphers
• A sequence of monoalphabetic ciphers (M 1, M2,
M3, ..., Mk) is used in turn to encrypt letters.
• A key determines which sequence of ciphers to
use.
• Each plaintext letter has multiple corresponding
ciphertext letters.
• This makes cryptanalysis harder since the letter
frequency distribution will be flatter.
22
Vigenère Cipher
• Simplest polyalphabetic substitution cipher
• Consider the set of all Caesar ciphers:
{ Ca, Cb, Cc, ..., Cz }
• Key: e.g. security
• Encrypt each letter using Cs, Ce, Cc, Cu, Cr,
Ci, Ct, Cy in turn.
• Repeat from start after Cy.
• Decryption simply works in reverse.
23
Example of Vigenère Cipher
• Keyword: deceptive
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
24
Security of Vigenère Ciphers
• There are multiple (how many?) ciphertext letters
corresponding to each plaintext letter.
• So, letter frequencies are obscured but not totally lost.
• To break Vigenere cipher:
28
Rail Fence cipher
write message letters out diagonally over a number of
rows
use a “W” pattern (not column-major)
then read off cipher row by row
eg. write message out as:
mematrhtgpry
etefeteoaat
giving ciphertext
MEMATRHTGPRYETEFETEOAAT
Row Transposition Ciphers
• Plaintext is written row by row in a rectangle.
• Ciphertext: write out the columns in an order
specified by a key.
a t t a c k p
Key: 3 4 2 1 5 6 7
o s t p o n e
d u n t i l t
Plaintext:
wo a mx y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
30
Product Ciphers
• Uses a sequence of substitutions and
transpositions
– Harder to break than just substitutions or transpositions
• This is a bridge from classical to modern ciphers.
31
Block Cipher modes of
Operation