Hand Book: Ahmedabad Institute of Technology
Hand Book: Ahmedabad Institute of Technology
1.
IT Department
Hand Book
Cryptography and Network
security (3161609)
Year: 2020-2021
Symmetric encryption
Asymmetric encryption
• Used to conceal small blocks of data, such as encryption keys and hash
function values, which are used in digital signatures
Authentication protocols
measures to deter,
prevent, detect, and
correct security
violations that involve
the transmission of
information
Computer Security
• The NIST Computer Security Handbook defines the
term computer security as:
Integrity
• Data integrity
• Assures that information and programs are changed only in a specified and
authorized manner
• System integrity
• Assures that a system performs its intended function in an unimpaired manner,
free from deliberate or inadvertent unauthorized manipulation of the system
Availability
• Assures that systems work promptly and service is not denied to authorized
users
CIA Triad
Possible additional concepts:
Authenticity Accountability
• Verifying that users • The security goal that
are who they say they generates the
are and that each requirement for
input arriving at the actions of an entity to
system came from a be traced uniquely to
trusted source that entity
Breach of Security
Levels of Impact
• The loss could be expected to have a severe or
High catastrophic adverse effect on organizational
operations, organizational assets, or individuals
• Security mechanism
• A process (or a device incorporating such a process) that is
designed to detect, prevent, or recover from a security
attack
• Security service
• A processing or communication service that enhances the
security of the data processing systems and the information
transfers of an organization
• Intended to counter security attacks, and they make use of
one or more security mechanisms to provide the service
Table 1.1
Threats and Attacks (RFC 4949)
Security Attacks
•A means of classifying security
attacks, used both in X.800 and
RFC 4949, is in terms of passive
attacks and active attacks
• Authentication
• Access control
• Data confidentiality
• Data integrity
• Nonrepudiation
Authentication
• Concerned with assuring that a communication is
authentic
• In the case of a single message, assures the recipient
that the message is from the source that it claims to
be from
• In the case of ongoing interaction, assures the two
entities are authentic and that the connection is not
interfered with in such a way that a third party can
masquerade as one of the two legitimate parties
Security
Services
(X.800)
Security
Mechanisms
(X.800)
(4-5) mod 8 = 7
(5 7) mod 8 = 3
(3/7) mod 8 = 5
(5*5) mod 8 = 1
Modular Arithmetic Properties
Homework
Determine 128107 mod 187
Group
Group: A set of elements that is closed with respect to
some operation.
Closed The result of the operation is also in the set
The operation obeys:
Obeys associative law:(a.b).c = a.(b.c)
Has identity e: e.a = a.e = a
Has inverses a-1: a.a-1 = e
Abelian Group: The operation is commutative
a.b = b.a
Example: Z8, + modular addition, identity =0
Cyclic Group
Symmetric Cipher
Model
Prof. Dhaval Khatri
Cryptographic techniques
Cryptography and
Cryptanalysis?...
Cryptography(Secret Writing) is the process of
protecting information by transforming it into a secure
(unreadable) format.
Hello Cryptography $!Ins
Sender Recipient
Security -related Info. Security -related
Message
Message
Message
Message
Transformation Channel Transformation
Secure
Secure
Secret Secret
Information Opponent Information
(Attacker)
Encryption and Decryption
In cryptography, the
encryption/decryption algorithms are
public; the keys are secret.
Requirements and Assumptions
Requirements for secure use of symmetric encryption:
1. Strong encryption algorithm: Given the algorithm and
cipher text, an attacker cannot obtain key or plaintext.
2. Shared secret keys: sender and receiver both have
shared a secret key; no-one else knows the key(keep it
secret).
Assumptions:
Cipher is known
Secure channel to distribute keys
Cryptanalysis and Brute-Force
Attack
Objective of attacker: recover key (not just message)
Approaches of attacker:
Cryptanalysis: This type of attack exploits the
characteristics of the algorithm to attempt to derive a
specific plaintext or to derive the key being used.
Brute-force attack: The attacker tries every possible key
on a piece of ciphertext until an intelligible translation into
plaintext is obtained.
On average, half of all possible keys must be tried to
achieve success.
Attacks on Encrypted
Mess
Type of Attack ages
Known to cryptanalyst
Ciphertext Only Encryption algorithm, Ciphertext
Attacks on Encrypted
Mess
Type of Attack ages
Known to cryptanalyst
Known Plaintext Encryption algorithm, Ciphertext, One or more plaintext-
cipher text pairs formed with the secret key
Attacks on Encrypted
Mess
Type of Attack ages
Known to cryptanalyst
Chosen Plaintext Encryption algorithm, Ciphertext, Plaintext message chosen by
cryptanalyst
Attacks on Encrypted
Mess
Type of Attack ages
Known to cryptanalyst
Chosen Encryption algorithm, Ciphertext, Ciphertext chosen by
Ciphertext cryptanalyst, with its corresponding decrypted plaintext
generated with the secret key
Attacks on Encrypted
Mess
Type of Attack ages
Known to cryptanalyst
Chosen text Encryption algorithm, Ciphertext, Plaintext chosen by
cryptanalyst, with its corresponding ciphertext generated with
the secret key , Ciphertext chosen by cryptanalyst, with its
corresponding decrypted plaintext generated with the secret
key
How does it work?
7
Example
encoder function is next letter in thealphabet
decoder function is …
“buubdl bu njeojhiu” -
ciphertext
Encoding the contents of the message (the plaintext) in such a
way that hides its contents from outsiders is called encryption.
The process of retrieving the plaintext from the cipher-text is
called decryption.
Encryption and decryption usually make use of a key, and the
coding method is such that decryption can be performed only by
knowing the proper key.
The Encryption Process
Aim: to hide a message content by making it unreadable
Key
Ciphertext
:
Scrambling
Plaintext unreadable
data
version
Encryption and Decryption
The encryption and decryption functions take a key as an
additional input.
1
1
Classification of Cryptography
Based on the factors
• Diffie-Hellman
• RSA
• El Gamal
• Elliptic Curve
Cryptography
• Caesar cipher
• Rail-Fence
Technique • Monoalphabetic
•Columnar Cipher
Transition • Playfair cipher
• Polyalphabetic cipher
Technique
• Hill Cipher
• One Time Pad
Symmetric Cryptosystems
SECRET KEY, SINGLE KEY, PRIVATE KEY
1
2
Symmetric-key cryptography
Symmetric Encryption
Shared Key
Encryption
Decryption
Algorithm
Algorithm
1. Agree on a
PASSWORD
Shared Key IS GREEN!
2. Encrypt using
Shared Key
CJG5%jARGONS8 CJG5%jARGONS8*
* %K23##hsgdfey9
%K23##hsgdfey 826.
9 826. 3. Email file
4. Decrypt using
Shared Key
PASSWORD
IS GREEN!
1
8
Emailing an encrypted message
1. Agree on a
CREDIT CARD
Shared Key CODE IS 5206
2. Encrypt using
Shared Key
CJG5%jARGONS8 CJG5%jARGONS8
* *
%K23##hsgdfey
%K23##hsgdfey
9 826. 3. Email file 9 826.
4. Decrypt using
Shared Key
CREDIT CARD
CODE IS 5206 2
0
Symmetric Encryption
Private Key Encryption
In Private key encryption data is encrypted
using a single same key that only the sender
and the receiver know.
C = E(3, P) = (P + 3) mod 26
P = D(3, C) = (C - 3) mod 26
Caesar Cipher (Cont…)
Let us assign a numerical equivalent to each letter
a b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y z
13 14 15 16 17 18 19 20 21 22 23 24 25
C = E(3, P) = (P + 3) mod 26
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:
Plaintext: THE SMART BROWN FOX
Ciphertext: WKH UOCTV EURZQ IRA
Caesar Cipher (Cont…)
Generalised Caesar Cipher
Allow shift by k positions.
Encryption : C = E(K, P) = (P + K) mod 26
Decryption :
P = D(K, C) = (C - K) mod 26
Example:
Cipher: prjrydohynxeml
Plaintext: monoalphabetic
Try Brute force attack :
With 26 letters in alphabet, the possible permutations are 26! Keys
(>4x1026)
Attack on Monoalphabetic Cipher
The relative frequencies of the letters in the ciphertext (in %) are
Ciphertext:
uzqsovuohxmopvgpozpevsgzwszopfpesxudbmetsxaizvuephzhmdzshz
owsfpappdtsvpquzwymxuzuhsxepyepopdzszufpombzwpfupzhmdjudtm
ohmq
In our ciphertext, the most common digram is ZW, which appears
three times. So equate Z with t, W with h and P with e.
Now notice that the sequence ZWP appears in the ciphertext, and
we can translate that sequence as “the.”
Attack on Monoalphabetic Cipher
(Cont…)
If the cryptanalyst knows the nature of the
plaintext, then the analyst can exploit the
regularities of the language.
The relative frequency of the letters can be
determined and compared to a standard frequency
distribution for English.
If the message were long enough, this technique
alone might be sufficient, but because this is a
relatively short message, we cannot expect an
exact match.
Substitution Techniques
1. Caesar Cipher
2. Monoalphabetic Cipher
3. Playfair Cipher
4. Hill Cipher
5. Polyalphabetic Ciphers
6. One-Time Pad
3. Playfair Cipher
The Playfair algorithm is based on a 5 × 5 matrix (key) of
letters.
The matrix is constructed by filling in the letters of the
keyword (minus duplicates) from left to right and from top
to bottom, and then filling in the remainder of the matrix with
the remaining letters in alphabetic order. The letters I and J
count as one letter. O C U R E
Example:
N A B D F
Keyword= OCCURRENCE
Plaintext= TALL TREES G H I/J K L
M P Q S T
V W X Y Z
Playfair Cipher - Encrypt Plaintext
Operate on pair of letters (digram) at a time.
Special: if digram with same letters appears, separate by
special letter (e.g. x)
Plaintext= TALL TREES
Plaintext= TA LX LT RE ES
If the letters appear on the same column, replace them with the
letters immediately below, wrapping around to the top if
necessary.
For example, using the table above, the letter pair LT would be
encoded as TZ.
Playfair Cipher - Encrypt Plaintext
Map each pair in key matrix
O C U R E
Plaintext: TA LX LT RE ES
Ciphertext: PF IZ TZ EO RT N A B D F
G H I/J K L
M P Q S T
V W X Y Z
If the letters are on different rows and columns, replace them with
the letters on other corner of the same row.
The order is important - the first letter of the pair should be
replaced first.
For example, using the table above, the letter pair TA would be
encoded as PF.
Playfair Cipher - Is it
Breakable?
Better than monoalphabetic: relative frequency of
digrams much less than of individual letters.
But relatively easy (digrams, trigrams, expected
words)
Playfair Cipher Examples
1. Key= “engineering ” Plaintext= “test this process ”
2. Key= “keyword ” Plaintext= “come to the window”
3. Key= “moonmission ” Plaintext= “greet ”
C=PK mod 26
Ciphertext = “ELSC”
Hill Cipher Decryption
P=CK-1 mod 26
3 X 3 inverse of matrix
Step 1: Inverse of key matrix
-11 mod 26 = 15
Because, modulo for negative
number is = N- (B%N)
= 26 – (11%26)
Step 2: Modular
(Multiplicative) inverse
The inverse of a number A is 1/A since A * 1/A = 1
e.g. the inverse of 5 is 1/5
In modular arithmetic we do not have a division operation.
The modular inverse of A (mod C) is A-1
(A * A-1) ≡ 1 (mod C)
Example:
The modular inverse of A mod C is the B value that makes
A * A-1 mod C = 1
A = 3, C = 11
Since (3*4) mod 11 = 1, 4 is modulo inverse of 3
A = 10, C = 17 , A-1 = 12
Step 2: Modular (Multiplicative)
inverse
Determinants’ multiplicative inverse Modulo 26
Determinant 1 3 5 7 9 11 15 17 19 21 23 25
Inverse Modulo 26 1 9 21 15 3 19 7 23 11 5 17 25
Step 2: Multiply with adjoin of matrix
X%Y = X-(X/Y)*Y
77%26 = 77-(77/26)*26
= 77-(2)*26
= 77-52
= 25
Hill Cipher Encryption (Cont…)
P=CK-1 mod 26
Plaintext = “EXAM”
Hill Cipher Examples
1. Key: Hill Plaintext: short example
Ciphertext:
2. Key: ACBA Plaintext: DR GREER
ROCKS (A=1, B=2, … )
Ciphertext:
3. Key:DACB Ciphertext: SAKNOXAOJ
(A=1,B=2,…)
Plaintext:
Substitution Techniques
1. Caesar Cipher
2. Monoalphabetic Cipher
3. Playfair Cipher
4. Hill Cipher
5. Polyalphabetic Ciphers
6. One-Time Pad
5. Polyalphabetic Cipher
Monoalphabetic cipher encoded using only
one fixed alphabet
Polyalphabetic cipher is a substitution
cipher in which the cipher alphabet for the
plain alphabet may be different at different
places during the encryption process.
1. Vigenere cipher
2. Vernam cipher
Plaintext
K
e
y
PT = HELLO
KEY = GMGMG
CT = NQRXU
Vigenere Cipher
Keyword : DECEPTIVE Key must be as
Key : DECEPTIVEDECEPTIVEDECEPTIVE long as plaintext
else repeat a
Plaintext : WEAREDISCOVEREDSAVEYOURSELF keyword
Ciphertext : ZICVTWQNGRZGVTWAVZHCQYGLMGJ
An analyst looking at only the ciphertext would detect the repeated sequences
VTW at a displacement of 9 and make the assumption that the keyword is
either three or nine letters in length.
The material on the selected sheet is the key for this message. Each letter from
the pad will be combined in a predetermined way with one letter of the
message. (It is common, but not required, to assign each letter a numerical
value, e.g., "A" is 0, "B" is 1, and so on.)
In this example, the technique is to combine the key and the messageusing
modular addition. The numerical values of corresponding message and key
letters are added together, modulo 26. So, if key material begins with
"XMCKL" and the message is "HELLO", then the coding would be done as
follows:
ONE TIME PAD ENCRYPTION
H E L L O message
= 30 16 13 21 25 message + key
E Q N V Z → ciphertext
ONE TIME PAD ENCRYPTION
E Q N V Z ciphertext
H E L L O → message
Transposition Techniques
A transposition cipher does not substitute one symbol for
another, instead it changes the location of the symbols.
The simplest such cipher is the rail fence technique, in
which the plaintext is written down as a sequence of
diagonals and then read off as a sequence of rows.
For example, to send the message “Meet me at the park”
to Bob, Alice writes
M E M A T E A K
E T E T H P R
I R I N T S I
N O M T O A D E W K E R T
F A N N O U Y
Rows/Columns Transposition
Plaintextletters written in rows.
Ciphertext obtained by reading column-by-column, but re-
arranged.
Key determines order of columns to read.
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: TTNA APTM TSUO AODW COIX KNLY PETZ
Rows/Columns Transposition
Transposition ciphers can be made stronger by using
multiple stages of transposition
Plaintext: securityandcryptography
Key: 315624
Ciphertext:
Transpose again using same key:
Ciphertext:
EYYARDOYSTRRICGCAPPUNTH
YYCURRAHEOIPDRPYSGNATCT
Cryptographic Algorithms
Cryptographic algorithms and protocols can be grouped into four
main areas
Cryptographic
algorithms and
protocols
Cryptographic
algorithms and
protocols
Cryptographic
algorithms and
protocols
Cryptographic
algorithms and
protocols
C=PK mod 26
17 17 5
21 18 21
2 2 19
Encryption:
17 17 5
15 0 24 21 18 21
2 2 19
255 0 48 303
= 255 0 48 = 303 take mod 26.
75 0 456 531
C = ( 17 17 11) ( R R L)
17 17 5
12 14 17 21 18 21
2 2 19
C = ( 12 22 1) ( M W B)
17 17 5
4 12 14 21 18 21
2 2 19
68 252 28 348
= 68 216 28 = 312 take mod 26.
20 252 266 538
C = ( 10 0 18) ( K A S)
17 17 5
13 4 24 21 18 21
2 2 19
221 84 48 353
= 221 72 48 = 341 take mod 26.
65 84 456 605
C = ( 15 3 7) ( P D H)
DECRYPTION:
Calculating K-1:
adj $k&
| |
Formula ; K-1 =
17 17 5
K = 21 18 21
2 2 19
|K| ( 939.
26 1 0 R1
1 23 0 1 R2
7 3 +1 -1
1 2 -7 8
1 8 -9
26 * 8 + 23 (-9) =1
So x ≡ -9 mod 26
So
23 17
6
|5 |
K12 = 921 21
: $399 ( 42& 357
2 19
= 921 18
: $42 ( 36& 6
2 2
K
13
= 917 5
: $323 ( 10& 313
2 19
K
21
K22 = 917 5
: $323 ( 10& 313
2 19
K23 = 917 17
: $34 ( 34& 0
2 2
K31 = 917 5
: $357 ( 90& 267
18 21
K32 = 917 5
: $357 ( 105& 252
21 21
K33 = 917 17
: $306 ( 357& (51
21 18
300 (357 6
$co factor& (313 313 0
267 (252 (51
300 (313 267
$co factor& (357
>
313 (252
6 0 (51
Adj (k) = (cofactor) T
300 (313 267
?@ $ & (357 313 (252
6 0 (51
K 6 = | | adj (K)
5
300 (313 267
K 6
17 (357 313 (252
6 0 (51
300 17 (313 17 267 17
(357 17 313 17 (252 17
6 17 0 17 (51 17
5100 (5321 4539
(6069 5321 (4284
102 0 (867
4 (17 15
K 6
(11 17 (20
24 0 (9
To remove negative (-) value take “mod 26” for each value.
4 9 15
K 6
15 17 6
24 0 17
This is demonstrated as follows:
17 17 15 4 9 15
K K 6
21 18 21 15 17 6
2 2 19 24 0 17
68 255 120 84 270 504 8 30 456
153 289 0 189 306 0 18 34 0
255 102 85 315 108 357 30 12 323
443 858 494
442 495 52 mod 26
442 780 365
1 0 0
0 1 0
0 0 1
(unit matrix)
P = K 6 C mod 26
4 9 15 11
P 15 17 6 C13D
24 0 17 18
4 9 15 7
P 15 17 6 C 3 D
24 0 17 11
28 27 165 220
P 105 51 66 222 mod 26
168 0 187 355
P $12 14 17& E mor
4 9 15 4
P 15 17 6 C22D
24 0 17 12
4 9 15 19
P 15 17 6 F17G
24 0 17 22
76 153 330 559
P 285 289 132 706 mod 26
456 0 374 830
P $13 4 24& E ney
15 0 24
PI 12 14 17 J pay mor emo ney
4 12 14
13 4 24
*******
Symmetric key cryptographic algorithms
Examples:
Autokeyed Vigenère cipher
A5/1
RC4
Vernam cipher.
Stream Cipher
Bit-stream Bit-stream
Key(ki) Key(ki)
Generation Generation
010101 010101
algorithm algorithm
Ki Ki
Plaintext(pi) Ciphertext(ci) Plaintext(pi)
100101 110000 100101
ENCRYPTION DECRYPTION
Block Cipher
A block cipher is one in which a block of plaintext is
treated as a whole and used to produce a ciphertext block
of equal length.
Typically, a block size of 64 or 128 bits is used.
Examples:
Feistel cipher
DES
Triple DES
AES
Block Cipher Schemes
There is a vast number of block ciphers schemes that are in use. Many of them are
publically known. Most popular and prominent block ciphers are listed below.
Digital Encryption Standard (DES) − The popular block cipher of the 1990s. It is now
considered as a ‘broken’ block cipher, due primarily to its small key size.
Triple DES − It is a variant scheme based on repeated DES applications. It is still a
respected block ciphers but inefficient compared to the new faster block ciphers available.
Advanced Encryption Standard (AES) − It is a relatively new block cipher based on
the encryption algorithm Rijndael that won the AES design competition.
IDEA − It is a sufficiently strong block cipher with a block size of 64 and a key size of 128
bits. A number of applications use IDEA encryption, including early versions of Pretty
Good Privacy (PGP) protocol. The use of IDEA scheme has a restricted adoption due to
patent issues.
Twofish − This scheme of block cipher uses block size of 128 bits and a key of variable
length. It was one of the AES finalists. It is based on the earlier block cipher Blowfish with
a block size of 64 bits.
Serpent − A block cipher with a block size of 128 bits and key lengths of 128, 192, or
256 bits, which was also an AES competition finalist. It is a slower but has more secure
design than other block cipher.
Block Cipher
b bits b bits
Plaintext Ciphertext
Ciphertext Plaintext
b bits b bits
Stream cipher and Block
Cipher
Both Block and Stream cipher are the methods of
Encryptions which are primarily used for
converting the plain text into cipher text directly
and belong to the family of symmetric key
ciphers.
Ln+1 Rn+1
Li = R i – 1
On Decryption Side:
Symmetric Cryptosystems
Data Encryption Standard (DES)
Developed in the 1970s; made a standard by the US government, was
widely used in the financial industry until 2004.
DES is a Feistel cipher
• 64 bit block length
• 56 bit key length
• 16 rounds
• 48 bits of key used each round (subkey)
• Each round is simple (for a block cipher)
• Security depends primarily on “S-boxes”
• Each S-boxes maps 6 bits to 4 bits
64-bit plaintext 64-bit key
K16 48 56
Round 16 Permuted choice 2 Left circular shift
X
Encryption
64 K1
Round 1
DES 56 Ki
64 Encryption K16
Y Round 16
Final permutation
Y
DES Single Round
32- bits 32-bits 28-bits 28-bits
Substitution/choice
(S-box)
32
Permutation
(P)
32
XOR
DES Encryption Algorithm
1. Initial permutation: First, the 64-bit plaintext passes
through an initial permutation (IP) that rearranges the
bits to produce the permuted input.
2. The F function: This phase consisting of sixteen
rounds of the same function, which involves both
permutation and substitution functions.
3. Swap: L and R swapped again at the end of the cipher,
i.e., after round 16 followed by a final permutation.
4. Inverse (Final) permutation: It is the inverse of the
initial permutation.
5. Subkey generation: For each of the sixteen rounds, a
different subkey (Ki) derived from main key by the
combination of a left circular shift and a permutation.
Initial and Inverse Permutation
1 2 25 40 58 64
The initial permutation
of the DES algorithm
changes the order of
the plaintext prior to
the first round of 1 2 8 25 40 58 64
encryption.
The final permutation 16 Rounds
occurs after the sixteen 1 2 25 40 58 64
rounds of DES are
completed. It is the
inverse of the initial
permutation.
1 2 8 25 40 58 64
Initial and Final Permutation
IP IP-1
58 50 42 34 26 18 10 2 40 8 48 16 56 24 64 32
60 52 44 36 28 20 12 4 39 7 47 15 55 23 63 31
62 54 46 38 30 22 14 6 38 6 46 14 54 22 62 30
64 56 48 40 32 24 16 8 37 5 45 13 53 21 61 29
57 49 41 33 25 17 9 1 36 4 44 12 52 20 60 28
59 51 43 35 27 19 11 3 35 3 43 11 51 19 59 27
61 53 45 37 29 21 13 5 34 2 42 10 50 18 58 26
63 55 47 39 31 23 15 7 33 1 41 9 49 17 57 25
The F function Ri-1
32
Main operation of DES Expansion/permutation
f-function inputs: (E table)
Ri-1 and round key ki 48
Ki
XOR
4 Steps: 48
1. Expansion E 48
2. XOR with round key
6 6 6 6 6 6 6 6
3. S-box substitution
S1 S2 S3 S4 S5 S6 S7 S8
4. Permutation
4 4 4 4 4 4 4 4
32
Permutation
(P)
32
1. The Expansion Function E
Main purpose: Increases diffusion Ri-1
Since Ri-1 is a 32-bit input and Ki is a 32
48-bit key, we first need to expand Expansion/permutation
Ri-1 to 48 bits. (E table)
Input: (8 blocks, each of them 48
consisting 4 bits) - 32 bits
Output: (8 blocks, each of them Expansion Table E
consisting 6 bits) – 48 bits 32 1 2 3 4 5
4 5 6 7 8 9
8 9 10 11 12 13
12 13 14 15 16 17
16 17 18 19 20 21
20 21 22 23 24 25
24 25 26 27 28 29
28 29 30 31 32 1
2. Add round key
XOR Round Key Ri-1
After the expansion permutation, 32
DES uses the XOR operation on
the expanded right section and the Expansion/permutation
round key. (E table)
48
Note that both the right section
Ki
and the key are 48-bits in length XOR
48
now.
48
3. The DES S-Boxes
S-Box substitution. Ri-1
Eight substitution tables. 32
32
Role of S-box
The outer two bits of each group select one row of an S-box.
Inner four bits selects one column of an S-box.
S-box 1
Example:
0 1 1 0 0 1 1 0 0 1
Input Output
Row Column
4. The Permutation P
Ri-1
Permutation P 32
32
Permutation
(P)
32
Key schedule of DES
Derives 16 round keys (or K
subkeys) ki of 48 bits each from 64
28 28
56 C1 D1
Round 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
key 1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1
Key schedule of DES
In each round i permuted choice K
PC-2 selects a permuted subset of 64
48 bits of Ci and Di as round key PC-1
ki. 56
C0 D0
Permuted choice (PC-2) 28 28
Transform 1
14 17 11 24 01 05 03 28 LS1 LS1
15 06 21 10 23 19 12 04
28 28
26 08 16 07 27 20 13 02
K1 PC-2 C1 D1
41 52 31 37 47 55 30 40 48 56
51 45 33 48 44 49 39 56
34 53 46 42 50 36 29 32
SUBkey generation K
64
PC-1
56
C0 D0
28 28
Transform 1
LS1 LS1
28 28
K1 PC-2 C1 D1
48 56
28 28
LS2 LS2
LS16 LS16
28 28
K16 PC-2 C16 D16
48 56
Avalanche Effect
Desirable property of any encryption algorithm is that a change in one bit of the plaintext or of
the key should produce a change in many bits of cipher text.
DES performs strong avalanche effect.
Although the two plaintext blocks differ only in the rightmost bit, the ciphertext blocks differ in
29 bits.
This means that changing approximately 1.5 % of the plaintext creates a change of
approximately 45 % in the ciphertext.
Strength of DES
The use of 56-bit keys: 56-bit key is used in
encryption, there are 256 possible keys. A bruteforce
attack on such number of keys is impractical.
Plaintext
Ciphertext
128 bits
AES (Advanced Encryption
128 bits Plaintext
Standard) AES
AddRoundKey Cipher key
K0 (128, 192 or 256 bits)
Round-1
K1
Key expansion
Round-2
K2
Round-N
(slightly different) K10
AddRoundKey
Notes:
SubBytes 1. One AddRoundKey is applied
before the First round.
Round 1
ShiftRows 2. The third transformation is
missing in the last round
MixColumns
AddRoundKey
SubBytes
Round 10
ShiftRows
32 88 31 e0 2b 28 ab 09 19 a0 9a e9
43 5a 31 37 7e ae f7 cf 3d f4 c6 f8
f6 30 98 07 15 d2 15 4f = e3 e2 8d 48
a8 8d a2 34 16 a6 88 3c be 2b 2a 08
SubByte Transformation
The forward substitute byte transformation, called
SubBytes, is a simple table lookup
Input: 19 Output: D4
Row Column
SubByte output
Input for SubByte Output of SubByte
19 a0 9a e9 d4 e0 b8 le
3d f4 c6 f8 27 bf b4 41
e3 e2 8d 48 11 98 5d 52
be 2b 2a 08 ae f1 e5 30
ShiftRows
The first row of State is not altered.
For the second row, a 1-byte circular left shift is performed.
For the third row, a 2-byte circular left shift is performed.
For the fourth row, a 3-byte circular left shift is performed.
d4 e0 b8 le No rotation d4 e0 b8 le
27 bf b4 41 Rotate 1 byte bf b4 41 27
11 98 5d 52 Rotate 2 bytes 5d 52 11 98
ae f1 e5 30 Rotate 3 bytes 30 ae f1 e5
Input for ShiftRows Output of ShiftRows
MixColumns
Each byte of a column is mapped into a new value that is a
function of all four bytes in that column.
Constant matrices used by MixColumns.
MixColumns
d4 e0 b8 le 02 03 01 01 04 e0 48 28
bf b4 41 27
5d 52 11 98
01
01
02
01
03
02
01
03
= 66 cb f8 06
81 19 d3 26
30 ae f1 e5 03 01 01 02 e5 9a 7a 4c
02 03 01 01 d4 04
01 02 03 01 bf 66
01 01 02 03 5d = 81
03 01 01 02 30 e5
AddRoundKey
In the forward add round key transformation, the 128 bits
of State are bitwise XORed with the 128 bits of the round
key.
04 e0 48 28 a0 88 23 2a A4 68 6b 02
66 cb f8 06 fa 54 a3 6c 9c 9f 5b 6a
81 19 d3 26 fe 2c 39 76
= 7f 35 Ea 50
e5 9a 7a 4c 17 b1 39 05 F2 2b 43 49
04 a0 A4
66 fa 9c
81 fe = 7f
e5 17 F2
AES Overall Structure
AES key expansion
Words for each round
Round Words
Pre-round W0 W1 W2 W3
Round 1 W4 W5 W6 W7
Round 2 W8 W9 W10 W11
... ...
Round N W40 W41 W42 W43
AES key expansion
K0 K4 K8 K12 The AES key expansion algorithm
K1 K5 K9 K13 takes as input a four-word (16-byte)
K2 K6 K10 K14
key and produces a linear array of 44
K3 K7 K11 K15
words (176 bytes).
V1 V2 V3 V0
Rcon Table
1 2 3 4 5 6 7 8 9 10 S S S S
01 02 04 08 10 20 40 80 1b 36
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
RC[i]
00 00 00 00 00 00 00 00 00 00
32
Key Expansion Example
Introduction to Cryptography
Safe with a strong lock, only Alice and Bob have a copy of the key
• Alice encrypts: locks message in the safe with her key
• Bob decrypts: uses his copy of the key to open the safe
Public-Key Cryptosystems
It is used two keys for encryption and for
decryption.
– a public-key, which may be known by
anybody, and can be used to encrypt messages
– a private-key, known only to the recipient,
used to decrypt messages
• It has six ingredient
1 Plain text
2 Encryption algorithm
3 Public and private keys
4 Ciphertext
5 Decryption algorithm
Public-Key Cryptosystems
• public-key/two-key/asymmetric cryptography
involves the use of two keys:
- a public-key, which may be known by anybody, and
can be used to encrypt messages, and verify signatures
• is asymmetric because
those who encrypt messages or verify signatures cannot
decrypt messages or create signatures
A Asymmetric Key Encryption with Public Key
The entire encrypted message
Bob’s
Public serves as a confidentiality.
Joy key ring
Ted
Mike Alice
Transmitted
X cipher text X
Y = E(PUa, X)
Plaintext Plaintext
input Encryption Algorithm Decryption Algorithm
output
(e.g. RSA)
Bob Alice
Asymmetric Key Encryption with Private Key
The entire encrypted message Alice’s
serves as a digital signature. Public
Joy key ring
Ted
Mike Bob
Transmitted
X cipher text X
Y = E(PRb, X)
Plaintext Plaintext
input Encryption Algorithm Decryption Algorithm
output
(e.g. RSA)
Bob Alice
Asymmetric Key Encryption
example New Idea:
Use the good old mailbox principle:
Public Key
Private Key
Why Public-Key Cryptography?
Developed to address two key issues:
key distribution – how to have secure
communications in general without having to
trust a KDC with your key
No need for secure key delivery
No one else needs to know your private key
digital signatures – how to verify a message
comes intact from the claimed sender
Public-Key Characteristics
Public-Key algorithms rely on two keys with the
characteristics that it is:
- computationally infeasible to find decryption
key knowing only algorithm & encryption
key
PUb PRb
Key pair
PRa PUa source
Key pair
source
C1 C2 CN
64-bit 64-bit 64-bit
K K K
Decrypt Decrypt … Decrypt
𝐶𝑗 = 𝐸(𝐾, 𝑃𝑗 ) 𝑗 = 1, . . , 𝑁
𝑃𝑗 = 𝐷(𝐾, 𝐶𝑗 ) 𝑗 = 1, . . , 𝑁
Electronic Code Book (ECB) (cont…)
• ECB Advantages:
– No block synchronization between sender and receiver is required.
OK if some blocks are lost in transit.
– Bit errors caused by noisy channels only affect the corresponding
block but not succeeding blocks.
– Block cipher operating can be parallelized.
• ECB Disadvantages:
– Identical plaintexts result in identical ciphertexts.
– An attacker recognizes if the same message has been sent twice
simply by looking at the ciphertext.
– Plaintext blocks are encrypted independently of previous blocks.
An attacker may reorder ciphertext blocks which results in valid
plaintext.
Substitution Attack on ECB
• Consider an electronic bank transfer
1 2 3 4 5
Sending Sending Receiving Receiving Amount
Bank A Account # Bank B Account # $
C1 C2 CN
C1 C2 CN
K K K
Decrypt Decrypt … Decrypt
IV CN-1
P1 P2 PN
Cipher Block Chaining (CBC) (cont…)
𝐶1 = 𝐸(𝐾, (𝑃1 ⊕ 𝐼𝑉)
𝑃1 = 𝐷(𝐾, 𝐶1 ) ⊕ 𝐼𝑉
Select Discard
s bits b-s bits
Select Discard
s bits b-s bits
… Select Discard
s bits b-s bits
S bits S bits S bits
P1 P2 PN
C1 C2 CN
S bits S bits S bits
CFB Encryption (cont…)
𝐼1 = 𝐼𝑉
𝐼𝑗 = 𝐿𝑆𝐵𝑏−𝑠 (𝐼𝑗−1 )||𝐶𝑗−1 𝑗 = 2, . . , 𝑁
𝑂𝑗 = 𝐸(𝐾, 𝐼𝑗 ) 𝑗 = 1, . . , 𝑁
𝐶𝑗 = 𝑃𝑗 ⊕ 𝑀𝑆𝐵𝑠 (𝑂𝑗 ) 𝑗 = 1, . . , 𝑁
CFB Decryption
CN-1
Shift register Shift register
IV b-s bits | s bits b-s bits | s bits
K K K
Encrypt Encrypt Encrypt
Select Discard
s bits b-s bits
Select Discard
s bits b-s bits
… Select Discard
s bits b-s bits
C1 C2 CN
S bits S bits S bits
P1 P2 PN
S bits S bits S bits
CFB Decryption (Cont…)
𝐼1 = 𝐼𝑉
𝐼𝑗 = 𝐿𝑆𝐵𝑏−𝑠 (𝐼𝑗−1 )||𝐶𝑗−1 𝑗 = 2, . . , 𝑁
𝑂𝑗 = 𝐸(𝐾, 𝐼𝑗 ) 𝑗 = 1, . . , 𝑁
𝑃𝑗 = 𝐶𝑗 ⊕ 𝑀𝑆𝐵𝑠 (𝑂𝑗 ) 𝑗 = 1, . . , 𝑁
Cipher Feedback Mode (CFB) (cont…)
• The input to the encryption function is a b-bit shift register
that is initially set to some initialization vector (IV).
• The leftmost (most significant) s bits of the output of the
encryption function are XORed with the first segment of
plaintext P1 to produce the first unit of ciphertext C1 ,
which is then transmitted.
• In addition, the contents of the shift register are shifted
left by s bits, and C1 is placed in the rightmost (least
significant) s bits of the shift register.
• For decryption, the same scheme is used, except that the
received ciphertext unit is XORed with the output of the
encryption function to produce the plaintext unit.
4. OFB Encryption
Nonce
K K K
Encrypt Encrypt … Encrypt
P1 P2 PN
C1 C2 CN
𝐼1 = 𝑁𝑜𝑛𝑐𝑒
𝐼𝑗 = 𝑂𝑗−1 𝑗 = 2, . . , 𝑁
𝑂𝑗 = 𝐸(𝐾, 𝐼𝑗 ) 𝑗 = 1, . . , 𝑁
𝐶𝑗 = 𝑃𝑗 ⊕ 𝑂𝑗 𝑗 = 1, . . , 𝑁 − 1
OFB Decryption
Nonce
K K K
Encrypt Encrypt … Encrypt
C1 C2 CN
P1 P2 PN
𝐼1 = 𝑁𝑜𝑛𝑐𝑒
𝐼𝑗 = 𝑂𝑗−1 𝑗 = 2, . . , 𝑁
𝑂𝑗 = 𝐸(𝐾, 𝐼𝑗 ) 𝑗 = 1, . . , 𝑁
𝑃𝑗 = 𝐶𝑗 ⊕ 𝑂𝑗 𝑗 = 1, . . , 𝑁 − 1
Output Feedback Mode(OFB) (cont..)
• The output feedback (OFB) mode is similar in
structure to that of CFB.
• For OFB, the output of the encryption function is
fed back to become the input for encrypting the
next block of plaintext.
• In CFB, the output of the XOR unit is fed back to
become input for encrypting the next block.
• The other difference is that the OFB mode
operates on full blocks of plaintext and
ciphertext, whereas CFB operates on an s-bit
subset.
OFB Mode (cont..)
• Nonce: A time-varying value that has at most a
negligible chance of repeating, for example, a
random value that is generated anew for each
use, a timestamp, a sequence number, or some
combination of these.
• Each bit in the ciphertext is independent of the
previous bit or bits.
• This avoids error propagation.
• Pre-compute of forward cipher is possible.
5. CTR Encryption
Counter 1 Counter 2 Counter N
K K K
Encrypt Encrypt … Encrypt
P1 P2 PN
C1 C2 CN
𝐶𝑗 = 𝑃𝑗 ⊕ 𝐸 𝐾, 𝑇𝑗 𝑗 = 1, . . , 𝑁
CTR Decryption
Counter 1 Counter 2 Counter N
K K K
Encrypt Encrypt … Encrypt
C1 C2 CN
P1 P2 PN
𝑃𝑗 = 𝐶𝑗 ⊕ 𝐸 𝐾, 𝑇𝑗 𝑗 = 1, . . , 𝑁
Counter Mode (CTR) (cont…)
• Counter (CTR) mode has increased recently with
applications to ATM (asynchronous transfer
mode) network security and IP sec (IP security).
• A counter equal to the plaintext block size is
used.
• The counter value must be different for each
plaintext block that is encrypted.
• Typically, the counter is initialized to some value
and then incremented by 1 for each subsequent
block.
Advantages of the CTR Mode
• Strengths:
– Needs only the encryption algorithm.
– Random access to encrypted data blocks.
– blocks can be processed (encrypted or decrypted) in parallel.
– Simple and fast encryption/decryption.
• Counter must be
– Must be unknown and unpredictable.
– pseudo-randomness in the key stream is a goal.
Summary of all modes
Operation Description Type of
Mode Result
ECB Each n-bit block is encrypted Block Cipher
independently with same key.
CBC Same as ECB, but each block is XORed Block Cipher
with previous cipher text.
CFB Each s-bit block is XORed with s-bit key Stream Cipher
which is part of previous cipher text.
OFB Same as CFB, but input to the encryption Stream Cipher
is preceding encryption output.
CTR Same as OFB, but a counter is used Stream Cipher
instead of nonce.
Multiple Encryption
• Given the potential vulnerability of DES to a
brute-force attack, there has been considerable
interest in finding an alternative.
• For DES requires 256 operations for brute force
attack.
• One approach is to design a completely new
algorithm, of which AES is a prime example.
• Another alternative, which would preserve the
existing investment in software and equipment, is
to use multiple encryption with DES and multiple
keys.
Double DES
Key K1 Key K2
𝑋 = 𝐸(𝐾1 , 𝑃) = 𝐷(𝐾2 , 𝐶)
Key K2 Key K1
𝑃 = 𝐷(𝐾1 , 𝐷(𝐾2 , 𝐶))
𝑋 = 𝐷(𝐾2 , 𝐶)
Ciphertext Decryption Decryption Plaintext
Decryption
Double DES
• For double DES, 2 × 56-bit keys, meaning 112-bit
key length.
• Requires 2112 operations for brute force attack.
• Meet-in-the-middle attack makes it easier.
Meet in the Middle Attack
• This attack involves encryption from one end, decryption
from the other and matching the results in the middle.
• Suppose cryptanalyst knows Pi and corresponding Ci.
• Now, the aim is to obtain the values of K1 and K2.
All Possible keys All Possible keys
K1 = 256 K2 = 256
Known Known
Plaintext Middle Ciphertext
Encryption Decryption
Text
Possible
P Table of Table of C Keys
Possibl Cipher Text Cipher Text (Key = K1)
e Keys
010 (Key = 111 00
Find equal
110 K1) 011 01
match and store
101 00 E corresponding 001
D 10
01 K1 and K2.
000 110 11
10
11
Values of K1=01 and K2=11
Triple DES
Key K1 Key K2 Key K1
A B
Plaintext E D E Ciphertext
𝐶 = 𝐸(𝐾1 , 𝐷 𝐾2 , 𝐸 𝐾1 , 𝑃 )
B A
Ciphertext D E D Plaintext
𝑃 = 𝐷(𝐾1 , 𝐸 𝐾2 , 𝐷 𝐾1 , 𝐶 )
Message Authentication Requirements
1. Disclosure: Release of message contents.
2. Traffic analysis: Analyses the traffic and observe the
pattern of traffic between parties.
3. Masquerade: Insertion of messages into the network
from a fraudulent source.
4. Content modification: Changes to the contents of a
message.
5. Sequence modification: Any modification to a sequence
of messages between parties.
6. Timing modification: Delay or replay of messages.
7. Source repudiation: Denial of transmission of message by
source.
8. Destination repudiation: Denial of receipt of message by
destination.
Message Authentication Requirements
1. Disclosure Requires Message
Confidentiality
2. Traffic analysis (Encryption)
3. Masquerade Requires Message
4. Content modification Authentication
5. Sequence modification
6. Timing modification Requires Digital
Signature
7. Source repudiation
8. Destination repudiation
Hash Function
• A hash function H accepts
a variable-length block of
data M as input and
produces a fixed-size hash
value h = H(M).
• A “good” hash function
has the property that the
results of applying a
change to any bit or bits
in M results, with high
probability, in a change to
the hash code.
Input-Output behaviour of hash functions
Message Message
digest
Alice was beginning to get very tired of
sitting by her sister on the bank, and have H DFDB349C
nothing to do.
H E D
E(K, H(M))
S ll H
H(M || S)
• It is possible to use a hash function but no encryption for message
authentication.
• A and B share a common secret value S.
• A computes the hash value over the concatenation of M and S
and appends the resulting hash value to M. Because B possesses
S, it can recompute the hash value to verify the message.
• An opponent cannot modify an intercepted message.
Message authentication method - 4
Source A Destination B
ll H
E D M S
M ll
Compare
ll H K K
S
H(M || S)
E (K, [ M || H(M || S)])
S1 S2 … SN
Three Problems
Computational overhead
Message overhead
Security limitations
• Attacker could re-order or re-use signed blocks.
Digital Signature
Solution:
• Instead of signing the whole message, sign only a
digest (=hash) Also secure, but much faster.
• Needed: Hash Functions
X1 X2 … XN
Kpr Sig
S
Digital Signature method - 1
Source A Destination B
H
M ll M Compare
PRa PUa
H E D
E(PRa, H(M))
H E K K D
E(PRa, H(M))
E (K, [ M || E(PRa, H(M)])
F F F
+ + +
Message
schedule
a b c d e f g e 64
W0 K0
Round 0
a b c d e f g e 64
W79 K79
Round 79
+ + + + + + + +
Hi
SHA - 512 Processing of a Single 1024-Bit Block
• Each round takes as input the 512-bit buffer
value, abcdefgh, and updates the contents of the
buffer.
• At input to the first round, the buffer has the
value of the intermediate hash value, Hi-1.
• Each round t makes use of a 64-bit value Wt,
derived from the current 1024-bit block being
processed.
• The output of the eightieth round is added to the
input to the first round (Hi-1) to produce Hi.
Step – 5 Output
• After all Nth block of 1024-bit have been
processed, the output from the Nth stage is the
512-bit message digest.
SHA - 512 Round Function
SHA - 512 Round Function – Cont…
a b c d e f g h
Ch +
Ʃ Maj
+ Ʃ +
+ +
+ Wt
+ Kt
a b c d e f g h
ℎ=𝑔
𝑔=𝑓
𝑓=𝑒
𝑒 = 𝑑 + 𝑇1
𝑑=𝑐
𝑐=𝑏
𝑏=𝑎
𝑎 = 𝑇1 + 𝑇2
512
𝑇1 = ℎ + Ch 𝑒, 𝑓, 𝑔 + 𝑒 + 𝑊𝑡 + 𝐾𝑡
1
512
𝑇2 = 𝑎 + Maj 𝑎, 𝑏, 𝑐
0
SHA - 512 Round Function Elements
• Maj(a,b,c) = (a AND b) XOR (b AND c) XOR (a AND c)
Majority of arguments are true.
• Conditional function = (e AND f) XOR (NOT e and g)
• ∑(a) = ROTR(a,28) XOR ROTR(a,34) XOR ROTR(a,39)
• ∑(e) = ROTR(e,14) XOR ROTR(e,18) XOR ROTR(e,41)
• + = addition modulo 264
• Kt = a 64-bit additive constant.
• Wt = a 64-bit word derived from plaintext.
• ROTR = Circular right shift rotataion
Message Authentication
• Message authentication is a procedure to verify
that received message came from the genuine
source and has not been altered.
• Message authentication may also verify
sequencing and timeliness.
• Message authentication is a mechanism or
service used to verify the integrity of a message.
• Message authentication assures that data
received are exactly same as sent (i.e., message
contains no modification, no insertion, no
deletion, or no replay).
Message Authentication Requirements
1. Disclosure: Release of message contents.
2. Traffic analysis: Analyses the traffic and observe the
pattern of traffic between parties.
3. Masquerade: Insertion of messages into the network
from a fraudulent source.
4. Content modification: Changes to the contents of a
message.
5. Sequence modification: Any modification to a sequence
of messages between parties.
6. Timing modification: Delay or replay of messages.
7. Source repudiation: Denial of transmission of message by
source.
8. Destination repudiation: Denial of receipt of message by
destination.
Message Authentication Requirements
1. Disclosure Requires Message
Confidentiality
2. Traffic analysis
3. Masquerade Requires Message
4. Content modification Authentication
5. Sequence modification
6. Timing modification Requires Digital
Signature
7. Source repudiation
8. Destination repudiation
Message Authentication
Source A Destination B
M E D M
K 𝑬(𝑲, 𝑴) K
(a) Symmetric encryption : confidentiality and authentication
M E D M
M E E D D M
K K K
Encrypt Encrypt … Encrypt
C1 C2 CN
Data Authentication Algorithm (DAA)
Time = 1 Time = 2 Time = N
D1
D2 DN
(64 bits)
O1
O2 ON
(64 bits)
Data Authentication Algorithm (DAA)
𝑂1 = 𝐸 𝐾, 𝐷1
𝑂2 = 𝐸 𝐾, 𝐷2 ⊕ 𝑂1
𝑂3 = 𝐸(𝐾, 𝐷3 ⊕ 𝑂2 )
.
.
𝑂𝑁 = 𝐸(𝐾, 𝐷𝑁 ⊕ 𝑂𝑁−1 )
Data Authentication Algorithm (DAA)
• The data (e.g. message, record, file, or program)
to be authenticated are grouped into contiguous
64-bit blocks D1, D2, …, Dn.
• If necessary, the final block is padded on the right
with zeroes to form a full 64-bit block.
• Using the DES encryption algorithm E and a
secret key K, a data authentication code (DAC) is
calculated.
Cipher-Based Message Authentication Code (CMAC)
• Cipher-based Message Authentication Code
(CMAC) mode of operation for use with AES and
triple DES.
• First, let us define the operation of CMAC when
the message is an integer multiple of n of the
cipher block length b.
• For AES, b = 128, and for triple DES, b = 64. The
message is divided into n blocks (M1, M2,…, Mn).
Cipher-Based Message Authentication Code (CMAC)
• The algorithm makes use of a k-bit encryption key
K and a b-bit constant K1.
• For AES, the key size k is 128, 192 or 256 bits.
• For triple DES, the key size is 112 or 168 bits.
Cipher-Based Message Authentication Code (CMAC)
M1 M2 … Mn
b K1
k
K Encrypt K Encrypt K Encrypt
M1 M2 … Mn 10..0
K2
𝐶1 = 𝐸 𝐾, 𝑀1
𝐶2 = 𝐸 𝐾, 𝑀2 ⊕ 𝐶1
𝐶3 = 𝐸(𝐾, 𝑀3 ⊕ 𝐶2 )
.
.
.
𝐶𝑛 = 𝐸 𝐾, 𝑀𝑛 ⊕ 𝑂𝑛−1 ⊕ 𝐾1
𝑇 = 𝑀𝑆𝐵𝑇𝑙𝑒𝑛(𝐶𝑛)
Cryptographic Goals
Cryptographic Goals
Encrypt
Compare
S
Return Signature
Bob’s Signature for M valid or not valid
Hash Code, MAC and Digital Signature
Hash Code
• A hash of the message, if appended to the message itself,
only protects against accidental changes to the message, as
an attacker who modifies the message can simply calculate
a new hash and use it instead of the original one. So this
only gives integrity.
MAC
• A message authentication code (MAC) (sometimes also
known as keyed hash) protects against message forgery by
anyone who doesn't know the secret.
• This means that the receiver can forge any message – thus
we have both integrity and authentication (as long as the
receiver doesn't have a split personality), but not non-
repudiation.
Hash Code, MAC and Digital Signature
Digital Signature
• A digital signature is created with a private key,
and verified with the corresponding public key of
an asymmetric key-pair.
• Only the holder of the private key can create this
signature, and normally anyone knowing the
public key can verify it. So digital signature
provides non-repudiation.
Attacks
• C = Attacker, A = victim
• Key-only attack: C only knows A’s public key.
• Known message attack: C has set of messages, signatures.
• Generic chosen message attack: C obtains A’s signatures
on messages selected without knowledge of A’s public key.
• Directed chosen message attack: C obtains A’s signatures
on messages selected after knowing A’s public key.
• Adaptive chosen message attack: C may request
signatures on messages depending upon previous
message-signature pairs.
Forgeries
• Total break: C determines A’s private key.
• Universal forgery: C finds an efficient signing
algorithm that provides an equivalent way of
constructing signatures on arbitrary messages.
• Selective forgery: C forges a signature for a
particular message chosen by C.
• Existential forgery: C forges a signature for a
particular message not chosen by C.
Consequently, this forgery may only be a minor
nuisance to A.
Digital Signature Requirements
1. The signature must be a bit pattern that depends on the message
being signed.
2. The signature must use some information unique to the sender to
prevent both forgery and denial.
3. It must be relatively easy to produce the digital signature.
4. It must be relatively easy to recognize and verify the digital
signature.
5. It must be computationally infeasible to forge a digital signature,
either by constructing a new message for an existing digital signature
or by constructing a fraudulent digital signature for a given message.
6. It must be practical to retain a copy of the digital signature in
storage.
Digital Signature Standard / DSA
• The DSS uses an algorithm that is designed to
provide only the digital signature function.
• Unlike RSA, it cannot be used for encryption or
key exchange.
RSA Approach
• In the RSA approach, the message to be signed is input to a hash
function that produces a secure hash code of fixed length.
• This hash code is then encrypted using the sender’s private key to
form the signature.
• Both the message and the signature are then transmitted.
• The recipient takes the message and produces a hash code.
H
M PRa
ll M Compare
PUa
H E D
E(PRa, H(M))
RSA Approach
• The recipient also decrypts the signature using
the sender’s public key.
• If the calculated hash code matches the
decrypted signature, the signature is accepted as
valid.
• Because only the sender knows the private key,
only the sender could have produced a valid
signature.
DSA Approach
• The hash code is provided as input to a signature function along
with a random number K generated for this particular signature.
• The signature function also depends on the sender’s private key
(PRa) and a set of parameters known to a group of communicating
principals.
• We can consider this set to constitute a global public key (PUG)
• The result is a signature consisting of two components, labelled as
s and r.
H
ll M
M
PUG PRa PUG PUa
s
r
H Sig Compare
Ver
K
DSA Approach
• At the receiving end, the hash code of the incoming
message is generated.
• This plus the signature is input to a verification
function.
• The verification function also depends on the global
public key(PUG) as well as the sender’s public key
(PUa), which is paired with the sender’s private key.
• The output of the verification function is a value that
is equal to the signature component 𝑟 if the
signature is valid.
• The signature function is such that only the sender,
with knowledge of the private key, could have
produced the valid signature.
Digital Signature Algorithm
Global Public-Key Components
𝑝∶ Prime number where 2𝐿−1 < p < 2𝐿
For 512 ≤ 𝐿 ≤ 1024 and 𝐿 a multiple of 64;
i.e., bit length of between 512 and 1024 bits in
increments of 64 bits.
𝑔∶ = ℎ(𝑝−1)/𝑞 𝑚𝑜𝑑 𝑝
Where ℎ is any integer with 1 < ℎ < (𝑝 − 1)
Such that ℎ(𝑝−1)/𝑞 mod p > 1
Digital Signature Algorithm
User’s Private key
𝑥 Random or pseudorandom integer with 0 < 𝑥 < 𝑞
H
ll M
M PUG PUa
PUG PRa
s
r
H Sig Compare
Ver
k
DSA Signing
𝑀
𝑝 𝑞 𝑔
𝑀
𝑘 𝑟 = 𝑔𝑘 𝑚𝑜𝑑 𝑝 𝑚𝑜𝑑 𝑞
−1 𝑟
𝐻 𝑠= 𝑘 𝐻 𝑀 + 𝑥𝑟 𝑚𝑜𝑑 𝑞
𝐻(𝑀)
𝑥 𝑠
𝑥
Digital Signature Algorithm
Verifying
𝑤 = (𝑠 ′ )−1 𝑚𝑜𝑑 𝑞
𝑢1 = 𝐻 𝑀′ 𝑤 𝑚𝑜𝑑 𝑞
𝑢2 = 𝑟 ′ 𝑤 𝑚𝑜𝑑 𝑞
𝑀 = message to be signed
𝑣 = [(𝑔𝑢1 𝑦 𝑢2 )𝑚𝑜𝑑 𝑝] 𝑚𝑜𝑑 𝑞
𝐻(𝑀) = hash of M using SHA-1
𝑇𝑒𝑠𝑡: 𝑣 = 𝑟′ 𝑀′ , 𝑟 ′ , 𝑠′ = received versions of M, r, s
H
ll M
M PUG PUa
PUG PRa
s
r
H Sig Compare
Ver
k
DSA Verifying
𝑦 𝑞 𝑔
𝑢1 = 𝐻 𝑀′ 𝑤 𝑚𝑜𝑑 𝑞
𝐻 𝑢2 = 𝑟 ′ 𝑤 𝑚𝑜𝑑 𝑞
𝐻(𝑀′) 𝑣 = [(𝑔𝑢1 𝑦 𝑢2 )𝑚𝑜𝑑 𝑝] 𝑚𝑜𝑑 𝑞
𝑀′
𝑤 𝑟′ 𝑣
Signature
verification
𝑟′ 𝑞 𝑟 ′ = 𝑣?
𝑠′ 𝑤 = (𝑠 ′ )−1 𝑚𝑜𝑑 𝑞
ElGamal Digital Signatures
• Uses private key for encryption (signing)
• Uses public key for decryption (verification)
• Each user generates their key
– Chooses a secret key (number): 1 < 𝑋𝐴 < 𝑞
– Compute their public key: 𝑌𝐴 = 𝑎 𝑋𝐴 𝑚𝑜𝑑 𝑞
ElGamal Digital Signature
• Alice signs a message M to Bob by computing
– The hash 𝑚 = 𝐻 𝑀 , 0 ≤ 𝑚 ≤ (𝑞 − 1)
– Choose random integer 𝐾 with 1 <= 𝐾 <= 𝑞 − 1 and
𝑔𝑐𝑑(𝐾, 𝑞 − 1) = 1
– Compute temporary key: 𝑆1 = 𝑎𝐾 𝑚𝑜𝑑 𝑞
– Compute 𝐾 −1 the inverse of 𝐾 𝑚𝑜𝑑 (𝑞 − 1)
– Compute the value: 𝑆2 = 𝐾 −1 𝑚 − 𝑋𝐴 𝑆1 𝑚𝑜𝑑 (𝑞 − 1)
– Signature is: (𝑆1, 𝑆2)
• Any user B can verify the signature by computing
– 𝑉1 = 𝑎𝑚 𝑚𝑜𝑑 𝑞
– 𝑉2 = 𝑌𝐴 𝑆1 𝑆1 𝑆2 𝑚𝑜𝑑 𝑞 = (𝑎 𝑋𝐴 )𝑆1 (𝑎𝐾 )𝑆2 𝑚𝑜𝑑 𝑞
= 𝑎 𝑋𝐴𝑆1+𝑚−𝑋𝐴𝑆1 𝑚𝑜𝑑 𝑞 = 𝑎𝑚 𝑚𝑜𝑑 𝑞
– Signature is valid if 𝑉1 = 𝑉2
ElGamal Signature Example
• Use field GF(19) 𝑞 = 19 and 𝑎 = 10
• Alice computes her key:
16
– A chooses 𝑋𝐴 = 16 & computes 𝑌𝐴 = 10 𝑚𝑜𝑑 19 = 4
• Alice signs message with hash 𝑚 = 14 as (3, 4)
– Choosing random 𝐾 = 5 which has 𝑔𝑐𝑑(18, 5) = 1
5
– Computing 𝑆1 = 10 𝑚𝑜𝑑 19 = 3
– Finding 𝐾 −1 𝑚𝑜𝑑 𝑞 − 1 = 5−1 𝑚𝑜𝑑 18 = 11
– Computing 𝑆2 = 11 14 − 16 ∗ 3 𝑚𝑜𝑑 18 = 4
• Any user B can verify the signature by
computing
14
– 𝑉1 = 10 𝑚𝑜𝑑 19 = 16
– 𝑉2 = 43 ∗ 34 = 5184 = 16 𝑚𝑜𝑑 19
– Since 16 == 16 signature is valid
Schnorr Digital Signatures
• Also uses exponentiation in a finite (Galois)
• Security based on discrete logarithms
• Minimizes message dependent computation
• Multiplying a 2𝑛 𝑏𝑖𝑡 integer with an 𝑛 𝑏𝑖𝑡 integer
• Main work can be done in idle time
• Have using a prime modulus 𝑝
• 𝑝 − 1 has a prime factor 𝑞 of appropriate size
• Typically 𝑝 is 1024-bit and 𝑞 is 160-bit numbers
Schnorr Key Setup
• Choose suitable primes 𝑝 𝑎𝑛𝑑 𝑞
𝑞
• choose 𝑎 such that 𝑎 = 1 𝑚𝑜𝑑 𝑝
• (𝑎, 𝑝, 𝑞) are global parameters for all
• Each user generates a key
• Chooses a secret key (number): 0 < 𝑆𝐴 < 𝑞
• Compute their public key: 𝑉𝐴 = 𝑎−𝑆𝐴 𝑚𝑜𝑑 𝑞
Schnorr Signature
• User signs message by
• Choosing random number 𝑟 with 0 < 𝑟 < 𝑞 and computing:
X = 𝑎𝑟 𝑚𝑜𝑑 𝑝
• Concatenate message with 𝑋 and hash result to computing:
𝑒 = 𝐻(𝑀 || 𝑋)
• Computing: 𝑌 = 𝑟 + 𝑠𝑒 𝑚𝑜𝑑 𝑞
• Signature pair: (𝑒, 𝑌)
• Any other user can verify the signature as follows:
• Computing: 𝑋 ′ = 𝑎𝑌 𝑉 𝑒 𝑚𝑜𝑑 𝑝 = 𝑎𝑌 𝑎−𝑆𝑒 𝑚𝑜𝑑 𝑝
= 𝑎𝑌−𝑠𝑒 𝑚𝑜𝑑 𝑝 = 𝑎𝑟 𝑚𝑜𝑑 𝑝 = 𝑋
• Verifying that: 𝑒 = 𝐻(𝑀 || 𝑋′)
Key Distribution
• Key distribution is the function that delivers a key
to two parties who wish to exchange secure
encrypted data.
• Some sort of mechanism or protocol is needed to
provide the secure distribution of keys.
• Key distribution often involves the use of
– Master keys, which are infrequently used and are long lasting.
– Session keys, which are generated and distributed for
temporary use between two parties.
Symmetric Key Distribution using Symmetric Encryption
• Objective: Two entities share same secret key.
• Principle: Change keys frequently.
• How to exchange a secret key?
• For two parties A and B, key distribution can be achieved in a number
of ways, as follows:
1. A can select a key and physically deliver it to B.
2. Third party can select the key and physically deliver it to A and B.
3. If A and B have previously and recently used a key, one party can
transmit the new key to the other, encrypted using the old key.
4. If A and B each has an encrypted connection to a third party C, C
can deliver a key on the encrypted links to A and B.
Using a Key Distribution Centre
• Key Distribution Centre (KDC) is trusted third
party.
• Hierarchy of keys used:
– Data sent between end-systems are encrypted with temporary
session key.
– Session keys obtained from KDC over network are encrypted
with master key.
– Master keys can be distributed using manual delivery.
Key Hierarchy
• Communication
between end systems is
encrypted using a
temporary key, often
referred to as a session
key.
• Session keys are
transmitted in
encrypted form, using a
master key that is
shared by the key
distribution center and
an end system or user.
Key Distribution Scenario
Key
Distribution
Center (Key)
Initiator Initiator
A B
Initiator Initiator
A B
(2) 𝐸(𝐾𝑚 , [𝐾𝑠 ||𝐼𝐷𝐴 ||𝐼𝐷𝐵 || 𝑓(𝑁1) || 𝑁2])
Initiator Initiator
A B
(2) 𝐸(𝑃𝑈𝑎, 𝐾𝑠 )
1. The authority maintains a directory with a {name, public key} entry for
each participant.
2. Each participant registers a public key with the directory authority.
3. A participant may replace the existing key with a new one at any time.
4. Participants could also access the directory electronically. For this
purpose, secure, authenticated communication from the authority to
the participant is mandatory.
3. Public-Key Authority
Public-Key
Authority
(1) 𝑅𝑒𝑞𝑢𝑒𝑠𝑡 || 𝑇1
(4) 𝑅𝑒𝑞𝑢𝑒𝑠𝑡 || 𝑇2
Initiator Initiator
A B
(6) 𝐸(𝑃𝑈𝑎, [𝑁1 || 𝑁2])
𝑃𝑈𝑎 𝑃𝑈𝑏
(1) 𝐶𝐴
Initiator Initiator
A B
(2) 𝐶𝐴
4. Public-Key Certificates – Cont…
• Each participant applies to the certificate authority,
supplying a public key and requesting a certificate.
• For participant A, the authority provides a certificate
of the form
𝐶𝐴 = 𝐸 (𝑃𝑅𝑎𝑢𝑡ℎ, [𝑇 || 𝐼𝐷𝑎 ||𝑃𝑈𝑎 ] )
• A may then pass this certificate on to any other
participant, who reads and verifies the certificate as
follows:
= 𝐷 𝑃𝑈𝑎𝑢𝑡ℎ, 𝐶𝐴
= 𝐷(𝑃𝑈𝑎𝑢𝑡ℎ, 𝐸 (𝑃𝑅𝑎𝑢𝑡ℎ, [𝑇 || 𝐼𝐷𝑎 ||𝑃𝑈𝑎 ] ))
= (𝑇 || 𝐼𝐷𝑎 ||𝑃𝑈𝑎 )
X.509 Certificates
• An X.509 certificate is a digital certificate that uses
the widely accepted international X.509 public key
infrastructure (PKI) standard to verify that a public
key belongs to the user, computer or service identity
contained within the certificate.
• X.509 defines the format for public-key certificates
used in a variety of applications.
• The directory may serve as a repository of public-key
certificates.
• Each certificate contains the public key of a user and
is signed with the private key of a trusted
certification authority.
Version
Certificate X.509
serial number
Signature
algorithm
Algorithm Formats
Version 1
identifier Parameters
Issuer name
Proof of Not before
Version 2
Version 3
validity Not after
Subject name
Subject’s Algorithms
public key Parameters
info Key
Issuer Unique
identifier
Subject Unique
identifier
Extensions
Versions
Algorithms
All
Signature Parameters
Encrypted hash
X.509 Format – Cont…
• Version: Differentiates among successive versions of
the certificate format; the default is version 1.
• Serial number: The identity creating the certificate
must assign it a serial number that distinguishes it
from other certificates.
• Signature algorithm identifier: The algorithm used
by the issuer to sign the certificate.
• Issuer name: The name of the entity issuing the
certificate (usually a certificate authority).
• Period of validity: Consists of two dates: the first and
last on which the certificate is valid.
• Subject name: The name of the user to whom this
certificate refers.
X.509 Format – Cont…
• Subject’s public-key information: The public key
associated with the identity.
• Issuer unique identifier: An optional-bit string
field used to identify uniquely the issuing
Certificate Authority (CA).
• Subject unique identifier: An optional-bit string
field used to identify uniquely the subject name.
• Extensions: A set of one or more extension fields.
Public-Key Certificate Use
Unsigned certificate: Bob’s ID
contains user ID, information
user's public key
Bob’s Public H
key
Recipient can verify
H CA signature by comparing
information hash code values
E D
Generate hash Signed Certificate
code of unsigned
certificate
Encrypt hash code Decrypt signature
with CA's private key with CA's public key
to form signature to recover hash code
Public key Infrastructure (PKI)
• A public-key infrastructure (PKI) is defined as the
set of hardware, software, people, policies, and
procedures needed to create, manage, store,
distribute, and revoke digital certificates based on
asymmetric cryptography.
• It provides the identification of public keys and
their distribution.
• The principal objective for developing a PKI is to
enable secure, convenient, and efficient
acquisition of public keys.
Public key Infrastructure (PKI)
PKI users
Certificate/CRL retrieval
End entity
Registration,
Certificate/CRL Repositories
Initialization,
Certification,
Key pair recovery,
Registration Key pair update,
Certificate authority Revocation request
publication
Certificate
Certificate/CRL publication authority
Cross
certification
CRL Issuer Certificate
CRL publication
authority
PKI management
entities
Public key Infrastructure (PKI) – Cont…
• End entity: A generic term used to denote end users,
devices (e.g., servers, routers), or any other entity that can
be identified in the subject field of a public-key certificate.
• Certification authority (CA): The issuer of certificates and
certificate revocation lists (CRLs).
• Registration authority (RA): CA may use a third-party
Registration Authority (RA) to perform the necessary
checks on the person or company requesting the certificate
to confirm their identity.
• CRL issuer: An optional component that a CA can delegate
to publish CRLs.
• Repository: A generic term used to denote any method for
storing certificates and CRLs so that they can be retrieved
by end entities.