Understanding and Applying Cryptography and Data Security
Understanding and Applying Cryptography and Data Security
Information Security Management Metrics: A Definitive Understanding and Applying Cryptography and
Guide to Effective Security Monitoring and Measurement Data Security
W. Krag Brotby Adam J. Elbirt
ISBN: 978-1-4200-5285-5 ISBN: 978-1-4200-6160-4
AUERBACH PUBLICATIONS
www.auerbach-publications.com
To Order Call: 1-800-272-7737 • Fax: 1-800-374-3401
E-mail: [email protected]
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts
have been made to publish reliable data and information, but the author and publisher cannot assume
responsibility for the validity of all materials or the consequences of their use. The authors and publishers
have attempted to trace the copyright holders of all material reproduced in this publication and apologize to
copyright holders if permission to publish in this form has not been obtained. If any copyright material has
not been acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmit-
ted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented,
including photocopying, microfilming, and recording, or in any information storage or retrieval system,
without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.
com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood
Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and
registration for a variety of users. For organizations that have been granted a photocopy license by the CCC,
a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used
only for identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
1 Introduction 1
1.5 Supplements . . . . . . . . . . . . . . . . . . . . . . 8
2 Symmetric-Key Cryptography 9
vii
viii CONTENTS
5.1.2 Cryptosystem . . . . . . . . . . . . . . . . . 87
References . . . . . . . . . . . . . . . . . . . . . . . . . . 595
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
List of Figures
xvii
xviii LIST OF FIGURES
xxiii
xxiv LIST OF TABLES
xxv
xxvi ABOUT THE AUTHOR
xxvii
Chapter 1
Introduction
Security
1
2 CHAPTER 1. INTRODUCTION
Cryptology
Cryptography Cryptanalysis
Private-Key Public-Key
Protocols
Algorithms Algorithms
Stream Block
Ciphers Ciphers
The material for this book is derived from the author’s teach-
ing notes and research publications, with other books and research
articles in recent literature used as supplementary material to pro-
vide information on state-of-the art implementations when eval-
uating different methods. The book is designed to be used in
electrical engineering and computer science courses focused on ap-
plied cryptography, where students are taught not only the under-
lying mathematics theory behind cryptographic algorithms, but
also how to efficiently implement these algorithms for a variety of
target technologies.
1.5 Supplements
Symmetric-Key
Cryptography
9
10 CHAPTER 2. SYMMETRIC-KEY CRYPTOGRAPHY
Oscar
X Y Open Y X
Alice e d Bob
Channel
• eki and dki are inverse functions for identical keys such that
dki (Y ) = dki (eki (X )) = X.
a ≡ r mod m
15 ≡ 3 mod 4
a ≡ r mod m
−15 ≡ 1 mod 4
r = 67 % 13; /* r = 67 mod 13 = 2 */
r = r + 11; /* r = -5 + 11 = 6 */
From this it is evident that r ≡ 3 mod 11. In this case, the expo-
nentiation results in a large number — 762,939,453,125 — which
must then be reduced via division. Both of these operations be-
come exceedingly complex due to the multi-precision arithmetic
18 CHAPTER 2. SYMMETRIC-KEY CRYPTOGRAPHY
517 = 55 · 55 · 55 · 52 mod 11
517 = 3, 125 · 3, 125 · 3, 125 · 25 mod 11
517 = (3, 125 mod 11 · 3, 125 mod 11 · 3, 125 mod 11 · 25
mod 11) mod 11
3, 125/11 = 284 + r1
3, 125 = 284 · 11 + r1
r1 = 3, 125 − 284 · 11
r1 = 1
25/11 = 2 + r2
25 = 2 · 11 + r2
r2 = 25 − 22
r2 = 3
517 = (1 · 1 · 1 · 3) mod 11
517 = 3
2.3. GREATEST COMMON DIVISOR 19
440 = 23 × 5 × 11
128 = 27
gcd(440, 128) = 23
20 CHAPTER 2. SYMMETRIC-KEY CRYPTOGRAPHY
2. Two operations:
m = 7
3 + 5 = 8 ≡ 1 mod 7
3 × 5 = 15 ≡ 1 mod 7
first column will be the elements in the Ring Zm and the second
column will be the multiplicative inverse of each element. If an
element does not have a multiplicative inverse, enter a dash in the
multiplicative inverse column.
Symmetric-Key
Cryptography:
Substitution Ciphers
25
26CHAPTER 3. SYMMETRIC-KEY CRYPTOGRAPHY: SUBSTITUTION CIPHERS
that:
1. Ciphertext-Only:
2. Known-Plaintext:
3. Chosen-Plaintext:
4. Chosen-Ciphertext:
P = Zl
C = Zl
K = Zl
x P
y C
k K
3.2. SHIFT CIPHERS 31
X = CRY P T OGRAP HY
X = 2, 17, 24, 15, 19, 14, 6, 17, 0, 15, 7, 24
Encryption
x0 = 2 → e3 (2) = 2 + 3 mod 26 = 5 mod 26 = F
x1 = 17 → e3 (17) = 17 + 3 mod 26 = 20 mod 26 = U
x2 = 24 → e3 (24) = 24 + 3 mod 26 = 27 mod 26 ≡ 1 mod 26 = B
x3 = 15 → e3 (15) = 15 + 3 mod 26 = 18 mod 26 = S
x4 = 19 → e3 (19) = 19 + 3 mod 26 = 22 mod 26 = W
x5 = 14 → e3 (14) = 14 + 3 mod 26 = 17 mod 26 = R
x6 = 6 → e3 (6) = 6 + 3 mod 26 = 9 mod 26 = J
x7 = 17 → e3 (17) = 17 + 3 mod 26 = 20 mod 26 = U
x8 = 0 → e3 (0) = 0 + 3 mod 26 = 3 mod 26 = D
x9 = 15 → e3 (15) = 15 + 3 mod 26 = 18 mod 26 = S
x10 = 7 → e3 (7) = 7 + 3 mod 26 = 10 mod 26 = K
x11 = 24 → e3 (24) = 24 + 3 mod 26 = 27 mod 26 ≡ 1 mod 26 = B
32CHAPTER 3. SYMMETRIC-KEY CRYPTOGRAPHY: SUBSTITUTION CIPHERS
P = Zl
C = Zl
x P
y C
k = (a, b) Zl
Note that because the affine cipher requires the use of a−1 , the
gcd(a, l) = 1 must be true for a−1 to exist. Therefore the size
of the key space varies based on l, the number of letters in the
language’s alphabet. In particular, the size of the key space will
depend on the number of elements 1 ≤ a ≤ l − 1 that are
relatively prime to l, which is defined as φ(l) (also known as Euler’s
Phi Function) and will be discussed further in Section 6.6. Using
φ(l) the size of the affine cipher’s key space may now be defined
as K = φ(l) · l because there are φ(l) possible choices for a and
l possible choices for b, the two parameters that form the key k.
Using these definitions, affine ciphers for specific languages and
alphabets may now be examined.
Example 3.2: What are the valid choices for a and thus the size
of the key space for an affine cipher that is based on the English
language and associated alphabet?
To answer this question, the elements within Z26 that are relatively
prime to 26, i.e. that have a gcd(a, 26) = 1, must be determined
because there are 26 letters in the English alphabet. Therefore, all
elements 1 ≤ a ≤ 25 must be factored into their integer prime
factors and compared with the integer prime factors of 26.
3.3. AFFINE CIPHERS 35
1=1 14 = 2·7
2=2 15 = 3·5
3=3 16 = 24
4 = 22 17 = 17
5=5 18 = 2 · 32
6=2·3 19 = 19
7=7 20 = 22 · 5
8 = 23 21 = 3·7
9 = 32 22 = 2 · 11
10 = 2 · 5 23 = 23
11 = 11 24 = 23 · 3
12 = 22 · 3 25 = 52
13 = 13
26 = 2 · 13
X = CRY P T OGRAP HY
X = 2, 17, 24, 15, 19, 14, 6, 17, 0, 15, 7, 24
36CHAPTER 3. SYMMETRIC-KEY CRYPTOGRAPHY: SUBSTITUTION CIPHERS
Encryption
x0 = 2 → e(5,9) (2) = 5 · 2 + 9 mod 26 = 19 mod 26 = T
x1 = 17 → e(5,9) (17) = 5 · 17 + 9 mod 26 = 94 mod 26 ≡ 16 mod 26 = Q
x2 = 24 → e(5,9) (24) = 5 · 24 + 9 mod 26 = 129 mod 26 ≡ 25 mod 26 = Z
x3 = 15 → e(5,9) (15) = 5 · 15 + 9 mod 26 = 84 mod 26 ≡ 6 mod 26 = G
x4 = 19 → e(5,9) (19) = 5 · 19 + 9 mod 26 = 104 mod 26 ≡ 0 mod 26 = A
x5 = 14 → e(5,9) (14) = 5 · 14 + 9 mod 26 = 79 mod 26 ≡ 1 mod 26 = B
x6 = 6 → e(5,9) (6) = 5 · 6 + 9 mod 26 = 39 mod 26 ≡ 13 mod 26 = N
x7 = 17 → e(5,9) (17) = 5 · 17 + 9 mod 26 = 94 mod 26 ≡ 16 mod 26 = Q
x8 = 0 → e(5,9) (0) = 5 · 0 + 9 mod 26 = 9 mod 26 = J
x9 = 15 → e(5,9) (15) = 5 · 15 + 9 mod 26 = 84 mod 26 ≡ 6 mod 26 = G
x10 = 7 → e(5,9) (7) = 5 · 7 + 9 mod 26 = 44 mod 26 ≡ 1 mod 18 = B
x11 = 24 → e(5,9) (24) = 5 · 24 + 9 mod 26 = 129 mod 26 ≡ 25 mod 26 = Z
9 = a · 0 + b mod 26
14 = a · 1 + b mod 26
14 = a · 1 + 9 mod 26
14 mod 26 − 9 mod 26 = a mod 26
5 mod 26 = a mod 26
PKVUADHUAAOLTAVMVYNLAYBAOPQBZADHUAAOLTAVYLTLTILYTL
NYSYXDSYAXDKYALMWVKYADWDPROPYSNYSYXDKYACZM
b) Use the largest possible value from part (a) for a and encrypt
the message BLACK ELK using 8 for b.
a) What is the size of the key space for this affine cipher?
a) How large is the key space of the affine cipher for this
alphabet?
a) How large is the key space of the affine cipher for this
alphabet?
3.4. HOMEWORK PROBLEMS 45
a) How large is the key space of the affine cipher for this alpha-
bet?
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY affine IS
PORT ( plaintext : IN std_logic_vector (4 DOWNTO 0);
clk, rst : IN std_logic;
ciphertext : OUT std_logic_vector (4 DOWNTO 0));
END affine;
ARCHITECTURE behav OF affine IS
BEGIN
-- Your code goes here
END behav;
46CHAPTER 3. SYMMETRIC-KEY CRYPTOGRAPHY: SUBSTITUTION CIPHERS
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY gen_affine IS
PORT ( plaintext : IN std_logic_vector (7 DOWNTO 0);
a,b : IN std_logic_vector (7 DOWNTO 0);
clk, rst : IN std_logic;
ciphertext : OUT std_logic_vector (7 DOWNTO 0));
END gen_affine;
ARCHITECTURE behav OF gen_affine IS
BEGIN
-- Your code goes here
END behav;
Symmetric-Key
Cryptography: Stream
Ciphers
49
50 CHAPTER 4. SYMMETRIC-KEY CRYPTOGRAPHY: STREAM CIPHERS
zi Oscar zi
Alice Bob
xi yi xi
X = {x0 , x1 , . . .} P
Y = {y0 , y1 , . . .} C
K = {k0 , k1 , . . .} K
x i , y i , ki {0, 1}
y0 = (x0 + k0 ) mod 2
y1 = (x1 + k1 ) mod 2
y2 = (x2 + k2 ) mod 2
..
.
yi = (xi + ki ) mod 2
Oscar
zi zi
Alice Bob
xi yi xi
the next key stream bit zi . The term Synchronous Stream Cipher
is used to describe stream ciphers that use key stream generators
that generate the key stream independent of the plaintext and the
ciphertext, i.e. that use synchronous key stream generators. The
term Asynchronous Stream Cipher is used to describe stream ci-
phers that synchronize automatically. In all cases, Alice and Bob
must reach a state where their key stream generators are synchro-
nized so that each zi arrives at the same time as its corresponding
yi because loss of synchronization will result in corruption of the
plaintext xi upon decryption of the ciphertext yi .
K3 K2 K1 K0
D3 Q3 D2 Q2 D1 Q1 D0 Q0 zi
z3 z2 z1 z0
Clock
The LFSR of Figure 4.3 yields the following equations for the flip-
flop inputs:
D0 = Q1
D1 = Q2
D2 = Q3
D3 = Q1 ⊕ Q0
4.3. KEY STREAM GENERATORS 59
z4 = z0 ⊕ z1 mod 2 = 1 ⊕ 0 = 1
z5 = z1 ⊕ z2 mod 2 = 0 ⊕ 0 = 0
z6 = z2 ⊕ z3 mod 2 = 0 ⊕ 1 = 1
z7 = z3 ⊕ z4 mod 2 = 1 ⊕ 1 = 0
z8 = z4 ⊕ z5 mod 2 = 1 ⊕ 0 = 1
z9 = z5 ⊕ z6 mod 2 = 0 ⊕ 1 = 1
z10 = z6 ⊕ z7 mod 2 = 1 ⊕ 0 = 1
z11 = z7 ⊕ z8 mod 2 = 0 ⊕ 1 = 1
z12 = z8 ⊕ z9 mod 2 = 1 ⊕ 1 = 0
z13 = z9 ⊕ z10 mod 2 = 1 ⊕ 1 = 0
z14 = z10 ⊕ z11 mod 2 = 1 ⊕ 1 = 0
z15 = z11 ⊕ z12 mod 2 = 1 ⊕ 0 = 1
z16 = z12 ⊕ z13 mod 2 = 0 ⊕ 0 = 0
60 CHAPTER 4. SYMMETRIC-KEY CRYPTOGRAPHY: STREAM CIPHERS
zi = 1001101011110001001101011110 . . .
the key stream begins repeating at z15 , and the length of the key
stream before repeating is 15.
Km–1 Km–2 K1 K0
zi+m zi+2 zi+1 zi
Dm–1 Qm–1 Dm–2 Qm–2 D1 Q1 D0 Q0
zm–1 zm–2 z1 z0
Clock
Example 4.2: What are the values for m and the feedback coef-
ficients ci for the LFSR in Figure 4.3?
Example 4.3: What is the key k for the LFSR in Figure 4.3 using
the initial vector of (z3 = 1, z2 = 0, z1 = 0, z0 = 1)?
4.3. KEY STREAM GENERATORS 63
The LFSR yields the following equations for the flip-flop inputs:
D0 = Q1
D1 = Q2
D2 = Q3
D3 = Q3 ⊕ Q2 ⊕ Q1 ⊕ Q0
z4 = z0 ⊕ z1 ⊕ z2 ⊕ z3 mod 2 = 1 ⊕ 0 ⊕ 0 ⊕ 1 = 0
z5 = z1 ⊕ z2 ⊕ z3 ⊕ z4 mod 2 = 0 ⊕ 0 ⊕ 1 ⊕ 0 = 1
z6 = z0 ⊕ z3 ⊕ z4 ⊕ z5 mod 2 = 0 ⊕ 1 ⊕ 0 ⊕ 1 = 0
z7 = z0 ⊕ z4 ⊕ z5 ⊕ z6 mod 2 = 1 ⊕ 0 ⊕ 1 ⊕ 0 = 0
z8 = z0 ⊕ z5 ⊕ z6 ⊕ z7 mod 2 = 0 ⊕ 1 ⊕ 0 ⊕ 0 = 1
z9 = z0 ⊕ z6 ⊕ z7 ⊕ z8 mod 2 = 1 ⊕ 0 ⊕ 0 ⊕ 1 = 0
The LFSR yields the following equations for the flip-flop inputs:
D0 = Q1
D1 = Q2
D2 = Q3
D3 = Q3 ⊕ Q2 ⊕ Q1 ⊕ Q0
z4 = z0 ⊕ z1 ⊕ z2 ⊕ z3 mod 2 = 0 ⊕ 0 ⊕ 0 ⊕ 1 = 1
z5 = z1 ⊕ z2 ⊕ z3 ⊕ z4 mod 2 = 0 ⊕ 0 ⊕ 1 ⊕ 1 = 0
z6 = z0 ⊕ z3 ⊕ z4 ⊕ z5 mod 2 = 0 ⊕ 1 ⊕ 1 ⊕ 0 = 0
z7 = z0 ⊕ z4 ⊕ z5 ⊕ z6 mod 2 = 1 ⊕ 1 ⊕ 0 ⊕ 0 = 0
z8 = z0 ⊕ z5 ⊕ z6 ⊕ z7 mod 2 = 1 ⊕ 0 ⊕ 0 ⊕ 0 = 1
z9 = z0 ⊕ z6 ⊕ z7 ⊕ z8 mod 2 = 0 ⊕ 0 ⊕ 0 ⊕ 1 = 1
P (x) = x4 + c3 · x3 + c2 · x2 + c1 · x + c0
P (x) = x4 + x3 + x2 + x + 1
P (x) = x4 + c3 · x3 + c2 · x2 + c1 · x + c0
P (x) = x4 + x + 1
4.3. KEY STREAM GENERATORS 67
LFSR 2
Clock LFSR 1 zi
LFSR 3
Once the first 2 · m bits of the key stream are known, Oscar
employs the generalized LFSR characterization equation zi + m =
m − 1
j=0 zi + j · cj mod 2; cj {0, 1}; i = 0, 1, 2, 3, . . ., used
to generate the key stream, to solve for each feedback coefficient
ci :
4.3. KEY STREAM GENERATORS 71
A ⇔ 0 = 000002
B ⇔ 1 = 000012
..
.
Z ⇔ 25 = 110012
0 ⇔ 26 = 110102
1 ⇔ 27 = 110112
..
.
5 ⇔ 31 = 111112
⎛ ⎞
⎜ 1 1 1 1 1 1 ⎟
⎜ ⎟
⎜ 1 1 1 1 1 0 ⎟
⎜ ⎟
⎜ ⎟
⎜ ⎟
⎜ 1 1 1 1 0 0 ⎟
⎜ ⎟ (4.3)
⎜ ⎟
⎜ 1 1 1 0 0 0 ⎟
⎜ ⎟
⎜ ⎟
⎜ 1 1 0 0 0 0 ⎟
⎜ ⎟
⎝ ⎠
1 0 0 0 0 0
is: ⎛ ⎞
⎜ 0 0 0 0 0 1 ⎟
⎜ ⎟
⎜ 0 0 0 0 1 1 ⎟
⎜ ⎟
⎜ ⎟
⎜
⎜ 0 0 0 1 1 0 ⎟
⎟
⎜ ⎟ (4.4)
⎜ ⎟
⎜ 0 0 1 1 0 0 ⎟
⎜ ⎟
⎜ ⎟
⎜ 0 1 1 0 0 0 ⎟
⎜ ⎟
⎝ ⎠
1 1 0 0 0 0
Draw the schematic for the stream cipher. Compute the first eight
output bits.
1. m3 = 4, x4 + x + 1
2. m3 = 7, x7 + x + 1
3. m3 = 9, x9 + x + 1
where each of the LFSRs has maximum period. Which LFSR re-
sults in the longest sequence length for the stop-and-go generator?
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY lfsr IS
PORT ( clk, rst, start : IN std_logic;
z_i : OUT std_logic);
END lfsr;
BEGIN
ARCHITECTURE behav OF lfsr IS
-- Your code goes here
END behav;
Symmetric-Key
Cryptography: Block
Ciphers
83
84 CHAPTER 5. SYMMETRIC-KEY CRYPTOGRAPHY: BLOCK CIPHERS
• Modular multiplication.
• Modular inversion.
• Look-up-table substitution.
86 CHAPTER 5. SYMMETRIC-KEY CRYPTOGRAPHY: BLOCK CIPHERS
k0
k1
k2
k3
D
D
A
C
B
f
f
D
A
C
C
B
D
A
C
B
B
D
A
A
C
B
k0
k1
k2
A
C
C
B
f
f
A
C
B
B
A
A
C
B
k0
k1
L
R
R
f
f
R
L
5.1.2 Cryptosystem
Plaintext
IP
L0 R0
f
K1
L1 = R0 R0 = L0 f(R0 , K1)
f
K2
L2 = R1 R2 = L1 f(R1, K2)
f
K16
IP–1
Ciphertext
Shift Shift
S-Box Substitution
P-Box Permutation
Li Ri Key
FP
40 8 48 16 56 24 64 32
39 7 47 15 55 23 63 31
38 6 46 14 54 22 62 30
37 5 45 13 53 21 61 29
36 4 44 12 52 20 60 28
35 3 43 11 51 19 59 27
34 2 42 10 50 18 58 26
33 1 41 9 49 17 57 25
Table 5.2: DES Final Permutation (FP)
rewiring the incoming bits to meet the needs of the DES algo-
rithm while rewiring the outgoing bits to match the bus format of
the preexisting hardware interfaces.
Li–1 Ri–1
32
Expansion E(Ri–1)
48
48
Ki
6 6 6 6 6 6 6 6
S1 S2 S3 S4 S5 S6 S7 S8
4 4 4 4 4 4 4 4
32
Permutation P
32
32
32
Ri
E
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
Table 5.3: DES Expansion (E)
column addresses range from zero to fifteen. Also note that row
addresses increment from the top to the bottom of the grid whereas
column addresses increment from the left to the right of the grid.
S1
14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
S2
15 1 8 14 6 11 3 4 9 7 2 13 12 0 5 10
3 13 4 7 15 2 8 14 12 0 1 10 6 9 11 5
0 14 7 11 10 4 13 1 5 8 12 6 9 3 2 15
13 8 10 1 3 15 4 2 11 6 7 12 0 5 14 9
S3
10 0 9 14 6 3 15 5 1 13 12 7 11 4 2 8
13 7 0 9 3 4 6 10 2 8 5 14 12 11 15 1
13 6 4 9 8 15 3 0 11 1 2 12 5 10 14 7
1 10 13 0 6 9 8 7 4 15 14 3 11 5 2 12
S4
7 13 14 3 0 6 9 10 1 2 8 5 11 12 4 15
13 8 11 5 6 15 0 3 4 7 2 12 1 10 14 9
10 6 9 0 12 11 7 13 15 1 3 14 5 2 8 4
3 15 0 6 10 1 13 8 9 4 5 11 12 7 2 14
S5
2 12 4 1 7 10 11 6 8 5 3 15 13 0 14 9
14 11 2 12 4 7 13 1 5 0 15 10 3 9 8 6
4 2 1 11 10 13 7 8 15 9 12 5 6 3 0 14
11 8 12 7 1 14 2 13 6 15 0 9 10 4 5 3
S6
12 1 10 15 9 2 6 8 0 13 3 4 14 7 5 11
10 15 4 2 7 12 9 5 6 1 13 14 0 11 3 8
9 14 15 5 2 8 12 3 7 0 4 10 1 13 11 6
4 3 2 12 9 5 15 10 11 14 1 7 6 0 8 13
S7
4 11 2 14 15 0 8 13 3 12 9 7 5 10 6 1
13 0 11 7 4 9 1 10 14 3 5 12 2 15 8 6
1 4 11 13 12 3 7 14 10 15 6 8 0 5 9 2
6 11 13 8 1 4 10 7 9 5 0 15 14 2 3 12
S8
13 2 8 4 6 15 11 1 10 9 3 14 5 0 12 7
1 15 13 8 10 3 7 4 12 5 6 11 0 14 9 2
7 11 4 1 9 12 14 2 0 6 10 13 15 3 5 8
2 1 14 7 4 10 8 13 15 12 9 0 3 5 6 11
P
16 7 20 21
29 12 28 17
1 15 23 26
5 18 31 10
2 8 24 14
32 27 3 9
19 13 30 6
22 11 4 25
Table 5.12: DES Permutation (P)
The 56-bit key is broken into eight 7-bit groupings and a parity
bit is generated for each grouping, resulting in a 64-bit master key.
5.1. THE DATA ENCRYPTION STANDARD 95
PC-1
57 49 41 33 25 17 9
1 58 50 42 34 26 18
10 2 59 51 43 35 27
19 11 3 60 52 44 36
63 55 47 39 31 23 15
7 62 54 46 38 30 22
14 6 61 53 45 37 29
21 13 5 28 20 12 4
Table 5.13: DES Permuted Choice (PC-1)
64
PC-1
56
C0 D0
28 28
LS1 LS1
28 28
48 56
K1 PC-2 C1 D1
28 28
LS2 LS2
28 28
48 56
K2 PC-2 C2 D2
28 28
.
.
.
28 28
LS16 LS16
28 28
48 56
K16 PC-2 C16 D16
PC-2
14 17 11 24 1 5
3 28 15 6 21 10
23 19 12 4 26 8
16 7 27 20 13 2
41 52 31 37 47 55
30 40 51 45 33 48
44 49 39 56 34 53
46 42 50 36 29 32
Table 5.14: DES Permuted Choice (PC-2)
knowledge that:
R1d = Ld0 ⊕ f (R0d , K16 )
Substituting decryption values for values from the encryption pro-
cess yields:
R1d = R16
e
⊕ f (Le16 , K16 )
This is significant because it is known that:
e
R16 = Le15 ⊕ f (R15
e
, K16 )
e
Substituting for R16 results in:
R1d = Le15 ⊕ f (R15
e
, K16 ) ⊕ f (Le16 , K16 )
Right Shift units denoted as RSi. A Cyclic Right Shift unit RSi
will shift by the same amount as LSi but in the opposite direction.
The DES decryption Key Schedule is shown in Figure 5.6.
64
PC-1
56
48 56
K16 PC-2 C0 = C16 D0 = D16
28 28
RS1 RS1
28 28
48 56
K15 PC-2 C15 D15
28 28
RS2 RS2
28 28
48 56
K14 PC-2 C14 D14
28 28
.
.
.
28 28
RS15 RS15
28 28
48 56
K1 PC-2 C1 D1
56 56
k k
3. Knowing the block format of the data stream for the bank
transaction (from Figure 5.7) and assuming that the key k
does not change, identify and extract the block that contains
the encrypted value for the account number to receive the $1
transfer, i.e. Oscar’s Block 4.
IV
64xi
DES–1 64
yi–1
k
56
64
yi
DES
yi–1
k
56
64
64xi
IV
x i = yi − 1 ⊕ DESk−1 (yi )
xi = y i − 1 ⊕ DESk−1 (DESk (xi ⊕ yi − 1 ))
xi = y i − 1 ⊕ xi ⊕ yi − 1
y0 = DESk (x0 ⊕ IV )
yi = DESk (xi ⊕ xi − 1 ⊕ yi − 1)
106 CHAPTER 5. SYMMETRIC-KEY CRYPTOGRAPHY: BLOCK CIPHERS
xi
xi–1
IV
64
64
DES–1
k
56
yi–1
yi
64
yi–1
DES
k
56
64
64
xi–1
IV
xi
x0 = IV ⊕ DESk−1 (y0 )
xi = x i − 1 ⊕ yi − 1 ⊕ DESk−1 (yi )
Cipher Feedback (CFB) mode differs from ECB and CBC mode in
that the block cipher is used as a pseudo-random number generator
as opposed to performing encryption and decryption. In such a
configuration, the block cipher generates a key stream zi used to
encrypt the plaintext xi via the XOR operation, resulting in a
stream cipher as shown in Figure 5.11.
L
L
Shift Register
B
Cipher
Block
Lxi
yi–1
B
B:L
L
yi
L
B:L
yi–1
L
B
L
Cipher
Block
L
xi
k
L
Shift Register
B
B
L
B
Shift Register
B
L
Cipher
Block
Lxi
B
B:L
yi
L
B:L
L
B
L
Cipher
Block
xi
k
L
Shift Register
B
B
b Block b
LFSR
Cipher
b b
xi yi
64 64 64 64
xi DES yi
64 56 64
k2 k1 k3
1. The 56-bit key was too small, allowing for an Exhaustive Key
Search attack.
118 CHAPTER 5. SYMMETRIC-KEY CRYPTOGRAPHY: BLOCK CIPHERS
Key
010101010101010116
FEFEFEFEFEFEFEFE16
1F1F1F1F0E0E0E0E16
E0E0E0E0F1F1F1F116
Table 5.15: DES Weak Keys
5.1. THE DATA ENCRYPTION STANDARD 119
Key Dual
E001E001F101F10116 01E001E001F101F116
FE1FFE1FFE0EFE0E16 1FFE1FFE0EFE0EFE16
E01FE01FF10EF10E16 1FE01FE00EF10EF116
01FE01FE01FE01FE16 FE01FE01FE01FE0116
011F011F010E010E16 1F011F010E010E0116
E0FEE0FEF1FEF1FE16 FEE0FEE0FEF1FEF116
Table 5.16: DES Semi-Weak Keys
Example 5.2: Consider the IDEA block cipher. IDEA has a 64-
bit block size and a 128-bit key size. How many (x, y) pairs are
needed to ensure that the key being tested is the correct key with
a 99 % probability?
5.1.6.3 Meet-In-The-Middle
DESKi(x) = zi DES–1Kj(y) = zj
z
64 64 64
x DES DES y
56 56
ki kj
3. Compute DESk−1
j
(y0 ) = zj .
DES–1K23(y) = z1
56 56 56
k1 k2 k3
candidate key pair is the true key pair, the likelihood that the
wrong key pair has been chosen must be minimized. If one (x, y)
− tn
pair is used, the average number of false key pairs is 2lk =
· 56) − (1 · 64)
2(2 = 248 . If two (x, y) pairs are used, the average
− tn · 56) − (2 · 64)
number of false keys is 2lk = 2(2 = 2−16 =
1.5 × 10−5 . Therefore, two (x, y) pairs are needed to ensure
that the key pair being tested is the correct key pair with a 99 %
probability.
a) x1 = 0000002 , x2 = 0000012
b) x1 = 1111112 , x2 = 1000002
c) x1 = 1010102 , x2 = 0101012
x = (x1 , x2 , . . . , x64 )
a 64-bit vector. Show that IP −1 (IP (x)) = x for the first five
bits of x, i.e. for xi , i = 1, 2, 3, 4, 5.
d) Using the results from parts (a) and (b), show that if ki are
the keys generated from k, then ki are the keys generated from k
where i = 1, 2, . . . , 16.
r bits per second. Ignore the time needed for the Initial Permu-
tation and the Final Permutation.
which searches 5 · 107 keys per second. Also assume that 100,000
of these chips are used in parallel. How long does an average key
search take? Relate this time to the age of the universe, which is
approximately 1010 years.
where the leftmost bit is bit 1 and bits 8, 16, 24, . . . , 64 are parity
bits that are not passed through to PC-1. Compute the sub-key
k16 .
edge of the clock. Assume that the user will provide a loadkey
signal to indicate that the master key is ready to be loaded from
the plaintext bus on the next rising edge of the clock. Also as-
sume that the user will provide a loadiv signal to indicate that the
Initialization Vector, IV, is ready to be loaded on the next rising
edge of the clock via the plaintext bus. Your system must output
a valid signal to indicate when the output ciphertext is valid, i.e.
an encryption has completed. Use the following entity declaration
for your implementation:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY des_cbc IS
PORT ( plaintext : IN std_logic_vector (63 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
loadkey : IN std_logic;
loadiv : IN std_logic;
valid : OUT std_logic;
ciphertext : OUT std_logic_vector (63 DOWNTO 0));
END des_cbc;
ARCHITECTURE behav OF des_cbc IS
BEGIN
-- Your code goes here
END behav;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY des_ecb IS
PORT ( plaintext : IN std_logic_vector (63 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
loadkey : IN std_logic;
valid : OUT std_logic;
ciphertext : OUT std_logic_vector (63 DOWNTO 0));
END des_ecb;
ARCHITECTURE behav OF des_ecb IS
BEGIN
-- Your code goes here
END behav;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY des_ecb_single IS
PORT ( plaintext : IN std_logic_vector (63 DOWNTO 0);
key : IN std_logic_vector (63 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
loadkey : IN std_logic;
valid : OUT std_logic;
ciphertext : OUT std_logic_vector (63 DOWNTO 0));
END des_ecb_single;
ARCHITECTURE behav OF des_ecb_single IS
BEGIN
-- Your code goes here
END behav;
5.2. THE ADVANCED ENCRYPTION STANDARD 139
Addition
+ mod 5 0 1 2 3 4
0 0 1 2 3 4
1 1 2 3 4 0
2 2 3 4 0 1
3 3 4 0 1 2
4 4 0 1 2 3
Multiplication
× mod 5 0 1 2 3 4
0 0 0 0 0 0
1 0 1 2 3 4
2 0 2 4 1 3
3 0 3 1 4 2
4 0 4 3 2 1
Example 5.7: Given the polynomials A(x) and B(x), each con-
tained in the Extension Field GF(24 ):
A(x) = x3 + x2 + x + 1
5.2. THE ADVANCED ENCRYPTION STANDARD 143
B(x) = x2 + x
A(x) = x3 + x2 + x + 1
B(x) = x2 + x
Example 5.8: Given the polynomials A(x) and B(x), each con-
tained in the Extension Field GF(24 ):
A(x) = x3 + x + 1
B(x) = x + 1
P (x) = x4 + x + 1
x4 = P (x) − x − 1
5.2. THE ADVANCED ENCRYPTION STANDARD 145
x4 = P (x) + x + 1
x4 = (x + 1) mod P (x)
C(x) = x4 + x3 + x2 + 1
C(x) = x + 1 + x3 + x2 + 1
C(x) = x3 + x2 + x + (2 mod 2)
C(x) = x3 + x2 + x
A(x) = x3 + x + 1 = 10112
B(x) = x + 1 = 00112
C(x) = x3 + x2 + x = 11102
146 CHAPTER 5. SYMMETRIC-KEY CRYPTOGRAPHY: BLOCK CIPHERS
5.2.2 Cryptosystem
K0
Rounds 1-9
Round 10
SubBytes SubBytes
ShiftRows
ShiftRows
MixColumns
Kr K10
⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞
c0 1 1 1 1 1 0 0 0 b0 0
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ c1 ⎟ ⎜ 0 1 1 1 1 1 0 0 ⎟ ⎜ ⎟ ⎜ 1 ⎟
⎜ ⎟ ⎜ ⎟ ⎜ b1 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ c2 ⎟ ⎜ 0 0 1 1 1 1 1 0 ⎟ ⎜ ⎟ ⎜ 1 ⎟
⎜ ⎟ ⎜ ⎟ ⎜ b2 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ c3 ⎟ ⎜ 0 0 0 1 1 1 1 1 ⎟ ⎜ b ⎟ ⎜ 0 ⎟
⎜ ⎟ = ⎜ ⎟⎜ 3 ⎟+⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟. (5.1)
⎜ c4 ⎟ ⎜ 1 0 0 0 1 1 1 1 ⎟ ⎜ ⎟ ⎜ 0 ⎟
⎜ ⎟ ⎜ ⎟ ⎜ b4 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ c5 ⎟ ⎜ 1 1 0 0 0 1 1 1 ⎟ ⎜ ⎟ ⎜ 0 ⎟
⎜ ⎟ ⎜ ⎟ ⎜ b5 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ c6 ⎟ ⎜ 1 1 1 0 0 0 1 1 ⎟ ⎜ b6 ⎟ ⎜ 1 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠ ⎝ ⎠
c7 1 1 1 1 0 0 0 1 b7 1
P (x) = x8 + x4 + x3 + x + 1
Because Rijndael does not have a Feistel structure and thus one
round of the cipher operates on the entire 128-bit block, each of the
encryption transformations must be inverted as part of the decryp-
tion process. Figure 5.21 details the Rijndael decryption round
structure for a 128-bit Cipher Key and thus the number of rounds
(Nr ) is once again ten. For the first round, the InvMixColumns
152 CHAPTER 5. SYMMETRIC-KEY CRYPTOGRAPHY: BLOCK CIPHERS
K10 Kr
Rounds 2-10
Round 1
InvMixColumns
InvShiftRows
InvShiftRows
InvSubBytes
InvSubBytes
K0
output with the round’s associated sub-key via the XOR operation.
AddRoundKey is its own inverse because xi ⊕ zi ⊕ zi = xi . This
equation holds true because of the XOR properties zi ⊕ zi = 0
and xi ⊕ 0 = xi .
P (x) = x8 + x4 + x3 + x + 1
(a) To create the next 4-byte word of the Expanded Key, the
previous 4-byte word of the Expanded Key is rotated one
byte to the left.
(c) The least significant byte of the 4-byte word output from
Step 3b is combined with Rcon[i] via the XOR operation.
(e) The 4-byte word N k · 4 bytes before the new 4-byte word
of the Expanded Key is combined with the 4-byte word
output from Step 3c via the XOR operation. The result
is assigned to the next 4-byte word of the Expanded Key.
NIST has published its recommendations for AES (or any other
block cipher) modes of operation, defining four specific categories
[214]:
k1
Selector
Cn
T
Mn*
MSB
e
k
...
...
M3
C3
e
k
M2
C2
e
k
M1
C1
e
k
k2
100...00
Selector
Cn
T
MSB
e
Mn*
k
...
...
C3
M3
e
k
C2
M2
e
k
C1
M1
e
k
F
TL ≥ log2
PV
5.2. THE ADVANCED ENCRYPTION STANDARD 163
F
TL ≥ log2
PV
25
TL ≥ log2 ( −30 )
2
TL ≥ log2 (235 )
TL ≥ 35
with block ciphers with 128-bit block sizes, and the only block
cipher of that type that has been approved by NIST for use in
CCM mode is AES . CCM mode accepts a three-part input [76]:
The formatting function for CCM mode requires that the bit
lengths of the Payload, Associated Information, and the Nonce be
a multiple of eight bits. These bit lengths are denoted by the
parameters p, a, and n. By extension, the MAC T must also be
a multiple of eight bits in length and the length is denoted by the
parameter t. p is represented within the first block of formatted
data as the string Q which is also a multiple of eight bits whose
length is denoted as q. Q is the binary representation of p in q
8-bit groupings. The parameter length requirements are:
5.2. THE ADVANCED ENCRYPTION STANDARD 167
4. n + q = 15.
5. a < 264 .
The first byte of the first block, B0 , contains four control flags.
Bit 7 is Reserved to enable future formatting extensions and must
be set to zero. Bit 6 represents the Adata field and is set to one if
a > 0 (the Associated Information is present); otherwise, it is set
to zero. Bits 5-3 represent the encoded MAC length. The MAC
t − 2
length t is encoded as 2
. Because the maximum value of t is
16 − 2
sixteen, the maximum value of the encoding is 2
= 4 which
fits within the 3-bit field. Bits 2-0 represent the encoded value of
q. q is encoded as q − 1, resulting in values between one and
seven and thus fitting within the 3-bit field. The remaining bytes
of B0 are used to represent the Nonce and Q. Bytes 1-(15 − q) are
dedicated to the Nonce and bytes (16 − q)-16 are dedicated to Q.
Therefore, the first block B0 indicates if there will be Associated
Information, the MAC length, the size of the Payload, and the
Nonce.
all set to zero, necessary to partition the entire string into 16-byte
blocks denoted as B1 , B2 , . . . , Bu , where the value of u depends
on a.
00000000 100000002
F
TL ≥ log2
PV
F
TL ≥ log2
PV
232
TL ≥ log2 ( −30 )
2
TL ≥ log2 (262 )
TL ≥ 62
⎛ ⎞ ⎛ ⎞⎛ ⎞
B
⎜ 0 ⎟
K
⎜ 00
K01 K02 K03 A
⎟⎜ 0 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ B1 ⎟ ⎜ K10 K11 K12 K13 ⎟ ⎜ A1 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟=⎜ ⎟⎜ ⎟ (5.2)
⎜
⎜ B2 ⎟
⎟
⎜ ⎟⎜ ⎟
⎜ K20 K21 K22 K23 ⎟ ⎜ A2 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠
B3 K30 K31 K32 K33 A3
b(x) = a7 x8 + a6 x7 + a5 x6 + a4 x5 + a3 x4 + a2 x3 + a1 x2 +
a0 x mod p(x)
⎛ ⎞ ⎛ ⎞⎛ ⎞
b0 0 0 0 0 0 0 0 1 a0
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b1 ⎟ ⎜ 1 0 0 0 0 0 0 1 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a1 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b2 ⎟ ⎜ 0 1 0 0 0 0 0 0 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a2 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b3 ⎟ ⎜ 0 0 1 0 0 0 0 1 ⎟ ⎜ a ⎟
⎜ ⎟ = ⎜ ⎟⎜ 3 ⎟ (5.3)
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b4 ⎟ ⎜ 0 0 0 1 0 0 0 1 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a4 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b5 ⎟ ⎜ 0 0 0 0 1 0 0 0 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a5 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b6 ⎟ ⎜ 0 0 0 0 0 1 0 0 ⎟ ⎜ a6 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠
b7 0 0 0 0 0 0 1 0 a7
⎛ ⎞ ⎛ ⎞⎛ ⎞
b0 1 0 0 0 0 0 0 0 a0
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b1 ⎟ ⎜ 0 1 0 0 0 0 0 0 ⎟⎜ a1 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b2 ⎟ ⎜ 0 0 1 0 0 0 0 0 ⎟⎜ a2 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b3 ⎟ ⎜ 0 0 0 1 0 0 0 0 ⎟⎜ a3 ⎟
⎜ ⎟ = ⎜ ⎟⎜ ⎟ (5.4)
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b4 ⎟ ⎜ 0 0 0 0 1 0 0 0 ⎟⎜ a4 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b5 ⎟ ⎜ 0 0 0 0 0 1 0 0 ⎟⎜ a5 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b6 ⎟ ⎜ 0 0 0 0 0 0 1 0 ⎟⎜ a6 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠
b7 0 0 0 0 0 0 0 1 a7
5.2. THE ADVANCED ENCRYPTION STANDARD 179
⎛ ⎞ ⎛ ⎞⎛ ⎞
b0 1 0 0 0 0 0 0 1 a0
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b1 ⎟ ⎜ 1 1 0 0 0 0 0 1 ⎟⎜ a1 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b2 ⎟ ⎜ 0 1 1 0 0 0 0 0 ⎟⎜ a2 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b3 ⎟ ⎜ 0 0 1 1 0 0 0 1 ⎟⎜ a3 ⎟
⎜ ⎟ = ⎜ ⎟⎜ ⎟ (5.5)
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b4 ⎟ ⎜ 0 0 0 1 1 0 0 1 ⎟⎜ a4 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b5 ⎟ ⎜ 0 0 0 0 1 1 0 0 ⎟⎜ a5 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b6 ⎟ ⎜ 0 0 0 0 0 1 1 0 ⎟⎜ a6 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠
b7 0 0 0 0 0 0 1 1 a7
⎛ ⎞ ⎛ ⎞⎛ ⎞
b0 1 0 0 0 0 1 0 0 a0
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b1 ⎟ ⎜ 0 1 0 0 0 1 1 0 ⎟⎜ a1 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b2 ⎟ ⎜ 0 0 1 0 0 0 1 1 ⎟⎜ a2 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b3 ⎟ ⎜ 1 0 0 1 0 1 0 1 ⎟⎜ a3 ⎟
⎜ ⎟ = ⎜ ⎟⎜ ⎟ (5.6)
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b4 ⎟ ⎜ 0 1 0 0 1 1 1 0 ⎟⎜ a4 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b5 ⎟ ⎜ 0 0 1 0 0 1 1 1 ⎟⎜ a5 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b6 ⎟ ⎜ 0 0 0 1 0 0 1 1 ⎟⎜ a6 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠
b7 0 0 0 0 1 0 0 1 a7
⎛ ⎞ ⎛ ⎞⎛ ⎞
b0 1 0 0 0 0 1 0 1 a0
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b1 ⎟ ⎜ 1 1 0 0 0 1 1 1 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a1 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b2 ⎟ ⎜ 0 1 1 0 0 0 1 1 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a2 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜
⎜ b3 ⎟ ⎜ 1 0 1 1 0 1 0 0 ⎟ ⎜ ⎟
⎟ ⎜ a3 ⎟
⎜ ⎟ = ⎜ ⎟⎜ ⎟ (5.7)
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b4 ⎟ ⎜ 0 1 0 1 1 1 1 1 ⎟ ⎜ a4 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b5 ⎟ ⎜ 0 0 1 0 1 1 1 1 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a5 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b6 ⎟ ⎜ 0 0 0 1 0 1 1 1 ⎟ ⎜ a6 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠
b7 0 0 0 0 1 0 1 1 a7
⎛ ⎞ ⎛ ⎞⎛ ⎞
b0 1 0 0 0 0 1 1 0 a0
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b1 ⎟ ⎜ 0 1 0 0 0 1 0 1 ⎟⎜ a1 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b2 ⎟ ⎜ 1 0 1 0 0 0 1 0 ⎟⎜ a2 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b3 ⎟ ⎜ 1 1 0 1 0 1 1 1 ⎟⎜ a3 ⎟
⎜ ⎟ = ⎜ ⎟⎜ ⎟ (5.8)
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b4 ⎟ ⎜ 0 1 1 0 1 1 0 1 ⎟⎜ a4 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b5 ⎟ ⎜ 0 0 1 1 0 1 1 0 ⎟⎜ a5 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b6 ⎟ ⎜ 0 0 0 1 1 0 1 1 ⎟⎜ a6 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠
b7 0 0 0 0 1 1 0 1 a7
182 CHAPTER 5. SYMMETRIC-KEY CRYPTOGRAPHY: BLOCK CIPHERS
⎛ ⎞ ⎛ ⎞⎛ ⎞
b0 0 0 0 0 0 1 1 1 a0
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b1 ⎟ ⎜ 1 0 0 0 0 1 0 0 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a1 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b2 ⎟ ⎜ 1 1 0 0 0 0 1 0 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a2 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜
⎜ b3 ⎟
⎟
⎜
⎜ 1 1 1 0 0 1 1 0 ⎟ ⎜ ⎟
⎟ ⎜ a3 ⎟
⎜ ⎟ = ⎜ ⎟⎜ ⎟ (5.9)
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b4 ⎟ ⎜ 0 1 1 1 0 1 0 0 ⎟ ⎜ a4 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b5 ⎟ ⎜ 0 0 1 1 1 0 1 0 ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟ ⎜ a5 ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜ b6 ⎟ ⎜ 0 0 0 1 1 1 0 1 ⎟ ⎜ a6 ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠
b7 0 0 0 0 1 1 1 0 a7
n
(composed of linear trails) significantly larger than 2 2 where n
is the block size. In the case of Rijndael the correlations must be
significantly larger than 264 to be of concern. It has been proven
for Rijndael that no 4-round differential trails exist with propa-
gation ratios greater than 2−75 and no 8-round differential trails
exist with correlations greater than 2−150 for all block lengths [57].
Thus, Rijndael has sufficient strength to resist Linear Cryptanal-
ysis attacks.
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY aes_128_cbc IS
PORT ( plaintext : IN std_logic_vector (127 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
loadkey : IN std_logic;
loadiv : IN std_logic;
valid : OUT std_logic;
keygendone : OUT std_logic;
ciphertext : OUT std_logic_vector (127 DOWNTO 0));
END aes_128_cbc;
ARCHITECTURE behav OF aes_128_cbc IS
BEGIN
-- Your code goes here
END behav;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY aes_128_ecb IS
PORT ( plaintext : IN std_logic_vector (127 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
loadkey : IN std_logic;
valid : OUT std_logic;
keygendone : OUT std_logic;
ciphertext : OUT std_logic_vector (127 DOWNTO 0));
END aes_128_ecb;
ARCHITECTURE behav OF aes_128_ecb IS
BEGIN
-- Your code goes here
END behav;
mode. Write a user interface that queries the user for an input
file that contains the key, K, the Initialization Vector, IV, and five
plaintexts P0 — P4 , in hexadecimal notation. The program must
output the five ciphertexts to the screen in hexadecimal notation
and include code that measures the time required to encrypt each
of the five ciphertexts, outputting this information to the screen.
Specify the computer model used and the amount of available
RAM.
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY aes_128_ecb_single IS
PORT ( plaintext : IN std_logic_vector (127 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
loadkey : IN std_logic;
valid : OUT std_logic;
keygendone : OUT std_logic;
ciphertext : OUT std_logic_vector (127 DOWNTO 0));
END aes_128_ecb_single;
ARCHITECTURE behav OF aes_128_ecb_single IS
BEGIN
-- Your code goes here
END behav;
Public-Key Cryptography
195
196 CHAPTER 6. PUBLIC-KEY CRYPTOGRAPHY
KAD
A D
KAB KCD
K
AC
B C KBD
KBC
based on the idea that what was previously the master key, k, in
a symmetric-key cryptosystem could be split into two parts. The
first part, known as the Public Key (denoted as KP U B ), is used
to encrypt information and the second part, known as the Private
Key (denoted as KP R ), is used to decrypt information [70]. This
idea transformed the symmetric-key cryptosystem locked cabinet
analogy to the public-key cryptosystem analogy of a post office
mailbox; anyone can deposit information into the mailbox, but
only one party can unlock the mailbox and withdraw the informa-
tion. Information deposits occur using the public key and informa-
tion withdrawals occur using the private key. The basic public-key
protocol for Alice to encrypt and transmit information to Bob is
as follows:
1. Integer Factorization
2. Discrete Logarithms
3. Elliptic Curves
Example 6.1: Compute the gcd(39, 12) using the Euclidean Al-
gorithm.
6.4. THE EUCLIDEAN ALGORITHM 201
r0 = q1 · r1 + r2 → r2 = 1 · r0 + −q1 · r1
= s2 · r0 + t2 · r1
r1 = q2 · r2 + r3 → r3 = r1 - q2 · r2
= r1 - q2 (r0 − q1 · r1 )
= −q2 · r0 + (1 + q1 · q2 ) · r1
= s3 · r0 + t3 · r1
.. ..
. .
ri − 2 = qi − 1 · ri − 1 + ri → ri = si · r0 + ti · r1
ri − 1 = qi · ri + ri + 1 → ri + 1 = si + 1 · r0 + ti + 1 · r1
ri = qi + 1 · ri + 1 + ri + 2 → ri + 2 = si + 2 · r0 + ti + 2 · r1
.. ..
. .
rm − 2 = qm − 1 · rm − 1 + rm → rm = sm · r0 + tm · r1
rm − 1 = qm · rm + 0 → s = sm , t = tm
s · m + t · a = 1
t · a = (−s) · m + 1
Example 6.3: Compute the inverse of 139 mod 586 using the
Extended Euclidean Algorithm.
586 = 4 · 139 + 30 t2 = t0 − q1 · t1 = 0 - 4 · 1 = -4
139 = 4 · 30 + 19 t3 = t1 − q2 · t2 = 1 - 4 · -4 = 17
30 = 1 · 19 + 11 t4 = t2 − q3 · t3 = -4 - 1 · 17 = -21
19 = 1 · 11 + 8 t5 = t3 − q4 · t4 = 17 - 1 · -21 = 38
11 = 1 · 8 + 3 t6 = t4 − q5 · t5 = -21 - 1 · 38 = -59
8=2·3+2 t7 = t5 − q6 · t6 = 38 - 2 · -59 = 156
3=1·2+1 t8 = t6 − q7 · t7 = -59 - 1 · 156 = -215
2=2·1+0
1. g ← 1
(a) r0 ← r0 /2
(b) r1 ← r1 /2
(c) g ← 2 · g
3. u ← r0 , v ← r1 , A ← 1, B ← 0, C ← 0, D ← 1
4. While u is even:
(a) u ← u/2
i. A ← A/2
ii. B ← B/2
Else
i. A ← (A + r1 )/2
ii. B ← (B − r0 )/2
5. While v is even:
(a) v ← v/2
i. C ← C/2
ii. D ← D/2
Else
206 CHAPTER 6. PUBLIC-KEY CRYPTOGRAPHY
i. C ← (C + r1 )/2
ii. D ← (D − r0 )/2
6. If u ≥ v Then
(a) u ← u − v
(b) A ← A − C
(c) B ← B − D
Else
(a) v ← v − u
(b) C ← C − A
(c) D ← D − B
7. If u = 0 Then
(a) gcd(r1 , r0 ) = v · g
(b) If the gcd(r1 , r0 ) = 1 then r1−1 mod r0 ≡ D mod r0
Else go to Step 4
gcd(0, 7) = 7
gcd(1, 7) = 1
gcd(2, 7) = 1
gcd(3, 7) = 1
gcd(4, 7) = 1
gcd(5, 7) = 1
gcd(6, 7) = 1
Therefore, φ(7) is 6.
212 CHAPTER 6. PUBLIC-KEY CRYPTOGRAPHY
gcd(0, 8) = 8
gcd(1, 8) = 1
gcd(2, 8) = 2
gcd(3, 8) = 1
gcd(4, 8) = 4
gcd(5, 8) = 1
gcd(6, 8) = 2
gcd(7, 8) = 1
Therefore, φ(8) is 4.
Show every iteration step of the algorithm and for every gcd pro-
vide the chain gcd(r0 , r1 ) = gcd(r1 , r2 ) = . . .
a) a = 7, m = 26
b) a = 19, m = 999
4. Write a user interface that queries the user for r0 and r1 and
returns the values for s, t, and gcd(r0 , r1 ) after calling the
function.
218 CHAPTER 6. PUBLIC-KEY CRYPTOGRAPHY
a) m is prime.
Verify your formulae for m = 12, 15, 26 with the results from
Homework Problem 6.9.6.
a) m = 12, 111
b) m = 12, 553
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY bin_euc IS
PORT ( r0, r1 : IN std_logic_vector (15 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
load : IN std_logic;
gvalid : OUT std_logic;
ivalid : OUT std_logic;
gcd : OUT std_logic_vector (15 DOWNTO 0);
r1inverse : OUT std_logic_vector (15 DOWNTO 0));
END bin_euc;
ARCHITECTURE behav OF bin_euc IS
BEGIN
-- Your code goes here
END behav;
6.9. HOMEWORK PROBLEMS 221
Use the results from Examples 6.4, 6.5, 6.6, and 6.7 to validate
your design. Specify the target technology used to implement
the design and the maximum operating frequency as specified by
your place-and-route tools. What is the execution time of your
implementation for each of the four examples?
Public-Key Cryptography:
RSA
7.1 Cryptosystem
2. Compute n = p · q.
223
224 CHAPTER 7. PUBLIC-KEY CRYPTOGRAPHY: RSA
Once the private and public keys have been established, en-
cryption of the plaintext x to form the ciphertext y is performed
as follows:
to calculate his private and public keys. Also show the result of
Alice’s encryption of x using Bob’s public key and the result of
Bob’s decryption of y using his own private key.
1. n = 5 · 17 = 85.
− 1) · (q − 1) w
dKP R (y) = (x(p ) · x mod n
· (q − 1) w
dKP R (y) = (xφ(p) ) · x mod n
− 1) w
dKP R (y) = ((xφ(p) )(q ) · x mod n
7.2.2 Exponentiation
x2 = x · x
x 3 = x2 · x
x 4 = x3 · x
..
.
z = x ; i4 = 1
z = x · x = x2 = x102 ; i3 = 0
z = x2 · x2 = x4 = x1002 ; i2 = 0
z = x4 · x4 = x8 = x10002 ; i1 = 0
z = x8 · x8 = x16 = x100002
z = x16 · x = x17 = x100012 ; i0 = 1
7.2. EFFICIENT IMPLEMENTATION 233
z = x ; i4 = 1
z = x · x = x2 = x102 ; i3 = 0
z = x2 · x2 = x4 = x1002
z = x4 · x = x5 = x1012 ; i2 = 1
z = x5 · x5 = x10 = x10102
z = x10 · x = x11 = x10112 ; i1 = 1
z = x11 · x11 = x22 = x101102
z = x22 · x = x23 = x101112 ; i0 = 1
z = x ; i6 = 1
z = x · x = x2 = x102 ; i5 = 0
z = x2 · x2 = x4 = x1002
z = x4 · x = x5 = x1012 ; i4 = 1
z = x5 · x5 = x10 = x10102
z = x10 · x = x11 = x10112 ; i3 = 1
z = x11 · x11 = x22 = x101102 ; i2 = 0
z = x22 · x22 = x44 = x1011002
z = x44 · x = x45 = x1011012 ; i1 = 1
z = x45 · x45 = x90 = x10110102
z = x90 · x = x91 = x10110112 ; i0 = 1
1. z = x
2. For k = (l − 2) Downto 0
(a) z = z · z mod n
z = x0102 = x2
z = x2 · x2 = x4 = x010 02
z = x4 · x4 = x8 = x010 002
The k-ary Method requires a total of four squarings and six multi-
plications to compute x17 . Example 7.2 required four squarings
and one multiplications to compute x17 . Therefore, in this case
the Square-and-Multiply Algorithm performs better than the k-ary
Method for k = 3.
z = x0102 = x2
z = x2 · x2 = x4 = x010 02
z = x4 · x4 = x8 = x010 002
The k-ary Method requires a total of four squarings and six multi-
plications to compute x23 . Example 7.3 required four squarings
and three multiplications to compute x23 . Therefore, in this case
the Square-and-Multiply Algorithm performs better than the k-ary
Method for k = 3.
z = x0012 = x
z = x · x = x2 = x001 02
z = x2 · x2 = x4 = x001 002
z = x4 · x4 = x8 = x001 0002
z = x112 = x3
z = x3 · x3 = x6 = x11 02
z = x0012 = x
z = x · x = x2 = x001 02
z = x2 · x2 = x4 = x001 002
z = x4 · x4 = x8 = x001 0002
The k-ary Method requires a total of nine squarings and five multi-
plications to compute x1023 for k = 2 and a total of ten squarings
and eight multiplications for k = 3. The Square-and-Multiply
Algorithm requires eight squarings and eight multiplications to
compute x1023 . Therefore, in this case the Square-and-Multiply
Algorithm performs better than the k-ary Method for k = 3, but
the k-ary Method performs better than the Square-and-Multiply
Algorithm for k = 2. In the latter case, if a squaring is consid-
ered equivalent to a multiplication, the k-ary Method outperforms
the Square-and-Multiply Algorithm by two multiplications.
244 CHAPTER 7. PUBLIC-KEY CRYPTOGRAPHY: RSA
Examples 7.7, 7.8, 7.9, and 7.10 demonstrate that the perfor-
mance of the k-ary Method versus the Square-and-Multiply Algo-
rithm is dependent upon both the number of bits in the exponent
i versus the value chosen for k and how many of the bits in the ex-
ponent i are one. Moreover, the additional squaring and multipli-
cations incurred as part of the precomputation stage significantly
impact the performance of the k-ary Method versus the Square-
and-Multiply Algorithm for exponents with short bit lengths.
3. A = 1
7.2. EFFICIENT IMPLEMENTATION 251
4. While j ≥ 0:
(a) If ij = 0 Then
ii. j = j − 1
(b) Else
z = 1
l
operations required for each method and that t = k
, the k-ary
Method has a complexity of (c · l2 ) · (l − k + 2k − 2 + ( kl −
2k − 1
1) · 2k
) while the Improved k-ary Method has a complexity
− 1 2k − 1
of (c · l ) · (l − k + 2k
2
+ ( kl − 1) · 2k
). Clearly,
the complexity of these methods are highly dependent upon k, the
window size of the groupings of bits of the exponent i.
X Y = f(X) mod M Y
T T–1
yi = f(xi) mod mi
(x1, x2, x3, ..., xt) (y1, y2, y3, ..., yt)
t
Y = yi · Mi · ci mod mi
i=1
Y = yi · Mi · ci mod mi
Y = (yi mod mi ) · (Mi · ci mod mi )
t
Thus, because Y = yi mod mi is true for all i, Y = i=1 yi ·
Mi · ci mod M must be true and the inverse transformation must
also hold true.
X Y = Xa mod n Y
T T–1
− 1) + ap
xap mod p = xi(p
p
and
− 1) + aq
xaq mod q = xj(q
q
− 1)i
xap mod p = x(p
p · xapp
and
− 1)j
xaq mod q = x(q
q · xaq q
− 1
However, according to Fermat’s Little Theorem, ap ≡ 1 mod p
if the gcd(a, p) = 1, which must be the case if p is prime. There-
fore, xap mod p ≡ xapp mod p and xaq mod q ≡ xaq q mod p, where
ap ≡ a mod (p − 1) and aq ≡ a mod (q − 1). xap mod p and
xaq mod q may be computed using the Square-and-Multiply Algo-
rithm or any of the other fixed exponent exponentiation methods
described in Section 7.2.2.
7.2. EFFICIENT IMPLEMENTATION 259
M = n
Mp = n/p = q
Mq = n/q = p
cp = Mp−1 mod p = q −1 mod p
cq = Mq−1 mod q = p−1 mod q
− 1
qp ≡ 1 mod p
and
− 1
pq ≡ 1 mod q
if the gcd(q, p) = 1, which must be the case because both p and
q are prime numbers. Expanding on these relationships yields:
− 2
q · qp ≡ 1 mod p
260 CHAPTER 7. PUBLIC-KEY CRYPTOGRAPHY: RSA
and
− 2
p · pq ≡ 1 mod q
q −1 mod p ≡ q p − 2
mod p = cp
and
p−1 mod q ≡ pq − 2
mod q = cq
bp = a mod (p − 1) = 7 mod 16
bq = a mod (q − 1) = 7 mod 18
The vector (yp , yq ) must then pass through the inverse transforma-
tion to yield the ciphertext y. The inverse transformation requires
the precomputation of Mp , Mq , cp , and cq :
Mp = n/p = q = 19
Mq = n/q = p = 17
cp = Mp−1 mod p = q −1 mod p = 19−1 mod 17 ≡ 9 mod 17
cq = Mq−1 mod q = p−1 mod q = 17−1 mod 19 ≡ 9 mod 19
262 CHAPTER 7. PUBLIC-KEY CRYPTOGRAPHY: RSA
y = yp · q · cp + yq · p · cq mod n
y = 13 · 171 + 14 · 153 mod 323
y = 2, 223 + 2, 142 mod 323
y = 166 mod 323
The vector (xp , xq ) must then pass through the inverse trans-
formation to yield the plaintext x. The inverse transformation
requires the precomputation of Mp , Mq , cp , and cq :
Mp = n/p = q = 19
Mq = n/q = p = 17
cp = Mp−1 mod p = q −1 mod p = 19−1 mod 17 ≡ 9 mod 17
cq = Mq−1 mod q = p−1 mod q = 17−1 mod 19 ≡ 9 mod 19
x = xp · q · cp + xq · p · cq mod n
x = 4 · 171 + 2 · 153 mod 323
x = 684 + 306 mod 323
x = 21 mod 323
l2
is c · ( 2l )2 = c · 4
, where c is a constant. The Square-
and-Multiply Algorithm requires 1.5 · ( 2l − 1) operations and
two exponentiations must be performed to compute xp and xq ,
l2
resulting in a total of 2 · 1.5 · ( 2l − 1) · c · 4
≈ 1.5 ·
l3
c· 4
operations. Exponentiation without the Chinese Remainder
Theorem requires 1.5 · c · l3 operations. Therefore the speed-
up associated with the use of the Chinese Remainder Theorem is
1.5 · c · l3
3 = 4.
1.5 · c · l4
W Bits
D = D0 + D1 · 2w + D2 · 22w + . . . +
Dn−1 · 2(n−1)w + Dn · 2nw
7.2.4.1 Addition
X = (Xn , Xn−1 , . . . X1 , X0 )b
Y = (Ym , Ym−1 , . . . Y1 , Y0 )b
Z = (Zn + 1 , Zn , Zn − 1, . . . Z1 , Z0 )b
1. C = 0
2. For i = 0 T o n
(a) zi = xi + yi + C mod b
(b) If zi = xi + yi + C < b Then C = 0
(c) Else C = 1
3. zn + 1 = C
7.2.4.2 Multiplication
X = (Xn , Xn−1 , . . . X1 , X0 )b
Y = (Ym , Ym−1 , . . . Y1 , Y0 )b
− 1
X = x n · bn + xn − 1 · bn + . . . x1 · b + x0
− 1
Y = ym · b m + y m − 1 · bm + . . . y1 · b + y0
7.2. EFFICIENT IMPLEMENTATION 269
Z = X· Y
Z = x n · ym · b n + m
+
+ m − 1
(xn · ym − 1 + xn − 1 · ym ) · bn + ... +
x0 · y 0
X = x3 · b3 + x2 · b2 + x1 · b + x0
Y = y3 · b 3 + y 2 · b 2 + y 1 · b + y 0
Z= X · Y
Z= x3 · y3 · b6 + x3 · y2 · b5 + x3 · y1 · b4 + x3 · y0 · b 3 +
x2 · y3 · b5 + x2 · y2 · b4 + x2 · y1 · b3 + x2 · y0 · b 2 +
x1 · y3 · b4 + x1 · y2 · b3 + x1 · y1 · b2 + x1 · y0 · b +
x0 · y3 · b3 + x0 · y2 · b2 + x0 · y1 · b1 + x0 · y0
Z= x3 · y3 · b6 + (x3 · y2 + x2 · y3 ) · b5 +
(x3 · y1 + x2 · y2 + x1 · y3 ) · b4 +
(x3 · y0 + x2 · y1 + x1 · y2 + x0 · y3 ) · b3 +
(x2 · y0 + x1 · y1 + x0 · y2 ) · b2 +
(x1 · y0 + x0 · y1 ) · b + x0 · y0
270 CHAPTER 7. PUBLIC-KEY CRYPTOGRAPHY: RSA
X = (Xn , Xn−1 , . . . X1 , X0 )b
Y = (Ym , Ym−1 , . . . Y1 , Y0 )b
1. W = 0
2. For i = 0 T o t
(a) C = 0
(b) For j = 0 T o n
i. (u, v)b = xj · yi + wi + j + c
ii. wi + j = v
iii. c = u
(c) wi + j + 1 = u
7.2.4.3 Squaring
Z = X2
− 1
Z = xn · xn · b2n + (xn · xn − 1 + xn − 1 · xn ) · b2n +
. . . + x20
X = x3 · b3 + x2 · b2 + x1 · b + x 0
Compute Z = X 2 .
Z is computed as:
Z= X2
Z= x3 · x3 · b6 + x3 · x2 · b5 + x3 · x1 · b4 + x3 · x0 · b3 +
x2 · x3 · b5 + x2 · x2 · b4 + x2 · x1 · b3 + x2 · x0 · b2 +
x1 · x3 · b4 + x1 · x2 · b3 + x1 · x1 · b2 + x1 · x0 · b +
x0 · x3 · b3 + x0 · x2 · b2 + x0 · x1 · b1 + x0 · x0
Z= x23 · b6 + (2 · x3 · x2 ) · b5 + (2 · x3 · x1 + x22 ) · b4 +
(2 · x3 · x0 + 2 · x2 · x1 ) · b3 + (2 · x2 · x0 + x21 ) · b2 +
(2 · x1 · x0 ) · b + x20
7.2. EFFICIENT IMPLEMENTATION 273
W = (w2n + 1, w2n , . . . w1 , w0 )b
1. W = 0
2. For i = 0 T o n
a, b c = a · b mod M c
T T–1
~
c~ = f(a~ · b )
~ ~
a, b c~
1. gcd(m, R) = 1
2. m = −m−1 mod R
3. 0 ≤ T < R · m
1. U ≡ T · m mod R
2. t = (T + U · m)/R
3. If t ≥ m Then M Red(T ) = t − m
4. Else M Red(T ) = t
7.2. EFFICIENT IMPLEMENTATION 277
U ≡ T · m mod R
U · m ≡ (T · m ) · m mod R
U · m ≡ (T · −m−1 ) · m mod R
U · m ≡ −T mod R
U · m ≡ h · R − T
t = (T + U · m)/R
t = (T + [h · R − T ])/R
t = [h · R]/R
t = h
278 CHAPTER 7. PUBLIC-KEY CRYPTOGRAPHY: RSA
t = (T + U · m)/R
t · R = T + U · m
t · R ≡ T mod m
Step 1
U ≡ T · m mod R
U ≡ 7 · 67 mod 100
U ≡ 469 mod 100
U ≡ 69 mod 100
Step 2
t = (T + U · m)/R
t = (7 + 69 · 97)/100
t = (7 + 6693)/100
t = 6700/100
t = 67
Step 3
t = T · R−1 mod m
t = 7 · 65 mod 97
t = 455 mod 97
t ≡ 67 mod 97
280 CHAPTER 7. PUBLIC-KEY CRYPTOGRAPHY: RSA
ã = a · R mod m
b̃ = b · R mod m
ã · b̃ = a · b · R2 mod m
ã · b̃ = c · R2 mod m
a, b c = a · b mod M c
T T–1
~
c~ = MRed(a~ · b )
~ ~ ~
a, b c
c · R mod m = c̃
c · R · R−1 mod m = c̃ · R−1 mod m
c mod m = c̃ · R−1 mod m
c mod m = M Red(c̃)
~
T T–1 = MRed(x)
Exponentiation
~ with MRed ~i
x = x · R mod n x mod n
1. A = T
2. For i = 0 T o n − 1
(a) ui = ai · m mod b
(b) A = A + ui · m · bi
7.2. EFFICIENT IMPLEMENTATION 283
3. A = A/bn
4. If A ≥ m Then A = A − m
7.2.4.5 Inversion
X = (Xn − 1, Xn − 2, . . . X1 , X0 )b
Y = (Yn − 1, Yn − 2, . . . Y1 , Y0 )b
− 1
X = xn − 1 · bn + . . . x1 · b + x0
− 1
Y = yn − 1 · bn + . . . y1 · b + y0
− 2
Z = xn − 1 · yn − 1 · b2n +
− 3
(xn − 1 · yn − 2 + xn − 2 · yn − 1) · b2n + ...
+ x0 · y 0
A = a1 · x + a 0
B = b1 · x + b0
C = a1 · b1 · x2 + (a1 · b0 + a0 · b1 ) · x + a0 · b0
1. D0 = a0 · b0
2. D1 = (a0 + a1 ) · (b0 + b1 )
3. D2 = a1 · b1
C = D2 · x2 + (D1 − D0 − D2 ) · x + D0
7.2. EFFICIENT IMPLEMENTATION 287
− 1
A(x) = an − 1 · xn + ... +
n n
− 1
a n2 · x 2 + a n2 − 1 · x2 + ... +
a0
n
− 1
Ah (x) = an − 1 · x2 + . . . + a n2
n
− 1
Al (x) = a n2 − 1 · x2 + . . . + a0
n
then A(x) = Ah (x) · x 2 + Al (x). B(x) may be represented in
a similar manner, resulting in:
n2
The complexity of each multiplication is ( n2 )2 = 4
. Using the
straightforward method results in four multiplications for a total
n2
complexity of 4 · 4
= n2 . Using the Karatsuba-Ofman Multi-
plication Algorithm to compute C(x) yields:
C(x) = D2 (x) · xn +
n
(D1 (x) − D0 (x) − D2 (x)) · x 2 +
D0 (x)
n2
The complexity of each multiplication is ( n2 )2 = 4
. Using the
Karatsuba-Ofman Multiplication Algorithm results in three multi-
n2
plications for a total complexity of 3 · 4
. The Karatsuba-Ofman
Multiplication Algorithm may be applied in a recursive manner to
the three multiplications contained in each of the three interme-
diate values, D0 (x), D1 (x), and D2 (x), resulting in each having a
3 · n2
complexity of 3 · ( n4 )2 = 16
. Therefore, the total complexity
3 · n2
is 3 · 16
= ( 34 )2 · n ≈ 0.56 · n2 . If n = 2i , a likely char-
2
7.2.6 Performance
7.3 Attacks
a) x = 2, e = 79, m = 101
b) x = 3, e = 197, m = 101
a) p = 3, q = 11, a = 7, x = 5
b) p = 5, q = 11, b = 3, x = 9
tocol using the RSA cryptosystem that will allow the two parties,
Alice and Bob, to agree on a shared secret key. Who determines
the key in this protocol — Alice, Bob, or both?
b) Decrypt the ciphertext 182, 67, 67, 182, 84, 147 encrypted
using the RSA cryptosystem with n = 221 and b = 5 without
factoring the modulus n.
b) Use the valid b from part (a) and provide the public key
KP U B = (n, b) and the private key KP R = (p, q, a).
y = 5219 6736 5906 7685 5149 7563 7563 5149 0 6996 8069
Provide a table that shows the number of Inner Products for each
of the five cases as a percentage relative to the straightforward
7.4. HOMEWORK PROBLEMS 305
method. Why is it not possible for more than five iterations of the
Karatsuba-Ofman Multiplication Algorithm to be used?
A(x) = a3 · x3 + a2 · x2 + a1 · x + a0
B(x) = b3 · x3 + b2 · x2 + b1 · x + b0
d) Redo parts (b) and (c) considering exponents with 256 bits
and exponents with 1,024 bits.
k = k = k = k = kopt
Method S M t S M t S M t S M t
Sq-and-Mul
k-ary
Imp k-ary
Slid Win
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY rsa_4 IS
PORT ( n, b, x : IN std_logic_vector (3 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
pload : IN std_logic;
xload : IN std_logic;
valid : OUT std_logic;
y : OUT std_logic_vector (3 DOWNTO 0));
END rsa_4;
ARCHITECTURE behav OF rsa_4 IS
BEGIN
-- Your code goes here
END behav;
310 CHAPTER 7. PUBLIC-KEY CRYPTOGRAPHY: RSA
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY rsa_8 IS
PORT ( n, b, x : IN std_logic_vector (7 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
pload : IN std_logic;
xload : IN std_logic;
valid : OUT std_logic;
y : OUT std_logic_vector (7 DOWNTO 0));
END rsa_8;
ARCHITECTURE behav OF rsa_8 IS
BEGIN
-- Your code goes here
END behav;
Public-Key Cryptography:
Discrete Logarithms
1. A set of elements.
313
314CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
Example 8.1: If the set of all integers and the binary operation
= +, i.e. addition, are used, does the set of all integers and
= + form a Group?
Example 8.2: If the set of all integers and the binary operation
= ×, i.e. multiplication, are used, does the set of all integers
and = × form a Group?
∗
Example 8.5: What are the elements of Z15 ?
∗
Z15 = {1, 2, 4, 7, 8, 11, 13, 14}
∗
Example 8.6: What are the elements of Z17 ?
∗
Z17 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
∗
Example 8.7: Construct the multiplication table of Z15 .
8.1. CYCLIC GROUPS 317
Multiplication
× mod 15 1 2 4 7 8 11 13 14
1 1 2 4 7 8 11 13 14
2 2 4 8 14 1 7 11 13
4 4 8 1 13 2 14 7 11
7 7 14 13 4 11 2 1 8
8 8 1 2 11 4 13 14 7
11 11 7 14 2 13 1 8 4
13 13 11 7 1 14 8 4 2
14 14 13 11 8 7 4 2 1
∗
|(Z15 , ×)| = 8
|(Zp∗ , ×)| = p − 1
318CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
51 mod 7 = 5 mod 7
52 mod 7 = 5 · 5 mod 7 = 25 mod 7 ≡ 4 mod 7
53 mod 7 = 5 · 4 mod 7 = 20 mod 7 ≡ 6 mod 7
54 mod 7 = 5 · 6 mod 7 = 30 mod 7 ≡ 2 mod 7
55 mod 7 = 5 · 2 mod 7 = 10 mod 7 ≡ 3 mod 7
56 mod 7 = 5 · 3 mod 7 = 15 mod 7 ≡ 1 mod 7
14 = 1 mod 5
24 = 16 mod 5 ≡ 1 mod 5
34 = 81 mod 5 ≡ 1 mod 5
8.1. CYCLIC GROUPS 321
21 mod 17 = 2 mod 17
22 mod 17 = 2 · 2 mod 17 = 4 mod 17
23 mod 17 = 2 · 4 mod 17 = 8 mod 17
24 mod 17 = 2 · 8 mod 17 = 16 mod 17
25 mod 17 = 2 · 16 mod 17 = 32 mod 17 ≡ 15 mod 17
26 mod 17 = 2 · 15 mod 17 = 30 mod 17 ≡ 13 mod 17
27 mod 17 = 2 · 13 mod 17 = 26 mod 17 ≡ 9 mod 17
28 mod 17 = 2 · 9 mod 17 = 18 mod 17 ≡ 1 mod 17
∗
Therefore, the Subgroup of the Cyclic Group formed by the set Z17
and the multiplication operation formed by repeatedly applying
the multiplication operation to the element 2 is {1, 2, 4, 8, 9,
13, 15, 16} and thus the element 2 is a primitive element of the
Subgroup. Because the element 2 has an order of eight, there are
eight elements in the Subgroup.
Multiplication
× mod 17 1 2 4 8 9 13 15 16
1 1 2 4 8 9 13 15 16
2 2 4 8 16 1 9 13 15
4 4 8 16 15 2 1 9 13
8 8 16 15 13 4 2 1 9
9 9 1 2 4 13 15 16 8
13 13 9 1 2 15 16 8 4
15 15 13 9 1 16 8 4 2
16 16 15 13 9 8 4 2 1
∗
Therefore, the Subgroup of the Cyclic Group formed by the set Z17
and the multiplication operation formed by repeatedly applying
the multiplication operation to the element 16 is {1, 16} and thus
the element 16 is a primitive element of the Subgroup. Because
the element 16 has an order of two, there are two elements in the
Subgroup.
324CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
Multiplication
× mod 17 1 16
1 1 16
16 16 1
Example 8.19: Given the Cyclic Group formed by the set Z17
and the addition operation, the primitive element α = 3, and
β = i × α mod 17 = 16. Solve the Discrete Logarithm problem
for i.
8.2. THE DISCRETE LOGARITHM PROBLEM 325
∗
Example 8.20: Given the Cyclic Group formed by the set Z17
and the multiplication operation, the primitive element α = 3,
and β = αi mod 17 = 7. Solve the Discrete Logarithm problem
for the exponent i.
31 mod 7 = 3 mod 17
32 mod 7 = 3 · 3 mod 17 = 9 mod 17
33 mod 7 = 3 · 9 mod 17 = 27 mod 17 ≡ 10 mod 17
326CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
For the Cyclic Group formed by Zp∗ and the multiplication op-
eration, the set-up stage proceeds as follows:
wish to communicate.
2 Compute Compute
KP U BA = bA = αaA mod p KP U BB = bB = αaB mod p
4 Compute Compute
a a
KAB = bBA mod p KAB = bAB mod p
= (αaB )aA mod p = αaA aB mod p = (αaA )aB mod p = αaA aB mod p
The same holds true for Alice, as she must solve the Discrete Log-
arithm problem aB = logα bB mod p to extract Bob’s private key
KP RB . This Discrete Logarithm problem has been shown to be
computationally intensive and difficult to solve. As will be dis-
cussed in Section 8.6, the Discrete Logarithm problem parameters
p and α, the plaintext x, and the ciphertext y are typically on the
order of 1,024 bits or more in length to ensure the computational
complexity of the Discrete Logarithm problem.
Per Section 8.2, the Cyclic Group (G, ) based on the set
Zp∗ and the binary operation = × is the primary Discrete
Logarithm problem of interest, where β = αi mod p. More-
over, implementation of the Diffie-Hellman Key Agreement Pro-
tocol based on the Discrete Logarithm problem requires an addi-
tional two exponentiation operations to compute αaA mod p and
KAB = (αaA )aB mod p. Sections 7.2.3, 7.2.4, 7.2.4.4, and 7.2.5
discussed methods for accelerating the Group operation, multi-
plication (multi-precision multiplication in particular), and Sec-
tion 7.2.2 examined methods for reducing the number of Group
operations performed during exponentiation.
2. For i = 0 T o k
p − 1
(a) b = α qi
mod p
3. Return α
332CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
4. Compute β = αa mod p.
Once the private and public keys have been established, en-
cryption of the plaintext x to form the ciphertext y is performed
as follows:
2. Compute y1 = αk mod p.
3. Compute y2 = β k · x mod p.
β = αa mod p
β = 174 mod 31
8.5. ELGAMAL ENCRYPTION 335
y1 = αk mod p
y1 = 176 mod 31
y1 = 24, 137, 569 mod 31
y1 ≡ 8 mod 31
y2 = β k · x mod p
y2 = 76 · 3 mod 31
y2 = 117, 649 · 3 mod 31
y2 = 352, 947 mod 31
y2 ≡ 12 mod 31
x ≡ 8 · 12 mod 31
x ≡ 96 mod 31
x ≡ 3 mod 31
8.6 Attacks
β = αi mod p
β = αsm + t
mod p
β = αsm · αt mod p
where the table entries are sorted such that αt0 < αt1 <
αt2 . . . αtm − 1
. Such a table may be searched in log2 m steps
using a Binary Search Algorithm.
340CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
y0 = β mod p
y1 = α−m · β mod p = μ · β mod p
y2 = α−2m · β mod p = μ2 · β mod p = y1 · μ mod p
y3 = α−3m · β mod p = μ3 · β mod p = y2 · μ mod p
..
.
x0 = Initial V alue
x1 = f (x0 )
x2 = f (x1 )
x3 = f (x2 )
..
.
xi + 1 = f (xi )
xμ+1
xμ
xμ+ λ–1
xμ–1
x2
x1
x0
x0 = 5
x1 = 52 + 9 mod 19 = 34 mod 19 ≡ 15 mod 19
x2 = 152 + 9 mod 19 = 234 mod 19 ≡ 6 mod 19
x3 = 62 + 9 mod 19 = 45 mod 19 ≡ 7 mod 19
x4 = 72 + 9 mod 19 = 58 mod 19 ≡ 1 mod 19
8.6. ATTACKS 345
x5 = 12 + 9 mod 19 = 10 mod 19
x6 = 102 + 9 mod 19 = 109 mod 19 ≡ 14 mod 19
x7 = 142 + 9 mod 19 = 205 mod 19 ≡ 15 mod 19
x0 = 3
x1 = 32 + 9 mod 19 = 18 mod 19
x2 = 182 + 9 mod 19 = 333 mod 19 ≡ 10 mod 19
x3 = 102 + 9 mod 19 = 109 mod 19 ≡ 14 mod 19
x4 = 142 + 9 mod 19 = 205 mod 19 ≡ 15 mod 19
x5 = 152 + 9 mod 19 = 234 mod 19 ≡ 6 mod 19
x6 = 62 + 9 mod 19 = 45 mod 19 ≡ 7 mod 19
x7 = 72 + 9 mod 19 = 58 mod 19 ≡ 1 mod 19
x8 = 12 + 9 mod 19 = 10 mod 19
346CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
f (xi ) = f (xj )
αa · β b mod p = αa · β b mod p
αa · (αi )b mod p = αa · (αi )b mod p
+ ib
αa + ib
mod p = αa mod p
8.6. ATTACKS 349
⎧
⎪
⎪ β · xt mod p for xt S1
⎪
⎪
⎨
f (xt ) = xt + 1 =⎪ x2t mod p for xt S2 (8.1)
⎪
⎪
⎪
⎩ α · xt mod p for xt S3
where xt is an integer and
xt + 1 = β · xt
xt + 1 = β · αat · β bt
xt + 1 = αat · β bt + 1
xt + 1 = α at + 1
· β bt + 1
xt + 1 = xt · x t
xt + 1 = αat · β bt · αat · β bt
xt + 1 = α2at · β 2bt
xt + 1 = α at + 1
· β bt + 1
xt + 1 = α · xt
xt + 1 = α · αat · β bt
8.6. ATTACKS 351
xt + 1 = α at + 1
· β bt
xt + 1 = α at + 1
· β bt + 1
⎧
⎪
⎪ at mod n for xt S1
⎪
⎪
⎨
fa (xt , at ) = at + 1 = ⎪ 2 · at mod n for xt S2 (8.2)
⎪
⎪
⎪
⎩ at + 1 mod n for xt S3
⎧
⎪
⎪ bt + 1 mod n for xt S1
⎪
⎪
⎨
fb (xt , bt ) = bt + 1 = ⎪ 2 · bt mod n for xt S2 (8.3)
⎪
⎪
⎪
⎩ bt mod n for xt S3
2. x0 = αa0 · β b0 mod p
3. t = 1
4. While xt = x2t :
(a) xt = f (xt − 1)
(b) at = fa (at − 1, xt − 1)
352CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
(c) bt = fb (bt − 1, xt − 1)
− 1
ip1 = c0p1 + c1p1 · p1 + c2p1 · p21 + . . . + c(e1 −1)p1 · pe11
− 1
ip2 = c0p2 + c1p2 · p2 + c2p2 · p22 + . . . + c(e2 −1)p2 · pe22
− 1
ip3 = c0p3 + c1p3 · p3 + c2p3 · p23 + . . . + c(e3 −1)p3 · pe33
..
.
− 1
ipt = c0pt + c1pt · pt + c2pt · p2t + . . . + c(et −1)pt · ptet
∗
Z13 has an order of 12 = 22 · 3. Therefore, the equations for
each is are:
356CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
i2 = c02 + c12 · 2
i 3 = c 03
Once the equations for each is have been generated, the in-
dividual Discrete Logarithm problems must be solved and then
the results combined via the Chinese Remainder Theorem to de-
termine the cryptosystem’s Discrete Logarithm. However, if the
prime factors of p − 1 are small, then the individual Discrete
Logarithm problems may be quickly computed.
∗
Z13 has an order of 12 = 22 · 3. Therefore, the equations for
each is are:
i2 = c 0 2 + c 1 2 · 2
i 3 = c 03
8.6. ATTACKS 357
p − 1
12
p2
α 2 mod p = 2 22 mod 13
p − 1
p2
α 2 mod p = 212/4 mod 13
p − 1
p2
α 2 mod p = 23 mod 13
p − 1
p2
α 2 mod p = 8 mod 13
and that:
p − 1
12
p2
β 2 mod p = 11 22 mod 13
p − 1
p2
β 2 mod p = 1112/4 mod 13
p − 1
p2
β 2 mod p = 113 mod 13
p − 1
p2
β 2 mod p = 1, 331 mod 13
p − 1
β p2
2 mod p ≡ 5 mod 13
p − 1
p2
(α 2 )p2 mod p = 82 mod 13
p − 1
p2
(α 2 )p2 mod p = 64 mod 13
p − 1
(α p2
2 )p2 mod p ≡ 12 mod 13
p − 1 p − 1
+ c12 · p2 )
β p2
2 mod p ≡ (α p2
2 )(c02 mod p
p − 1 p − 1
+ c12 · p2 )
(β p2
2 )p2 mod p ≡ ((α p2
2 )p2 )(c02 mod p
p − 1 p − 1 p − 1
2
(β p2
2 )p2 mod p ≡ ((α p2
2 )p2 )c02 · ((α p2
2 )p2 )c12 mod p
p − 1 p − 1
− 1 c12
(β p2
2 )p2 mod p ≡ ((α p2
2 )p2 )c02 · (αp ) mod p
p − 1 p − 1
(β p2
2 )p2 mod p ≡ ((α p2
2 )p2 )c02 · (1)c12 mod p
p − 1 p − 1
(β p2
2 )p2 mod p ≡ ((α p2
2 )p2 )c02 mod p
p − 1 p − 1
(β p2 2
)p2 mod p ≡ ((α p2 2
)p2 )c02 mod p
52 mod 13 ≡ 12c02 mod 13
25 mod 13 ≡ 12c02 mod 13
12 mod 13 ≡ 12c02 mod 13
p − 1 p − 1
+ c12 · p2 )
β p2
2 mod p ≡ (α p2
2 )(c02 mod p
p − 1 p − 1
+ c12 · p2 )
β p2
2 mod p ≡ (α p2
2 )(1 mod p
p − 1 p − 1 p − 1
· p2 )
β p2
2 mod p ≡ (α p2
2 ) · (α p2
2 )(c12 mod p
· 2)
5 mod 13 ≡ 8 · 8(c12 mod 13
8.6. ATTACKS 359
p − 1
α p3
mod p = 212/3 mod 13
p − 1
α p3
mod p = 24 mod 13
p − 1
α p3
mod p = 16 mod 13
p − 1
α p3
mod p ≡ 3 mod 13
and that:
p − 1
β p3
mod p = 1112/3 mod 13
p − 1
β p3
mod p = 114 mod 13
p − 1
β p3
mod p = 14, 641 mod 13
p − 1
β p3
mod p ≡ 3 mod 13
360CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
p − 1 p − 1
β p3
mod p ≡ (α p3
)(c03 ) mod p
p − 1 p − 1
(β p2
2 )p2 mod p ≡ ((α p2
2 )p2 )c02 mod p
3 mod 13 ≡ 3c03 mod 13
i = i2 mod pe22
i = 3 mod 22
i = 3 mod 4
and:
i = i3 mod p3
i = 1 mod 3
8.6. ATTACKS 361
yields:
p − 1
M2 = = 12/4 = 3
pe22
p − 1
M3 = = 12/3 = 4
p3
αi mod p = 27 mod 13
362CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
1. Set-up.
The set-up stage begins with the selection of a Factor Base, de-
noted as S, where S = {p1 , p2 , p3 , . . . pt } and each ps is a
prime number contained in the Cyclic Group. The elements ps of
S are chosen such that a significant number of the elements con-
tained in the Cyclic Group may be represented as the product of
the elements of the Factor Base.
∗
Example 8.28: For the Cyclic Group based on the set Z229 and
the Factor Base S = {2, 3, 5, 7, 11}, determine if the Cyclic
Group element 216 can be represented via the elements of the
Factor Base S.
364CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
∗
Example 8.29: For the Cyclic Group based on the set Z229 and
the Factor Base S = {2, 3, 5, 7, 11}, determine if the Cyclic
Group element 136 can be represented via the elements of the
Factor Base S.
p1 = αl1 mod p
p2 = αl2 mod p
p3 = αl3 mod p
..
.
pt = αlt mod p
αk mod p = gk mod p
αk mod p = (αl1 )m1 · (αl2 )m2 · (αl3 )m3 · . . . · (αlt )mt mod p
∗
Example 8.31: For the Cyclic Group based on the set Z229 and
the primitive element α = 6, the Factor Base S = {2, 3, 5, 7, 11}
is chosen for use in an attack based on the Index Calculus Method .
If k = 100 and 6100 mod 229 ≡ 180 mod 229, generate the asso-
ciated linear equation for use in the Index Calculus Method attack.
100 = (2 · l1 ) + (2 · l2 ) + (1 · l3 ) +
(0 · l4 ) + (0 · l5 ) mod 228
a · l1 + b · l2 ≡ c mod p − 1
368CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
d · l1 + e · l2 ≡ f mod p − 1
terms of the elements in the Factor Base S, then the value for
the exponent k is discarded, a new value is chosen for k, and the
process is repeated.
The values for each ls in the Factor Base are known from hav-
ing solved the system of linear equations. The values for each ds
370CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
2 = 3l1 mod 89
3 = 3l2 mod 89
5 = 3l3 mod 89
7 = 3l4 mod 89
11 = 3l5 mod 89
1 = (0 · l1 ) + (1 · l2 ) + (0 · l3 ) + (0 · l4 ) +
(0 · l5 ) mod 88
1 = l2 mod 88
αk mod p = 35 mod 89
αk mod p = 243 mod 89
αk mod p ≡ 65 mod 89
αk mod p ≡ 5 · 13 mod 89
αk mod p = 39 mod 89
αk mod p = 19, 683 mod 89
αk mod p ≡ 14 mod 89
αk mod p ≡ 2 · 7 mod 89
9 = (1 · l1 ) + (0 · l2 ) + (0 · l3 ) + (1 · l4 ) +
(0 · l5 ) mod 88
9 = l1 + l4 mod 88
12 = (1 · l1 ) + (0 · l2 ) + (0 · l3 ) + (0 · l4 ) +
(1 · l5 ) mod 88
12 = l1 + l5 mod 88
14 = (2 · l1 ) + (0 · l2 ) + (1 · l3 ) + (0 · l4 ) +
(0 · l5 ) mod 88
14 = 2 · l1 + l3 mod 88
16 = (1 · l1 ) + (0 · l2 ) + (0 · l3 ) + (0 · l4 ) +
(0 · l5 ) mod 88
16 = l1 mod 88
9 = l1 + l4 mod 88
9 = 16 + l4 mod 88
−7 = l4 mod 88
81 ≡ l4 mod 88
12 = l1 + l5 mod 88
12 = 16 + l5 mod 88
−4 = l5 mod 88
84 ≡ l5 mod 88
14 = 2 · l1 + l3 mod 88
14 = 2 · 16 + l3 mod 88
14 = 32 + l3 mod 88
−18 = l3 mod 88
70 ≡ l3 mod 88
Therefore:
l1 = 16 mod 89
l2 = 1 mod 89
l3 = 70 mod 89
l4 = 81 mod 89
l5 = 84 mod 89
β · αk mod p = 3 mod 89
β · αk mod p = (αl2 )d2 mod 89
where d2 = 1.
β = αi mod p
61 = 369 mod 89
61 = (320 )3 · 39 mod 89
61 = (3, 486, 784, 401)3 · 19, 683 mod 89
61 ≡ (73)3 · 14 mod 89
61 = 389, 017 · 14 mod 89
61 ≡ 87 · 14 mod 89
61 = 1, 218 mod 89
61 ≡ 61 mod 89
Thus, the Discrete Logarithm problem has been solved using the
Index Calculus Method .
a) Z5∗
∗
b) Z11
∗
c) Z13
Create a table with two columns for every Cyclic Group. Each row
should contain a Cyclic Group element a and the order of element
a, denoted as ord(a). Compute all orders.
∗
e) Verify for all elements a of Zp∗ that a|Zp | ≡ 1 mod p for
p = 7, i.e. prove that Fermat’s Little Theorem holds true.
a) How many Subgroups are there for each of the three Cyclic
Groups described in Homework Problem 8.7.1? Exclude the
trivial Subgroup, which consists of only the element 1. What is
the cardinality of each Subgroup?
c) For each of the Subgroups identified in part (a), list all of the
primitive elements. Under what conditions are all elements of a
Subgroup, with the exception of 1, primitive elements?
a) aA = 98, aB = 17
b) aA = 287, aB = 134
c) aA = 9, aB = 17
382CHAPTER 8. PUBLIC-KEY CRYPTOGRAPHY: DISCRETE LOGARITHMS
In all cases, perform the computation of the common key for Alice
and Bob.
a) aA = 310, aB = 107
b) aA = 77, aB = 107
∗
Homework Problem 8.7.9: Consider Z17 :
b) For each Subgroup found in part (a), give the complete multi-
plication table as a square table which describes the multiplication
of all Subgroup elements with each other.
a) β = 76
b) β = 77
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY dl_4 IS
PORT ( i : IN std_logic_vector (3 DOWNTO 0);
p : IN std_logic_vector (3 DOWNTO 0);
alpha : IN std_logic_vector (3 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
pload : IN std_logic;
valid : OUT std_logic;
beta : OUT std_logic_vector (3 DOWNTO 0));
END dl_4;
ARCHITECTURE behav OF dl_4 IS
BEGIN
-- Your code goes here
END behav;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY dl_8 IS
PORT ( i : IN std_logic_vector (7 DOWNTO 0);
p : IN std_logic_vector (7 DOWNTO 0);
alpha : IN std_logic_vector (7 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
pload : IN std_logic;
valid : OUT std_logic;
beta : OUT std_logic_vector (7 DOWNTO 0));
END dl_8;
ARCHITECTURE behav OF dl_8 IS
BEGIN
-- Your code goes here
END behav;
b) p = 7, α = 5, a = 5, k = 6
8.7. HOMEWORK PROBLEMS 391
c) p = 7, α = 5, a = 6, k = 6
(x1 , x2 , . . . , xn )
Alice keeps the same k for all encryptions. Show how Oscar can
recover the entire plaintext with a Known-Plaintext attack. As-
sume Oscar has knowledge of a single piece of plaintext, x1 , all
ciphertext, and the public key.
GF (24 )∗
Public-Key Cryptography:
Elliptic Curves
9.1 Cryptosystem
395
396 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
y 2 ≡ x3 + a · x + b mod p
4 · a3 + 27 · b2 = 0 mod p
2. Extend the line between points P1 and P2 such that the line
intersects the parabola.
P2
P1 y2
y1
X
x1 x2
x3
y3 P3 = P1 + P2
1. Draw the line tangent to the circle passing through the point P1 .
2. Extend the line through the point P1 such that the line in-
tersects the parabola.
y2
y1 P2 = P1 + P1
P1
X
x1 x2
x3 ≡ λ2 − x2 − x1 mod p
9.1. CRYPTOSYSTEM 399
y3 ≡ λ · (x1 − x3 ) − y1 mod p
⎧
⎪
⎨ y2 − y 1
x2 − x1
mod p P1 = P2
λ =
⎪ 2
⎩ 3x1 + a
2y1
mod p P1 = P2
y 2 ≡ x3 + x + 6 mod 11
92 ≡ 73 + 7 + 6 mod 11
81 mod 11 ≡ 343 + 7 + 6 mod 11
4 mod 11 ≡ 356 mod 11
4 mod 11 ≡ 4 mod 11
α = (7, 9)
9.1. CRYPTOSYSTEM 401
2 · α = (7, 9) + (7, 9)
3x21 + a
λ = mod p
2y1
3 · 72 + 1
λ = mod 11
2 · 9
3 · 49 + 1
λ = mod 11
18
148
λ = mod 11
18
5
λ ≡ mod 11
7
λ ≡ 5 · 7−1 mod 11
λ ≡ 5 · 8 mod 11
λ ≡ 40 mod 11
λ ≡ 7 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 72 − 7 − 7 mod 11
x3 ≡ 49 − 7 − 7 mod 11
x3 ≡ 35 mod 11
x3 ≡ 2 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 7 · (7 − 2) − 9 mod 11
y3 ≡ 7 · 5 − 9 mod 11
y3 ≡ 35 − 9 mod 11
y3 ≡ 26 mod 11
y3 ≡ 4 mod 11
2 · α = (2, 4)
402 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
3 · α = (2, 4) + (7, 9)
y2 − y 1
λ = mod p
x2 − x 1
9 − 4
λ = mod 11
7 − 2
5
λ = mod 11
5
λ ≡ 5 · 5−1 mod 11
λ ≡ 5 · 9 mod 11
λ ≡ 45 mod 11
λ ≡ 1 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 12 − 7 − 2 mod 11
x3 ≡ 1 − 7 − 2 mod 11
x3 ≡ −8 mod 11
x3 ≡ 3 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 1 · (2 − 3) − 4 mod 11
y3 ≡ 1 · −1 − 4 mod 11
y3 ≡ −1 − 4 mod 11
y3 ≡ −5 mod 11
y3 ≡ 6 mod 11
3 · α = (3, 6)
9.1. CRYPTOSYSTEM 403
4 · α = (3, 6) + (7, 9)
y2 − y 1
λ = mod p
x2 − x 1
9 − 6
λ = mod 11
7 − 3
3
λ = mod 11
4
λ ≡ 3 · 4−1 mod 11
λ ≡ 3 · 3 mod 11
λ ≡ 9 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 92 − 7 − 3 mod 11
x3 ≡ 81 − 7 − 3 mod 11
x3 ≡ 71 mod 11
x3 ≡ 5 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 9 · (3 − 5) − 6 mod 11
y3 ≡ 9 · −2 − 6 mod 11
y3 ≡ −18 − 6 mod 11
y3 ≡ −24 mod 11
y3 ≡ 9 mod 11
4 · α = (5, 9)
404 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
5 · α = (5, 9) + (7, 9)
y2 − y 1
λ = mod p
x2 − x 1
9 − 9
λ = mod 11
7 − 5
0
λ = mod 11
2
λ ≡ 0 · 2−1 mod 11
λ ≡ 0 · 6 mod 11
λ ≡ 0 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 02 − 7 − 5 mod 11
x3 ≡ 0 − 7 − 5 mod 11
x3 ≡ −12 mod 11
x3 ≡ 10 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 0 · (5 − 10) − 9 mod 11
y3 ≡ 0 · −5 − 9 mod 11
y3 ≡ 0 − 9 mod 11
y3 ≡ −9 mod 11
y3 ≡ 2 mod 11
5 · α = (10, 2)
9.1. CRYPTOSYSTEM 405
6 · α = (10, 2) + (7, 9)
y2 − y1
λ = mod p
x2 − x 1
9 − 2
λ = mod 11
7 − 10
7
λ = mod 11
−3
7
λ ≡ mod 11
8
λ ≡ 7 · 8−1 mod 11
λ ≡ 7 · 7 mod 11
λ ≡ 49 mod 11
λ ≡ 5 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 52 − 7 − 10 mod 11
x3 ≡ 25 − 7 − 10 mod 11
x3 ≡ 8 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 5 · (10 − 8) − 2 mod 11
y3 ≡ 5 · 2 − 2 mod 11
y3 ≡ 10 − 2 mod 11
y3 ≡ 8 mod 11
6 · α = (8, 8)
406 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
7 · α = (8, 8) + (7, 9)
y2 − y 1
λ = mod p
x2 − x 1
9 − 8
λ = mod 11
7 − 8
1
λ = mod 11
−1
1
λ ≡ mod 11
10
λ ≡ 1 · 10−1 mod 11
λ ≡ 1 · 10 mod 11
λ ≡ 10 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 102 − 7 − 8 mod 11
x3 ≡ 100 − 7 − 8 mod 11
x3 ≡ 85 mod 11
x3 ≡ 8 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 10 · (8 − 8) − 8 mod 11
y3 ≡ 10 · 0 − 8 mod 11
y3 ≡ 0 − 8 mod 11
y3 ≡ −8 mod 11
y3 ≡ 3 mod 11
7 · α = (8, 3)
9.1. CRYPTOSYSTEM 407
8 · α = (8, 3) + (7, 9)
y2 − y 1
λ = mod p
x2 − x 1
9 − 3
λ = mod 11
7 − 8
6
λ = mod 11
−1
6
λ ≡ mod 11
10
λ ≡ 6 · 10−1 mod 11
λ ≡ 6 · 10 mod 11
λ ≡ 60 mod 11
λ ≡ 5 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 52 − 7 − 8 mod 11
x3 ≡ 25 − 7 − 8 mod 11
x3 ≡ 10 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 5 · (8 − 10) − 3 mod 11
y3 ≡ 5 · −2 − 3 mod 11
y3 ≡ −10 − 3 mod 11
y3 ≡ −13 mod 11
y3 ≡ 9 mod 11
8 · α = (10, 9)
408 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
9 · α = (10, 9) + (7, 9)
y2 − y1
λ = mod p
x2 − x 1
9 − 9
λ = mod 11
7 − 10
0
λ = mod 11
−3
0
λ ≡ mod 11
8
λ ≡ 0 · 8−1 mod 11
λ ≡ 0 · 7 mod 11
λ ≡ 0 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 02 − 7 − 10 mod 11
x3 ≡ 0 − 7 − 10 mod 11
x3 ≡ −17 mod 11
x3 ≡ 5 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 0 · (10 − 5) − 9 mod 11
y3 ≡ 0 · 5 − 9 mod 11
y3 ≡ 0 − 9 mod 11
y3 ≡ −9 mod 11
y3 ≡ 2 mod 11
9 · α = (5, 2)
9.1. CRYPTOSYSTEM 409
10 · α = (5, 2) + (7, 9)
y2 − y 1
λ = mod p
x2 − x 1
9 − 2
λ = mod 11
7 − 5
7
λ = mod 11
2
λ ≡ 7 · 2−1 mod 11
λ ≡ 7 · 6 mod 11
λ ≡ 42 mod 11
λ ≡ 9 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 92 − 7 − 5 mod 11
x3 ≡ 81 − 7 − 5 mod 11
x3 ≡ 69 mod 11
x3 ≡ 3 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 9 · (5 − 3) − 2 mod 11
y3 ≡ 9 · 2 − 2 mod 11
y3 ≡ 18 − 2 mod 11
y3 ≡ 16 mod 11
y3 ≡ 5 mod 11
10 · α = (3, 5)
410 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
11 · α = (3, 5) + (7, 9)
y2 − y 1
λ = mod p
x2 − x 1
9 − 5
λ = mod 11
7 − 3
4
λ = mod 11
4
λ ≡ 4 · 4−1 mod 11
λ ≡ 4 · 3 mod 11
λ ≡ 12 mod 11
λ ≡ 1 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 12 − 7 − 3 mod 11
x3 ≡ 1 − 7 − 3 mod 11
x3 ≡ −9 mod 11
x3 ≡ 2 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 1 · (3 − 2) − 5 mod 11
y3 ≡ 1 · 1 − 5 mod 11
y3 ≡ 1 − 5 mod 11
y3 ≡ −4 mod 11
y3 ≡ 7 mod 11
11 · α = (2, 7)
9.1. CRYPTOSYSTEM 411
12 · α = (2, 7) + (7, 9)
y2 − y 1
λ = mod p
x2 − x 1
9 − 7
λ = mod 11
7 − 2
2
λ = mod 11
5
λ ≡ 2 · 5−1 mod 11
λ ≡ 2 · 9 mod 11
λ ≡ 18 mod 11
λ ≡ 7 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 72 − 7 − 2 mod 11
x3 ≡ 49 − 7 − 2 mod 11
x3 ≡ 40 mod 11
x3 ≡ 7 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 7 · (2 − 7) − 7 mod 11
y3 ≡ 7 · −5 − 7 mod 11
y3 ≡ −35 − 7 mod 11
y3 ≡ −42 mod 11
y3 ≡ 2 mod 11
12 · α = (7, 2)
412 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
13 · α = (7, 2) + (7, 9)
y2 − y1
λ = mod p
x2 − x 1
9 − 2
λ = mod 11
7 − 7
7
λ = mod 11
0
13 · α = P oint of Inf inity
This Section will focus on the use of the Diffie-Hellman Key Agree-
ment Protocol in the Cyclic Group formed by the points on the
Elliptic Curve and the Point of Infinity using point addition as
defined in Section 9.1 as the binary operation. In this case, the
Diffie-Hellman Key Agreement Protocol is composed of two stages:
set-up and key establishment. The set-up stage proceeds as fol-
lows:
1 Choose a Choose a
random integer random integer
KP RA = aA K P RB = a B
where where
aA {2, 3, 4, . . . #E − 1} aB {2, 3, 4, . . . #E − 1}
2 Compute Compute
KP U BA = bA KP U BB = bB
= aA · α = aB · α
= (xA , yA ) = (xB , yB )
because for a given xk there are only two possible values for y and
therefore only one variable is required for use as the key. Both Al-
ice and Bob have contributed to the computation of KAB without
being able to extract information regarding the other party’s pri-
vate key, KP R . This is because for Bob to extract Alice’s private
key, KP RA , he must solve the Discrete Logarithm problem for aA
based on the equation bA = aA · α. The same holds true for Alice,
as she must solve the Discrete Logarithm problem for aB based on
the equation bB = aB · α to extract Bob’s private key, KP RB .
The Discrete Logarithm problem has been shown to be computa-
9.2. DIFFIE-HELLMAN KEY AGREEMENT PROTOCOL 415
109, 120, 159, 173, 177, 204, 238, 272, 295, 320], with reported
point addition times as fast as 21 μs [9] for 163-bit Irreducible
Polynomials and 734 μs [61] for up to 256-bit Irreducible Polyno-
mials. Similarly, a wide variety of FPGA implementations of El-
liptic Curve cryptosystems over the Extension Fields GF(2m ) and
GF(p) exist in the literature [9, 18, 24, 25, 78, 92, 93, 111, 115, 79,
130, 145, 157, 188, 195, 220, 233, 235, 236, 257, 266, 267, 286, 315],
with reported point addition times as fast as 41 μs [9] for 163-bit
Irreducible Polynomials, 56 μs [267] for 191-bit Irreducible Polyno-
mials, 89 μs [286] for 233-bit Irreducible Polynomials, and 144 μs
[79] for up to 256-bit Irreducible Polynomials. A comprehensive
review of hardware implementations of Elliptic Curve cryptosys-
tems over the Extension Field GF(2m ) is available in [62]. Soft-
ware implementations of Elliptic Curve cryptosystems over the
Extension Fields GF(2m ) and GF(p) are available, targeting pro-
cessors such as the CalmRISC and Digital Signal Processors such
as the Texas Instruments TMS320C6201 are also available in the
literature [44, 137]. These implementations have yielded point ad-
dition times as fast as 3.09 ms [137] for 160-bit Irreducible Poly-
nomials over GF(p), two full orders of magnitude slower than the
best hardware implementations. Implementations targeting 64-
bit dual-field processors exhibit better performance [80, 269], with
point addition times as fast as 190 μs for 160-bit Irreducible Poly-
nomials over the Extension Field GF(2m ) and 1.21 ms for 160-bit
Irreducible Polynomials over GF(p) [269].
that the necessary security services are provided while also main-
taining a high level of performance. Therefore, Elliptic Curve
cryptosystems are typically used for infrequently occurring oper-
ations, such as key establishment and the generation of Digital
Signatures. Key establishment occurs only at the start of a com-
munication session, and a Digital Signature is generated only once
for the entire stream of data being transmitted to provide message
authentication and non-repudiation, as discussed in Section 11.1.
4. Compute β = a · α = (xβ , yβ ).
9.4. MENEZES-VANSTONE ENCRYPTION 421
Once the private and public keys have been established, en-
cryption of the plaintext x to form the ciphertext y is performed
as follows:
2. Compute y0 = k · α.
3. Compute y1 = c1 · x1 mod p.
4. Compute y2 = c2 · x2 mod p.
(c1 , c2 ) = a · y0
(c1 , c2 ) = a · y0
β = a · α
β = 2 · (3, 5)
9.4. MENEZES-VANSTONE ENCRYPTION 423
β = (3, 5) + (3, 5)
3x21 + a
λ = mod p
2y1
3 · 32 + 1
λ = mod 11
2 ·5
3 · 9 + 1
λ = mod 11
10
28
λ = mod 11
10
6
λ = mod 11
10
λ = 6 · 10−1 mod 11
λ = 6 · 10 mod 11
λ = 60 mod 11
λ = 5 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 52 − 3 − 3 mod 11
x3 ≡ 25 − 3 − 3 mod 11
x3 ≡ 19 mod 11
x3 ≡ 8 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 5 · (3 − 8) − 5 mod 11
y3 ≡ 5 · −5 − 5 mod 11
y3 ≡ −25 − 5 mod 11
y3 ≡ −30 mod 11
y3 ≡ 3 mod 11
β = (8, 3)
424 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
(c1 , c2 ) = k · β
(c1 , c2 ) = 1 · (8, 3)
(c1 , c2 ) = (8, 3)
y0 = k · α
y0 = 1 · (3, 5)
y0 = (3, 5)
y1 = c1 · x1 mod p
y1 = 8 · 4 mod 11
y1 = 32 mod 11
y1 = 10 mod 11
y2 = c2 · x2 mod p
y2 = 3 · 4 mod 11
y2 = 12 mod 11
y2 = 1 mod 11
9.4. MENEZES-VANSTONE ENCRYPTION 425
(c1 , c2 ) = a · y0
(c1 , c2 ) = 2 · (3, 5)
(c1 , c2 ) = (3, 5) + (3, 5)
3x21 + a
λ = mod p
2y1
3 · 32 + 1
λ = mod 11
2 · 5
3 · 9 + 1
λ = mod 11
10
28
λ = mod 11
10
6
λ = mod 11
10
λ = 6 · 10−1 mod 11
λ = 6 · 10 mod 11
λ = 60 mod 11
λ = 5 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 52 − 3 − 3 mod 11
x3 ≡ 25 − 3 − 3 mod 11
x3 ≡ 19 mod 11
x3 ≡ 8 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 5 · (3 − 8) − 5 mod 11
426 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
y3 ≡ 5 · −5 − 5 mod 11
y3 ≡ −25 − 5 mod 11
y3 ≡ −30 mod 11
y3 ≡ 3 mod 11
(c1 , c2 ) = (8, 3)
c−1
1 mod p = 8
−1
mod 11
c−1
1 mod p = 7 mod 11
c−1
2 mod p = 3
−1
mod 11
c−1
2 mod p = 4 mod 11
9.5 Attacks
a) (2, 7) + (5, 2)
b) (3, 6) + (3, 6)
δ = (5, 2)
2δ = . . .
3δ = . . .
..
.
13δ = . . .
14δ = . . .
430 CHAPTER 9. PUBLIC-KEY CRYPTOGRAPHY: ELLIPTIC CURVES
Verify that the last element, 13δ, is the point at infinity and that
14δ = δ.
Note that a denotes the public key, not the Elliptic Curve coeffi-
cient. Use the Elliptic Curve from Homework Problem 9.6.1 as
the underlying structure. For each example, compute β, (c1 , c2 ),
and (y0 , y1 , y2 ). Also, for each example perform the decryption
operation. This will require writing a function that computes the
multiplicative inverse modulo p.
a) Compute β = a · α.
((16, 8), 14, 5), ((6, 24), 17, 18), ((5, 22), 15, 4)
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY ecc_31 IS
PORT ( xp : IN std_logic_vector (4 DOWNTO 0);
yp : IN std_logic_vector (4 DOWNTO 0);
i : IN std_logic_vector (5 DOWNTO 0);
clk : IN std_logic;
rst : IN std_logic;
pload : IN std_logic;
valid : OUT std_logic;
xout : OUT std_logic_vector (4 DOWNTO 0);
yout : OUT std_logic_vector (4 DOWNTO 0));
END ecc_31;
ARCHITECTURE behav OF ecc_31 IS
BEGIN
-- Your code goes here
END behav;
Using the point (9, 10), generate all points on the Elliptic Curve.
Demonstrate that the order of the point (9, 10) is #E = 34.
Specify the target technology used to implement the design and
the maximum operating frequency as specified by your place-and-
route tools. What is the execution time of your implementation?
What is the gate count of your implementation?
a) Compute β = a · α.
Cryptographic
Components
437
438 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
y = sigKP R (x)
3. Bob uses his private key and the Digital Signature signing
function to sign the message x, yielding the Digital Signature
y = sigKP RB (x).
5. Alice verifies the Digital Signature y for the message x via the
Digital Signature verification function verKP U B (x, y), yield-
ing a value of true (indicating successful verification) or false
(indicating failed verification).
• Everyone with access to the sender’s public key can verify the
signature of a message allegedly signed by the sender.
10.1.1 RSA
2. Compute n = p · q.
Once the private and public keys have been established, signing
of the message x to form the signature y is performed as follows:
y = xa mod n
y = 33 mod 33
y = 27 mod 33
10.1.2 ElGamal
4. Compute β = αa mod p.
Once the private and public keys have been established, sign-
ing of the message x to form the ElGamal Digital Signature is
performed as follows:
2. Compute γ = αk mod p.
3. Compute δ = (x − a · γ) · k −1 mod p − 1.
− a · γ) · k−1 mod p − 1
β γ · γ δ mod p = (αa )γ · (αk )(x mod p
· γ · (x − a · γ) · k−1 mod p − 1
β γ · γ δ mod p = αa · αk mod p
· γ · x · k−1 − k · a · γ · k−1 mod p − 1
β γ · γ δ mod p = αa · αk mod p
· γ − a · γ mod p − 1
β γ · γ δ mod p = αa · αx mod p
· γ
β γ · γ δ mod p = αa · αx · α−a · γ mod p − 1
mod p
· γ − a · γ mod p − 1
β γ · γ δ mod p = αa · αx mod p
β γ · γ δ mod p = 1 · αx mod p
β γ · γ δ mod p = αx mod p
γ = αk mod p
γ = 239 mod 467
γ = 549, 755, 813, 888 mod 467
γ ≡ 118 mod 467
10.1. DIGITAL SIGNATURES 447
δ = (x − a · γ) · k −1 mod p − 1
δ = (3 − 127 · 118) · 39−1 mod 466
δ = (3 − 14, 986) · 239 mod 466
δ ≡ −14, 983 · 239 mod 466
δ ≡ 395 · 239 mod 466
δ ≡ 94, 405 mod 466
δ ≡ 273 mod 466
β = αa mod p
β = 2127 mod 467
β = 260 · 260 · 27 mod 467
β = 1, 152, 921, 504, 606, 846, 976 · 1, 152, 921, 504, 606, 846, 976 ·
128 mod 467
β ≡ 169 · 169 · 128 mod 467
β ≡ 3, 655, 808 mod 467
β ≡ 132 mod 467
448 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
Once the DSA parameters, i.e. the private and public keys,
have been established, signing of the message M is performed as
follows:
3. Compute u2 = r · w mod q.
p − 1
g q mod p = (h q mod p)q mod p
− 1
g q mod p = hp mod p
g q mod p = 1 mod p
+ k · q
g m mod p = g n mod p
g m mod p = g n mod p · (g q mod p)k mod p
v = (g u1 · y u2 mod p) mod q
· w mod q · w mod q
v = (g h(M ) · yr mod p) mod q
· w mod q · w mod q
v = (g h(M ) · (g x mod p)r mod p) mod q
· w mod q · r · w mod q
v = (g h(M ) · gx mod p) mod q
· w + x · r · w mod q
v = (g h(M ) mod p) mod q
· (h(M ) + x · r mod q)
v = (g w mod p) mod q
w = s−1 mod q
w = ((h(M ) + x · r) · k −1 )−1 mod q
w = (h(M ) + x · r)−1 · k mod q
4. Compute β = k · α = (xβ , yβ ).
Once the private and public keys have been established, signing
of the message M = (xM , yM ) to form the Elliptic Curve Digital
Signature is performed as follows:
2. Compute γ = m · α = (xγ , yγ ).
where the plaintext M is a point on the Elliptic Curve and the El-
liptic Curve Digital Signature is the pair sigKP R (M, k) = (r, s).
Verification of the signature is achieved as follows:
4. Compute δ = u1 · α + u2 · β = (xδ , yδ ).
β = k · α
β = 2 · (3, 5)
β = (3, 5) + (3, 5)
3x21 + a
λ = mod p
2y1
3 · 32 + 1
λ = mod 11
2 ·5
3 · 9 + 1
λ = mod 11
10
28
λ = mod 11
10
6
λ = mod 11
10
λ = 6 · 10−1 mod 11
λ = 6 · 10 mod 11
λ = 60 mod 11
456 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
λ = 5 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 52 − 3 − 3 mod 11
x3 ≡ 25 − 3 − 3 mod 11
x3 ≡ 19 mod 11
x3 ≡ 8 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 5 · (3 − 8) − 5 mod 11
y3 ≡ 5 · −5 − 5 mod 11
y3 ≡ −25 − 5 mod 11
y3 ≡ −30 mod 11
y3 ≡ 3 mod 11
β = (8, 3)
γ = m · α
γ = 2 · (3, 5)
3x21 + a
λ = mod p
2y1
3 · 32 + 1
λ = mod 11
2 ·5
3 · 9 + 1
λ = mod 11
10
28
λ = mod 11
10
10.1. DIGITAL SIGNATURES 457
6
λ = mod 11
10
λ = 6 · 10−1 mod 11
λ = 6 · 10 mod 11
λ = 60 mod 11
λ = 5 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 52 − 3 − 3 mod 11
x3 ≡ 25 − 3 − 3 mod 11
x3 ≡ 19 mod 11
x3 ≡ 8 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 5 · (3 − 8) − 5 mod 11
y3 ≡ 5 · −5 − 5 mod 11
y3 ≡ −25 − 5 mod 11
y3 ≡ −30 mod 11
y3 ≡ 3 mod 11
γ = (8, 3)
r = xγ mod #E
r = 8 mod 13
458 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
Thus the Elliptic Curve Digital Signature is the pair sigKP R (M, k) =
(r, s) = (8, 10).
c = s−1 mod #E
c = 10−1 mod 13
c ≡ 4 mod 13
u1 = xM · c mod #E
u1 = 4 · 4 mod 13
u1 = 16 mod 13
u1 ≡ 3 mod 13
10.1. DIGITAL SIGNATURES 459
u2 = r · c mod #E
u2 = 8 · 4 mod 13
u2 = 32 mod 13
u2 ≡ 6 mod 13
δ = u1 · α + u 2 · β
δ = 3 · (3, 5) + 6 · (8, 3)
x3 ≡ 52 − 3 − 3 mod 11
x3 ≡ 25 − 3 − 3 mod 11
x3 ≡ 19 mod 11
x3 ≡ 8 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 5 · (3 − 8) − 5 mod 11
y3 ≡ 5 · −5 − 5 mod 11
y3 ≡ −25 − 5 mod 11
y3 ≡ −30 mod 11
y3 ≡ 3 mod 11
2 · (3, 5) = (8, 3)
x3 ≡ 16 − 3 − 8 mod 11
x3 ≡ 5 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 4 · (8 − 5) − 3 mod 11
y3 ≡ 4 · 3 − 3 mod 11
y3 ≡ 12 − 3 mod 11
y3 ≡ 9 mod 11
3 · (3, 5) = (5, 9)
x3 ≡ 12 − 8 − 8 mod 11
x3 ≡ 1 − 8 − 8 mod 11
x3 ≡ −15 mod 11
x3 ≡ 7 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 1 · (8 − 7) − 3 mod 11
y3 ≡ 1 · 1 − 3 mod 11
y3 ≡ 1 − 3 mod 11
y3 ≡ −2 mod 11
y3 ≡ 9 mod 11
2 · (8, 3) = (7, 9)
δ = 3 · (3, 5) + 6 · (8, 3)
δ = (5, 9) + (3, 6)
y 2 − y1
λ = mod p
x2 − x 1
6 − 9
λ = mod 11
3 − 5
−3
λ = mod 11
−2
8
λ ≡ mod 11
9
λ ≡ 8 · 9−1 mod 11
10.1. DIGITAL SIGNATURES 463
λ ≡ 8 · 5 mod 11
λ ≡ 40 mod 11
λ ≡ 7 mod 11
x3 ≡ λ2 − x2 − x1 mod p
x3 ≡ 72 − 3 − 5 mod 11
x3 ≡ 49 − 3 − 5 mod 11
x3 ≡ 41 mod 11
x3 ≡ 8 mod 11
y3 ≡ λ · (x1 − x3 ) − y1 mod p
y3 ≡ 7 · (5 − 8) − 9 mod 11
y3 ≡ 7 · −3 − 9 mod 11
y3 ≡ −21 − 9 mod 11
y3 ≡ −30 mod 11
y3 ≡ 3 mod 11
δ = (8, 3)
v = xδ mod #E
v = 8 mod 13
a) KP R = 127, k = 213, x = 33
b) KP R = 127, k = 123, x = 33
c) How many valid Digital Signatures are there for the cryp-
tosystem in Homework Problem 10.1.5.3?
b) How many valid Digital Signatures are there for each message
x using the parameters chosen for this Digital Signature scheme?
b) How many valid Digital Signatures are there for each message
x using the parameters chosen for this Digital Signature scheme?
a) Find the private key and sign the message x = 2 using the
Chinese Remainder Theorem.
h(x)
SIGKpr(h(x))
The Hash Function h(x) is publicly known and has no key. The
input message x is of arbitrary length while the output of the Hash
Function h(x) is of fixed length. To generate the output, the Hash
Function h(x) must often be applied in an iterative manner, as
shown in Figure 10.2.
h(x)
SIGKpr(h(x))
nature scheme.
4. Bob uses his private key and the Digital Signature signing
function to sign the message digest z, yielding the Digital
Signature y = sigKP RB (z).
and xM
F . These messages appear visibly identical to xF and xM but
pair (xM
L , y) to Alice, but Oscar intercepts the transmission and
replaces xM M
L with xF . Alice receives the message/signature pair
(xM M
F , y), and the verification function verKP U BB (xF , y) yields a
1
probability that a person has a given birth date is 365
. Thus the
probability that two people do not have the same birth date, i.e.
that there is no collision, is 1 − 1
365
. In the case where there are
three people, the probability that no two people have the same
birth date is:
1 2
P (no collision) = (1 − ) · (1 − )
365 365
Similarly, when there are four people, the probability that no two
people have the same birth date is:
1 2 3
P (no collision) = (1 − ) · (1 − ) · (1 − )
365 365 365
1 2
P (no collision) = (1 − ) · (1 − )
365 365
3 p − 1
· (1 − ) · . . . · (1 − )
365 365
p− 1
i
P (no collision) = (1 − )
i=1 365
x2 x3 x4
e−x = 1 − x + − + − ...
2! 3! 4!
− 1
p
−i
P (no collision) ≈ en
i=1
−1 −2 −3 −(p − 1)
P (no collision) ≈ e n · e n · e n · ... · e n
−(1 + 2 + 3 + ... + p − 1)
P (no collision) ≈ e n
p · (p − 1)
1 + 2 + 3 + ... + p − 1 =
2
p − 1
P (no collision) ≈ e−p · 2n
p − 1
ε ≈ 1 − e−p · 2n
p − 1
e−p · 2n ≈ 1 − ε
−p · (p − 1)
≈ ln(1 − ε)
2n
p · (p − 1) ≈ −2n · ln(1 − ε)
1
p2 − p ≈ 2n · ln( )
1 − ε
1
p2 ≈ 2n · ln( )
1 − ε
1
p ≈ 2n · ln( )
1 − ε
1
p ≈ 2n · ln( )
1 − ε
1
p ≈ 2 · 365 · ln( )
1 − 0.50
1
p ≈ 730 · ln( )
0.50
p ≈ 730 · ln(2)
√
p ≈ 730 · 0.693
√
p ≈ 505.89
p ≈ 22.5
1
p ≈ 2n · ln( )
1 − ε
1
p ≈ 2 · 280 · ln( )
1 − 0.50
1
p ≈ 2 · 280 · ln( )
0.50
p ≈ 2 · 280 · ln(2)
√
p ≈ 2 · 280 · 0.693
√
p ≈ 280 · 1.386
√ √
p ≈ 280 · 1.386
p ≈ 240 · 1.177
482 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
10.2.2 Algorithms
Hash Functions based on block ciphers use the block cipher’s en-
cryption function in an iterative manner similar to CBC mode, as
described in Section 5.1.3.2. The final output of the function is
the hashed output for the entire message. Figure 10.3 shows an
example of a Hash Function constructed from a block cipher.
xi
PT
n Map m Encrypt
Hi–1 KEY n
g(k) e(x)
CT
Hi
10.2.2.2 MD4
h1 = 6745230116
h2 = EF CDAB8916
h3 = 98BADCF E16
h4 = 1032547616
Additive Constants
⎧
⎪
⎪ 0000000016 0 ≤ j ≤ 15
⎪
⎪
⎨
yj = ⎪ 5A82799916 16 ≤ j ≤ 31
⎪
⎪ ⎪
⎩ 6ED9EBA116 32 ≤ j ≤ 47
486 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
3. Compute the 64-bit value b mod 264 and append this value
to the result of Step 2 using little-endian notation, i.e. the
lower 32-bit word followed by the upper 32-bit word.
the input x has been padded to form x , MD4 completes its set-up
phase by establishing the initial values for working variables [202]:
1. H1 = h1 , H2 = h2 , H3 = h3 , H4 = h4
2. For i = 0 T o m − 1
(a) For j = 0 T o 15
i. T emp[j] = x16i + j
3. A = H1 , B = H2 , C = H3 , D = H4
MD4 processes the input data via three rounds that are each exe-
cuted sixteen times. Each round employs a different function, and
these functions are defined as [202]:
f (u, v, w) = (u · v) + (u · w)
g(u, v, w) = (u · v) + (u · w) + (v · w)
h(u, v, w) = u ⊕ v ⊕ w
Round 1
1. For j = 0 T o 15
(b) A = D, B = t sj , C = B, D = C
Round 2
1. For j = 16 T o 31
(b) A = D, B = t sj , C = B, D = C
Round 3
1. For j = 32 T o 47
(b) A = D, B = t sj , C = B, D = C
H1 = H1 + A
H 2 = H2 + B
10.2. HASH FUNCTIONS 489
H 3 = H3 + C
H 4 = H4 + D
10.2.2.3 MD5
h1 = 6745230116
h2 = EF CDAB8916
h3 = 98BADCF E16
h4 = 1032547616
Additive Constants
yj = | sin(j + 1) | ; 0 ≤ j ≤ 63
Note that the Order for Accessing Source Words for the sec-
ond and third rounds in MD5 have changed versus the Order for
Accessing Words in MD4 . Also note that the number of Word
Access Orders has been expanded from 48 to 64 to account for the
additional round present in MD5 .
Note that the Left Rotate Bit Positions for all rounds in MD5
have changed versus the Left Rotate Bit Positions for all rounds in
MD4 . Also note that the number of Left Rotate Bit Positions has
been expanded from 48 to 64 to account for the additional round
present in MD5 .
3. Compute the 64-bit value b mod 264 and append this value
to the result of Step 2 using little-endian notation, i.e. the
lower 32-bit word followed by the upper 32-bit word.
1. H1 = h1 , H2 = h2 , H3 = h3 , H4 = h4
2. For i = 0 T o m − 1
(a) For j = 0 T o 15
i. T emp[j] = x16i + j
3. A = H1 , B = H2 , C = H3 , D = H4
MD5 processes the input data via four rounds that are each ex-
ecuted sixteen times. Note that MD5 uses an additional fourth
round as opposed to the three rounds used by MD4 . Each of the
MD5 rounds employs a different function, and these functions are
defined as [202]:
10.2. HASH FUNCTIONS 493
f (u, v, w) = (u · v) + (u · w)
g(u, v, w) = (u · w) + (v · w)
h(u, v, w) = u ⊕ v ⊕ w
k(u, v, w) = v ⊕ (u + w)
Round 1
1. For j = 0 T o 15
Note that the update of the working variable B now includes the
addition of the output from the previous iteration. This change is
present in each of the MD5 rounds.
494 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
Round 2
1. For j = 16 T o 31
(b) A = D, B = B + (t sj ), C = B, D = C
Round 3
1. For j = 32 T o 47
(b) A = D, B = B + (t sj ), C = B, D = C
Round 4
1. For j = 48 T o 63
(b) A = D, B = B + (t sj ), C = B, D = C
H1 = H1 + A
H 2 = H2 + B
10.2. HASH FUNCTIONS 495
H 3 = H3 + C
H 4 = H4 + D
As was the case with MD4 , because MD5 employs 32-bit Boolean
and arithmetic operations, high speed implementations of the Hash
Function are easily achieved in both software and hardware. Al-
though the computation of yj = | sin(j + 1) | is complex,
this operation is only performed once to yield a set of constants
and does not contribute to the operating speed of the compression
portion of MD5 . The use of little-endian notation results in MD5
mapping extremely well to Intel microprocessors, as was the case
for MD4 . In terms of security, collisions have been found during
the compression portion of MD5 [65, 255, 256], i.e. the round
functions, and thus MD5 is no longer considered to be collision
resistant [202, 275].
h1 = 6745230116
h2 = EF CDAB8916
h3 = 98BADCF E16
h4 = 1032547616
h5 = C3D2E1F 016
Additive Constants
y1 = 5A82799916
y2 = 6ED9EBA116
y3 = 8F 1BBCDC16
y4 = CA62C1D616
10.2. HASH FUNCTIONS 497
3. Compute the 64-bit value b mod 264 and append this value to
the result of Step 2 using big-endian notation, i.e. the upper
32-bit word followed by the lower 32-bit word.
1. H1 = h1 , H2 = h2 , H3 = h3 , H4 = h4 , H5 = h5
2. For i = 0 T o m − 1
498 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
(a) For j = 0 T o 15
i. T emp[j] = x16i + j
3. A = H1 , B = H2 , C = H3 , D = H4 , E = H5
4. For j = 16 T o 79
SHA-1 processes the input data via four rounds that are each
executed sixteen times. Note that SHA-1 uses an additional fourth
round as opposed to the three rounds used by MD4 . Each of the
SHA-1 rounds employs one of three functions, and these functions
are the same functions used in MD4 :
f (u, v, w) = (u · v) ⊕ (u · w)
g(u, v, w) = (u · v) ⊕ (u · w) ⊕ (v · w)
h(u, v, w) = u ⊕ v ⊕ w
Round 1
1. For j = 0 T o 19
(b) A = t, B = A, C = B 30, D = C, E = D
Round 2
1. For j = 20 T o 39
(b) A = t, B = A, C = B 30, D = C, E = D
Round 3
1. For j = 40 T o 59
(b) A = t, B = A, C = B 30, D = C, E = D
Round 4
1. For j = 60 T o 79
(b) A = t, B = A, C = B 30, D = C, E = D
500 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
H1 = H1 + A
H 2 = H2 + B
H 3 = H3 + C
H 4 = H4 + D
H 5 = H5 + E
D (used in the functions f (u, v, w), g(u, v, w), and h(u, v, w)),
the attack against MD4 proposed in [64] cannot be applied to
SHA-1 . Finally, because of the increased bit length of SHA-1 ver-
sus the bit lengths of MD4 and MD5 (160 bits versus 128 bits),
SHA-1 is more resistant to exhaustive collision searches that at-
tempt to take advantage of the Birthday Paradox [275]. However,
in 2005, collisions were found in SHA-1 after 269 computations
and thus SHA-1 is no longer considered to be collision resistant
[324]. As a result, other options were made available via the Au-
gust 2002 change notice to the SHS . As part of FIPS Standard
180-2 [224], SHA-256,, SHA-384 , and SHA-512 are specified in
addition to SHA-1 . The different properties associated with each
of these Hash Functions are detailed in Table 10.1 from [224].
Note that all sizes are in bits and the Security Size is based
on taking advantage of the Birthday Paradox , resulting in the
complexity of a collision search being approximately equivalent
to the square root of the Digest Size in bits. However, FIPS
Standard 180-2 [224] was published prior to the attack published
502 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
h0 = 6A09E66716
h1 = BB67AE8516
h2 = 3C6EF 37216
h3 = A54F F 53A16
h4 = 510E527F16
h5 = 9B05688C16
h6 = 1F 83D9AB16
h7 = 5BE0CD1916
10.2. HASH FUNCTIONS 503
Additive Constants
y0 = 428A2F 9816 y1 = 7137449116
y2 = B5C0F BCF16 y3 = E9B5DBA516
y4 = 3956C25B16 y5 = 59F 111F 116
y6 = 923F 82A416 y7 = AB1C5ED516
y8 = D807AA9816 y9 = 12835B0116
y10 = 243185BE16 y11 = 550C7DC316
y12 = 72BE5D7416 y13 = 80DEB1F E16
y14 = 9BDC06A716 y15 = C19BF 17416
y16 = E49B69C116 y17 = EF BE478616
y18 = 0F C19DC616 y19 = 240CA1CC16
y20 = 2DE92C6F16 y21 = 4A7484AA16
y22 = 5CB0A9DC16 y23 = 76F 988DA16
y24 = 983E515216 y25 = A831C66D16
y26 = B00327C816 y27 = BF 597F C716
y28 = C6E00BF 316 y29 = D5A7914716
y30 = 06CA635116 y31 = 1429296716
y32 = 27B70A8516 y33 = 2E1B213816
y34 = 4D2C6DF C16 y35 = 53380D1316
y36 = 650A735416 y37 = 766A0ABB16
y38 = 81C2C92E16 y39 = 92722C8516
y40 = A2BF E8A116 y41 = A81A664B16
y42 = C24B8B7016 y43 = C76C51A316
y44 = D192E81916 y45 = D699062416
y46 = F 40E358516 y47 = 106AA07016
y48 = 19A4C11616 y49 = 1E376C0816
y50 = 2748774C16 y51 = 34B0BCB516
y52 = 391C0CB316 y53 = 4ED8AA4A16
y54 = 5B9CCA4F16 y55 = 682E6F F 316
y56 = 748F 82EE16 y57 = 78A5636F16
y58 = 84C8781416 y59 = 8CC7020816
y60 = 90BEF F F A16 y61 = A4506CEB16
y62 = BEF 9A3F 716 y63 = C67178F 216
3. Compute the 64-bit value b mod 264 and append this value to
the result of Step 2 using big-endian notation, i.e. the upper
32-bit word followed by the lower 32-bit word.
1. H0 = h0 , H1 = h1 , H2 = h2 , H3 = h3 , H4 = h4 ,
H5 = h5 , H6 = h6 , H7 = h7
2. For i = 0 T o m − 1
(a) For j = 0 T o 15
i. T emp[j] = x16i + j
3. A = H0 , B = H1 , C = H2 , D = H3 , E = H4 , F = H5 ,
G = H6 , H = H7
10.2. HASH FUNCTIONS 505
4. For j = 16 T o 63
1. For j = 0 T o 63
H0 = H0 + A
H 1 = H1 + B
H 2 = H2 + C
H 3 = H3 + D
H 4 = H4 + E
H 5 = H5 + F
H 6 = H6 + G
H 7 = H7 + H
h(x) = H0 || H1 || H2 || H3 || H4 || H5 || H6 || H7
10.2. HASH FUNCTIONS 507
h0 = 6A09E667F 3BCC90816
h1 = BB67AE8584CAA73B16
h2 = 3C6EF 372F E94F 82B16
h3 = A54F F 53A5F 1D36F 116
h4 = 510E527F ADE682D116
h5 = 9B05688C2B3E6C1F16
h6 = 1F 83D9ABF B41BD6B16
h7 = 5BE0CD19137E217916
10.2. HASH FUNCTIONS 509
Additive Constants
y0 = 428A2F 98D728AE2216 y1 = 7137449123EF 65CD16
y2 = B5C0F BCF EC4D3B2F16 y3 = E9B5DBA58189DBBC16
y4 = 3956C25BF 348B53816 y5 = 59F 111F 1B605D01916
y6 = 923F 82A4AF 194F 9B16 y7 = AB1C5ED5DA6D811816
y8 = D807AA98A303024216 y9 = 12835B0145706F BE16
y10 = 243185BE4EE4B28C16 y11 = 550C7DC3D5F F B4E216
y12 = 72BE5D74F 27B896F16 y13 = 80DEB1F E3B1696B116
y14 = 9BDC06A725C7123516 y15 = C19BF 174CF 69269416
y16 = E49B69C19EF 14AD216 y17 = EF BE4786384F 25E316
y18 = 0F C19DC68B8CD5B516 y19 = 240CA1CC77AC9C6516
y20 = 2DE92C6F 592B027516 y21 = 4A7484AA6EA6E48316
y22 = 5CB0A9DCBD41F BD416 y23 = 76F 988DA831153B516
y24 = 983E5152EE66DF AB16 y25 = A831C66D2DB4321016
y26 = B00327C898F B213F16 y27 = BF 597F C7BEEF 0EE416
y28 = C6E00BF 33DA88F C216 y29 = D5A79147930AA72516
y30 = 06CA6351E003826F16 y31 = 142929670A0E6E7016
y32 = 27B70A8546D22F F C16 y33 = 2E1B21385C26C92616
y34 = 4D2C6DF C5AC42AED16 y35 = 53380D139D95B3DF16
y36 = 650A73548BAF 63DE16 y37 = 766A0ABB3C77B2A816
y38 = 81C2C92E47EDAEE616 y39 = 92722C851482353B16
y40 = A2BF E8A14CF 1036416 y41 = A81A664BBC42300116
y42 = C24B8B70D0F 8979116 y43 = C76C51A30654BE3016
y44 = D192E819D6EF 521816 y45 = D69906245565A91016
y46 = F 40E35855771202A16 y47 = 106AA07032BBD1B816
y48 = 19A4C116B8D2D0C816 y49 = 1E376C085141AB5316
y50 = 2748774CDF 8EEB9916 y51 = 34B0BCB5E19B48A816
y52 = 391C0CB3C5C95A6316 y53 = 4ED8AA4AE3418ACB16
y54 = 5B9CCA4F 7763E37316 y55 = 682E6F F 3D6B2B8A316
y56 = 748F 82EE5DEF B2F C16 y57 = 78A5636F 43172F 6016
y58 = 84C87814A1F 0AB7216 y59 = 8CC702081A6439EC16
y60 = 90BEF F F A23631E2816 y61 = A4506CEBDE82BDE916
y62 = BEF 9A3F 7B2C6791516 y63 = C67178F 2E372532B16
y64 = CA273ECEEA26619C16 y65 = D186B8C721C0C20716
y66 = EADA7DD6CDE0EB1E16 y67 = F 57D4F 7F EE6ED17816
y68 = 06F 067AA72176F BA16 y69 = 0A637DC5A2C898A616
y70 = 113F 9804BEF 90DAE16 y71 = 1B710B35131C471B16
y72 = 28DB77F 523047D8416 y73 = 32CAAB7B40C7249316
y74 = 3C9EBE0A15C9BEBC16 y75 = 431D67C49C100D4C16
y76 = 4CC5D4BECB3E42B616 y77 = 597F 299CF C657E2A16
y78 = 5F CB6F AB3AD6F AEC16 y79 = 6C44198C4A47581716
510 CHAPTER 10. CRYPTOGRAPHIC COMPONENTS
3. Compute the 128-bit value b mod 2128 and append this value
to the result of Step 2 using big-endian notation, i.e. the
upper 64-bit word followed by the lower 64-bit word.
1. H0 = h0 , H1 = h1 , H2 = h2 , H3 = h3 , H4 = h4 ,
H5 = h5 , H6 = h6 , H7 = h7
2. For i = 0 T o m − 1
(a) For j = 0 T o 15
10.2. HASH FUNCTIONS 511
i. T emp[j] = x16i + j
3. A = H0 , B = H1 , C = H2 , D = H3 , E = H4 , F = H5 ,
G = H6 , H = H7
4. For j = 16 T o 79
σ0 (u) = (u 1) ⊕ (u 8) ⊕ (u >>> 7)
σ1 (u) = (u 19) ⊕ (u 61) ⊕ (u >>> 6)
1. For j = 0 T o 79
H0 = H0 + A
H 1 = H1 + B
H 2 = H2 + C
H 3 = H3 + D
H 4 = H4 + E
H 5 = H5 + F
H 6 = H6 + G
H 7 = H7 + H
h(x) = H0 || H1 || H2 || H3 || H4 || H5 || H6 || H7
h0 = CBBB9D5DC1059ED816
h1 = 629A292A367CD50716
h2 = 9159015A3070DD1716
h3 = 152F ECD8F 70E593916
h4 = 67332667F F C00B3116
h5 = 8EB44A876858151116
h6 = DB0C2E0D64F 98F A716
h7 = 47B5481DBEF A4F A416
10.2.2.5 RIPEMD-160
h1 = 6745230116
h2 = EF CDAB8916
h3 = 98BADCF E16
h4 = 1032547616
h5 = C3D2E1F 016
Additive Constants
⎧
⎪
⎪ 0000000016 0 ≤ j ≤ 15
⎪
⎪
⎪
⎪
⎪
⎪ 5A82799916 16 ≤ j ≤ 31
⎪
⎪
⎨
yLj = ⎪ 6ED9EBA116 32 ≤ j ≤ 47
⎪
⎪
⎪
⎪
⎪
⎪
⎪
8F 1BBCDC16 48 ≤ j ≤ 63
⎪
⎪
⎩
A953F D4E16 64 ≤ j ≤ 79
10.2. HASH FUNCTIONS 517
⎧
⎪
⎪ 50A28BE616 0 ≤ j ≤ 15
⎪
⎪
⎪
⎪
⎪
⎪ 5C4DD12416 16 ≤ j ≤ 31
⎪
⎪
⎨
yRj = ⎪ 6D703EF 316 32 ≤ j ≤ 47
⎪
⎪
⎪
⎪
⎪
⎪
⎪
7A6D76E916 48 ≤ j ≤ 63
⎪
⎪
⎩
0000000016 64 ≤ j ≤ 79
s R0 ... sR15 = 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6
sR16 ... sR31 = 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11
sR32 ... sR47 = 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5
sR48 ... sR63 = 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8
sR64 ... sR79 = 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
3. Compute the 64-bit value b mod 264 and append this value
to the result of Step 2 using little-endian notation, i.e. the
lower 32-bit word followed by the upper 32-bit word.
1. H1 = h1 , H2 = h2 , H3 = h3 , H4 = h4 , H5 = h5
2. For i = 0 T o m − 1
(a) For j = 0 T o 15
i. T emp[j] = x16i + j
10.2. HASH FUNCTIONS 519
3. AL = H1 , BL = H2 , CL = H3 , DL = H4 , EL = H5
4. AR = H1 , BR = H2 , CR = H3 , DR = H4 , ER = H5
Both the RIPEMD-160 left line and right line process the input
data via five rounds that are each executed sixteen times. Each
round employs a different function, and these functions are defined
as [202]:
f (u, v, w) = u ⊕ v ⊕ w
g(u, v, w) = (u · v) + (u · w)
h(u, v, w) = (u + v) ⊕ w
k(u, v, w) = (u · w) + (v · w)
l(u, v, w) = u ⊕ (v + w)
1. For j = 0 T o 15
1. For j = 16 T o 31
1. For j = 32 T o 47
1. For j = 48 T o 63
1. For j = 64 T o 79
(b) AL = EL , BL = EL + (t sLj ), CL = BL ,
DL = CL 10, EL = DL
1. For j = 0 T o 15
1. For j = 16 T o 31
1. For j = 32 T o 47
(b) AR = ER , BR = ER + (t sRj ), CR = BR ,
DR = CR 10, ER = DR
1. For j = 48 T o 63
1. For j = 64 T o 79
Following the completion of the fifth round of both the left line
and the right line, a final update occurs [202]:
t = H1
H1 = H2 + CL + DR
H2 = H3 + DL + ER
H3 = H4 + EL + AR
H4 = H5 + AL + BR
H5 = t + BL + CR
10.2. HASH FUNCTIONS 523
Hash Throughput
Algorithm Processor (Mbps)
MD4 [72] 90 MHz Pentium (Assembly) 165.7
MD5 [72] 90 MHz Pentium (Assembly) 113.5
SHA-1 [249] 133 MHz DEC Alpha 41.5
SHA-256 [281] 3 GHz Pentium 4 59.8
SHA-384 [302] 800 MHz Athlon 95.0
SHA-512 [302] 800 MHz Athlon 91.5
RIPEMD-160 [249] 133 MHz DEC Alpha 48.0
a) Hi = Hi − 1 ⊕ exi (Hi − 1)
b) Hi = Hi − 1 ⊕ xi ⊕ eg(Hi − 1)
(xi )
a) Explain why DES is a poor choice for the block cipher core
of the Hash Function.
must be a function of both the shared secret key and the message
being sent. Such a structure allows two communicating parties,
Alice and Bob, to prove that one of the parties generated a given
message because only these parties have access to their shared se-
cret key. For a given message x, the protocol for transmitting a
message between two communicating parties, Alice and Bob, using
MACs is as follows:
3. Bob uses the secret key and the MAC function, sometimes
referred to as a cryptographic checksum, to generate the MAC
y = M ACk (x) for the message x.
10.3.1 Algorithms
y0 = ek (x0 ⊕ IV )
yi = ek (xi ⊕ yi − 1)
IV
yn
xi
64
64
DES–1
yi–1
64
k
56
yn xn...x0
64
DES
yi–1
k
64
56
64
64
IV
xi
Cryptographic Protocols
537
538 CHAPTER 11. CRYPTOGRAPHIC PROTOCOLS
• Confidentiality
• Data Integrity
• Message Authentication
• Non-repudiation
Alice Bob
Y
X e(x) e–1(x) X
Oscar
k k
a given message because Alice may claim that Bob fabricated the
message and sent it to himself. Alice may make this claim because
she and Bob share the same key, k, for use with the symmetric-key
encryption algorithm.
Alice Bob
Y
X e(x) e–1(x) X
Oscar
KPUB-BOB KPRIV-BOB
[X, h(X)]
X II X
k k
The use of a MAC provides weak data integrity for the in-
formation transmitted between Alice and Bob, assuming that the
MAC is secure. Should Oscar modify the message X or the MAC
M ACk (X), Bob will detect the modification when comparing the
computed MAC value and the received MAC value. However,
this service exists only if there are a total of two communicating
parties. If a third communicating party, Charlie, is added to the
network, Bob is unable to determine the integrity of the message
sent by Alice because the message may be intercepted, modified,
a new MAC generated, and then forwarded by Charlie to Bob.
Bob is unable to detect the attack initiated by Charlie because all
communicating parties on the network share the same key, k, for
use with the MAC . Note that this protocol also provides other se-
curity services in addition to data integrity. If the recipient Bob is
capable of distinguishing between valid and invalid messages, then
the protocol provides weak message authentication for the same
11.1. SECURITY SERVICES 543
[X, SIGKPR-ALICE(X)]
X II X
Alice Bob
Oscar
SIG VER T/F
KPR-ALICE KPUB-ALICE
[X, SIGKPR-ALICE(h(X))]
X II X
SIGKPR-ALICE(h(X))
SIGKPR-ALICE(h(X)) X
Oscar
h(X) SIG h(X) VER T/F
KPR-ALICE KPUB-ALICE
545
Alice Bob
eK[X, SIGKPR-ALICE(h(X))]
X II e(X) e–1(X) X
SIGKPR-ALICE(h(X))
SIGKPR-ALICE(h(X)) X
KPR-ALICE KPUB-ALICE
547
T/F
X
MACK1(X)
+MAC
K1
Bob
X
e–1(X)
K2
eK2[X, MACK1(X)]
Oscar
e(X)
K2
MACK1(X)
Alice
II
MAC
K1
X
• Entity Authentication
• Access Control
Alice Bob
Trusted
KAF KBF KCF KDF KEF Frank Authority Charlie KAC KBC KCD KCE KCF
Edward David
KAE KBE KCE KDE KEF KAD KBD KCD KDE KDF
n · (n − 1) n2 − n n2
2
= 2
≈ 2
keys. Moreover, the Trusted Authority
must transmit n · (n − 1) = n2 − n ≈ n2 keys so that
all of the parties may communicate securely with each other. Fi-
nally, such an architecture scales poorly because the addition of
a communicating party to the network requires that every other
communicating party receive a new key to allow secure communi-
cation with the newly added party.
4. Alice and Bob decrypt the session key, KS , using the agreed
upon symmetric-key cryptosystem.
Alice and Bob are now able to communicate securely using the
session key, KS , and an agreed upon symmetric-key cryptosystem.
Note that this symmetric-key cryptosystem is not necessarily the
same symmetric-key cryptosystem used to transmit the session key
from the Key Distribution Center to Alice and Bob. In this model,
the Key Distribution Center stores a total of n secret keys, allow-
ing the Key Distribution Center to communicate with each party
on the network. If a communicating party is added to the network,
only one new key must be generated so that this new communi-
cating party can communicate securely with the Key Distribution
Center . Moreover, each party on the network must store only one
key, the secret key that allows the party to communicate securely
with the Key Distribution Center .
6. Bob decrypts the session key KS using the secret key he shares
with the Key Distribution Center and then decrypts the mes-
sage x using the session key KS .
11.2.4 Certificates
For the Cyclic Group formed by Zp∗ and the multiplication op-
eration, the Diffie-Hellman Key Agreement Protocol key establish-
ment stage may be modified to include the use of certificates, as
shown in Figure 11.11, to establish a shared secret between two
parties, Alice and Bob, who wish to communicate.
2 Compute KP U BA = bA Compute KP U BB = bB
= αaA mod p = αaB mod p
3 Send −→ ←− Send
C(A) = C(B) =
[ID(A), bA , sigCA (ID(A), bA )] [ID(B), bB , sigCA (ID(B), bB )]
to Bob to Alice
2 Compute KP U BA = bA
= αaA mod p
3 Send bA to Bob −→
8 ←− Send
[C(B), bB , sigB (bA , bB )]
to Alice
13 Send −→
[C(A), sigA (bA , bB )]
to Bob
11.3 Applications
11.3.1 Kerberos
Stage 1
use by the client and the TGS that the Kerberos authentica-
tion server encrypts with the client’s secret key.
6. The client decrypts the first Ticket Granting Ticket using the
client’s secret key, extracting the session key.
Stage 2
Database Check
Ticket Granting Ticket 1 = eKCLIENT(KSESSION1)
Client Kerberos
Authentication
Server
6. The TGS sends the encrypted Server Ticket and the en-
crypted session key for use by the client and the specified
server to the client.
7. Using the session key shared by the client and the TGS , the
client decrypts the session key for use by the client and the
specified server.
Stage 3
2. The client sends the encrypted Server Ticket and the en-
crypted authenticator to the specified server.
AUTHCLIENT = dKSESSION1(eKSESSION1(AUTHCLIENT))
KSESSION2 = dKSESSION1(KSESSION2)
Server Ticket = eKSERVER(AUTHCLIENT, KSESSION2)
AUTHCLIENT = dKSESSION2(eKSESSION2(AUTHCLIENT))
Client Server
Pretty Good Privacy (PGP) [108, 274, 297, 340, 341] is a security
program developed by Phil Zimmermann in 1995 for electronic
mail. PGP employs four cryptographic components:
SIGKPR-SENDER(h(X)) eKPUB-RECIPIENT[KSESSION]
h(X) Public
SHA–1 SIG Key
Algorithm
6. The signed 160-bit hashed value is is verified via one of the ap-
proved Digital Signature algorithms using the sender’s public
key and the 160-bit hashed value generated by the recipient.
eKPUB-RECIPIENT[KSESSION]
KSESSION
Public
Key SHA–1
Algorithm
h(X)
KPR-RECIPIENT SIGKPR-SENDER(h(X))
VER T/F
KPUB-SENDER
(now owned by AOL LLC) and the design of SSL Version 3 was
open to public scrutiny. The goal of SSL is to provide end-to-
end security over TCP via two protocol layers that form the SSL
Protocol Stack . The SSL Record Protocol resides above the TCP
layer on the SSL Protocol Stack and provides security services to
upper layer protocols, including the Hypertext Transfer Protocol
(HTTP). SSL also defines three upper layer protocols that reside
above the TCP layer on the SSL Protocol Stack — the SSL Hand-
shake Protocol , the SSL Change Cipher Spec Protocol , and the
SSL Alert Protocol [298].
Note that the MAC employs either the MD5 or the SHA-1
Hash Function and a shared secret key. Also note that SSL encryp-
tion supports the use of the block ciphers AES , IDEA, RC2-40 ,
DES-40 , DES , Triple-DES , and Fortezza in addition to the stream
ciphers RC4-40 and RC4-128 . Clearly, many of these encryption
algorithms are no longer considered to be secure. However, SSL al-
lows communicating parties to negotiate the encryption algorithm
on a per-session basis. Therefore, algorithms no longer considered
secure must be given the lowest priority for selection whereas se-
cure algorithms must be given the highest priority for selection to
guarantee the security of the connection.
11.3. APPLICATIONS 581
The SSL Change Cipher Spec Protocol uses the SSL Record Pro-
tocol to transmit a message that causes the update of the current
state and thus updates the Connection’s list of supported crypto-
graphic algorithms, termed the Cipher Suite. The Cipher Suite
lists algorithms in order of preference with the most preferred al-
gorithm listed first. Each list element also defines a key exchange
method and the Cipher Spec, which specifies the encryption algo-
rithm and the Hash Function used for MAC generation.
The SSL Alert Protocol uses the SSL Record Protocol to trans-
mit alert messages to the Connection’s other peer. Fatal alert
messages result in the immediate termination of the Connection.
Warning messages do not cause the termination of the Connection
but are still indications of serious error conditions.
2. The server sends a hello message to the client with entries for
the associated parameters:
(b) The Cipher Suite chosen by the server from the client’s
list.
1. The server sends its certificate to the client so that the client
can authenticate the server’s identity. Note that this step
does not occur if the Anonymous Diffie-Hellman Key Agree-
ment Protocol was selected as the key exchange method.
1. The client verifies the server’s certificate if the server has sent
its certificate to the client.
2. The client sends its certificate to the server if the server has
requested the client’s certificate.
Protocol Completion
delivered with SSL built into the application. Note that Transport
Layer Security (TLS) is a standardized version of SSL [67] that is
based on SSL Version 3 [298].
ing data. These elements control the application of the input and
output cryptographic algorithms to the data, perform verification
of authentication data, and modify the IP headers if necessary
[232].
595
596 REFERENCES
Press.
[60] A. Daly, W. Marnane, T. Kerins, and E. Popovici. An FPGA
Implementation of a GF(p) ALU for Encryption Processors.
Microprocessors and Microsystems, 28(5-6):253–260, August
2004.
[61] A. K. Daneshbeh and M. A. Hasan. Area Efficient High
Speed Elliptic Curve Cryptoprocessor for Random Curves.
In Proceedings of the Symposium on Information Technology:
Coding and Computing — ITCC 2004, volume 2, pages 588–
592, Las Vegas, Nevada, USA, April 5–7 2004.
[62] G. M. de Dormale and J.-J. Quisquater. High-Speed Hard-
ware Implementations of Elliptic Curve Cryptography: A
Survey. Journal of Systems Architecture, 53(2-3):72–84,
February 2007.
[63] J. Deepakumara, H. M. Heys, and R. Venkatesan. FPGA
Implementation of MD5 Hash Algorithm. In Proceedings of
the Canadian Conference on Electrical and Computer Engi-
neering — CCECE 2001, volume 2, pages 919–924, Toronto,
Ontario, Canada, May 13–16 2001.
[64] B. den Boer and A. Bosselaers. An Attack on the Last
Two Rounds of MD4. In J. Feigenbaum, editor, Advances in
Cryptology — CRYPTO ’91, volume LNCS 576, pages 194–
203, Santa Barbara, California, USA, August 11–15 1991.
Springer-Verlag.
[65] B. den Boer and A. Bosselaers. Collisions for the Compres-
sion Function of MD5. In T. Helleseth, editor, Advances in
Cryptology — EUROCRYPT ’93, volume LNCS 765, pages
293–304, Lofthus, Norway, May 23–27 1993. Springer-Verlag.
[66] C. D’Halluin, G. Bijnens, V. Rijmen, and B. Preneel. At-
tack on Six Rounds of Crypton. In L. R. Knudson, editor,
Sixth International Workshop on Fast Software Encryption,
volume LNCS 1636, pages 46–59, Rome, Italy, March 24–26
1999. Springer-Verlag.
[67] T. Dierks and C. Allen. RFC 2246: The TLS Protocol Ver-
sion 1.0. Corporation for National Research Initiatives, In-
ternet Engineering Task Force, Network Working Group, Re-
ston, Virginia, USA, January 1999.
[68] M. J. Diez, S. Bojanić, L. J. Stanimirović, C. Carreras,
and O. Nieto-Taladriz. Hash Algorithms for Cryptographic
Protocols: FPGA Implementations. In Proceedings of the
Telecommunications Forum — TELFOR 2002, pages 26–28,
Belgrade, Yugoslavia, November 26–28 2002.
[69] W. Diffie. The First Ten Years of Public-Key Cryptography.
Proceedings of the IEEE, 76(5):560–577, May 1988.
[70] W. Diffie and M. E. Hellman. New Directions in Cryptogra-
602 REFERENCES
Technology.
[103] T. El Gamal. A Public-Key Cryptosystem and a Signature
Scheme Based on Discrete Logarithms. IEEE Transactions
on Information Theory, 31(4):469–472, 1985.
[104] T. S. Ganesh, M. T. Frederick, T. S. B. Sudarshan, and
A. K. Somani. Hashchip: A Shared-Resource Multi-Hash
Function Processor Architecture on FPGA. Integration, the
VLSI Journal, 40(1):11–19, January 2007.
[105] T. S. Ganesh and T. S. B. Sudarshan. ASIC Implementa-
tion of a Unified Hardware Architecture for Non-Key Based
Cryptographic Hash Primitives. In Proceedings of the In-
ternational Conference on Information Technology: Coding
and Computing — ITCC ’05, volume 1, pages 580–585, Las
Vegas, Nevada, USA, April 4–6 2005.
[106] T. S. Ganesh, T. S. B. Sudarshan, N. K. Srinivasan, and
K. Jayapal. Pre-Silicon Prototyping of a Unified Hard-
ware Architecture for Cryptographic Manipulation Detec-
tion Codes. In Proceedings of the Third IEEE International
Conference on Field Programmable Technology — ICFPT
2004, pages 323–326, Brisbane, Australia, December 6–8
2004.
[107] F. Gang. Design of Modular Multiplier Based on Improved
Montgomery Algorithm and Systolic Array. In Proceedings
of the First International Multi-Symposiums on Computer
and Computational Sciences — IMSCCS ’06, volume 2,
pages 356–359, Hangzhou, China, April 20–24 2006.
[108] S. L. Garfinkel. PGP: Pretty Good Privacy. O’Reilly and
Associates, Sebastopol, California, USA, 1995.
[109] W. Geiselmann and R. Steinwandt. A Redundant Represen-
tation of GF (q n ) for Designing Arithmetic Circuits. IEEE
Transactions on Computers, 52(7):848–853, July 2003.
[110] P. Gil. How Big Is the Internet?
http://netforbeginners.about.com/cs/technoglossary/
f/FAQ3.htm, 2005.
[111] C. Grabbe, M. Bednara, J. von zur Gathen, J. Shokrol-
lahi, and J. Teich. A High Performance VLIW Proces-
sor for Finite Field Arithmetic. In Proceedings of the
Seventeenth International Parallel and Distributed Process-
ing Symposium, Reconfigurable Architectures Workshop —
IPDPS 2003, RAW 2003, Nice, France, April 22 2003.
[112] T. Grembowski, R. Lien, K. Gaj, N. Nguyen, P. Bellows,
J. Flidr, T. Lehman, and B. Schott. Comparative Anal-
ysis of the Hardware Implementations of Hash Functions
SHA-1 and SHA-512. In A. H. Chan and V. Gligor, editors,
Proceedings of the Fifth International Information Security
606 REFERENCES
224, 1993.
[202] A. J. Menezes, P. C. van Oorschot, and S. A. Vanstone.
Handbook of Applied Cryptography. CRC Press, Boca Raton,
Florida, USA, 1997.
[203] Q. Meng, Y.-F. Liu, and Z.-B. Dai. FPGA Implementation
of Expandable RSA Public-Key Cryptographic Coprocessor.
In Proceedings of the 2006 First International Symposium
on Pervasive Computing and Applications, pages 552–555,
Urumqi, China, August 3–5 2006.
[204] N. Mentens, S. B. Örs, and B. Preneel. An FPGA Implemen-
tation of an Elliptic Curve Processor GF(2m ). In Proceedings
of the ACM Great Lakes Symposium on VLSI, pages 454–
457, Boston, Massachusetts, USA, April 26–28 2004.
[205] N. Mentens, K. Sakiyama, L. Batina, I. Verbauwhede, and
B. Preneel. FPGA-Oriented Secure Data Path Design: Im-
plementation of a Public Key Coprocessor. In Proceedings of
the International Conference on Field Programmable Logic
and Applications — FPL ’06, pages 1–6, Madrid, Spain, Au-
gust 28–30 2006.
[206] H. Michail, A. P. Kakarountas, O. Koufopavlou, and C. E.
Goutis. A Low-Power and High-Throughput Implementa-
tion of the SHA-1 Hash Function. In Proceedings of the
2005 IEEE International Symposium on Circuits and Sys-
tems — ISCAS 2005, volume 4, pages 4086–4089, Kobe,
Japan, May 23–26 2005. IEEE, Inc.
[207] E. A. Michalski and D. A. Buell. A Scalable Architecture
for RSA Cryptography on Large FPGAs. In Proceedings of
the International Conference on Field Programmable Logic
and Applications — FPL ’06, pages 1–8, Madrid, Spain,
August 28–30 2006.
[208] S. P. Miller, B. C. Neuman, J. I. Schiller, and J. H. Saltzer.
Kerberos Authentication and Authorization System. Tech-
nical Report Section E.2.1: Project Athena Technical Plan,
Department of Electrical Engineering and Computer Sci-
ence, Massachusetts Institute of Technology, Cambridge,
Massachusetts, USA, October 27 1987.
[209] V. Miller. Uses of Elliptic Curves in Cryptography. In H. C.
Williams, editor, Advances in Cryptology — CRYPTO ’85,
volume LNCS 218, pages 417–426, Santa Barbara, Califor-
nia, USA, August 18–22 1985. Springer-Verlag.
[210] P. L. Montgomery. Modular Multiplication without Trial Di-
vision. Mathematics of Computation, 44(170):519–521, April
1985.
[211] N. Nedjah and L. de Macedo Mourelle. Three Hardware Ar-
616 REFERENCES
629
630 INDEX