2 Cryptographic Algorithms
2 Cryptographic Algorithms
• Symmetric
DES
• Asymmetric
RSA
Digital signatures
1) TYPES OF CRYPTOGRAPHIC
SCHEMES
a) Totally secret schemes
b) Symmetric schemes
c) Asymmetric schemes
1‐1) Totally secret schemes
• All aspects of the system are secret
Encryption/ Decryption
The key
• Stream ciphers
• Block ciphers
2‐1) Stream ciphers
• Individual characters (usually binary digits) of
a plaintext message are encrypted one at a
time using an encryption transformation
which varies with time.
• The simplest stream cipher is the one‐time
pad defined by
• Decryption is defined by
Stream ciphers – The Vigenere
• A key is repeatedly added to the plaintext in mod
26 using convention that A = 0, B = 1, ‐ ‐ ‐, Z = 25.
C = P K mod 26
For example P(15) U(20) mod 26 = J(9). So the
encryption of P under key U is J and vice versa.
Drill question:
Plaintext: vigenerescipher
Key : keykeykeykeykey
Ciphertext:
The Vigenere ‐ Cryptanalysis
• Ciphertext‐only attack, that is if the ciphertext
and the distribution of plaintext are known to
the attacker;
• The ciphertext is arranged in rows with the
same length as the key;
• Every column can be seen as encryption using
substitution process
• Decipher based on frequency in plaintext
The Vigenere ‐ Cryptanalysis
• For example, the most frequently used letter
in an English word is e as shown below:
The Vigenere ‐ Cryptanalysis
• Consider an arbitrary ciphertext for which the
frequency of letters in the first column is as
follows:
• Decryption is defined by
Stream ciphers‐ generalized form
2‐2) Block ciphers
• A block cipher cuts up a plaintext of arbitrary
length into a series of blocks having a constant
size of n bits. It then encrypts a single block of
plaintext at a time and converts it into a block
of ciphertext. In a good block cipher, each of
the n bits of the ciphertext block is a function
of all n bits of the plaintext and the k bits of
the secret key.
Block ciphers
• Block ciphers tend to simultaneously encrypt
groups of characters of a plaintext message
using a fixed encryption transformation.
• Example of a block cipher
Consider a 3‐bit input and a 3‐bit output block cipher
system shown below
Block ciphers
Plaintext, m = {m0 ,m1 ,m2 }
Ciphertext, c= {c0 c1 c2 }
c = f(kE, m); m = f‐1(kD, c).
The key is a vector that determines the
permutation.
kE = {4, 0, 7, 1, 2, 5, 3, 6}8
kD = {1, 3, 4, 6, 0, 5, 7, 2}8
BLOCK CIPHER MODES ‐ ECB
BLOCK CIPHER MODES ‐ ECB
• Electronic Code Book (ECB) block cipher mode, a
plaintext is mapped statically to a ciphertext output
block. With sufficient memory resources a lookup table
or ECB could be built linking any ciphertext block
pattern to its corresponding plaintext block.
• Block ciphers in ECB are vulnerable to block replay
attacks because an opponent (without knowing the
key) could replay an already transmitted ciphertext
block at a later time if he thinks that a block contained
e.g an encrypted money transfer
BLOCK CIPHER MODES ‐ ECB
• If a session key is kept in use sufficiently long
an attacker could also try to build a codebook
of intercepted ciphertext blocks and guessed
plaintext blocks
BLOCK CIPHER MODES ‐ CBC
BLOCK CIPHER MODES ‐ CBC
• Cipher Block Chaining (CBC) Mode is used inorder
to inhibit block replay attacks and codebook
compilation
• Modern block ciphers such as the DES are usually
in the CBC mode
• Each plaintext is XORed with the previous
ciphertext block before encryption, so that
identical plaintext blocks occuring in the same
message show up as different ciphertext blocks.
BLOCK CIPHER MODES ‐ CBC
• At the receiving side, each block coming out of
the decryption algorithm must first be XORed
with the previously received ciphertext block
in order to recover the plaintext.
• Any CBC‐encrypted message must be
initialized by an initialization vector (IV) that is
openly transmitted over the insecure channel
at the beginning of the session.
BLOCK CIPHER MODES ‐ CBC
• In order to avoid replay attacks an IV value
should be used only once and never be used
again. This can be achieved either by assigning
a monotonically increasing counter or a
random value to the IV
• Example: Use the 3‐bit block cipher in slide 20
and initialization vector (IV) of {0, 1, 1} to
encrypt the planitext message
{011011111000}
BLOCK CIPHER MODES ‐ OFB
BLOCK CIPHER MODES ‐ OFB
• A block cipher in the Output Feedback Mode
(OFB) works as a key stream generator
producing a pseudo‐random key sequence a
block at a time. By XOR‐ing the key stream
with the plaintext the block cipher actually
works as a stream cipher.
COMPARISON – STREAM vs BLOCK
• Stream ciphers usually work on a bit‐level
architecture and were traditionally in dedicated
hardware (ASICs). Single bit errors in the
ciphertext affect only a single plaintext bit and do
not propagate;
• Block ciphers usually work on a word‐level
architecture and were traditionally implemented
as software functions. Single bit errors propagate
and affect two consecutive plaintext blocks in the
CBC mode.
2‐3) PRODUCT CIPHERS
• A product cipher combines two or more
transformations in a manner intending that
the resulting cipher is more secure than the
individual components
• A substitution‐permutation (SP) network is a
product cipher composed of a network of
stages each involving substitutions and
permutations
S‐BOXES AND P‐BOXES
• Substitution boxes or (S‐boxes) perform
pairwise substitution of plaintext bits to give
ciphertext bits.
• For 2‐bit plaintext, the following S‐box and P‐
box could be proposed
S‐BOXES AND P‐BOXES
Propose S‐boxes and P‐boxes for the 8‐bit
plaintext [0 0 1 0 1 1 0 1] and find corresponding
ciphertext when
• S‐box is used
• P‐box is used
S‐BOXES
• Using plaintex as [A1 A2 B1 B2 C1 C2 D1 D2]
S‐boxes
• A possible shuffle using the S‐box could be [A3
A4 B3 B4 C3 C4 D3 D4] [1 1 0 1 0 0 1 0].
Using this S‐box, [A1 A2 B1 B2 C1 C2 D1 D2]
[A3 A4 B3 B4 C3 C4 D3 D4], the plaintext [0 0
1 0 1 1 0 1] could be shuffled to [1 1 0 1 0 0
1 0].
• The S‐boxes are in effect look‐up tables which
maps the bits from the plaintext to well‐
defined bits of the ciphertext.
P‐boxes
• The plaintext bits and ciphertext bits could be
permuted or interconnected in at least 77 =
823543 ways.
• One possible way is as follows
C xe (mod m).
Send ciphertext, C to Bob
Decryption
Compute d satisfying
e.d 1 (mod (p – 1). (q – 1)).
Compute X’ Cd (mod m)
Then X’ equals the plaintext X
RSA ‐ EXAMPLE
• Key generation
‐ Choose two secret primes
p = 1223 and q = 1987;
‐ Compute public modulus
m = p . q = 1223 x 1987 = 2430101
‐ Choose public encryption, e = 948047
such that
gcd (e, (p‐1)(q‐1)) = gcd (948047, 2426892) = 1
RSA ‐ EXAMPLE
• Encryption
‐ Choose integer, X as plaintext message,
let X = 1070777 satisfying 1 X < m;
‐ Use public key
(m, e) = (2430101, 948047) to compute
C Xe (mod m)
C 1070777948047 (mod 243010)
1473513 (mod 243010)
RSA ‐ EXAMPLE
• Decryption
‐ Bob knows (p – 1) (q – 1) = 1222. 1986
= 2426892;
‐ Bob solves ed (mod (p – 1) (q – 1))
948047.d 1 (mod 2426892)
and finds that d = 1051235
‐ Bob takes the ciphertext C = 1473513 and computes
Cd (mod m),
14735131051235 = 1070777 (mod 2430101),
The value that he computes is Alice’s message,
X = 1070777.
RSA – DRILL QUESTION
• Using the RSA algorithm, encrypt the following
a) p = 3; q = 11; e = 7; plaintext, P = 12
b) p = 7; q = 11; e = 17; plaintext, P = 25
• Find the corresponding d’s for (a) and (b) and
decrypt the ciphertexts, C
• The following table of prime numbers may
be useful
RSA – DRILL QUESTION
• TABLE OF PRIME NUMBERS < 355
RSA ‐ CRYPTANALYSIS
• The main methods used in the attacks against the
RSA cryptography are the factoring methods;
• The Number Field Sieve (NFS) method is the most
effective general‐purpose factorization method;
• The NFS is based on a method known as “Fermat
Factorization”: one tries to find integers x, y, such
that x2 ≡ y2 mod n but x ≠ ± y mod n.
RSA ‐ CRYPTANALYSIS
• In RSA theory, the two primes p and q should
be close and approximately equal to the
square root of n, one of the integers could be
written as x = (p + q)/ 2 and the number of
steps, S required to factor the integer, n could
be computed as follows
RSA ‐ CRYPTANALYSIS
• For example, to factor n = 5959, one computes
and performs trials starting from x> . For
different values of x, x2 ≡ y2 mod n are calculated.
The calculated values are as follows:
X 78 79 80
y2 128 282 441
PK (2,4) (5,9) (8,8) (10, (3,5) (7,2) (7,9) (3,6) (10, (8,3) (5,2) (2,7) O
9) 2)
s 3 9 8 2 1 4 1 2 8 9 3
yo 9 8 10 0 2 7 2 0 10 8 9 ‐ ‐
ECC – secret key exchange
EQUIVALENT CRYPTOGRAPHIC
STRENGTH
EXAMPLES
1. Tony advertised the public key n = 3599, e =
31. Unfortunately, he has become confused as
to whether his PIN (private key) is 3301, 3031, or
3013. Which is it?
• SOLUTION
3599 = 61 x 59 , so (n) = 60 x 58 = 3480.
Thus the private key is given by
31 d = 1 (mod 3480) which is true when d =
3031
EXAMPLES
2. Bob is using RSA with public key n = 4189, e = 97.
Eve has discovered that Bob’s value of is 4060.
Find the primes p, q such that n = pq and Bob’s
private key d.
• SOLUTION
Given n = 4189 and = 4060, it follows that p + q =
n ‐ + 1 = 130. Hence p and q are the roots of x2 –
130x + 4189 = 0. Using the formula we find p = 71, q
= 59. Finally
d = e‐1 (mod 4060) = 3023
EXAMPLES
3. Suppose Fiona, Georgina and Henrietta have
agreed to encrypt their text messages using the
Diffie‐Hellman system with modulus, p = 101 and
base, r = 2. They have chosen the private keys f’ =
13, g’ = 21, h’ = 30 respectively.
a) What common information will be stored in the
directory of each girl’s phone?
b) What key will be used for messages between
Georgina and Henrietta and how do they obtain it?
c) How could Fiona eavesdrop on messages
between Georgina and Henrietta?
SOLUTION – P3
a) Each directory will contain the values p = 101, r = 2, and the
public keys f, g, h computed by the rules f = 213, g = 221, h = 230
as follows
f g h
12 89 17
b) The key for communication between Georgina and
Henrietta is
kGH = 221x30 = 17
Georgina can calculate this as hg’ = 1721 and Henrietta as
gh’ = 8930
c) If Fiona wishes to discover kGH she could try to find either g’
or h’, by solving one of the equations 2x = 89, 2x = 17.
EXAMPLES
4. Four people A, B, C, D have chosen to
communicate using the Diffie‐Hellman system, with
p = 149 and r = 2. If A has chosen the private key 33,
what is her public key?
• SOLUTION
Since A’s private key is xA = 33, her public key is yA =
x
2 A = 233 (mod 149).
If necessary, this can be calculated by hand as:
22 = 4, 24 = 16, 28 = 256 = 107, 216 = 1072 = 125,
232 = 1252 = 129, 233 = 109