Class
Class
Class
Private Message
Bob Alice
Eavesdropping
Eve
The Solution
Private Message Private Message
Encryption Decryption
Scrambled Message
Bob Alice
Eavesdropping
Nonsense
Eve
Classical Encryption
Techniques
• Cryptography
• Steganography
What is cryptography?
• kryptos – “hidden”
• grafo – “write”
• 1.1.Substitution ciphers
• 1.2.Permutation (or transposition) ciphers
• Also called as confusion and diffusion
method
Confusion and Diffusion(another
terminology)
plaintext ciphertext plaintext
Encryption Decryption
Key KA Key KB
Note
3.19
Eg for additive cipher
Caesar Cipher
• Aka shift cipher/additive cipher
• earliest known substitution cipher
• first attested use in military affairs
• replaces each letter by 3rd letter on
• example:
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
• What’s the key?
Caesar Cipher
• can define transformation as:
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
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
Note
Example 3.7
What is the key domain for any multiplicative cipher?
Solution
3.23
1.1.a.3.Affine Ciphers
3.24
monoalphabetic Continued
Example 3.09
The affine cipher uses a pair of keys in which the first key is
from Z26* and the second is from Z26. The size of the key
domain is
26 × 12 = 312.
Example 3.10
Use an affine cipher to encrypt the message “hello” with the key
pair (7, 2).
Monoalphabetic ciphers cont..
Example 3.11
Use the affine cipher to decrypt the message “ZEBBW” with the
key pair (7, 2) in modulus 26.
Solution
Example 3.12
The additive cipher is a special case of an affine cipher in which
k1 = 1. The multiplicative cipher is a special case of affine cipher
in3.26
which k2 = 0.
1.1.a.4.Monoalphabetic Substitution Cipher
Example 3.13
We can use the key in Figure 3.12 to encrypt the message
The ciphertext is
Cryptanalysis of Caesar Cipher
1.1.b.1.Autokey Cipher
Polyalphabetic 1.1.b.1.Autokey cipher
Example
Assume that Alice and Bob agreed to use an autokey cipher
with initial key value k1 = 12. Now Alice wants to send Bob the
message “Attack is today”. Enciphering is done character by
character.
Polyalphabetic cont…
1.1.b.2.Playfair Cipher
Figure 3.13 An example of a secret key in the Playfair cipher
Example 3.15
Let us encrypt the plaintext “hello” using the key in Figure 3.13.
1.1.b.3.Vigenère Cipher
• simplest polyalphabetic substitution cipher
is the Vigenère 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
1.1.b.3. Continued
Vigenere Cipher
Example 3.16
We can encrypt the message “She is listening” using the 6-
character keyword “PASCAL”.
1.1.b.3. Continued
Example 3.16
Let us see how we can encrypt the message “She is listening”
using the 6-character keyword “PASCAL”. The initial key stream
is (15, 0, 18, 2, 0, 11). The key stream is the repetition of this
initial key stream (as many times as needed).
1.1.b.3.Vigenere Table
1.1.b.3.Security of Vigenère Ciphers
Note
Now she has the key and can break any ciphertext encrypted
with
3.45that key.
1.1.b.5 One-Time Pad
One of the goals of cryptography is perfect secrecy. A study by Shannon has shown
that perfect secrecy can be achieved if each plaintext symbol is encrypted with a key
randomly chosen from a key domain. This idea is used in a cipher called one-time
pad, invented by Vernam.
1.1.b.5.One-Time Pad
A rotor cipher
1.2.Transposition Ciphers
• 1.2.a.Keyless transposition
– Rail fence cipher
• 1.2.b.Keyed transposition
• 1.2.c.Combination of two approach
1.2.a.1.Rail Fence cipher
Courtesy:
Andreas
Steffen
3.57
Module II
Call the plaintext stream P, the ciphertext stream C, and the key stream K.
Stream cipher
Stream Cipher
• Stream ciphers
• Rather than divide bit stream into discrete blocks, as block ciphers do, XOR
each bit of your plaintext continuous stream with a bit from a pseudo-
random sequence
• At receiver, use same symmetric key, XOR again to extract plaintext
Continued
Block cipher
3.63
Block Cipher
• Divide input bit stream into n-bit sections, encrypt only that section, no
dependency/history between sections
Courtesy:
Andreas
Steffen
• In a good block cipher, each output bit is a function of all n input bits
and all k key bits
Continued
Li = Ri-1
Ri = (Li-1 XOR F(Ri-1 ,Ki))
One DES Round
<----32 bits------> <----32 bits------>
Li-1 Ri-1
exp/perm to 48
--- 48 bits
x Ki
--- 48 bits
S-box
--- 32 bits
permutation
--- 32 bits
x
Li Ri
DES function
DES Round Structure
• uses two 32-bit L & R halves
• as for any Feistel cipher can describe as:
Li = Ri–1
Ri = Li–1 xor F(Ri–1, Ki)
• takes 32-bit R half and 48-bit subkey and:
– expands R to 48-bits using perm E
– adds to subkey
– passes through 8 S-boxes to get 32-bit result
– finally permutes this using 32-bit perm P
Substitution Boxes S
• have eight S-boxes which map 6 to 4 bits
• each S-box is actually 4 little 4 bit boxes
– outer bits 1 & 6 (row bits) select one rows
– inner bits 2-5 (col bits) are substituted
– result is 8 lots of 4 bits, or 32 bits
• row selection depends on both data & key
– feature known as autoclaving (autokeying)
• example:
S(18 09 12 3d 11 17 38 39) = 5fd25e03
DES Key Schedule
• forms subkeys used in each round
• consists of:
– initial permutation of the key (PC1) which
selects 56-bits in two 28-bit halves
– 16 stages consisting of:
• selecting 24-bits from each half
• permuting them by PC2 for use in function f,
• rotating each half separately either 1 or 2 places
depending on the key rotation schedule K
DES key generation
DES Decryption
• decrypt must unwind steps of data computation
• with Feistel design, do encryption steps again
• using subkeys in reverse order (SK16 … SK1)
• note that IP undoes final FP step of encryption
• 1st round with SK16 undoes 16th encrypt round
• 16th round with SK1 undoes 1st encrypt round
• then final FP undoes initial encryption IP
• thus recovering original data value
Key properties
• avalanche
– small change in plaintext or in key produces
significant change in ciphertext
– test for avalanche
• encrypt two plaintext blocks that differ only in one
bit
• about half the (ciphertext) bits will differ
• Completeness effect
– Each bit of the ciphertext needs to depend on
many bits in the plain text
DES controversy
• DES choice was intensely criticized:
– original LUCIFER key length was 128 bits, and
DES used 56 bit key (to fit on chip, they said)
– critics feared brute force attacks
– design criteria for the S-boxes was classified, so
users not sure that internal structure was free of
hidden weak points that might let NSA break
cipher
Cryptanalysis of DES
• increased computing speed has made a 56
bit key susceptible to exhaustive key search
• demonstrated breaks:
– 1997 – taking a few months, a large network of
computers broke DES
– 1998 – Electronic Frontier Foundation broke
DES in a few days on dedicated hardware
– 1999 – break accomplished in 22 hours
• in practice DES is used, and works
Module II
• Rijndael design:
– simplicity
– has 128/192/256 bit keys, 128 bits data J. Daemen
– resistant against known attacks
– speed and code compactness on many CPUs
The AES Cipher
• Block length is limited to 128 bit
• The key size can be independently
specified to 128, 192 or 256 bits
k3 k7 k11 k15
The AES Cipher
in2 in6 in10 in14 S20 S21 S22 S23 o2 o6 o10 o14
in3 in7 in11 in15 S30 S31 S32 S33 o3 o7 o11 o15
The AES Cipher
• Number of rounds, Nr, depends on key
size
• Each round is a repetition of functions that
perform a transformation over State array
• Consists of 4 main functions:1,2,and 3 -
permutation and substitutions,4 actual
encryption
Substitute bytes, Shift rows, Mix columns, Add round
key
The AES Cipher
• AddRoundKey() – round key is added to the
State using XOR operation
• MixColumns() – takes all the columns of the
State and mixes their data, independently of one
another, making use of arithmetic over GF(2^8)
• ShiftRows() – processes the State by cyclically
shifting the last three rows of the State by
different offsets
• SubBytes() – uses S-box to perform a byte-by-
byte substitution of State
AES functions
• simpler way to view the AES function
order is:
– 1. Scramble each byte (SubBytes).
– 2. Scramble each row (ShiftRows).
– 3. Scramble each column (MixColumns).
– 4. Encrypt (AddRoundKey).
Subbytes()
• S-Box operation on an example string of
“ABC,”
• take the hexadecimal value of each byte.
ASCII “A” == hex 0x42, “B” == 0x43 and
“C” == 0x44.
– Look up the first (left) hex digit in the S-Box
column and the second in the S-Box row.
0x42 becomes 0x2c; 0x43 becomes 0x1a,
and 0x44 becomes 0x1b.
ShiftRows()
Mix columns()
AddRoundkey()
plaintext
The AES Cipher
Shift rows
Round 1