Modern Cryptography Primer BOOK
Modern Cryptography Primer BOOK
Marian Srebrny
Modern
Cryptography
Primer
Theoretical Foundations
and Practical Applications
Modern Cryptography Primer
[email protected]
Czesław Kościelny r Mirosław Kurkowski r
Marian Srebrny
Modern
Cryptography
Primer
Theoretical Foundations
and Practical Applications
[email protected]
Czesław Kościelny Marian Srebrny
Faculty of Information Technology Institute of Computer Science
Wrocław School of Information Technology Polish Academy of Sciences
Wrocław, Poland Warsaw, Poland
and
Mirosław Kurkowski
Inst. of Computer and Information Sciences Section of Informatics
Czestochowa University of Technology University of Commerce
Czestochowa, Poland Kielce, Poland
and
European University of Information
Technology and Economics
Warsaw, Poland
[email protected]
Preface
For centuries, the need to ensure confidentiality of some gathered or transmitted in-
formation got a lot of attention in various political or military contexts. Nowadays,
in the era of a general necessity for privacy, and the conscious awareness of one’s
rights to it, cryptography is found useful in a wide range of practical applications.
For the most part, it is used for securing confidentiality in interpersonal computer-
ized communication. The turn of the 21st century is sometimes called the Internet
age, computer era; communication takes place instantly and without hindrance. Ob-
viously, no one can imagine the functioning of various types of communication and
telecommunication networks without the appropriate security measures against un-
desirable listening in on our information.
Modern cryptography would not exist without solid mathematical foundations,
especially in number theory. The recent and most advanced security algorithms are
built on such arithmetic constructs as integer arithmetic divisibility, modulo opera-
tions, prime numbers, or the Euler function.
Today’s societies depend to a large extent on computers which process huge
amounts of information, often transferred via telecommunication networks, and
stored in databases. This information often needs adequate security protection
against being read by unauthorized users of computer systems and networks, par-
ticularly illegal users. Cryptography provides economical means that enable this
protection. The experts in cryptography work on more and more efficient methods
of ensuring the secrecy of information and electronic documents which require it.
Striking advances in the proliferation of electronic data storage, linkage, and trans-
mission have created significant new challenges in maintaining confidentiality and
developing adequate methods of authentication. The ambition of cryptanalysis and
cryptanalysts is to break the security codes and forge encrypted messages in such a
way that they look authentic.
Until quite recently, cryptography was applied only in the area of military forces
and diplomacy. This is also why cryptographers usually worked in agencies dealing
with state security, and all research work concerning cryptography, as well as crypt-
analysis, was classified. It was not until the late 1960s that a multinational group
of scholars, who were not controlled by security agencies, became interested in the
[email protected]
vi Preface
problems of cryptology and started to publish their research papers on this subject,
thanks to which cryptographic data protection was found useful also in various civil-
ian fields. The new paradigm requires that the cryptographic algorithms be publicly
known, whereas only the private keys must be secret. Nowadays, the public access
to the algorithms is treated as a safeguard of their security, assurance that there are
no flaws due either to poor, unprofessional work by their designers or to deliberate
insertion of so-called hidden backdoors (e.g., collecting copies of private keys).
Cryptographic methods are the most efficient ways of secure protection of mod-
ern telecommunication network users against computer break-ins, which have by
now become a plague. That is why business promotes the use of cryptography since
a basic requirement for worldwide economic growth is the development of secure
worldwide computer networks underlying the information society economic infras-
tructure. In this context, possible administrative limitations on the use of cryptogra-
phy are considered responsible for a substantial decline in a country’s attractiveness
in the eyes of foreign investors. Cryptographic security means are inevitable in or-
der to improve trading and legal proceedings in the electronic economy, as well as
to ensure at least the minimum of civil privacy and freedom.
The aim of this book is to introduce the currently most interesting and most
important issues of modern applied cryptography in the technological practice of
telecommunication networks, along with the necessary basic mathematics. Cryp-
tography is an area on the edge of mathematics and practical software engineering.
Like no other, it combines immense, challenging unsolved mathematical problems
with the issues of authentic use in practical security tools in currently deployed vital
data communication systems.
We present all the best known and most often used technologies, algorithms and
protocols, and methods of their design and analysis. The algorithms are presented
in readable pseudocode; i.e., written in English with some mathematical or pro-
gramming symbols, or simple graphics and diagrams. We will not go into details
on finding implementation bugs or methods of program engineering depending on
the features of a particular programming environment, specification and implemen-
tation in any favorite programming language.
We bring particular attention in this book to performance analysis of the pre-
sented algorithms and protocols because since the late 1980s efficiency has essen-
tially become the central concept to understanding modern cryptographic mecha-
nisms, their usage, and many related problems, especially the problems of breaking
the codes.
There are many very good publications on the market devoted to cryptography
and/or its usage. However, only very few of them can serve as course textbooks.
The material they present seems to us either extensively broad or too narrow for a
graduate course, often too mathematical, and therefore very difficult for the majority
of student readers with no deep mathematical background.
This book is written at the level of a graduate lecture course textbook for students
of any technical university in the European Union or North America. As prerequi-
sites it requires only some very basic elementary mathematical experience in alge-
bra, number theory, probability, data structures, as well as the design and efficient
[email protected]
Preface vii
analysis of algorithms. The material presented in the book can constitute a one-year
graduate course, as well as providing material for shorter courses on selected topics
to be used without the need to search other parts of the book. Each chapter contains
all the necessary background information concerning the problems being discussed.
Selected chapters can constitute a reasonable basis for further studies of the subject,
e.g., in the form of seminar or term credit papers, etc. The references provided will
definitely be of help in completing such tasks. For the same reason, this book can be
treated as a useful source of information in the field of data and network transactions
security for practitioners and researchers just after their studies.
Today’s cryptography is a very broad and lively field. We are aware that many
areas need much broader treatment. For example, the elliptic curve algorithms,
quantum cryptography, secret sharing, and various cryptanalytic techniques. Cryp-
tographic hash algorithms are limited in this book to signaling the basic approaches
and challenges, with no coverage of the most recent very interesting advances. These
areas have got a lot of attention in the last few years, with many different methods
and their own challenges. These topics will be covered in full detail in our follow-up
textbook to appear soon.
This book consists of nine chapters discussing today’s actual practice in applied
cryptography from the very basics to strong state-of-the-art security algorithms and
protocols.
The first chapter introduces the basic concepts of cryptography. The general di-
agram of encryption/decryption, as well as the notion of a cryptographic algorithm
and the definition of cryptographic keys are discussed. The rules for building strong
cryptographic codes are introduced. The chapter also presents the fundamental no-
tions of theoretical and practical computational complexity, and discusses its mean-
ing for determining the difficulty of breaking cryptosystems. Next, we introduce
codes known from history such as Caesar’s ancient code, and Playfair and Enigma,
which were applied during the World Wars.
Modern cryptography would not exist without solid mathematical foundations,
therefore in Chap. 2 we recollect and present mathematical concepts and properties
required for continuing the course. Elements of the theory of algebraic structures, as
well as elements of number theory, are presented. Also, we present simple arithmetic
algorithms applied in cryptography. The chapter ends with a discussion on currently
applied algorithms for testing integer primality, and computationally hard problems
in number theory.
In Chap. 3 the most important symmetric ciphers are presented, among them the
standards of symmetric encryption applied in widespread practice today. The DES
(Data Encryption Standard) algorithm, its modifications and modes of operation
are given and discussed in detail. A lot of attention is focused on the most recent
American standard for symmetric cipher, the AES (Advanced Encryption Standard)
algorithm. The IDEA algorithm, as well as the algorithms of the RC family are pre-
sented. As an interesting detail illustrating the resistance of encryption algorithms
against attempts to break them, we present the process of the global competition in
breaking RC algorithms, and the results.
In Chap. 4 the reader will find exact descriptions of asymmetric algorithms, be-
ginning with the Diffie-Hellman scheme, through the ElGamal algorithm. Next, the
[email protected]
viii Preface
well known RSA algorithm, and various issues concerning unceasing attempts to
break it are discussed. An interesting detail is the discussion on the results of the
RSA factorization challenge, illustrating the cryptographic power of the RSA code.
Chapter 5 presents one of the most important modern applications of cryptogra-
phy, namely the electronic signature. The general scheme, as well as several of the
currently most essential and most interesting applied algorithms for generation and
verification of the validity of e-signature are covered. We present various algorithms
of digital signature and hash functions. We discuss the current issues concerning the
usage of these functions, and their security.
In Chap. 6 the reader will find the exact description of the popular cryptosystem
PGP (Pretty Good Privacy). The overall scheme of the system and the algorithms
used in it are surveyed. The installation and the usage of PGP are described, encryp-
tion and signing documents (messages, e-mails, files) among others. In this chapter,
the authors introduce other, non-commercial solutions enabling the application of
strong cryptography by any computer user.
Chapter 7 is devoted to the public key infrastructure as a solution enabling ap-
plication of the electronic signature for business and legal proceedings in the form
required by legislation in most countries. The role of the so-called trusted third party
in contemporary solutions, as well as the issues concerning certification of crypto-
graphic keys, are presented.
Another important feature of cryptography in day-to-day reality is the crypto-
graphic protocols applied often in mass scale in all kinds of communication via com-
puter networks, especially for entity authentication and preventing identity theft.
The goals to be achieved by the cryptographic protocols, as well as their examples,
are presented. Issues and problems of their specification, design and application,
methods of complexity analysis as well as methods of verification of correctness,
and the security of cryptographic protocols are introduced and covered more broadly
than in any other textbook available so far.
In Chap. 9 the remaining aspects of the application of cryptography in data and
transaction security are taken up. The problems and solutions of preserving the se-
crecy and privacy of electronic mail, as well as secure exchange of documents in
electronic form are discussed. The commonly applied SSH (Secure SHell) and SSL
(Secure Socket Layer) protocols are also studied.
Like every book, ours is surely not flawless. In case of any errors, mistakes or in-
accuracies in this publication, we would appreciate if the reader could kindly submit
them to us via e-mail at [email protected]. Any feedback will be appreciated.
In return, we promise an up-to-date list of corrections, a constantly revised corri-
gendum.
Our thanks for help and support in various stages of the process of writing and
editing this book are due to many of our friends and collaborators, as well as our
students, audience and participants in lectures and seminars given by each of us.
Our special thanks must be given to Professor Leonard Bolc (1934–2013) of the
Institute of Computer Science of the Polish Academy of Sciences, without whose
kind and gentle but tenaciously ongoing systematic encouragement this book would
most definitely never have come into existence. Very special acknowledgments go
[email protected]
Preface ix
to Professor Andrzej Borzyszkowski for his fruitful cooperation on the early ver-
sions of the materials for the chapter on the security protocols, their specification
and verification of correctness. Similarly to Maciej Orzechowski. The third author
gratefully acknowledges many useful conversations and discussions with Professors
Paweł Morawiecki, Stanisław Spież, and Jerzy Urbanowicz (1951–2012). The latter
was entirely responsible for dragging the third author in a friendly manner into the
world of cryptologic research and practice, and for educating him on the field’s spe-
cial beauty and problems, splendors and shadows. The first author acknowledges
support from Wrocław School of Information Technology. The second author ac-
knowledges support from Czestochowa University of Technology and the European
University of Information Technology and Economics, Warsaw. We would also like
to thank Kasia Grygiel, Gosia Berezowska, Ewelina Gajek and Janek Jay Halicki
for their help in the preparation of the English version of our book. Last but not
least, the authors thank the copyeditor for his excellent careful work, and Springer’s
Ronan Nugent for successfully and nicely driving us through the whole editorial and
production process.
Poland Czesław Kościelny
August 2013 Mirosław Kurkowski
Marian Srebrny
[email protected]
Contents
xi
[email protected]
xii Contents
[email protected]
Contents xiii
[email protected]
xiv Contents
[email protected]
Chapter 1
Basic Concepts and Historical Overview
1.1 Introduction
Cryptography is the science of transforming, or encoding, information into a form
non-comprehensible for anyone who does not know an appropriate key. In such
forms information can be securely transferred via any communication channel or
stored in data archives with its access restricted or even forbidden (for one rea-
son or another). Cryptography is a part of a broader discipline called cryptology,
which includes also so-called cryptanalysis—the art of breaking codes (ciphers),
i.e., regaining the content of encrypted messages without an authorized access to
the decryption keys.
1.1.1 Encryption
[email protected]
2 1 Basic Concepts and Historical Overview
clearly in general one can encrypt information presented in any form whatsoever—it
requires only an encryption algorithm to be applied or designed for this purpose. In
this book a cipher’s input is considered as binary data.
We usually denote a plaintext message by the letter M and its ciphertext by C.
Computer output ciphertext is a binary data sequence as well, often of the same size
as M, sometimes longer. (In the case of combining encryption with compression,
C may turn out smaller than M; encryption itself does not give this effect, usually.)
One can view encryption as a function E associating with each given plaintext data
its ciphertext data. The encryption procedure can then be written as the mathematical
formula:
E(M) = C.
Similarly, the decryption procedure can be thought of as the function
D(C) = M,
which takes a cipher text C and outputs its plaintext M.
The goal of decrypting an encrypted message is to recapture the input plaintext;
hence the following is required:
D(E(M)) = M.
Historically, the security offered by a cipher was to a large extent based on keep-
ing secret its encryption/decryption algorithm. Modern cryptography considers that
such ciphers do not provide an adequate level of security. For instance, they can-
not be used by a larger group of users. A problem arises when someone would like
to leave the group, the others would have to change the algorithm. A similar proce-
dure would apply when someone reveals the algorithm. Another serious concern and
source of doubt about secret ciphers is due to the impossibility of having the quality
of the algorithms, their standardization and implementations, checked by external
experts.
A secret cipher algorithm would have to be uniquely designed for each group of
users, which excludes the possibility of ready-to-use software or hardware imple-
mentations. Otherwise, an adversary would be able to purchase an identical prod-
uct and run the same encryption/decryption algorithms. Each group of users would
have to design and implement their own cipher. If in such a group there was no good
cryptographer and cryptanalyst, the group would not know if its cipher was reliable
enough.
[email protected]
1.1 Introduction 3
Modern cryptography solves the above security concerns in such a way that usu-
ally the cipher used is publicly known but its encryption/decryption execution uses
an extra private piece of information, called a cryptographic key, which is another
input parameter. A key is usually denoted by the letter K. It can take one of a wide
range or keyspace of possible values, usually numbers.
The central idea is that both encryption and decryption functions use a key, and
their outputs depend on the keys used, with the following formulae:
E(K, M) = C and D(K, C) = M.
In the literature often the following notation appears:
EK (M) = C and DK (C) = M
where the subscripts indicate the key. Note the following property (see Fig. 1.2):
DK (EK (M)) = M.
Some ciphers use different encryption and decryption keys (Fig. 1.3). This means
that the encryption key K1 is different from the corresponding decryption key K2 .
In this case we have the following properties:
EK1 (M) = C, DK2 (C) = M, DK2 (EK1 (M)) = M.
As pointed out above, the security of good ciphers is based on the secrecy of the
keys. The algorithms are publicly known and can be analyzed by the best experts.
Software and hardware implementations or partial components of the ciphers can
be produced and distributed on an industrial scale. Any potential intruder can have
access to the algorithms. As long as she does not know our private key and the cipher
is good enough, she will not be able to read our cryptograms.
By a cipher or cryptosystem we shall mean the two algorithms of encryption and
decryption together with (the space of) all the possible plaintexts, cryptograms and
keys. There are two general types of ciphers which use keys: symmetric ciphers and
public-key ciphers.
Symmetric ciphers, often also called traditional ciphers, secret-key ciphers,
single-key algorithms or one-key algorithms, use the same key for encryption and
decryption. Here, the same means that each of the two keys can be practically de-
termined (computed) from the other. The keys used in such ciphers have to be kept
[email protected]
4 1 Basic Concepts and Historical Overview
secret as long as the communication is supposed to be kept secret. Prior to use these
keys have to be exchanged over a secure channel between the sender and the re-
ceiver. Compromising such a key would enable intruders to encipher and decipher
messages and documents.
The basic idea of public key cryptographic algorithms is that encryption and
decryption use two different keys, matched in such a way that it is not possible in
practice to reconstruct one of them from the other. In such a cryptosystem each user
has a unique pair of keys—public and private. The first of them is publicly available.
Everybody can use it to encrypt messages. But only the corresponding private key
allows decryption. Thus the only person able to run decryption is the one who has
the private key.
[email protected]
1.1 Introduction 5
the frequency of occurrences of various characters. On this basis one can determine
whether the plaintext is a program written in C, a fragment of prose in Japanese, or
an audio file. In each of these cases in every plaintext there is an apparent redun-
dancy of information which can greatly facilitate cryptanalysis. By now many statis-
tical tests based on information theory have been developed, which effectively help
in the breaking of ciphers whenever the plaintext statistics parameters are known.
According to Shannon a cryptographic system that allows excellent protection
against unauthorized access must not provide any statistical information about the
encrypted plaintext at all. Shannon proved that this is the case when the number
of cryptographic keys is at least as large as the number of possible plaintexts. The
key should therefore be of roughly the same or more bits, characters or bytes as
the plaintext, with the assumption that no key can be used twice. Shannon’s perfect
encryption system is called the single-key system or one-time pad.
According to Shannon to define a mathematical model of a reliable system of
strong cryptography it is necessary to be able to reduce the redundancy of plaintext
information, so that the redundancy is not carried into the cryptograms. Shannon
proposed techniques of diffusion and confusion, which in practice have been reduced
by many crypto designers to some kind of alternation of combining block cipher
components with substitutions and permutations.
Claude Elwood Shannon (30 April 1916–24 February 2001) was an eminent
American mathematician, founder of information theory, one of the many schol-
ars working during World War II with US military and government agencies as a
consultant in the field of cryptology.
1 For more on this background topic the reader is referred to [27, 68].
[email protected]
6 1 Basic Concepts and Historical Overview
[email protected]
1.1 Introduction 7
[email protected]
8 1 Basic Concepts and Historical Overview
instances of the same size. We distinguish: pessimistic complexity, that is the case
of input data on which the analyzed algorithm requires the most resources over all
data of that size; expected, or average complexity; and asymptotic complexity, i.e.,
the limit of the complexity function values on arbitrarily large inputs.
Space complexity refers to how much space on the computer is required. Space
complexity of an algorithm (program) is a measure of the amount of memory
needed, for example, the number of cells visited on a Turing machine tape. In this
book, indeed in modern cryptography in general, the required space is expressed in
bits—as the maximum number of bits simultaneously written down (stored) in the
course of the analyzed algorithm run.
It is generally considered that a superpolynomial performance of an algorithm,
i.e., expressed by a function with asymptotic growth faster than all polynomials with
integer coefficients, is infeasible (or intractable) on sufficiently large input data.
For example, when we say that there is no known feasible algorithm for integer
factorization, we usually mean: no algorithm running in polynomial time.
Theoretical polynomial complexity is not a sufficient criterion for practicality.
For example, in 2002 [4] published a polynomial time algorithm checking whether
a given natural number is prime (that is, divisible only by 1 and itself). However, the
degree of this polynomial is too high for practical use in testing primality of numbers
of the size currently interesting in practical applications. These are approximately
1000-bit integers.
One more concept of computational complexity is often called practical com-
plexity and measured in seconds on currently available computers and on input data
of the size of current interest. Algorithm AKS, mentioned above, has too high prac-
tical complexity. Similarly, the currently (August 2012) best attacks on the SHA-1
hash function standard are treated as merely theoretical, because the best of them
gives a chance of finding a collision (i.e., two different messages with the same
hash) in time corresponding to over 260 SHA-1 evaluations. Nobody can have that
much time on currently available computers (without very high extra financial and
organizational effort).
The concepts introduced above have been extensively studied in computational
complexity theory. The standard reference textbooks are [27, 77].
In modern cryptology the strength of a cipher (in general, a cryptosystem) is usu-
ally expressed in terms of the computational complexity of the problem of breaking
the analyzed cipher—how much time or space is required to find the secret key or
recover the plaintext from its encrypted version with no prior knowledge of the ap-
propriate secret key, even when the cryptanalyst has possibly a large number of pairs
plaintext/ciphertext. How much time is required refers to the fastest currently known
algorithm performing this task. Cryptography can be called cryptocomplexity.
Similarly to time complexity, space complexity is defined as the amount of space
required for running an algorithm. It can be measured either by the maximum num-
ber of cells in an abstract machine model of the algorithm execution or by the size
of actual physical memory space expressed in bits or bytes.
[email protected]
1.1 Introduction 9
A specific big-oh notation has been introduced for comparison of the rate of
growth of functions describing the computational complexity of algorithms. The
expression
f (n) ∈ O(g(n))
is read and defined as: function f is at most of order g if and only if there exist
positive real c and natural no such that for every n greater than or equal to no , the
value f (n) is at most equal to the product c · g(n). In symbols it can be written as
follows:
f (n) = O(g(n)) ⇔ ∃c∈R+ ∃n0 ∈N (n ≥ n0 ⇒ f (n) ≤ c · g(n)).
By way of a simple illustration, we give an estimate of the time cost (computa-
tional time complexity) of the algorithms for grade-school addition and multiplica-
tion of binary integers.
Consider two binary numbers x and y of bit-length k. Adding these binary num-
bers is usually realized as k additions of single bits. So, the time complexity is
O(k). Multiplying x by y is in the worst case (when y has all ones in the binary
notation) k − 1 additions of x to x shifted by one bit to the left each time. It requires
(k − 1) · k = k 2 − k additions of single bits. So, the time complexity of integer
multiplication is O(k 2 ), i.e., quadratic.2
[email protected]
10 1 Basic Concepts and Historical Overview
The table clearly shows that even a big increase of hardware computational power
cannot beat the device-independent complexity of an algorithm. The time required
for its execution can become unimaginably large. For example, for n = 100, in both
cases probably we would never see the results.
Here we are talking about asymptotic complexity bounds. This does not exclude
the possibility of particular input data instances of even very large size that can be
computed very fast by an exponential time complexity algorithm. In practice an al-
gorithm’s running time, measured in seconds, behaves irregularly, with many downs
and ups. Over the last decade or two a whole domain of research has arisen with
significant successful real-life applications of some asymptotic exponential time al-
gorithms, often on some industrial-scale input sizes.
One of the simplest encryption algorithms is the so-called Caesar cipher, already
used by the Roman army.3 Let us assume that the texts we want to encrypt are writ-
ten in the 26-letter Latin alphabet excluding capitalization. We assign consecutive
positive integers to symbols of the alphabet (see Table 1.2).
The idea of the algorithm consists in replacing each symbol of a plaintext with
the symbol whose number is greater by three computing modulo 26 (the last three
letters of the alphabet X, Y, Z are replaced with, respectively, A, B, C). If we denote
the integer assigned to a letter x by Lx , then we can write the replacement operation
mathematically in the following way (addition is performed modulo 26, however
we do not replace 26 with 0):
C(Lx ) = Lx + 3.
3 One can find comprehensive information about this and many other ciphers used in the past in
[54]. The history of contemporary cryptography is well discussed in [29]. See also Sect. 7.3 in
[68].
[email protected]
1.2 Simple Stream Ciphers 11
Now we are going to present an encryption algorithm known in the literature as the
Vernam cipher or simply XOR. This algorithm, which requires some mathematical
knowledge, uses the XOR function. Formally, the latter is a Boolean function (i.e.,
a function f : {0, 1} × {0, 1} → {0, 1}) that satisfies the following conditions:
f (0, 0) = f (1, 1) = 0 and f (0, 1) = f (1, 0) = 1.
One can easily notice some of its properties. For arbitrary x, y, z ∈ {0, 1} the
following equations hold:
1. f (x, y) = f (y, x) (commutativity),
2. f (x, x) = 0,
3. f (x, 0) = x (0 is a neutral element of f ).
It can be proved that the function is associative, i.e.,
4. f (x, f (y, z)) = f (f (x, y), z).
When we consider the function XOR as an operation defined on the set {0, 1},
then the above equations can be expressed as follows:
(a) 0 XOR 0 = 1 XOR 1 = 0,
(b) 0 XOR 1 = 1 XOR 0 = 1,
(c) x XOR y = y XOR x,
(d) x XOR x = 0,
(e) x XOR 0 = x,
(f) (x XOR (y XOR z)) = ((x XOR y) XOR z).
[email protected]
12 1 Basic Concepts and Historical Overview
The second equation in the above notation follows from the associativity of XOR,
while the third and the fourth ones follow from properties 2 and 3, respectively.
The cost of this encryption is very low and, as in the case of the Caesar cipher,
is equal to O(k) for a k-bit ciphertext. Let us notice that if the key applied is appro-
priately long (for instance of several bits), then the cipher provides a high security
level. Due to its construction it is not vulnerable to any known attacks but the brute
force technique. The latter, however, is actually unfeasible in the case of long keys
because of its time complexity. Moreover, if the key length is as long as the length
of the ciphertext and the key is used only once, then the Vernam cipher turns out
to be an ideal cipher that cannot be broken. It can easily be seen that one can ad-
just a key for a ciphertext of a given length and any plaintext of the same length.
The complexity of the brute force method for breaking encryption with a k-bit key
equals O(2k ).
Despite its simplicity, the Vernam cipher is still applied: WordPerfect, a very
popular text editor, uses it in an only slightly modified version. This encryption
scheme is used in many other ciphers, e.g., DES and AES, as well. It is also applied
in secure communication with the use of the first quantum communication networks.
[email protected]
1.3 Simple Block Ciphers 13
1.3.1 Permutations
The Caesar cipher is one of the simplest substitution ciphers. Replacing each al-
phabet letter with another one is performed in a regular manner—it depends on the
alphabetical order. One can easily see that this assignment may be done arbitrarily.
Let us now recall some elementary mathematical facts. Given a finite set X, any
one-to-one function f : X → X is called a permutation.
If the cardinality of X is equal to n, then there are n! permutations (one-to-one
functions) on X.
The Caesar cipher can be generalized to all possible permutations of the alphabet.
In this situation a key is given by a 26-element non-repetitive sequence of integers
from 1 to 26. Such a sequence determines the substitution that has to be applied in
order to encrypt a message.
It can be seen that for an alphabet with 26 characters the number of all permu-
tations equals 26!, which amounts to about 4 · 1026 , a number that is large even for
modern computers. Verification of all possible keys (sequences) would take a great
deal of time.
It turns out, however, that substitution ciphers can easily be broken using so-
called frequency analysis. Certain letters and combinations of letters occur more
often than others. Therefore, it is easy to check which symbols appear in a given
ciphertext and with what frequency (for obvious reasons it is better to work with
suitably long ciphertext messages).
1.3.2 Transpositions
[email protected]
14 1 Basic Concepts and Historical Overview
[email protected]
1.3 Simple Block Ciphers 15
[email protected]
16 1 Basic Concepts and Historical Overview
plaintext, the third to the 14th, etc. Using this table, which represents a permutation
of the set {1, 2, . . . , 48}, one may thus determine the encryption procedure more
precisely than by means of encryption templates. What is more, considering this
permutation as an encryption key, it is possible to specify the exact number of all
possible keys for the above cipher, which is equal to
48! = 12413915592536072670862289047373375038521486354677760000000000,
which amounts to about 1.241391559 · 1062 . Not a small number, especially when
compared to the number of all atoms on our planet which is estimated to be 1051 .
In order to decrypt ciphertexts of the cipher in question one has to apply the
permutation that is inverse to the encryption permutation presented in Table 1.9. At
first sight it seems that the cipher may be broken by trying 48! permutations one
by one. Assuming that we would be able to test a million permutations per second
(even such an assumption is too optimistic for the current state of technology), it
would take around 1047 years to break a ciphertext. On the other hand, the age of
the universe is estimated to be 1011 years. However, if cryptanalysts apply statistical
tests, then breaking such a cipher takes them just a couple of seconds.
[email protected]
1.3 Simple Block Ciphers 17
In the easiest case the operation of substitution block ciphers consists in replacing
symbols of a plaintext with other symbols one by one. Hence, when performing
the encryption algorithm we have to apply a table which contains the rule of this
substitution, i.e., the table represents some permutation of the alphabet. Of course,
in order to decrypt messages one uses the inverse permutation.
Let us assume that in the considered case the same alphabet as in the example of a
transposition cipher is used, the 48-symbol block of a plaintext is the same as previ-
ously, and the substitution table presented in Table 1.10 is applied during encryption.
Then one obtains immediately a table for use during decryption (Table 1.11).
Now, we can illustrate the process of creating a cryptogram using the substitu-
tion cipher. If the plaintext is given by the block presented in Table 1.6, then, after
applying Table 1.10 and executing 48 symbol substitution operations, one gets the
cryptogram shown in Table 1.12. The obtained cryptogram may yet be easily de-
crypted since its symbols occur in the same order as the corresponding symbols in
the plaintext. For this reason cryptanalysts break substitution ciphers very quickly.
[email protected]
18 1 Basic Concepts and Historical Overview
is encrypted with the second one, which results in the ciphertext of the product ci-
pher. This method can be explained by encrypting the plaintext given in Table 1.6
with the use of the substitution cipher described above and then by considering the
resulting ciphertext (Table 1.7) as an input for the transposition cipher encryption
algorithm. The cryptogram obtained in this way is presented in Table 1.13. One may
easily check that decryption of the ciphertext presented in Table 1.13 should be per-
formed in the reverse order to the encryption process: the decryption algorithm for
the substitution cipher followed by the decryption algorithm for the transposition
cipher have to be executed.
Although the product encryption algorithm presented above consists of two weak
ciphers, breaking it is a non-trivial task—even for an advanced cryptanalyst.
As indicated by Claude Shannon, such an alternate use of transposition and sub-
stitution ciphers results in break-resistant ciphers. A slight modification of this prin-
ciple is applied in many practically used cryptographic block encryption systems
operating on a two-element alphabet, such as DES, IDEA or AES.
Simple substitution ciphers, which apply single symbols of an alphabet, can easily
be generalized to ciphers that apply substitutions of blocks (sequences) of symbols.
Instead of permutations f : X → X (where X is a set of alphabet symbols), one
can consider, in the simplest case, permutations f : X × X → X × X (f : X 2 →
X 2 ) or, more generally, f : X n → X n . Of course, the number of possible keys
significantly increases in this approach. Indeed, in the simplest case when n = 2 the
number of permutations reaches 676!, while for an arbitrary n it increases to (26n )!.
A problem for the cryptographer is to represent a key (a permutation)—let us
notice that even in the simplest case when n = 2 we have 676 values of the given
permutation. For the sake of simplicity, geometric methods are used in order to
represent the key.
The Playfair cipher, used by British forces during World War I, is an example of
such systems. It uses a 25-symbol alphabet (the letter J is substituted by the letter I).
A key is given by an arbitrary expression contained in a square matrix of size 5 × 5.
We demonstrate execution of the algorithm by the following example.
[email protected]
1.3 Simple Block Ciphers 19
of the key without repetitions. The empty entries of the matrix are filled with the
remaining letters of the alphabet (i.e., those that do not appear in the key).
We obtain the following matrix:
C R Y P T
O G A H I
S K B D E
F L M N Q
U V W X Z
The cryptogram is created from a plaintext by appropriate, i.e., with respect to the
matrix, substitutions of pairs of letters (if the text has an odd number of symbols,
then it is completed with any symbol).
Let us consider the following plaintext: ENCRYPTIONKEYS. At the first stage
of encryption, the sequence of letters is divided into pairs EN CR YP TI ON KE YS.
Each pair is transformed with respect to the rectangle contained in the matrix de-
termined by the letters that form the pair (according to the row-wise order). For
instance, the pair EN is converted to the pair QD (as these two letters form the two
remaining corners of the rectangle defined by the digraph EN). If encrypted letters
are placed in the same row/column or they are equal, then we choose the symbols
to their right, e.g., AW is converted to HX, while FL is converted to LM.
D E
N Q
A H
B D
M N
W X
The whole ciphertext is as follows: QDRYPTCOFHBSBC.
Example 1.3 Keys are given by two independent permutations of a 25-letter alpha-
bet. We place them in two square matrices (of dimension 5 × 5).
A K N Y E E R T B O
R D U O I W I U M K
Q S W B G N D A S F
H C X T Z Q X G Z V
V M L P F H Y P L C
A plaintext, for instance TODAYISABEAUTIFULDAY, is divided into several rows
of a fixed length:
T O D A Y I S A B E
A U T I F U L D A Y
[email protected]
20 1 Basic Concepts and Historical Overview
The encryption process consists in replacing columns of the plaintext with entries of
matrices (keys) that are determined by the corresponding rectangle, similarly to the
Playfair system. The upper symbol of the bigram is marked in the left matrix and
the lower symbol in the right one. Thus, in our example, the bigram TA is replaced
with BG, and so on.
The whole plaintext is transformed into the following cryptogram:
BG IM KU RR BO RM MS QR GS FR.
Both systems presented above are substitution block ciphers. Let us recall that
cryptanalysis of simple substitutions is hindered by the fact that now all operations
are performed on blocks of letters. The number of functions that map blocks into
blocks is very much greater than the number of functions that map single symbols.
Applying statistical methods is much more complex, as well.
[email protected]
1.4 Wheel Cipher and Rotor Machines 21
of a plaintext are not necessarily mapped into the same symbols in a cryptogram. In
general, this hinders cryptanalysis that applies statistical methods.
However, even this cipher is not very hard to break. If only the length of blocks
is known, then given cryptograms that are sufficiently long one can focus on each
n-th symbol and analyze the obtained set with the use of statistical methods. In case
the parameter n is not known, the problem is a bit more complex, nonetheless, it is
still not very difficult to solve. It is enough to analyze the text for consecutive values
of the parameter n, starting with 2. Applying computers the cipher may quickly be
broken.
[email protected]
22 1 Basic Concepts and Historical Overview
a century later. A wheel cipher consists of a set of several disks with permutations
of alphabet symbols arranged around their edges. The permutations are different for
all disks. With a dozen or even tens of such disks stacked on one axle, it is possible
to place them in such a way that the number of letters of a plaintext corresponds to
the number of disks set in one row. The encryption process is based on reading a
text placed one or more rows above or below. A person decrypting the text arranges
consecutive letters of the cryptogram in one row of the wheel and reads the plaintext
from the appropriate row (for instance, in the case of 30 disks it gives 30!, i.e., about
2.6 · 1032 possibilities).
According to current criteria, this method does not provide a sufficient security
level. An intruder may come into possession of the device used for encryption. They
could then quite easily find the appropriate arrangement of disks.
A wheel cipher known as the M-94 [54] was used by the United States Army
from 1923 until 1942 (Fig. 1.6).
Rotor machines were a step forward with respect to cipher cylinders—they were the
first encryption devices that used electricity. Below, we present how they work.
Let us consider a disk containing an alphabet permutation. A simplified version
of this situation (for a 4-letter alphabet) is depicted in Fig. 1.7.
Encryption by means of such a disk corresponds to a simple substitution cipher,
thus its encryption power is not very impressive. Let us notice, however, that this
disk may rotate around its axis in a specific way during the encryption process. The
cipher obtained in this way constitutes the Vigenère cipher described before.
Now, let us consider several disks containing different alphabet permutations
stacked on one axle (Fig. 1.8). Composing the appropriate number of such disks
(permutations) gives a unique permutation, however, it turns out that such a scheme
allows us to rotate all disks during encryption. This increases the encryption power
significantly and complicates analysis of ciphertexts.
[email protected]
1.5 Enigma 23
The algorithm for rotating the disks has to be specified precisely and both parties
exchanging messages need to know it, as well as how to arrange the disks to form
the whole device. The cipher key is given by the output positions and the order of
disks (the initial configuration of the machine).
Machines constructed in this way are called rotor machines. Patents for such
machines were filed around 1920 by several inventors concurrently. Disks of these
machines are called drums or rotors.
Physically, rotors were thick disks made of an insulator. Every disk had 26 con-
tacts equidistant and symmetric from the center on both its sides. Each contact on
the left side was connected to exactly one contact on the right side—the pattern
of connection (some permutation of the alphabet) was of course to be kept secret.
There were 26 circuit terminals (corresponding to letters of the alphabet) adjacent
to each side of the disk. If voltage is applied to one of the terminals, then the current
flows through one of the contacts on the right side and lights one of 26 bulbs. In this
way, the machine performs the afore mentioned permutation of the alphabet.
The most famous machine of this type was Enigma, developed in Germany and
used before and during the World War II by the Axis powers.
1.5 Enigma
The name Enigma comes from Greek and literally means secret. The designation
Enigma was used to name a number of encryption machines with the same root
[email protected]
24 1 Basic Concepts and Historical Overview
and use. Before Enigma reached its final form, various models of the machine were
produced and deployed. This section presents a description of the origin of these
machines and their principles of operation.
[email protected]
1.5 Enigma 25
[email protected]
26 1 Basic Concepts and Historical Overview
were enciphered by combining randomly generated letters with the original text
using a variant of the XOR function, character by character. At the receiving end
Lorenz applied exactly the same obscuring letters back to the ciphertext to recover
the plaintext.
In its time, Enigma undoubtedly presented a significant technological advance
in the field of encryption. The machine had a very large key space, and thus, at
that time, it was not possible to break the code by brute force. However, as safe
as Enigma would seem before the war, it was effectively broken, first by Polish
intelligence, and then in later versions by the Allied intelligence services. This fact
significantly influenced the result of World War II.
Below, we present the construction and operation of the most popular version of
the Enigma machine—the so-called Wehrmacht Enigma model, widely used during
WWII by the German land forces and the air force (Luftwaffe).
As indicated above, the starting point for the construction of the Enigmas was
an electric typewriter. Pressing a key would close the electric circuit, and then the
flow of the electric current would cause the corresponding letter printing and ad-
vancement of the print head by one position on the printing machine. In the first
version of the device, Hebern connected two typewriters with a bundle of 26 cables.
This machine, of course, generated a simple permutation cipher code. One could
complicate its function by introducing additional encryption rotors.
The introduction of the stationary rotor between the contacts leading to the key-
board and the print head does not increase the strength of the cipher, which remains
a simple permutation. However, the same mechanism which is used to move the
print head can also turn the rotor on its spindle by one position. In this case, each
additional letter of the cryptogram will be encrypted by a different substitution (per-
mutation). After encrypting 26 letters, the machine returns to the initial substitution,
and the cycle of the used permutations is repeated. One can, of course, introduce
between the keyboard and the print head not one but several rotors mounted on
a common spindle and equipped with hooks, which will cause the turning of the
next rotor by one position each time the previous rotor makes a full turn. The same
mechanism is used by car odometers to show distance driven.
Consider an Enigma model with three movable rotors. The total cycle length of
all encrypting rotors causes the cipher substitution to repeat itself after 26 · 26 · 26 =
17576 characters. Let’s look at encryption operations performed by a simplified
three rotor machine, whose coded alphabet contains only characters A, B, C and D
(Fig. 1.11). In our simplified Enigma the first rotor replaces letter A by C, B by B,
etc., realizing the joint permutation described as (AC, BB, CA, DD). The second
rotor performs the permutation (AB, BD, CA, DC), the third (AB, BA, CD, DC).
As the figure above shows, the three rotors together implement the permutation
(AB, BC, CA, DD), which is the composition of the permutations equivalent to the
[email protected]
1.5 Enigma 27
actions of the first, second and third rotor, respectively. Taken together with the
application of the reflector application, the machine thus implements the permu-
tation (AC, BD, CA, DB). After encrypting the first letter, the first (leftmost) rotor
turns by one position, changing the permutation implemented jointly by the rotors
to (AA, BC, CD, DB). As one can see from the figure, the reflector plays the role of
an extra encrypting element as well as an element allowing decryption of messages
without changing the order of the rotors.
In reality, the Wehrmacht Enigma utilized three different rotors (Fig. 1.10). They
were placed on a common spindle in the order determined by the cipher key. Ro-
tors were identified by Roman numerals; from the moment it was put into use, the
Enigma machine was equipped with rotors I, II and III, rotors IV and V were added
at the end of 1938 (see Table 1.15).
A plugboard (Fig. 1.12) was also added to the discussed structure to perform one
more initial permutation. Enigma’s switchboard looked like an analog telephone
switchboard. The user would set the connections manually by inserting cable plugs
into plugboard sockets. Enigma was also equipped with a so-called initial rotor
directly connected to the plugboard, which could perform one more permutation.
However, in military machines the drum was used only to relay the signal and trans-
mit letters without any changes.
[email protected]
28 1 Basic Concepts and Historical Overview
Enigma cipher key elements need to be divided into those available to the regu-
lar signalman operating the device and those reserved for authorized officers only.
The encrypting rotors’ starting position belonged to the second category, however
the cryptographer operating the Enigma needed to have the possibility of position-
ing the rotors. It was therefore necessary to separate the real location of the rotor
from the description visible on the outside of the machine. Paul Bernstein suggested
covering the rotor with a moving ring which hid the actual configuration. Then the
officer would set the position of the rings on the rotors, and the cryptographer would
position the rotors in the machine according to the rings.
An Enigma key contained the following data:
1. the cable plugboard setting—the wiring plugs on the plugboard,
2. the selection of rotors—three of the available five were chosen (or eight in the
Kriegsmarine machine),
3. the sequence of selected rotors,
4. the starting position of the rotors—chosen by the operator, different for each
message,
5. in later versions, the wiring of the reversing drum.
Keys were typically valid for a specified period of time, usually one day, but
rotors were set individually for every message to be encrypted. During World War II,
the Enigma coding books contained only the information about the collection of
rotors, and their mutual positioning, without data relating to the daily keys.
[email protected]
1.5 Enigma 29
Before sending each message, a cryptographer would himself decide the initial
rotor positioning, such as ADE, and the key for that message, e.g., PQH. After the
Enigma rotors were positioned in the ADE configuration, the cryptographer typed
the message key PQH resulting, for example, in the string KLR.
Consequently, the machine rotors were set in the PQH configuration and the rest
of the information was encoded. The transmitted cipher text began with characters
describing the initial ADE setting, followed by the encoded message key KLR, and
the actual content of the ciphertext. The operator receiving the message performed
the same actions in the reversed order: he first positioned rotors in the ADE config-
uration to decode the KLR message key from the cipher text, that is PQH. Then he
configured the machine in accordance with the PQH key, to decipher the message.
The military Enigma used a 26-letter alphabet. Punctuation marks were replaced
by certain rare strings of letters. Space was usually ignored or replaced by the let-
ter X, which was also used as a dot. Some characters were used differently by dif-
ferent forces. The Wehrmacht and Luftwaffe used ZZ instead of a comma, a string
FRAQ or FRAGE instead of a question mark. The Navy, in turn, used the letter Y in-
stead of a comma and UD instead of a question mark. The letters CH, as in the word
Acht (eight) or Richtung (direction) were replaced by Q (AQT, RIQTUNG). Two,
three or four zeros were replaced by, respectively, CENTA, MILLE and MYRIA.
We will now describe the exact function and operations of the Wehrmacht Enigma
machine. Suppose that an analyst knows the principle of operation of the machine,
but does not know how the rotors are connected inside the device. This corresponds
to the situation in which the cryptoanalysts trying to attack the Enigma found them-
selves [48].
Each of the Enigma rotors has 26 pairs of terminals that can be connected to-
gether in 26! ways. Choosing a permutation for the first rotor eliminates one of
the theoretically possible combinations, so the number of possible combinations for
how the second rotor could be connected is equal to 26! − 1 thus the number of
possible connections for the second rotor is equal to 26! − 1.
Similarly, the third rotor adds 26! − 2 capabilities. In the same way, the number
of possible permutations of the input cylinder is 26! − 3. To summarize, the total
number of possible combinations of how the rotors can be connected is the product
of the above numbers and is equal to:
26453071587484435966565383154187825269596587475679144168629439112
098429555222911717025686471982186496000000.
Regardless of how the rotors are chosen from all the possible combinations, the
selected rotors can be ordered in 3! = 6 ways. The reflector has 13 connections
between the pairs of pins. Connecting a cable to the first pin allows the other end of
the cable to be connected to one of the remaining 25 pins. After selecting the first
[email protected]
30 1 Basic Concepts and Historical Overview
0 1 7 1305093289500
1 325 8 10767019638375
2 44850 9 53835098191875
3 3453450 10 150738274937250
4 164038875 11 205552193096250
5 5019589575 12 102776096548125
6 100391791500 13 7905853580625
end of the second wire there is a choice from the remaining 23 contacts, the third—
from 21, etc. The total number of possible combinations of reflector connections is
equal to 25 · 23 · 21 · · · 1, that is 7905853580625.
A ring on each of the Enigma rotors can be set in one of 26 positions. Positioning
the rings over the first and second rotors affects the number of available states,
because it determines the state in which another rotor is moved to the next position.
The third rotor is followed by a stationary reflector, so the position of its ring does
not affect the number of states. As a result, ring settings make 26 · 26 states, or 676.
Before the work is started, each of the Enigma rotors is set in one of the 26
possible locations, which translates into 263 combinations, i.e., 17576.
The last element of the Enigma that contributes to the number of possible states
is a plugboard. The number of connected letter pairs (we denote it by p) can vary
from 0 to 13. On 26 plugboard sockets, selection of connected letter groups can
be made in 26/2p ways. The number of possible connections within a selected
group of sockets is similar to the number of possible pairs of connections in the
reflector; when the first socket is selected, the location at which the wire will be
connected can be chosen from 2p − 1 possibilities. Selection of further sockets
gives 2p − 3, 2p − 5, . . . , 1 possible states. The total number of possible letter pair
connections is (26/2p) · (2p − 1) · (2p − 3) · · · 1.
Table 1.16 shows the number of possible combinations, depending on the value
of p.
Putting together the partial results, we get the number of possible Enigma states
(assuming p = 11), equal to:
30645377746677812451627832069168689492056918458201254350322252709
94269522075900473712575645083889591356267102713648819347298713600
000000000000,
or approximately 3 · 10114 .
These estimates are for the case when no details are known about Enigma set-
tings and wiring. In real war conditions the rotors and wiring were known from
captured equipment. In this case, the number of possible Enigma operating condi-
tions is 619953965349522804000000 (about 6 · 1023 ) [48]. Such a number does not
[email protected]
1.5 Enigma 31
shock today’s reader who has a fast computer at his disposal. For an average com-
puter, code breaking by brute force would not take a lot of time. However, during
World War II, that was a huge number preventing brute force attacks. The Enigma
code was broken by other techniques, mentioned below.
The first attempts to break the Enigma cipher were undertaken by the French, British
and Polish intelligence services in the late 1920s. However, the first attempts were
unsuccessful. The main problem was that the Enigma cipher was polyalphabetic,
a breakthrough for those times. That is a cipher in which the plaintext letters are
encrypted using various permutations of the alphabet. As we know, this hides lin-
guistic properties and precludes the use of statistical cryptanalysis.
So far, the most important role in code breaking had been played by special-
ist linguists who tried to capture specific language features, such as the frequency
of repetition of letters or words, or their lengths, etc. In the case of a mechanical
encryption machine, linguistic analysis did not bring any results. Poland’s military
Cipher Bureau offered to employ professional mathematicians. The selected young
candidates knew the German language very well. They had been recruited from ar-
eas in proximity to the German-Polish border, where knowledge of German was a
universal skill. Three of the brightest math students were hired: Marian Rejewski
(Fig. 1.13), Henryk Zygalski and Jerzy Różycki (Fig. 1.14).
From 1930, they worked with Poland’s intelligence service on cracking the
Enigma code. The Poles took advantage of Enigma machine engineering plans made
available to them by the French intelligence service, gained around 1931 by a French
agent, Hans-Thilo Schmidt (aka Asche).
In December 1932 Rejewski and his colleagues first broke the Enigma codes.
Soon after, in February 1933, they ordered an exact copy of the German cipher
machine to be manufactured by the AVA Radio Engineering Plant. After that time,
[email protected]
32 1 Basic Concepts and Historical Overview
the Poles could read German correspondence, despite the fact that the Germans
continued to improve both the machine and the encryption method [84].
The Poles developed very effective methods of breaking ciphers, in fact they de-
veloped a way of discovering Enigma’s work settings. For that purpose they applied
mathematical theories of combinatorial cycles and transpositions. To determine the
permutation cycles used by the Enigma rotors, so called cyclometer and special data
characteristics sheets were developed by Rejewski. In September 1938, using these
tools it took only about 15 minutes to determine the daily key. Then the Germans
changed the parameters of the machine.
At the end of 1938 Rejewski developed plans for another tool, this time an elec-
tromechanical device that could search by brute force through all 17576 possible
positions. He called the machine a cryptologic bomb [84].
The bomb would find the daily settings of the Enigma machines on the various
German military communication networks, e.g., the set of rotors in use and their
positions, and the rotor start positions for a particular message (the message key).
The purpose of this machine was to crack the Enigma cipher through the use of a
specially developed theory of cycles. The cryptologic bomb consisted of six copies
of the Polish Enigma coupled together and powered by an electric motor. In mid-
November of the same year six such bombs were built in Warsaw. They were used
only for decoding twice-encrypted daily keys, never to decode the ciphertexts. Those
were decoded using perforated Zygalski sheets, developed in order to find the proper
positions of the Enigma rotors. One cryptologic bomb made it possible to decode a
daily key in a couple of hours and did the work of about 100 people.
In 1939, Germany once again changed their encryption scheme, which created
the need to build an additional 54 cryptologic bombs (for a total of 60) and for
the development of 60 labor-intensive sets of Zygalski sheets (one set consisted of
26 sheets). Such investment far exceeded the financial capabilities of Poland’s in-
telligence service at that time. For this reason, and because of the threat of war, it
was decided to present the Polish Enigma to the British and the French intelligence
services—countries which at that time were associated with Poland through a mili-
[email protected]
1.5 Enigma 33
tary alliance. Each of them received a replica of the Polish Enigma machine together
with all the documentation. The transfer took place on July 25, 1939 at Pyry near
Warsaw, where the Polish cryptanalytic center was located [38].
In particular, the Poles passed all of their information over to two mathematicians
working at Bletchley Park, Alan Turing (Fig. 1.15) and Gordon Welchman, who
were able to build on this research to develop their substantially enhanced bombe
machine. Following Rejewski’s precedent, Turing called their new device a bombe
(an improvement after the original Polish bomba kryptologiczna. (The whole family
lineage became referred to as bombes at Bletchley Park and then in the US through-
out WWII, and in the following reports.) Soon after, at the Bletchley Park cryptan-
alytic center, the UK’s main decryption establishment—the Government Code and
Cypher School (GC&CS), mathematicians headed by Alan Turing and with intel-
ligence experts began the complex and urgent task of cracking the enemy military
and naval Enigma radio communications, with the help of primitive early computers.
They devised and modified cryptologic bombes, based on the equipment and mate-
rials provided by the Poles. Bletchley Park also hired a number of promising math-
ematicians, among them Hugh Alexander, Peter Hilton, and Max Newman [26].
After the outbreak of WWII, Poland’s Cipher Bureau personnel were evacu-
ated through Romania, to the French cryptanalytic center codenamed Bruno in the
Château de Bois-Vignolles in the village of Gretz-Armainvilliers, 40 km from Paris.
They continued cracking the Enigma traffic in close inter-Allied collaboration with
the French. Jerzy Różycki perished in 1942 in the Mediterranean Sea, near the
Balearic Islands, in unclear circumstances. Rejewski and Zygalski arrived in the
UK in August 1943. They immediately began working in the radio unit of the Chief
of Staff of the Polish Armed Forces in Boxmoor near London, where they remained
until the end of the war.
Bletchley Park is known mainly for cracking messages enciphered on the Enigma
cipher machine, and its greatest cryptographic achievement was the breaking of
the advanced teleprinter Lorenz version of the Enigma cipher. The most important
Bletchley Park machine was the highly advanced Colossus (Fig. 1.16) of which the
first started working in December 1943, and a total of ten were in use by WWII’s
[email protected]
34 1 Basic Concepts and Historical Overview
end. They were the world’s first electronic digital computers. Colossus’s parame-
ters could be changed through plugboards and jumper cables. Colossus compared
two data streams, counting each match. The encrypted message was read from a pa-
per tape. The other stream was an internally generated electronic simulation of the
Lorenz machine at various trial settings. If the match count for a setting was above
a certain threshold, it was sent as output. The Colossus was used to find possible
key setting combinations for the rotors, realizing the basic idea of a cryptographic
bombe. The Colossus decrypted Enigma and Lorenz traffic containing the most vital
secrets of the German High Command.
Bletchley Park produced modified bombes (Fig. 1.17), but it was through the
success of UK and US intelligence cooperation that a US Navy bombe was soon de-
signed and produced as well. The US Navy’s signals intelligence and cryptanalysis
group started investigating designs for a Navy bombe, based on the full blueprint
and wiring diagrams received from Bletchley Park in mid-1942. Turing travelled to
the US in November 1942 for five months and worked with US Navy cryptanalysts
on the naval four-rotor Enigma and the bombe construction in Naval Communica-
tions in Washington, DC, and in the Computing Machine Laboratory in Dayton,
Ohio [49].
In May 1943 two prototype bombes were ready, named Adam and Eve. In 1943
and 1944 many more bombe machines arrived from Dayton and worked in Naval
Communications in Washington, DC, bringing tremendous success for the Allied
navies over the German U-boats. Throughout the remainder of the war, as the Ger-
mans altered their Enigmas, the US Navy kept pace. The four-rotor problem fell
exclusively to the US. A total of 121 Navy bombes were assembled at the US Naval
Computing Machine Laboratory in Dayton, at a cost of about six million dollars,
see [101].
Like the Polish and British bombes, the American machines required pieces of
unencrypted text from intercepted messages, either assumed or known to appear in
the message. The text corresponded to the cipher and created the daily settings key
for the bombe. With the daily key, all the current day’s communication could be
[email protected]
1.5 Enigma 35
read. The text pieces could come through a variety of intelligence and cryptanalysis
methods. Some came from errors made by the German operators themselves. One
frequent German mistake was to use standardized messages. For example, a shore
weather station in the Bay of Biscay sent out a message every day at 7:00 a.m. which
began, The weather in the Bay of Biscay will be. . . . Knowing the exact wording of a
message was a great help for the Allies, so it became a high priority to intercept the
daily message from this weather station. Also, the initial rotor setting changed with
every message. Since the German cipher clerk determined the initial rotor settings,
they had to be sent to the intended recipient in the clear, that is, unencrypted. The
first three letters of the code group, sent unenciphered, told the receiver where to set
the rotors. But the clerk made up his own six-letter settings, and the cryptanalysts
could occasionally guess the settings. For example, if the first three letters were HIT,
the cryptanalysts could guess that it was followed by LER, spelling out HITLER.
BER was usually followed by the ciphers of LIN. One particular German code clerk
continually used his girlfriend’s name, Cillie, for his messages (see [103]).
Through the work of the Polish cryptographers, and later the British in Bletchley
Park and the US Navy and US Army, as well as thanks to the Enigma machines
and codes which were captured in the meantime, at the end of the war almost all
Enigma traffic, nearly thousands of encrypted messages each day, was being read
by the Allies. During the Normandy landings, Bletchley Park was deciphering over
18000 messages each day. On average, one or two days were enough to decrypt a
German message [89, 95, 96].
[email protected]
Chapter 2
Mathematical Foundations of Cryptography
1 Further background on mathematical structures in cryptography can be found in [27, 92], and
[68].
[email protected]
38 2 Mathematical Foundations of Cryptography
operations. For example, division is not an operation on the set of integers Z (the
result is not necessarily an integer) and subtraction is not an operation on the set of
natural numbers N (which does not contain negative integers). However, addition
and multiplication are well-defined operations on those sets.
We will also use the notion of an algebraic structure which is defined as a set S
together with operations defined on this set. Usually structures will contain either
one operation, in which case they will be denoted by S, +, or two operations when
we will denote them by S, +, ·.
2.1.1 Groups
∀a,b∈G [a • b = b • a],
then the group is called commutative or Abelian (in honor of the Norwegian
mathematician N.H. Abel).
[email protected]
2.1 Basic Concepts in the Theory of Algebraic Structures 39
where m, n, 0, 1 ∈ Z and the symbols 0 and 1 denote identity elements for opera-
tions in additive and multiplicative groups, respectively. Thus, in a multiplicative
group powers of elements exist. In an additive group multiples of elements are their
analogs.
The element g is called a generator of the cyclic group, since each element of G
can be represented as some power of g. We denote this fact by G = g. It follows
from this definition that every cyclic group is commutative (∀x,y∈Z [g x g y = g x+y ],
and because x + y = y + x, we have g y+x = g y g x = g x g y = g x+y ) and g |G| = 1
(where 1 is the unit of the group).
Such s divides the order of G, i.e., s | card G. For instance, if card G = 63, then G
contains elements of order 1, 3, 7, 9, 21 and 63.
[email protected]
40 2 Mathematical Foundations of Cryptography
There are two trivial subgroups of G: an algebraic structure e, • and the group
G itself. Therefore, if card H ∈ {1, card G}, then a subgroup H of G is called non-
trivial.
Operations + and · are usually called addition and multiplication, however, they
are not necessarily these commonly understood number operations. A neutral ele-
ment of a structure R, + is denoted by 0 and the inverse element of an element
a ∈ R by −a. For the sake of simplicity, we commonly use the following conven-
tion: a + (−b) = a − b, a · b = ab. On the basis of the definition of a ring, we get
that ∀a∈R [a0 = 0], since a0 = a(b − b) = ab − ab = 0. Similarly, it can be proven
that ∀a,b∈R [(−a)b = a(−b) = −ab].
Depending on the properties of multiplication, we can classify rings as follows:
1. If ∃e∈R ∀a∈R [ae = ea], then a ring R is called a ring with a unit.
2. If multiplication in a ring is commutative, then such a ring is called commutative.
3. If a ring is commutative and additionally it contains a neutral element of multipli-
cation e = 0 and ab = 0 ⇒ (a = 0) ∨ (b = 0), then it is called an integral domain
or an integral ring. A neutral element of multiplication is usually denoted by 1. It
follows from the definition that an integral domain does not contain zero divisors.
4. Let R be an integral domain. We call it a Euclidean ring if there exists a function
ν : R \ {0} → N ∪ {0}, called a norm of R, such that
∀a,b=0∈R ∃q,r∈R (a = bq + r) ∧ ν(r) < ν(b) ∨ r = 0 .
[email protected]
2.1 Basic Concepts in the Theory of Algebraic Structures 41
[email protected]
42 2 Mathematical Foundations of Cryptography
where [rs ] denotes the remainder class to which an element rs of the ring belongs.
Both operations are associative and multiplication of remainder classes is distribu-
[email protected]
2.1 Basic Concepts in the Theory of Algebraic Structures 43
tive over addition. In this way, from a ring R, +, · and its ideal I, +, ·, we obtain
a remainder class ring, denoted by R/I .
Example 2.2 The set of integers Z together with the arithmetical operations of ad-
dition and multiplication forms a ring. Let (4) denote the set of all multiples of 4:
It is easy to prove that the structure (4), +, · is an ideal of the ring Z, +, ·. Thus,
this ring can be decomposed into remainder classes with respect to the ideal (4):
GF(p) = Fp , ⊕,
, Fp = [0, 1, . . . , p − 1].
Then a finite field GF(p) is called a Galois field with p elements. Thus, we can
write: GF(p) = Zp , ⊕,
. Addition and multiplication in this field are performed
modulo p.
then the least integer n fulfilling this condition is called the characteristic of R. If
such an integer does not exist, the ring R has characteristic equal to 0.
[email protected]
44 2 Mathematical Foundations of Cryptography
Theorem 2.2 The characteristic of a ring R, +, · with a unit, where | R |= 0, and
with no zero divisors is equal to some prime p. Moreover, the following condition is
satisfied in such a ring:
n n n
∀a,b∈R ∀n∈N (a ± b)p = a p ± bp .
Example 2.3 The characteristic of the Galois field from Example 1 is equal to 2,
since ∀a∈GF(16) [a + a = 0].
Now let a denote a nonzero element from GF(q). Since the field GF(q) is closed
under multiplication then consecutive powers of a
a 1 = a, a 2 = a · a, a 3 = a · a · a, ...
[email protected]
2.1 Basic Concepts in the Theory of Algebraic Structures 45
are elements of the field. As in the case of addition, subsequent powers of a cannot
be all different, i.e.,
∃m,k m > k ∧ a k = a m .
a 1 , a 2 , a 3 , . . . , a n , a n+1 = a . . .
repeats after the element a n , and powers a 1 , a 2 , a 3 , . . . , a n−1 , a n = 1 are all pair-
wise different. Therefore, if i + j < n, then
a i · a j = a i+j .
ai · aj = an · ar = ar .
Theorem 2.4 Let a be a nonzero element of order n from the finite field GF(q).
Then n is a divisor of (q − 1).
where n ∈ N. The coefficients of a polynomial are elements from the ring, i.e.,
ai ∈ R, 0 ≤ i ≤ n, and the symbol x is called an independent variable. It is cus-
tomary to omit a monomial ai x i in the notation of a polynomial whenever ai = 0.
Verifying the equality of two polynomials consists of checking whether they have
the same coefficients standing at corresponding powers of their independent vari-
ables.
Let
n m
f (x) = ai x i , g(x) = bi x i , m ≤ n.
i=0 i=0
If n = m, then the condition on the equivalence of two polynomials can be written
as follows:
f (x) = g(x) ⇔ ai = bi , 0 ≤ i ≤ n.
[email protected]
46 2 Mathematical Foundations of Cryptography
We define the sum and the product of two polynomials in the following way:
n
f (x) + g(x) = (ai + bi )x i ,
i=0
n+m
f (x)g(x) = ck x k , ck = ai bj , 0 ≤ i ≤ n, 0 ≤ j ≤ m.
k=0 i+j =k
Definition 2.13 The set of all polynomials over a ring R, +, · together with op-
erations of polynomial addition and multiplication is called a polynomial ring and
we denote it by R[x].
The zero polynomial, i.e., the polynomial with only zero coefficients, is the zero
of R[x]. We denote it by 0, thus by the same symbol as the element of R. Therefore,
when considering a ring R[x] one has to be careful not to confuse the zero of the
polynomial ring with the zero of the ring from which coefficients of polynomials
are taken.
Definition 2.14 If
n
f (x) = ai x i ∈ R[x], an = 0,
i=0
then n is called the degree of the polynomial f (x), which is denoted by
deg(f (x)) = n, whereas an is the leading coefficient of the polynomial. If a ring
R has a neutral multiplication element, denoted by 1, and the leading coefficient of
a polynomial is equal to 1, then such a polynomial is called monic. If deg(f (x)) = 0,
then the polynomial f (x) is called constant. The coefficient a0 is called a free term.
Conventionally, we assume that the degree of the zero polynomial is equal to −∞.
Constant polynomials are in fact elements of a ring R, therefore R is a subring of
the ring R[x] and the latter inherits some properties of the ring R.
and
deg f (x)g(x) = deg f (x) + deg g(x) .
Definition 2.15 Similarly to the case of division in the ring Z, +, ·, we say that
polynomial f (x) divides g(x) (f (x) is a divisor of g(x)) if and only if there exists
a polynomial h(x) such that g(x) = f (x) · h(x). We denote this property by f (x) |
g(x). In symbols:
f (x) | g(x) ⇔ ∃h(x)∈F [x] g(x) = f (x) · h(x) .
[email protected]
2.1 Basic Concepts in the Theory of Algebraic Structures 47
The above theorem describes an algorithm for division in a polynomial ring. One
can thus compute the greatest common divisor of two polynomials f (x), g(x) ∈
F [x] by means of Euclid’s algorithm,2 repeating the algorithm for polynomial divi-
sion in the following way:
until the remainder equals zero. If the leading coefficient of the polynomial
rk+1 (x) ∈ R[x] is equal to c, then gcd(f (x), g(x)) = c−1 rk+1 (x), since it has to be
monic. Of course, Euclidean algorithm can be applied to compute the greatest com-
mon divisor of three or more polynomials, for instance: gcd(f1 (x), f2 (x), f3 (x)) =
gcd(gcd(f1 (x), f2 (x)), f3 (x)).
Theorem 2.6 If gcd(f (x), g(x)) = h(x), then there exist polynomials u(x), v(x) ∈
R[x] such that
u(x)f (x) + v(x)g(x) = h(x).
Theorem 2.7 Every polynomial f (x) ∈ F [x], deg(f (x)) > 0, can be presented in
the following form:
k
e
f =a gi (x) i ,
i=1
[email protected]
48 2 Mathematical Foundations of Cryptography
It can easily be checked that the set of all multiples of a polynomial f (x) ∈ F [x]
is an ideal in the ring F [x], which can be denoted by I = (f ) = {f (x)g(x) : g ∈
F [x]}. We say that the polynomial f (x) generates the ideal (f ).
Decomposition of the polynomial ring F [x] into remainder classes with respect
to an ideal generated by an irreducible polynomial plays an important role in appli-
cations of Galois fields.
Theorem 2.8 Let f (x) ∈ F [x]. The ring of remainder classes F [x]/(f ) is a field
if and only if f (x) is irreducible over F .
Definition 2.18 The least positive integer s satisfying the assumptions of the above
theorem is called the exponent of the polynomial f (x). If f (x) = 0, then f (x) =
x a g(x), a ∈ N, g(x) ∈ GF(q)[x], g(0) = 0. In such a case we regard the exponent
of f (x) as the exponent of g(x).
Example 2.4 The polynomial ring over the field GF(3), denoted by GF(3)[x], con-
sists of polynomials of all degrees with coefficients taken from the set {0, 1, 2}. Now,
we decompose this ring into remainder classes with respect to the ideal generated
by the polynomial f (x) = x 2 + x + 2. Thus, the ideal constitutes the following set
of polynomials:
(f ) = 0, f (x), 2f (x), xf (x), (1 + x)f (x), (2 + x)f (x), 2xf (x), . . .
In this case we can create the following remainder classes:
{0} = 0 + (f ),
{1} = 1 + (f ),
{α} = x + (f ),
{β} = 1 + 2x + (f ),
{γ } = 2 + 2x + (f ),
{δ} = 2 + (f ),
{η} = 2x + (f ),
{κ} = 2 + x + (f ),
{ζ } = 1 + x + (f ).
[email protected]
2.1 Basic Concepts in the Theory of Algebraic Structures 49
Table 2.5 Addition table for + {0} {1} {α} {β} {γ } {δ} {η} {κ} {ζ }
GF(9)
{0} {0} {1} {α} {β} {γ } {δ} {η} {κ} {ζ }
{1} {1} {δ} {ζ } {γ } {η} {0} {β} {α} {κ}
{α} {α} {ζ } {η} {1} {δ} {κ} {0} {γ } {β}
{β} {β} {γ } {1} {κ} {α} {η} {ζ } {0} {δ}
{γ } {γ } {η} {δ} {α} {ζ } {β} {κ} {1} {0}
{δ} {δ} {0} {κ} {η} {β} {1} {γ } {ζ } {α}
{η} {η} {β} {0} {ζ } {κ} {γ } {α} {δ} {1}
{κ} {κ} {α} {γ } {0} {1} {ζ } {δ} {β} {η}
{ζ } {ζ } {κ} {β} {δ} {0} {α} {1} {η} {γ }
Table 2.6 Multiplication · {0} {1} {α} {β} {γ } {δ} {η} {κ} {ζ }
table for GF(9)
{0} {0} {0} {0} {0} {0} {0} {0} {0} {0}
{1} {0} {1} {α} {β} {γ } {δ} {η} {κ} {ζ }
{α} {0} {α} {β} {γ } {δ} {η} {κ} {ζ } {1}
{β} {0} {β} {γ } {δ} {η} {κ} {ζ } {1} {α}
{γ } {0} {γ } {δ} {η} {κ} {ζ } {1} {α} {β}
{δ} {0} {δ} {η} {κ} {ζ } {1} {α} {β} {γ }
{η} {0} {η} {κ} {ζ } {1} {α} {β} {γ } {δ}
{κ} {0} {κ} {ζ } {1} {α} {β} {γ } {δ} {η}
{ζ } {0} {ζ } {1} {α} {β} {γ } {δ} {η} {κ}
forms, according to Theorem 2.8, the field GF(9) with operations defined as in
Tables 2.5 and 2.6.
Galois fields are mostly used as a mathematical tool applied in cryptography (e.g.,
in algorithms such as AES, IDEA, ElGamal) and in the theory of erasure codes. The
[email protected]
50 2 Mathematical Foundations of Cryptography
latter constitutes the basis for designing devices used in many systems, for example
in radar systems and systems of microwave links, mobile radio and satellite com-
munications. Knowledge of Galois fields is essential when designing data recording
systems with the use of magnetic tapes and disks and optical drives. Moreover,
Galois fields are applied in designing self-checking arithmetic and logical circuits,
high-speed semiconductor memories, digital television systems and Hi-Fi acoustic
systems. Galois field arithmetic is applied in spread spectrum radio communica-
tion systems. Computation techniques in Galois fields are very useful in developing
some types of radio and television antennas, and loudspeakers, and in cryptography
and the synthesis of random number generators. Galois fields can also be applied in
precise optical and acoustic measurements, in designing concert halls, and even in
handicrafts and graphic design.
2.2.1 Divisibility
Example 2.5 We have, of course, 2 | 4, 3 | 27, 1233 | 44388, but the following rela-
tions do not hold: 2 | 5, 3 | 26 and 123 | 14287.
a · y + b · z = a · p · x + b · q · x = x · (a · p + b · q),
so
x | (a · y + b · z).
[email protected]
2.2 Elements of Number Theory 51
Let us recall that if x, y ∈ N and y > 1, then there exists exactly one pair of
natural numbers p, r such that x = p · y + r ∧ r < y.
This property is called the unique factorization of natural numbers (a similar law
is valid for reals). The number p is simply the result of dividing y by x, while r is
the remainder of this division.
Let us introduce the following notation: r = x mod y and p = x div y.
We say that x is a common divisor of y and z when x | y and x | z.
The greatest common divisor of natural numbers y and z is defined as the natural
number x such that
1. x | y ∧ x | z,
2. (p | y ∧ p | z) ⇒ p | x.
Let us notice that the first condition states that x is a common divisor, while the
second determines that x is the greatest one.
If x is the greatest common divisor of y and z, then we write x = gcd(y, z).
Natural numbers x and y are called coprime if gcd(x, y) = 1. This means that
they have no common divisors but 1.
It is easy to observe the following fact.
Theorem 2.12 If we divide two natural numbers by their greatest common divisor,
then the obtained numbers are coprime. In symbols,
x y
gcd , = 1.
gcd(x, y) gcd(x, y)
Proof Let z = gcd(x, y). Then there exist two integers p, q such that x = p · z and
y
y = q · z (then, of course, p = gcd(x,y)
x
and q = gcd(x,y) ).
Unless p and q are coprime, then they have a common divisor greater than 1.
Let us denote it by d. Then the number z · d is also a divisor of both x and y. Since
d > 1, then it must be greater than z. We arrive at a contradiction.
We say that x is a common multiple of natural numbers y and z if y | x and z | x.
The least common multiple of two natural numbers y and z is defined as the
natural number x such that
1. y | x ∧ z | x,
2. (y | p ∧ z | p) ⇒ x | p.
Theorem 2.13 The product of two natural numbers x and y is equal to the product
of the greatest common divisor and the least common multiple of these two numbers.
[email protected]
52 2 Mathematical Foundations of Cryptography
In symbols,
x · y = gcd(x, y) · lcm(x, y).
Example 2.6 Let x = 957 and y = 2117. Then gcd(x, y) = gcd(957, 2117) = 29,
while lcm(x, y) = lcm(957, 2117) = 69861.
Let us notice that xy = 957 · 2117 = 2025969.
Furthermore, gcd(x, y) · lcm(x, y) = gcd(957, 2117) · lcm(957, 2117) = 29 ·
69861 = 2025969.
Definition 2.20 A natural number p > 1 is called prime if it has exactly two divi-
sors: 1 and p itself.3
Theorem 2.14 Every integer greater than 1 has at least one prime divisor.
Proof Let us consider an integer x > 1. This number has divisors greater than 1
(x itself is one of these divisors). Let us denote by q the least of these divisors. We
will prove that q is prime. Let us assume, on the contrary, that there exists p greater
than 1 and smaller than q that divides the latter. Then 1 < p < q, p | q and as q | x
we have that p is also a divisor of x. We get a contradiction with the assumption
that q is the least divisor of x. Therefore, q is prime.
Theorem 2.15 Every natural number larger than 1 can be uniquely, up to the order
of factors, factorized into the product of primes. In symbols, for a natural number n
we have
n = p1α1 · p2α2 · · · pkαk ,
where the pi (for i = 1, . . . , k) are different primes.
Proof (sketch) Let us consider an integer x greater than 1. According to the previous
theorem, x has at least one prime divisor. Let us denote it by q1 . Then we have
x = q1 · p1 for some p1 . As previously, p1 has at least one prime divisor, which we
denote by q2 . And so on. As a result we obtain a sequence of prime divisors of x. It
is obvious that this sequence is finite and its last element is prime. Therefore, x can
be represented as a product of primes.
[email protected]
2.2 Elements of Number Theory 53
β β β
Theorem 2.16 If n = p1α1 · p2α2 · · · pkαk and m = p1 1 · p2 2 · · · pk k , then
and
max(α1 ,β1 ) max(α2 ,β2 ) max(αk ,βk )
lcm(n, m) = p1 · p2 · · · pk .
It is easy to notice that natural numbers n and m are coprime if for all i (i =
1, . . . , k) we have min(ai , bi ) = 0. Then, of course,
p1 = 2 α1 = 3 β1 = 2
p2 = 7 α2 = 1 β2 = 0
p3 = 13 α3 = 2 β3 = 1
p4 = 19 α4 = 0 β4 = 2
gcd(x, y) = gcd(10976, 18772) = 22 · 70 · 131 · 190 = 52,
lcm(x, y) = lcm(10976, 18772) = 23 · 71 · 132 · 192 = 3963236.
Proof
• Euclid (5th century BC).
Let us assume that there are finitely many prime numbers. Let p1 , p2 , . . . , pk be
all of them and let P denote their product increased by one: P = p1 · p2 · · · pk + 1.
As we have already shown, each natural number, including P , has at least one
prime divisor. Let us denote a prime divisor of P by q. Now the question arises
whether q is one of numbers p1 , p2 , . . . , pk . If it were, then we would have q |
p1 · p2 · · · pk and q | P . Since P > p1 · p2 · · · pk , thus q | (P − p1 · p2 · · · pk ).
However, P − p1 · p2 · · · pk = 1, therefore q | 1, which is obviously impossible.
• Kummer (1878).
Let us suppose that there are finitely many primes. Let p1 , p2 , . . . , pk be all of
them and let P denote their product: P = p1 · p2 · · · pk . Obviously, P > 2. Let us
notice that P − 1 can be represented as a product of primes. Of course, all factors
of this product are taken from the set {p1 , p2 , . . . , pk }. Therefore, there exists
at least one prime pi (for some i = 1, . . . , k) that divides both P and P − 1.
However, then we get pi | P − 1 and pi | P , but since P > P − 1, we obtain
pi | (P − (P − 1)), thus pi | 1, which is obviously impossible.
[email protected]
54 2 Mathematical Foundations of Cryptography
• Stieltjes (1890).
Let us assume that there are finitely many primes. Let p1 , p2 , . . . , pk be all of
them and let P denote their product: P = p1 · p2 · · · pk . Now, let us represent P
as a product of two natural numbers, m and n, greater than or equal 1 (m and n
are products of some primes taken from the set {p1 , p2 , . . . , pk }. Thus, none of
p1 , p2 , . . . , pk divides both m and n. Then, if we consider the sum m + n, it turns
out that it does not have a prime divisor. But since this sum is greater than 1, it
has such a divisor. We obtain a contradiction.
Below we present more theorems, which imply that there exist infinitely many
primes.
Theorem 2.18 For every natural number n > 2 there exists at least one prime
greater than n and less than n!.
Proof Let us observe that N = n! − 1 is greater than 1 (since n > 2). Therefore,
N has a prime divisor, which we denote by p. Let us also notice that p cannot be
less than or equal to n, as it divides n! − 1. Thus, p is greater than n. On the other
hand, we know that p ≤ N , so p < N − 1. Finally, we get n < p < n!.
Corollary It follows from the above theorem that there are infinitely many primes.
Theorem 2.19 (Chebyshev) For every natural number n > 3 there exists at least
one prime greater than n and less than 2n − 2.
Theorem 2.20 (Breusch) For every natural number n > 7 there exist at least four
primes of the forms 3k + 1, 3k + 2, 4k + 1, 4k + 3 such that all of them are greater
than n and smaller than 2n.
It is worth mentioning that despite many efforts no formula for prime numbers
has been obtained. Moreover, nobody has proven that such a formula written by
means of elementary functions does not exist at all; however, it is assumed that
there is no such a formula.
n
In 1654 Fermat conjectured 22 + 1 to be a formula for primes. However, in
5
1732 Euler showed that 641 divides 22 + 1. Landry, in 1880, proved that 274177
5 11
is another divisor of 22 + 1. Now it is also known that 319489 divides 22 + 1 and
12 38
114689 divides 22 +1. As an interesting fact let us mention that 22 +1 (which has
tens billions of digits) was proven divisible by 3 · 241 + 1. Furthermore, it was shown
n
that numbers 22 + 1 are composite for n = 6, 7, 8, 9, 11, 12, 18, 23, 36, 38, 73.
Another interesting fact concerns the so-called Euler’s polynomial f (x) = x 2 +
x + 41, whose values are prime for all integer arguments taken from the interval
−40, 39.4
[email protected]
2.2 Elements of Number Theory 55
Example 2.8 For n = 4 there exist only two natural numbers not greater than and
coprime with 4. These are 1 and 3, hence Φ(4) = 2.
Similarly, Φ(13) = 12, Φ(20) = 8, Φ(143) = 120.
Table 2.7 provides the values of Euler’s function for natural numbers less than 90.
[email protected]
56 2 Mathematical Foundations of Cryptography
Proof (sketch) Let us notice that for all natural numbers a, b, c, n the congruence
relation ≡ has the following properties:
1. reflexivity—a ≡ a (mod n)
2. symmetry—a ≡ b (mod n) ⇒ b ≡ a (mod n)
3. transitivity—[a ≡ b (mod n) ∧ b ≡ c (mod n)] ⇒ a ≡ c (mod n)
Due to the properties of equivalence relations, each congruence relation (mod-
ulo n) determines a partition of the set of natural numbers into disjoint equivalence
classes. These classes are formed by natural numbers congruent modulo n.
Example 2.10 Let n = 4. Then the congruence relation partitions the set of natural
numbers into four disjoint classes:
Corollary For any equivalence class of a there exists some a0 from the set
{1, 2, . . . , n − 1} such that a ≡ a0 (mod n). Such a0 is called the canonical rep-
resentative of the equivalence class of a (the class [a]).
The set Zn = {0, 1, 2, . . . , n − 1} is called the set of natural numbers modulo n.
[email protected]
2.2 Elements of Number Theory 57
and inversion (whenever possible) takes O(k 2 ), while exponentiation costs O(k 3 ).5
These facts are crucial for the complexity of encryption algorithms presented in
subsequent chapters.
3 · 0 (mod 5) = 0,
3 · 1 (mod 5) = 3,
3 · 2 (mod 5) = 1,
3 · 3 (mod 5) = 4,
3 · 4 (mod 5) = 2.
3 · 0 (mod 6) = 0,
3 · 1 (mod 6) = 3,
3 · 2 (mod 6) = 0,
3 · 3 (mod 6) = 3,
3 · 4 (mod 6) = 0,
3 · 5 (mod 6) = 3.
[email protected]
58 2 Mathematical Foundations of Cryptography
3 · 0 (mod 6) = 0,
3 · 1 (mod 6) = 3,
3 · 2 (mod 6) = 0,
3 · 3 (mod 6) = 3,
3 · 4 (mod 6) = 0,
3 · 5 (mod 6) = 3.
k
x= ai · Ni · Mi (mod n),
i−1
where Ni = n
ni , a Mi = Ni−1 (mod n) .
x ≡ 3 (mod 7)
x ≡ 7 (mod 13)
We have
n1 = 7, n2 = 13, n = 7 · 13 = 91
N1 = 13, N2 = 7
M1 = 13−1 (mod 7) = 6−1 (mod 7) = 6
M2 = 7−1 (mod 13) = 2
x = 3 · 13 · 6 + 7 · 7 · 2 (mod 91) = 234 + 98 (mod 91) = 332 (mod 91) = 59.
[email protected]
2.3 Sieve of Eratosthenes, Euclidean Algorithms 59
x ≡ a (mod n1 ),
x ≡ a (mod n2 ),
Theorem 2.27 (Fermat’s Little Theorem) If p is a prime, then for all a ∈ Zp such
that a = 0 we have
a p−1 ≡ 1 (mod p).
Theorem 2.28 (Euler’s Theorem) For every positive integer n coprime with a,
where a ∈ Zn and a = 0, the following modular equation holds
The question of whether there are methods to determine primes in the set of natural
numbers was raised already by the ancients. According to current knowledge, the
6A very intelligible presentation of all these algorithms can be found in [87]. See also [68].
[email protected]
60 2 Mathematical Foundations of Cryptography
first algorithmic method solving this problem was developed in the second century
BC by the ancient Greek mathematician Eratosthenes (276 BC–184 BC).
Its simple idea is to arrange natural numbers in an ascending sequence (or in an
array) and eliminate composite numbers by crossing out multiples of, consecutively,
two, three, five, and so on.
Let us look at an example that illustrates the search for primes in the set
{2, 3, . . . , 60} by means of the sieve of Eratosthenes.
First, we arrange numbers in a sequence (or an array):
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
The first number in this sequence is equal to 2 (we do not take 1 into consider-
ation, as according to the definition it is not prime), hence 2 is prime. We cross out
all multiples of 2 except itself, which gives the following sequence:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
The next prime turns out to be 3. We cross out its multiples, as well:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
Afterwards, we continue this procedure with 5 and 7, respectively:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
Let us observe that in order to find all prime numbers in the set {1, 2, .√. . , n}, it
is sufficient to apply the sieve algorithm only for primes not greater
√ than n. This
follows from the fact that every √ composite number greater than n has to have a
prime factor which is less than n. Therefore, it must have already been crossed
out by the sieve. For this reason, in the case of the considered set {2, 3, . . . , 60} we
can stop the selection procedure on arriving at 7.
We obtain the following primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
47, 53, 59.
The algorithm presented below is attributed to Euclid (c. 300 BC), who is thought
to have been the first chief librarian of the ancient Library of Alexandria and who
wrote the famous Elements—the first treatise on geometry. The algorithm computes
[email protected]
2.3 Sieve of Eratosthenes, Euclidean Algorithms 61
the greatest common divisor of two natural numbers. Its extended version allows us
to determine the inverse of a given natural number in Zn .
The first version of the algorithm, presented in Elements, concerned the purely
geometric problem of determining whether two line segments are commensurable.
Later, it was proven that this problem can be expressed in the language of number
theory.
The easiest version of the Euclidean algorithm consists of repeatedly subtracting
the smaller number from the greater one until zero is obtained. The last nonzero
number achieved in this way is equal to the greatest common divisor of the two
input numbers. A faster version applies a function that returns the remainder of the
division of two natural numbers. There exist also recursive versions of the algorithm.
Below we present them written in pseudocode.
It is easy to notice that this algorithm can be rewritten in a simpler way using the
mod function, which finds the remainder of division:
[email protected]
62 2 Mathematical Foundations of Cryptography
9 end
10 until b=0;
11 gcd(a,b) :=a;
Theorem 2.29 For all natural numbers a, b, where b = 0, the common divisors of
a and b are the same as the common divisors of a and b mod a.
q = (b div a),
r = (b mod a),
thus
b = a · (b div a) + (b mod a).
Let us assume that the above formula holds also for a = 1. We have
b=d ·x and a = d · y.
[email protected]
2.3 Sieve of Eratosthenes, Euclidean Algorithms 63
We have
b = a · q + r = d · y · q + r,
hence
d · x = d · y · q + r, r = d · (x − y · q),
therefore
(b mod a) = d · (x − y · q).
It follows that d is also a common divisor of a and b mod a.
The proof of the other direction is analogous.
Corollary If the set of divisors of positive integers a and b mod a is equal to the set
of divisors of a and b, then the greatest common divisor of both pairs is the same:
Example 2.15 gcd(45, 12) = gcd(45 mod 12, 12) = gcd(9, 12) = gcd(9, 12 mod 9)
= gcd(9, 3) = gcd(9 mod 3, 3) = gcd(0, 3) = 3.
Example 2.16 gcd(20, 63) = gcd(63 mod 20, 20) = gcd(3, 20) = gcd(3, 20 mod 3)
= gcd(3, 2) = gcd(3 mod 2, 2) = gcd(1, 2) = gcd(1, 2 mod 1) = gcd(1, 1) = 1.
This shows that 63 and 20 are coprime (indeed, let us notice that 63 = 32 · 7,
while 20 = 22 · 5).
Theorem 2.30 The Euclidean algorithm is correct, i.e., it returns the greatest com-
mon divisor of two given positive integers.
Proof (for the second version of the algorithm) In order to prove the theorem, we
need to show two facts. Firstly, it is necessary to justify that the algorithm stops,
secondly, that its output is correct.
Let us consider two natural numbers n, m such that n ≤ m.
1. In the case when n = m, then gcd(n, m) = n = m, and hence the algorithm re-
turns the value gcd(n, m) (3rd line of the algorithm (2)).
2. Let us assume that n < m. After executing each loop 6–9, values of the variable b
form a strictly decreasing sequence of natural numbers. Obviously, each strictly
decreasing sequence of natural numbers is finite and thus the last value of b is
equal to 0. Therefore, the algorithm always stops.
As concerns the correctness of the result, let us observe that, due to the last the-
orem, gcd(n, m) is constant before and after each loop 6–9. The initial value of
gcd(n, m) is thus equal to the value after the last execution of the loop, where b = 0,
[email protected]
64 2 Mathematical Foundations of Cryptography
which gives gcd(n, m) = gcd(a, 0) = a. The last value of the variable a is the great-
est common divisor of n and m.
From the viewpoint of the computational complexity, it should be noticed that the
time complexity of the above algorithm applied to k-bit numbers equals O(k 2 ).7
Let us consider one more variant of the Euclidean algorithm which applies the func-
tion div instead of mod. This version allows us to present and justify the correctness
of the so-called extended Euclidean algorithm.
Example 2.17 Let us follow the execution of the above algorithm for n = 135 and
m = 40.
Table 2.8 below provides values of variables a, b, q and −q · b during the algo-
rithm’s execution for the numbers n, m set as above.
As can be seen in the presented example, the algorithm generates several se-
quences of natural numbers a0 , a1 , a2 , . . . , ak , b0 , b1 , b2 , . . . , bk , q1 , q2 , . . . , qk and
integers −q1 · b1 , −q2 · b2 , . . . , −qk · bk (where a0 = m, while b0 = n).
[email protected]
2.3 Sieve of Eratosthenes, Euclidean Algorithms 65
If ai−1 and bi−1 are values of variables a and b at the beginning of the loop
4–7, and ai and bi are values of these variables after the loop’s execution, then, for
i = 1, 2, . . . , k, the following properties hold:
1. ai = bi−1 ,
2. qi = ai−1 div ai
3. ai+1 = bi = ai−1 − qi · bi−1 = ai−1 − qi · ai , hence
4. ai+1 = ai−1 − qi · ai
Let us also notice that ak = gcd(n, m).
Now, we will construct two useful integer sequences (sn ) and (tn ). Let
s0 = 1, t0 = 0 and s1 = 0, t1 = 1.
Let us observe that for such coefficients s0 , t0 , s1 , t1 the following relations hold:
m = a0 = s0 · m + t0 · n and n = a1 = s1 · m + t1 · n,
sn+1 = sn−1 − qn · sn
tn+1 = tn−1 − qn · tn ,
then we can see that for all i = 0, 1, . . . , k − 1 the equation ai+1 = si+1 · m + ti+1 · n
is valid.
Therefore, this relation does not depend on the number of executions of the
loop 4–7.
Now, let us recall that the last value of a determines gcd(n, m), which results in
the following formula:
gcd(n, m) = ak = sk · m + tk · n.
We see that the greatest common divisor of two given numbers can be represented
as their linear combination with integer coefficients. This observation turns out to
be crucial for determining inverses in rings Zn .
Finally, we describe the so-called extended Euclidean algorithm, which takes into
account our considerations and which determines coefficients s and t mentioned
above.
[email protected]
66 2 Mathematical Foundations of Cryptography
7 while a <> 0 do
8 begin
9 q := a div a’;
10 (a,a’) := (a’, a - qa’)
11 (s,s’) := (s’, s - qs’)
12 (t,t’) := (t’, t - qt’)
13 end
14 gcd(n,m) := a
The extended Euclidean algorithm returns the greatest common divisor of two
given numbers, and, moreover, it determines the integer coefficients s and t of a
linear combination such that gcd(n, m) = s · n + t · m.
The proof is based on our discussion related to Example 2.17.
The above algorithm allows us, among other things, to find inverses in rings Zn .
Let us recall that if for a given number z ∈ Zn there exists y ∈ Zn such that
x · y ≡ 1 (mod n), then we call x and y mutually inverse. We adopt the following
notation: y = x −1 and x = y −1 .
We say that z ∈ Zn is invertible if and only if there exists its inverse.
We have the following result.
Example 2.18 Let us consider the following problem. We want to compute the in-
verse, provided it exists, of 10 in the set Z37 (37 is a prime, so due to the above
theorem 10 is invertible in Z37 ). Let us denote this inverse by x.
The following modular equation has to be satisfied: 10 · x = 1 (mod 37).
If we apply the extended Euclidean algorithm to 10 and 37, then we obtain
gcd(10, 37) = 1, s = −11 and t = 3. We have
1 = −11 · 10 + 3 · 37,
[email protected]
2.4 Tests for Primality 67
1 = 26 · 10 + 3 · 37 (mod 37),
therefore
1 = 26 · 10 (mod 37).
Thus, 27 is the inverse of 10 in the set Z37 .
It follows from this example that a simple way to determine the inverse of x in
Zn is to apply the extended Euclidean algorithm for numbers x and n.
The time complexity of the described algorithm applied to k-bit numbers is also
O(k 2 ).8
This section presents two probabilistic, or randomized, algorithms for testing pri-
mality of natural numbers—Fermat’s test and the Miller-Rabin test,9 both often
used in practice today. This is followed by pointing out the theoretic role of one
of the most important achievements in computer science of the last decade, namely
the AKS deterministic test for primality. The section closes with a brief discussion
of two computationally hard number theoretic problems—the integer factorization
and the discrete logarithm problem. These issues play a fundamental role when it
comes to the cryptographic strength of many of today’s security systems, considered
in the following chapters.
Let’s recall Fermat’s little theorem: If p is a prime integer, then for any a ∈ Zp and
a = 0,
a p−1 ≡ 1 (mod p).
Unfortunately, the primes are not the only numbers that satisfy the above condi-
tion. There are also composite numbers, for which the above holds true.
A composite n that satisfies condition a n−1 ≡ 1 (mod n) for every a coprime to
n is called a Carmichael number.
The smallest Carmichael number is 561 (3 · 11 · 17).
[email protected]
68 2 Mathematical Foundations of Cryptography
w n−1 ≡ 1 (mod n)
for the natural number n (w < n) is called a witness to the primality of n. Of course,
if n is prime, then all natural numbers less than n are witnesses to the primality of n.
It turns out that Fermat’s little theorem provides a method for checking primality.
The following assertion is true.
Proof Consider a natural n. Let T denote the set of all integers relatively prime to n.
Then for each w ∈ T , we have: gcd(w, n) = 1. There are two cases: either all the
elements of T are witnesses to the primality of n, that is, for each w ∈ T , we have:
w n−1 = 1 (mod n), or a number exists in T which is not a witness to the primality
of n. In the first case the conclusion is obvious.
Suppose that some w ∈ T is not a witness to the primality of n, i.e., w n−1 = 1
(mod n). Then n is composite. Let Tn = {w1 , w2 , . . . , wt } denote the set of those
numbers from T (Tn ⊆ T ) which are witnesses to the primality of n. We have, for
each k ∈ {1, 2, . . . , t}: wkn−1 = 1 (mod n).
Let ui = w · wi , for each i ∈ {1, 2, . . . , t}. Then any i, k ∈ {1, 2, . . . , t} satisfy the
following relationships:
1. ui = uk , for i = k.
Because suppose that for some i = j , we have ui = uk . Then of course ui −
uk = 0, therefore w · wi − w · wk = 0, and so n | (w · wi − w · wk ) and finally
n | w · (wi − wk ). But gcd(w, n) = 1. Therefore n | (wi − wk ). It is also true that
−n < wi − wk < n. Hence wi = wk , which contradicts the assumption.
2. un−1
i = (w · wi )n−1 = w n−1 · win−1 = w n−1 = 1 (mod n).
A direct application of these properties is the fact that in the latter case, for t
numbers which are witnesses to the primality of n, there exist as many numbers in
T which are not witnesses to the primality of n.
The test consists of k independent trials carried out for a given number n being
tested.
The parameter k is chosen by the user, in practice most often k is not less than
20 and not greater than 50.
[email protected]
2.4 Tests for Primality 69
Theorem 2.33 If n is not prime and is not a Carmichael number, then, in a single
trial a randomly selected number a (a < n) is not a witness to the primality of n
with probability of at least 12 .
It follows that, if we repeat the test k times and we do not hit on a Carmichael
number, the probability of a mistaken result is less than 21k . For k equal to 20, the
result is already satisfactory for our purposes.
Carmichael numbers are believed to be very rare. Their distribution has been
studied extensively for over 100 years with no definite answer, so far. Their rar-
ity has been proved for the primes up to 1021 (as of August 2012), see [80]. The
currently interesting cryptographic prime parameters are much bigger, in the range
of size between 160 and 4096 bits, (see [30, 82]). These are still very small from
the perspective of asymptotic (i.e., for arbitrarily large n) conjectures currently dis-
cussed in number theory research. The probability of randomly hitting a Carmichael
number cannot be precisely estimated with present knowledge. It is often believed
that they are sufficiently rare among small primes currently used in cryptography
to make the risk due to the fallibility of the Fermat test fallibility small enough in
practice. However, according to some researchers (e.g., [68]) this uncertainty makes
Fermat’s test excessively fallible.
It is interesting to note that Fermat’s test is now utilized for testing primality of
numbers used as keys in the PGP system (discussed thoroughly in the following
chapters).
This subsection presents the Miller-Rabin test, most often used in practice these
days.
[email protected]
70 2 Mathematical Foundations of Cryptography
Theorem 2.34 Let n be an odd prime, and let n − 1 = 2s · r where r is odd. Let a
be an integer coprime to n. Then either a r ≡ 1 (mod n) or a 2 ·r ≡ −1 (mod n) for
j
some j , 0 ≤ j ≤ s − 1.
n − 1 = 2s · r where r is odd.
Theorem 2.35 If n is prime, the test always gives the correct answer.
Theorem 2.36 If n is composite, then the probability that the selected number is a
witness to the primality and the test with a single trial declares prime is less than 14 .
Thus a single positive Miller–Rabin test trial gives twice the confidence that the
result is correct than does Fermat’s test. For k trials the confidence rises 2k -fold.
The seemingly more complicated Miller-Rabin test is in fact computationally no
more time-consuming than the Fermat test. The time complexity of each of the two
tests for k-bit input numbers is O(k 3 ).10
The tests presented above for primality are probabilistic. This means that the result
is correct with a certain large probability but the probability is not equal to 1.
So far, no feasible deterministic algorithm has been developed for checking pri-
mality of numbers of size interesting in cryptographic practice these days. Until
[email protected]
2.5 Computationally Hard Problems in Number Theory 71
2002 the only known deterministic algorithms testing primality were of exponential
time complexity.
In August 2002, Manindra Agrawal and his two undergraduate students, Neeraj
Kayal and Nitin Saxena of the Indian Institute of Technology in Kanpur, published
the first polynomial-time algorithm for testing primality.11 However practical usage
of this algorithm for large numbers of current interest is still impossible. The degree
of the polynomial is too high. Many research centers are working hard on optimizing
this algorithm.
Algorithm AKS (for abbreviation, we omit the names of the coauthors) is based
on a generalization of Fermat’s little theorem for polynomials.
11 See [4].
[email protected]
72 2 Mathematical Foundations of Cryptography
of the RSA algorithm, and the discrete logarithm problem, employed in the Digital
Signature Algorithm.
2.5.1 Factorization
The integer factorization problem is the problem of splitting any given composite
positive integer n into (preferably prime) non-trivial factors. The multiplication of
integers is instantly executed on any computer. But the inverse operation, i.e., fac-
torization, is computationally hard. This subsection summarizes the current status
of the integer factorization problem to the extent of its interest for cryptology.
In general running times of the factoring algorithms are functions of the size of n
only. In some special cases, these times may depend also on some specific properties
of n, e.g., on the size of the prime factors of n. It is advisable to try the algorithms
for finding small prime factors first. The hardest case is when n is the product of
two primes of roughly the same size.
In 1991, a global contest was started, the RSA Factoring Challenge,12 organized
by RSA Security in order to stimulate the scientific community to study efficient
algorithms for factoring large integers. A list of numbers was published, which were
known to be the products of two primes. These numbers are called RSA numbers.
A cash prize was offered for factorization of some of them. The first one, a 100-
digit RSA-100 number was factored out within a few days, but most of them still
remain unbroken. The contest lasted for sixteen years and was officially closed in
May 2007. Some of the smaller prizes had been awarded at the time. The remain-
ing prizes were retracted. Many numbers were factored during the challenge. Even
today, these results still determine the bounds of feasible factorization.
Here are some of the challenge details. In August 1999, the cryptological com-
munity was electrified to learn that a 512-bit number (155 decimal digits) was fac-
tored out into prime factors.
10941738641570527421809707322040357612003732945449205990913842131
47634998428893478471799725789126733249762575289978183379707653724
4027146743531593354333897.
10263959282974110577205419657399167590071656780803806680334193352
1790711307779
×
10660348838016845482092722036001287867920795857598929152227060823
7193062808643.
[email protected]
2.5 Computationally Hard Problems in Number Theory 73
Finding these factors took four months. Multiple computers were involved in the
calculations.
In March 2002, nCipher Inc. announced that it had developed software that al-
lowed it to break the 512-bit RSA key within six weeks, using tens of computers.
A little later, the computing time was shortened to one day.
These are obviously very good results, but it should be noted and emphasized
that increasing the number of bits by one doubles the search space.
In December 2003, factorization of the next RSA Challenge number was an-
nounced. This time it was RSA-576, a 576-bit (174-decimal-digit) integer. This
number is:
18819881292060796383869723946165043980716356337941738270076335642
29888597152346654853190606065047430453173880113033967161996923212
05734031879550656996221305168759307650257059.
39807508642406493739712550055038649119906436234252670840638518957
5946388957261768583317
×
47277214610743530253622307197304822463291469530209711645985217113
0520711256363590397527.
The team that managed to factorize RSA-576 received the $10,000 prize, as
promised by the RSA Challenge.
As of August 2012, the largest RSA Challenge cryptographically hard integer
(i.e., one that was chosen specifically to resist all known factoring attacks, and is a
product of two roughly equal primes) that has been factored is RSA-768, a 768-bit
(232-decimal-digit) integer:
12301866845301177551304949583849627207728535695953347921973224521
51726400507263657518745202199786469389956474942774063845925192557
32630345373154826850791702612214291346167042921431160222124047927
4737794080665351419597459856902143413
=
33478071698956898786044169848212690817704794983713768568912431388
982883793878002287614711652531743087737814467999489
×
36746043666799590428244633799627952632279158164343087642676032283
815739666511279233373417143396810270092798736308917
This was the result of a large collaboration across the globe stretching over more
than two years and using the general-purpose factoring algorithm called the general
number field sieve. The overall effort required more than 1020 operations, on the
[email protected]
74 2 Mathematical Foundations of Cryptography
order of 267 instructions. This is sufficiently low that even for short-term protection
of data of little value, 768-bit RSA moduli can no longer be recommended [58].
More RSA numbers are waiting in the queue (Table 2.9). For a person who man-
ages to decompose RSA-704, a US $30000 award was offered, and for the longest
presented number, the RSA-2048, a US $200000. Table 2.9 shows more on the RSA
Challenge.13
The longest number presented to the contest was the RSA-2048:
25195908475657893494027183240048398571429282126204032027777137836
04366202070759555626401852588078440691829064124951508218929855914
91761845028084891200728449926873928072877767359714183472702618963
75014971824691165077613379859095700097330459748808428401797429100
64245869181719511874612151517265463228221686998754918242243363725
90851418654620435767984233871847744479207399342365848238242811981
63815010674810451660377306056201619676256133844143603833904414952
63443219011465754445417842402092461651572335077870774981712577246
79629263863563732899121548314381678998850404453640235273819513786
36564391212010397122822120720357.
[email protected]
2.5 Computationally Hard Problems in Number Theory 75
Comparing this number to RSA-576, one can easily forecast that even using mod-
ern technology the factorization will remain an open problem for a very long time.
The best algorithms currently used for factorization of k-bit integers have the time
complexity O(ek·lg(k) )14 (see [68]). The work on them, and on new algorithms, does
not give much hope for easy and fast factorization of large numbers. A very nice sur-
vey of integer factorization methods and their complexities is given by [68], Chap. 3
and [75].
[email protected]
76 2 Mathematical Foundations of Cryptography
The most obvious algorithm for DLP is exhaustive search: successively compute
g 0 , g 1 , g 2 until y is obtained. It takes O(p) multiplications. This is exponential in
the bit-length of p, and is therefore infeasible if n is large, i.e., in cases of current
cryptographic interest.
In some important applications, in particular in the Digital Signature Algorithm
(DSA), operations are performed in a field Zp with a prime p which nowadays is
recommended to be of at least 2048 bits. This prime p is selected so that p − 1 is
divisible by a much smaller prime q specified in the standard FIPS 186-3 to be of
160-, 224-, or 256-bit length.
The currently best method known for computing discrete logs in finite fields
Zp is called the number field sieve, with a subexponential expected running time,
1
roughly equal to exp((log(m)) 3 ), where m is the order of the group. The currently
best general algorithms for computing discrete logs (including probabilistic or par-
1
allelized ones) in cyclic groups run in (expected) exponential time O(m 2 ), and with
low memory requirements.
The so-far largest discrete log case for a prime field Zp (with p chosen with
all the recommended precautions to resist the known simple attacks) that has been
solved, up to August 2012, is for a 530-bit (160 decimal digit) prime p, [57]. The
largest finite group discrete log problem with hard parameters that has been solved
is that of discrete logs over an elliptic curve modulo a 112-bit prime, i.e., in a group
of about 2112 elements [21].
The Diffie-Hellman problem (DHP) is the following: given a prime p, a gener-
ator g of Zp∗ and elements g a mod p and g b mod p, compute g ab mod p. From the
complexity theory standpoint, DHP is at most as hard as DLP; i.e., it is polytime
reducible to DLP. Whether these problems are computationally equivalent remains
unknown.
The hardness of the discrete logarithm problem is the basis for the security jus-
tification of the Digital Signature Algorithm, presented in the next section, and for
the Diffie-Hellman key exchange protocol. The discrete log problem in elliptic curve
groups is not explicitly considered in this book. We mention in passing that, elliptic
curve cryptosystems currently use much smaller key sizes than would be required
by DSA and RSA with comparable security.
It appears that computing like discrete logs in prime fields or in elliptic curve
groups is harder than factoring integers of the same size. However, one of the rea-
sons for this impression might be that much less attention and effort has been given
to discrete logs than to integer factorization, while many leading algorithms are
similar.
More on the discrete logarithm problem can be found in Sect. 3.6 of [68] and a
beautiful survey [74]. For recent advances see [75], and the references therein.
[email protected]
Chapter 3
Foundations of Symmetric Cryptography
As indicated in Chap. 1, symmetric-key cryptography uses the same key for en-
cryption and decryption, or the decryption key can easily be computed from the
encryption key, and the other way round. Usually, symmetric-key ciphers are very
fast. Their main disadvantage is that a secret key must be agreed or transferred se-
curely between two parties before they can start communicating with such a cipher.
It always requires an earlier-established secure method of key exchange. In the tra-
ditional framework this used to be arranged via special couriers. In the computerized
world, however, there is always a serious threat that the secret key could be inter-
cepted by an unauthorized party. (In this book for simplicity such an unauthorized
party is called an intruder, or adversary.) Since every symmetric cipher’s security is
based on the security of its keys, the keys must be kept secret. Compromising a key
in such ciphers enables anyone who has the key to decrypt all the communication
cryptograms. Also in future, as long as communication is required to remain secret,
the key must be kept secret. Figure 3.1 illustrates the idea of symmetric cryptogra-
phy.
[email protected]
78 3 Foundations of Symmetric Cryptography
Many of the currently used symmetric algorithms apply some modifications of the
so-called Feistel network, i.e., an encryption algorithm introduced by Horst Feistel
and published by IBM at the beginning of the 1970s.1
The Feistel network is a block algorithm which takes as an input blocks of an
arbitrary even length. A given block is divided into halves, left and right, denoted
by L and R respectively. During the encryption process a function fS , dependent on
the key S is applied. It returns a pair of transformed halves, L and R , as a result.
Proper encryption consists of two substitutions:
1. L := R.
2. R := L XOR fS (R).
In the first substitution we replace the left half with the value of the right half,
while in the second substitution first we apply the function fS to the right half and
then the obtained value along with the left half are processed by the XOR operation.
The course of the Feistel algorithm is depicted in Fig. 3.2.
Let us recall two basic properties of the XOR function:
1. x XOR x = 0,
2. x XOR 0 = x.
It is easy to notice that the ciphertext obtained by means of the Feistel network
can be effortlessly decrypted by applying the function fS , which is used also for
encryption. We have
L = L XOR fS (R) XOR fS (R) = R XOR fS (R).
Let us recall that R = L . Hence, it is possible to recover the plaintext.
Leaving half of the plaintext unmodified might raise some doubts. However,
the security of the algorithm can be increased by repeating the whole procedure
any number of times. Symmetric algorithms used in practice usually apply several
rounds similar to the round of the Feistel cipher. Often, each of them uses a different
key S.
It is worth emphasizing that the function fS is an arbitrary function that maps
bit sequences into sequences of the same length. This means that we can design fS
arbitrarily.
[email protected]
3.2 The DES Algorithm 79
3.2.1 S-Boxes
The algorithm for transforming data by means of S-boxes (S stands for substitution)
is a block algorithm. A DES S-box is represented as a 4 × 16 matrix whose entries
[email protected]
80 3 Foundations of Symmetric Cryptography
are taken from the set {0, 1, 2, . . . , 14, 15} and each row of the matrix forms some
permutation of this set. Each DES S-box uniquely determines a function that maps
6-bit sequences into sequences of 4 bits.
The function is defined in the following way.
Let us consider an arbitrary 6-bit sequence.
• The first and the last bit of the sequence specify an integer from the set {0, 1, 2, 3}
in its binary representation. This integer determines one of the rows from the
S-box (rows are numbered from 0 to 3).
• The remaining bits specify an integer from the set {0, 1, 2, . . . , 15} in its binary
representation. This integer determines one of the columns of the S-box (columns
are numbered from 0 to 15).
• The value of the given 6-element sequence of bits is the integer (in its binary
representation) from the S-box that lies at the crossing of the appropriate column
and row.
Let us consider the following S-box (Table 3.1) and the bit sequence 110010.
The first and the last bit indicate the row number of the S-box, in our case this
is the row numbered 2 (10). The remaining bits form the integer 9 (1001), thus
the value of the ciphertext is the integer that lies at the crossing of the third row
(numbered 2) and the column numbered 9. This gives us 12, which in binary repre-
sentation is equal to 1100.
Let us notice that a transformation executed by means of such S-boxes is not
invertible, i.e., it is not possible to uniquely recover the input on the basis of the
output. Therefore, such a transformation cannot be called encryption. However, the
construction of the DES algorithm that uses S-boxes allows us to apply them in
order to encrypt and decrypt data.
Information about constructing S-boxes can be found, e.g., in [79].
[email protected]
3.2 The DES Algorithm 81
[email protected]
82 3 Foundations of Symmetric Cryptography
The initial permutation P is the first operation performed by DES. Its values
are presented in Table 3.2 (a bit at the n-th position in the plaintext is shifted to the
position P (n)). The purpose of this permutation is to disperse bits in the transformed
block. The obtained rearrangement is quite regular. This can be seen by drawing the
diagram of the permutation as a directed graph.
Next, the algorithm consecutively performs sixteen rounds of the modified Feis-
tel network (Fig. 3.4).
[email protected]
3.2 The DES Algorithm 83
Before each round, 56 out of the 64 bits of the key are chosen and permuted by
the function PC1 (denoted so according to the standard). This function is presented
in Table 3.3.
Thereafter, the 56-bit key is divided into halves. Bits from both halves are then
shifted to the left by one or two places, depending on the round number (the first
bit(s) of both halves are shifted to the end). The value of each shift is given in
Table 3.4.
After this operation, we merge the halves into a modified 56-bit key. Then we
choose, in a suitable way, and permute 48 bits. The choice is determined by the
function PC2, whose values are shown in Table 3.5. Due to all these procedures,
in each round we use a different key for encryption; moreover, different bits of the
main key are applied in each round.
Just as in each execution of the Feistel network, a 64-bit block of the plaintext
is then divided into halves L and R. The right half is appropriately extended to 48
bits. Consecutive values of the function that maps 32 bits of the right half into a new
48-bit block are given in Table 3.6.
Next, the XOR operation is applied to the obtained block and the modified round
key. The result is divided into eight groups of six bits each. Every group is trans-
formed by means of S-boxes. The outcome consists of eight groups, each with four
bits. Therefore, as the result of all these operations, we again get 32 bits in the right
half. Next, this bit sequence is permuted by the P -box (see Table 3.7) and XORed
[email protected]
84 3 Foundations of Symmetric Cryptography
with the left half according to the Feistel network. The obtained sequence constitutes
the right half ready for the next round of DES.
The following relations hold:
1. L = R,
2. R = L XOR f (R, Ki ),
where f (R, Ki ) denotes the value of the block with the P -box omitted in the i-th
round.
After 16 rounds described above, the ciphertext is permuted by the inverse of the
function P .
Now, let us see how to decrypt DES ciphertexts. It seems that the simplest way
is to repeat the whole encryption process in the reversed order. But, of course, this
is not feasible, since S-box transformations are not invertible.
It turns out that an attempt to reverse the process is not necessary. Let us consider
the second equality that characterizes an algorithm round:
R = L XOR f (R, Ki ).
Of course, we get
R XOR f (R, Ki ) = L XOR f (R, Ki ) XOR f (R, Ki ).
Applying one of the properties of the XOR function, we obtain
R XOR f (R, Ki ) = L.
Finally, after a suitable substitution,
L = R XOR f L , Ki .
Thus, the following equations are valid
1. R = L ,
2. L = R XOR f (L , Ki ).
It can be seen that in order to recover the contents of the text encrypted in a given
round, it is sufficient to know the cryptogram and an appropriate part of the mod-
ified key (i.e., the part that corresponds to the given round). Therefore, decryption
consists of applying the same algorithm as for encryption using modified keys in the
reversed order.
At the first glance, the DES algorithm may appear to be complicated, hard to
implement and, most importantly, computationally laborious. However, if we look
at it more closely, we notice that all performed operations are simply bit shifts,
permutations, XOR operations or substitutions. All these procedures are easy for
hardware implementation and can be executed very quickly.
[email protected]
3.2 The DES Algorithm 85
For many years the DES algorithm was thoroughly analysed. The only publicly
known, and most importantly practically executable way to break the algorithm is,
until today, the brute force method which is the search of the entire space of all
cryptographic keys. The number of keys is 256 . In decimal format this is about
72000000000000000, or approximately 72 quadrillion. This many decryptions are
required to check every possible key-candidate to decipher a given cryptogram. At
the beginning of the use of DES as a symmetric encryption standard, which was in
the late 1970s and throughout the 1980s, the number was too big for contemporary
computers.
However, often what cannot be calculated by commonly available computers
may be calculated by systems specially dedicated to specific calculations. Already
in 1977, Hellman and Diffie estimated that for about $20 million, a specially dedi-
cated computing machine could be designed and constructed that would be able to
find the encryption key by the brute force method in just one day. In 1981, Diffie
revised his estimates and said it would be possible to identify the key within two
days, providing that the attacker had equipment worth $50 million. In 1993 Michael
Weiner suggested a construction which would break DES in a few hours. The cost
of building such a device was to estimated be about one million dollars. However,
publicly no organization or individual has claimed responsibility for building such
a device [92]. (For more details about the cryptographic power of DES code and
attempts to break it, the reader is referred to Sect. 7.4.3 in [68].)
Over the years, the computing power of computers and their number has in-
creased. The first practical breaking of DES was achieved and publicly demonstrated
at the end of the 1990s. It all started in 1997 when RSA Security offered $10000 for
practical breaking of the code. The winners were the members of the DESCHALL
project founded by Rocke Verser, Matt Curtin, and Justin Dolske. They made the
first well-known, publicly announced, and successful attempt to break DES in 1997.
It took them 96 days. To break the code they used thousands of computers scattered
all over the internet [51]. The next edition of the contest—in 1998—was won by
the distributed.net project, which got the key within 41 days. In the same year the
Electronic Frontier Foundation demonstrated the DES Cracker device, which cost
$250000 and deciphered the code within 56 hours [36]. A year later, in 1999, dis-
tributed.net and RSA Labs broke the code in less than 24 hours [36].
Another well-known project dealing with breaking the DES code was the CO-
PACOBANA project run by the German Universities of Bochum and Kiel [59].
A machine developed in 2006 within the framework of this project consisted of 120
reconfigurable computing FPGA cards of XILINX Spartan3-1000 type running in
parallel. The cost of the device was very low, about $10000. Fully breaking DES
was possible within a week. In 2008 the successor to the COPACABANA project,
the COPACOBANA RIVYERA machine broke DES in less than one day [25]. It
used 128 FPGA Spartan-3 5000 cards. Nowadays some specialised systems based
on FPGA architectures cope with DES within several hours.
[email protected]
86 3 Foundations of Symmetric Cryptography
There are also other methods of attack, which in theory are more effective than
brute force. One of these is the attack using differential cryptanalysis, specially de-
veloped for this purpose by Eli Biham and Adi Shamir [17, 18]. This method in-
volves comparing pairs of ciphertexts provided as a result of encryption using the
same key of explicit texts that differ in a certain prescribed way. Carrying out the
attack, however, requires preparation of a large number of data and, therefore, it
is infeasible [17, 92]. Another theoretical method is linear analysis, developed by
Mitsuru Matsui [67]. Research in this area continues. More methods are being de-
veloped, including hybrid methods. Also version of DES limited or modified in
different ways are being broken.
Currently, one solution to the insecurity of DES is to use repeated encryp-
tion with the algorithm. Even double encryption reduces the risk of being broken
72 quadrillion times, while only doubling the encryption time. In practice, Triple
DES (3DES) encryption is used. 3DES applies triple encryption with DES. Today
breaking this algorithm is infeasible. However, it is three times slower than DES
which is why it sometimes loses out to other symmetric algorithms.
Many users of the DES cryptosystem are not satisfied with a 56-bit key, therefore
some modifications of this algorithm have been developed.
This method applies two keys: K1 and K2 , and the encryption algorithm operates
according to the formula
C = DESK1 DES−1K2 DESK1 (M) . (3.1)
Thus, first a message M is encrypted by means of the key K1 , then the result of
this encryption is decrypted with the use of the key K2 and, finally, the outcome
of decryption is again encrypted with the key K1 . Hence, the decryption algorithm
corresponds to the equation
M = DES−1 −1
K1 DESK2 DESK1 (C) . (3.2)
Of course, DESK (T ) stands in the above equations for the algorithm encrypting
a 64-bit block T with a key K, while DES−1K (T ) denotes the inverse operation, i.e.,
the procedure of decrypting the block T with the key K. Therefore, the length of
the encryption key is doubled.
[email protected]
3.4 Modes of Operation of the DES Algorithm 87
3.3.2 DESX
When applying this method for encrypting a 64-bit data block M, three keys:
Kout , Kin , KDES , the DES algorithm, and the XOR operation are used. The first two
keys are 64 bits long. A cryptogram is generated according to the formula
C = Kout XOR DESKDES (M XOR Kin ), (3.3)
while correct decryption corresponds to the equation
M = Kin XOR DES−1
KDES (C XOR Kout ). (3.4)
This version of the DES algorithm, even when the recently invented so-called differ-
ential cryptanalysis is applied, requires checking 2120 = 1036 keys in order to break
the cipher.
A scheme of this mode of operation is depicted in Fig. 3.5, where each 64-bit block
Mi of a plaintext is encrypted with the same key K. Within this system cryptograms
corresponding to plaintext blocks are all distinct. Let us then imagine that 264 =
1.844674407 · 1019 possible plaintexts are included in a book in which a cryptogram
is assigned to every plaintext block. This justifies the name of the mode.
When using this mode it may happen that an encrypted message contains the
same ciphertext blocks corresponding to the same plaintext blocks, which provides
cryptanalysts with data that facilitates breaking the cipher. The electronic codebook
mode is thus unusable for encrypting long messages.
[email protected]
88 3 Foundations of Symmetric Cryptography
Fig. 3.5 Application of the DES algorithm in the electronic codebook mode
safely be sent through an open access channel to a receiver so that the latter is able
to decrypt the message correctly.
The decryption procedure is very similar: now the sequence IV along with the
outcome of the DES-algorithm applied to the first ciphertext block are XORed,
[email protected]
3.4 Modes of Operation of the DES Algorithm 89
Fig. 3.7 Application of the DES algorithm in the cipher feedback mode
which results in the first block of the plaintext. In a similar way the other plain-
text blocks of the received message are obtained.
This method is used to encrypt long texts and the principle of its operation is pre-
sented in Fig. 3.7.
Unlike previous modes, in this case not whole blocks are encrypted, but their
j -bit fragments. In practice, j = 1 or j = 8. When j = 1, then bits are encrypted
one by one, while in case j = 8 single ASCII symbols are encrypted consecutively.
Such a mode of operation can be applied in order to transmit data generated by
means of a keyboard to a server. In this case each generated symbol has to be sent
immediately, without waiting for the block to be completed with eight symbols.
Now let us look more closely at the process of encrypting symbol by symbol. In the
beginning the shift register contains a random sequence IV of zeroes and ones which
is encrypted with a key K. First, the eight leftmost bits of the created cryptogram
are XORed with the first typed symbol M1 , which results in the first symbol C1
of the ciphertext. After sending the symbol C1 to the receiver, it is placed in the
register, and at the same time the eight leftmost bits are deleted. Next, the second
symbol M2 is typed and all the operations executed for generating the symbol C1 are
repeated in order to generate the second symbol C2 of the ciphertext. This process
is repeated as many times as there are symbols contained in the message undergoing
the encryption process. The decryption procedure is analogous, but it is performed
according to a slightly different scheme.
It is worth noticing that in this mode of operation the input of the algorithm is in
the form of a stream of plaintext or ciphertext symbols or bits and a 56-bit key K.
[email protected]
90 3 Foundations of Symmetric Cryptography
The DES algorithm cooperating with the shift register outputs a stream of symbols
or bits which is of the same length as the plaintext and which actually constitutes a
key used for encrypting or decrypting message. The XOR operation acts here as an
encryption/decryption function.
The IDEA algorithm was published in 1991, see [61]. It uses 128-bit keys. Many
experts were not satisfied with the DES algorithm, which, in their opinion, was not
secure enough due to the key size being too small. Moreover, US law regarded
all American cryptographic products, including electronic equipment for DES re-
alization, as military products, the export of which required appropriate authoriza-
tion. This situation has caused conflicts when transmitting data to the US with the
(US) National Security Agency. For these reasons Xuejia Lai and James L. Massey
from ETH Zurich designed the International Data Encryption Algorithm (IDEA for
short).
Like the DES cryptosystem, the IDEA algorithm generates 64-bit blocks of a
cryptogram from 64-bit blocks of a plaintext; however, it uses a key of size 128 bits.
IDEA, instead of the explicit use of permutations, applies only the three following
operations, which are easy to realize in both software and hardware:
• bitwise addition modulo 2, denoted by ⊕,
• addition modulo 216 (neglecting overflows), denoted by ,
• multiplication modulo 216 + 1 (neglecting overflows), denoted by
.
The above operations are executed on 16-bit blocks, therefore the algorithm can
be performed on 16-bit processors very efficiently.
The scheme of the algorithm is depicted in Fig. 3.8.
As the input of the algorithm we take four 16-bit subblocks of a block of the
plaintext: X1 , X2 , X3 and X4 . These four subblocks, which—as can be seen in the
figure—constitute the input for the first transformation round (there are eight such
rounds), are processed by 14 operations with six blocks of subkeys. After swapping
two inner subblocks obtained after the first round, we get the input block for the
second round. After the eighth round the final transformation is executed and then
inner blocks are not swapped any more.
According to the scheme, the algorithm uses 52 subblocks of the key: six of them
after each round and four subblocks in the final transformation. The principle of
generating 16-bit subkey blocks is quite simple. First, 128 bits of the key are divided
into eight subkeys: six of them are used to begin the first iteration round, leaving the
other two subkeys for the second iteration. Next, the key cycles by shifting 25 bits
to the left, then it is again divided into eight 16-bit subkeys, yielding four more
subkeys for the second round and four subkeys for the third one. This procedure is
repeated until all the required keys are obtained.
[email protected]
3.5 The IDEA Algorithm 91
Exactly the same algorithm is used for decryption; however, in this case other
blocks of subkeys are used (see Table 3.8). In order to compute subkeys for the
decryption process, multiplicative or additive inverses of encryption subkeys have
(1)
to be applied. For example, the multiplicative inverse of the encryption subkey Z1
(1)−1 (1)
is denoted by Z1 , while −Z1 stands for the additive inverse (we assume that
−1
0 = 0). Hence,
(1) (1)−1
Z1 · Z1 ≡ 1 (mod 216 + 1),
Z1(1) + −Z1(1) ≡ 0 (mod 216 ).
[email protected]
92 3 Foundations of Symmetric Cryptography
Table 3.8 Encryption and decryption subkeys for the IDEA algorithm (ft—final transformation)
Round Encryption key Decryption key
(1) (1) (1) (1) (1) (1) (9)−1 (9) (9) (9)−1 (8) (8)
1 Z1 Z2 Z3 Z4 Z5 Z6 Z1 − Z2 − Z3 Z4 Z5 Z6
(2) (2) (2) (2) (2) (2) (8)−1 (8) (8) (8)−1 (7) (7)
2 Z1 Z2 Z3 Z4 Z5 Z6 Z1 − Z3 − Z2 Z4 Z5 Z6
(3) (3) (3) (3) (3) (3) (7)−1 (7) (7) (7)−1 (6) (6)
3 Z1 Z2 Z3 Z4 Z5 Z6 Z1 − Z3 − Z2 Z4 Z5 Z6
4 Z1(4) Z2(4) Z3(4) Z4(4) Z5(4) Z6(4) Z1(6)−1 − Z3(6) − Z2(6) Z4(6)−1 Z5(5) Z6(5)
5 Z1(5) Z2(5) Z3(5) Z4(5) Z5(5) Z6(5) Z1(5)−1 − Z3(5) − Z2(5) Z4(5)−1 Z5(4) Z6(4)
6 Z1(6) Z2(6) Z3(6) Z4(6) Z5(6) Z6(6) Z1(4)−1 − Z3(4) − Z2(4) Z4(4)−1 Z5(3) Z6(3)
7 Z1(7) Z2(7) Z3(7) Z4(7) Z5(7) Z6(7) Z1(3)−1 − Z3(3) − Z2(3) Z3(3)−1 Z5(2) Z6(2)
8 Z1(8) Z2(8) Z3(8) Z4(8) Z5(8) Z6(8) Z1(2)−1 − Z2(2) − Z2(2) Z3(2)−1 Z5(1) Z6(1)
Hardware realization of the IDEA algorithm is almost as fast as that for the DES
cryptosystem (50–200 Mbit/s). On fast Pentium processors, IDEA can encrypt data
at the rate of 40 MB/s.
The IDEA algorithm can be used in the same modes as the DES algorithm. A de-
scription of the cryptographic power of IDEA can be found in Remark 7.107 in [68].
The most significant cryptanalytic result against IDEA, at the time of writing this
book (August, 2012), is due to Biham, Dunkelman, and Keller [20] who can break
IDEA reduced to six (out of eight) rounds. This is a theoretic attack, of complexity
far beyond any reasonable feasibility bounds.
3.6 RC Algorithms
Now we are going to describe a few algorithms developed mainly by Ronald Rivest.
These algorithms are briefly denoted by RC (Ron’s Cipher or Rivest’s cipher). The
first one, widely applied in practice, is the RC4 algorithm.
The RC4 algorithm [47], sometimes called ARC4 or ARCFOUR, is the first RC
algorithm applied commercially in systems used in practice. Nowadays, it is also
applied in security protocols in computer networks such as SSL or WEP. Although
RC4 is resistant to linear and differential cryptanalysis, due to its short key and other
imperfections it is currently not considered a safe cryptosystem. At present, RC4 is
not recommended for use in new systems.
[email protected]
3.6 RC Algorithms 93
As already mentioned, RC4 was designed by Ron Rivest of RSA Security in 1987
and it was initially a trade secret. At the end of 1994, a C implementation of the
cipher leaked to the Internet via the sci.crypt newsgroup. Since then the algorithm
is no longer a secret, though its name, RC4, is still a registered trademark. In view
of international law, unofficial cipher implementations are legal, but they carry the
other names mentioned before: ARC4 or ARCFOUR.
The algorithm applies a basic key containing from 40 to 128 bits. Let us denote it
by key and its length by d. The algorithm can be briefly described by the following
scheme.
1. First, we generate a pseudorandom bit sequence based on the basic key.
2. Then, we determine an auxiliary pseudorandom permutation S of 256 bits.
3. By means of permutation S we generate a bit sequence whose length corresponds
to the length of a plaintext. This sequence is called a keystream and we denote it
by K.
4. The keystream acts as an encryption key in the Vernam cipher, which was de-
scribed in the first chapter, i.e., the encryption process consists of performing the
XOR operation on the stream (key) and the plaintext.
5. According to the XOR encryption principle, the decryption process consists of
applying the XOR function once more to the cryptogram and the key (a recipient
of a potential message holds the same basic key, thus they are able to generate
the same pseudorandom sequence of bits—the encryption key).
In order to generate a keystream, the cipher makes use of a secret initial state,
which consists of two parameters:
1. a permutation S of all 256 possible states,
2. two 8-bit pointers, i and j .
The process to create the keystream works as follows. First, the table S is initial-
ized to the identity permutation. Then, S is processed in 256 iterations according to
the algorithm for pseudorandom generation presented below, but at the same time it
is interleaved with consecutive bytes of the key. In detail, the process is carried out
as follows:
We generate the 256-element identity permutation S:
Algorithm 3.1
for i from 0 to 255
S[i] := i
Algorithm 3.2
j: = 0
for i from 0 to 255
j := (j + S[i] + key[i mod d]) mod 256
swap(S[i],S[j])
[email protected]
94 3 Foundations of Symmetric Cryptography
As can be seen, we compute the sum modulo 256 of the pointer j and the i-th
element of the permutation S and the i-th bit of the basic key key (if i is greater
than d, then we take the (i mod d)-th bit of the key. The so-obtained pointer j spec-
ifies some value of the permutation S[j ]. This value is switched in S with the value
S[i]. We get a new permutation S, which depends on the basic key key.
Now, an intermediate stage of the RC4 algorithm takes place. The value of the
keystream K results from applying S on S[i] + S[j ] (mod 256), where i and j are
pointers modified during the algorithm execution.
Algorithm 3.3
i := 0
j := 0
while CreatingCipherStream:
i := (i + 1) mod 256
j := (j + S[i]) mod 256
swap(S[i],S[j])
out S[(S[i] + S[j]) mod 256]
As can be noticed, the pseudorandom generation algorithm repeatedly modifies
the permutation S by replacing its values. As long as it is needed, we generate
consecutive bytes of the key, which will later be used for encryption of subsequent
plaintext bytes. At each step the algorithm increments the variable i by 1, takes the
index j and the i-th element of the permutation S, adds these numbers modulo 256,
and finally applies S to the so-obtained value. The result is switched in S with the
value S[i]. As output we take the element of S with the index (S[i] + S[j ]) mod 256.
This operation is continued as long as bytes of the stream are needed to encrypt
successive bytes of the plaintext. Let us notice that every value of the permutation S
is replaced at least once every 256 iterations.
The general scheme of RC4 consisting of all the described operations is illus-
trated in Fig. 3.9.
[email protected]
3.6 RC Algorithms 95
• The algorithm should be easy to implement with regard to both software and
hardware.
• The algorithm should be fast (therefore RC5 applies only operations on blocks
which correspond to words in terms of hardware, e.g., when run on 32-bit pro-
cessors, the algorithm executes operations on 32-bit blocks).
• The algorithm should be flexible as concerns encryption parameters used (sizes
of a block and a key, as well as the number of rounds should be modifiable).
The user should be able to set cipher parameters in order to have control over the
relation between the algorithm’s efficiency and its security level.
• The algorithm should be as simple as possible, so that the cryptographic strength
of RC5 can be rapidly determined.
• The algorithm should have low memory requirements, so that it may easily be
implemented, e.g., on smart cards.
• The algorithm should provide a suitably high security level.
The algorithm uses three operations: addition modulo n, addition modulo 232 ,
and permutations (cyclic shifts, to be precise). It is also possible to apply plaintext
blocks of variable length, but in the example described below we make use of 64-bit
data blocks. The number of algorithm cycles can also vary; we denote it by r. As in
the previous case, also here the algorithm uses a basic key, on which 32-bit auxiliary
keys used for plaintext processing are based. There are 2r + 2 such keys; we denote
them by S(0), S(1), S(2), . . . , S(2r + 1).
In the encryption process the plaintext block is first divided into 32-bit words:
A and B. Then, by means of keys S(i)(i = 1, . . . , 2r + 1), the following operations
are performed:
Algorithm 3.4
A = A + S(0)
B = B + S(1)
For i = 1 to r
A = ((A XOR B) <<< B) + S(2i)
B = ((B XOR A) <<< A) + S(2i+1)
Algorithm 3.5
For i = r downto 1
B = ((B -- S(2i+1)) >>> A) XOR A
A = ((A -- S(2i)) >>> B) XOR B
B = B -- S(1)
A = A -- S(0)
[email protected]
96 3 Foundations of Symmetric Cryptography
Once again, the symbol >>> denotes a bit-shift and all subtraction operations are
performed modulo 232 .
Creating the vector S(i) of keys is just a bit more complicated. First, bytes of
the key are copied to a vector L with 32-bit words (if needed, any unfilled byte
positions of the last word are zeroed). Next, the vector S, which applies a linear
generator modulo 232 , is initialized.
Algorithm 3.6
S(0) = P
For i = 1 to 2(r+1)
S(i) = (S(i-1) + Q)
Algorithm 3.7
i = j = 0
A = B = 0
For i = 1 to 3n (n is the greater of two values 2(r+1) and c)
A = S(i) = (S(i) + A + B) <<< 3
B = L(j) = (L(j) + A + B) <<< (A+B)
i = (i + 1) mod 2(r+1)
j = (j + 1) mod c
In 1997 RSA Security Inc. proposed a challenge to break several algorithms, in-
cluding RC5. The company offered a $10000 prize for breaking any of them. In the
[email protected]
3.6 RC Algorithms 97
same year, an organization called distributed.net was founded, aimed at the brute-
force breaking of the RC5-32/12/7 cipher (with a 56-bit key). It was one of the first
distributed processing projects ever. The idea of distributed.net was to make use of
thousands of PCs in order to create a system of enormous computational power.
Users (from all over the world) of the system install a small application, which ana-
lyzes downloaded data blocks whenever a computer is idle. By now, cryptograms en-
crypted with 56- and 64-bit keys have been already broken, see Tables 3.9 and 3.10.
Currently the project aims at breaking RC5 with a 72-bit key [36].
On a particular day in mid-February 2012, data about the searched keyspace
were as follows. On that day 2444 users took part in the project (in 2009 there were
daily 3500 users on average). 4060996 key blocks were searched, which amounts
to 0.002176 % of the space of blocks at the rate of 83 blocks per second (in June
2005 the rate reached only 32 blocks). This gave altogether 100500490969677824
keys (1163200126964 keys per second). Up to that day, there were 90811 users
participating in the projects. They also try to break the algorithm by working in
groups.
Tables describing attacks on RC-72 are worth some attention. They demonstrate
the progress of brute-force breaking that was achieved in just a few years of the
project (June 2005–December 2012).
Some statistics of the project, illustrating the computational power of cipher
breaking and obtained results, are presented in Table 3.11.
[email protected]
98 3 Foundations of Symmetric Cryptography
[email protected]
3.6 RC Algorithms 99
The RC6 algorithm [86] was designed in RSA Laboratories and submitted to the
AES competition in 1998. It was created by Ronald Rivest, Matthew Robshaw, Ray
Sidney and Yiqun Yin. The algorithm is based on the RC5 cipher presented above.
The authors introduced some modifications to meet the requirements of the AES
competition. Block and key sizes changed and due to some other improvements
security and efficiency of the algorithm increased.
According to the AES requirements, the algorithm supports 128-, 192- and 258-
bit encryption keys, while the size of a processed data block equals 128 bits. In the
algorithm a plaintext block is divided into four 32-bit fragments in order to apply
the 32-bit architecture of most currently used processors. The RC6 cipher, similarly
to RC5, makes use of only those operations that can be efficiently implemented on
modern processors. In the encryption process integer multiplication is applied for
interleaving bits.
The general scheme of one round of the RC6 algorithm is depicted in Fig. 3.10.
[email protected]
100 3 Foundations of Symmetric Cryptography
As in the case of the RC5 algorithm, RC6 can operate on blocks and keys of
different sizes, therefore its various versions can be denoted by means of parameters
by RC6-w/r/b, where w is the bit size of a plaintext block, r corresponds to the
number of rounds, and b stands for the key size counted in bytes. In the version
that was submitted to the AES competition these parameters are as follows: w = 32
(32 bits × 4 words = 128 bits), r = 20, b = 16, 24, 32 (b × 8 = 128, 192, 256 bits).
RC6-w/r/b operates on four w-bit words applying the following six simple op-
erations:
• a b integer addition modulo 2w ,
• a − b integer subtraction modulo 2w (used in decryption procedure),
• a ⊕ b bitwise XOR of w-bit words,
• a ⊗ b integer multiplication modulo 2w (used in F function, where F (x) = x ⊗
(2x 1)),
• a <<< b rotation (cyclic shift) to the left of a w-bit word by the value specified
by the log2 w (lg w) least significant bits of the word b,
• a >>> b rotation (cyclic shift) to the right of a w-bit word by the value specified
by the log2 w least significant bits of the word b (used in decryption procedure).
[email protected]
3.7 AES—The Successor to DES 101
[email protected]
102 3 Foundations of Symmetric Cryptography
[email protected]
3.7 AES—The Successor to DES 103
When a7 = 0, then
x • a(x) = a6 x 7 + a5 x 6 + a4 x 5 + a3 x 4 + a2 x 3 + a1 x 2 + a0 x,
otherwise
x • a(x) = a6 x 7 + a5 x 6 + a4 x 5 + (1 ⊕ a3 )x 4 + (1 ⊕ a2 )x 3 + a1 x 2 + (1 ⊕ a0 )x + 1.
Hence, multiplication of a(x) by x corresponds at the byte level to multiplication
by {00000010}, while in the hexadecimal representation to multiplication by {02},
and in fact it consists of shifting bits of the byte
a = {a7 a6 a5 a4 a3 a2 a1 a0 }
by one to the left if a7 = 0, and if a7 = 1, then to the so-shifted bits we have to add
modulo 2 the byte {00011011}. Therefore,
{00000010} • {a7 a6 a5 a4 a3 a2 a1 a0 }
{a6 a5 a4 a3 a2 a1 a0 0} if a7 = 0,
=
{a6 a5 a4 a3 a2 a1 a0 0} ⊕ {00011011} if a7 = 1.
An efficient hardware implementation of the above is important for of multiplica-
tion in the field GF(256)—it is then possible to perform multiplication by x several
times. For instance,
{10000011} • {00100110}
= {10000011} • {00000010} ⊕ {00000100} ⊕ {00100000} = {11101100},
since
[email protected]
104 3 Foundations of Symmetric Cryptography
Every byte may be represented by some number taken from the interval [0, 255].
Similarly, it is possible to represent each element from the field GF(256) as a num-
ber from the same interval. To this end, the following isomorphism should be ap-
plied:
σ : W → {0, 1, . . . , 255}.
W stands here for the set of polynomials of degree at most 7 over GF(2), i.e., for
the underlying set of the field GF(256):
W = wi (x) = vi,7 x 7 + vi,6 x 6 + · · · + vi,2 x 2 + vi,1 x + vi,0 , i = 0, 1, . . . , 255
The function σ , given by
σ wi (x) = wi (2),
is an isomorphism, hence there exists the inverse function σ −1 which can be rep-
resented by a simple algorithm that transforms a polynomial wi (x) into a number
from the interval [0, 255].
All operations over GF(256) required during the AES encryption and decryption
procedures can be efficiently performed in any programming language.
During realization of the AES procedures it may be necessary to compute the
multiplicative inverse of {00000000}, therefore it was additionally assumed that this
element is self-inverse, which is in contradiction to the general rules of algebra, yet
it makes the algorithm work. The fastest way to compute the multiplicative inverses
in GF(256) is to determine and store all of them as shown below. Notice that in
fact, it is a one-dimensional array which takes 256 bytes, even though it looks like
two-dimensional.
[email protected]
3.7 AES—The Successor to DES 105
x 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
inv(x) 2c 45 92 6c f3 39 66 42 f2 35 20 6f 77 bb 59 19
x 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
inv(x) 1d fe 37 67 2d 31 f5 69 a7 64 ab 13 54 25 e9 09
x 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
inv(x) ed 5c 05 ca 4c 24 87 bf 18 3e 22 f0 51 ec 61 17
x 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
inv(x) 16 5e af d3 49 a6 36 43 f4 47 91 df 33 93 21 3b
x 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f
inv(x) 79 b7 97 85 10 b5 ba 3c b6 70 d0 06 a1 fa 81 82
x 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f
inv(x) 83 7e 7f 80 96 73 be 56 9b 9e 95 d9 f7 02 b9 a4
x 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f
inv(x) de 6a 32 6d d8 8a 84 72 2a 14 9f 88 f9 dc 89 9a
x a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af
inv(x) fb 7c 2e c3 8f b8 65 48 26 c8 12 4a ce e7 d2 62
x b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf
inv(x) 0c e0 1f ef 11 75 78 71 a5 8e 76 3d bd bc 86 57
x c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf
inv(x) 0b 28 2f a3 da d4 e4 0f a9 27 53 04 1b fc ac e6
x d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df
inv(x) 7a 07 ae 63 c5 db e2 ea 94 8b c4 d5 9d f8 90 6b
x e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef
inv(x) b1 0d d6 eb c6 0e cf ad 08 4e d7 e3 5d 50 1e b3
x f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
inv(x) 5b 23 38 34 68 46 03 8c dd 9c 7d a0 cd 1a 41 1c
a(x) = a3 x 3 + a2 x 2 + a1 x + a0 ,
b(x) = b3 x 3 + b2 x 2 + b1 x + b0 , ai , bi ∈ GF(256),
which are considered as 4-byte words
a = [a3 , a2 , a1 , a0 ], b = [b3 , b2 , b1 , b0 ].
They are added in the following way:
[email protected]
106 3 Foundations of Symmetric Cryptography
c0 = a0 • b0 ,
c1 = a1 • b0 ⊕ a0 • b1 ,
c2 = a2 • b0 ⊕ a1 • b1 ⊕ a0 • b2 ,
c3 = a3 • b0 ⊕ a2 • b1 ⊕ a1 • b2 ⊕ a 0 • b3 ,
c4 = a 3 • b 1 ⊕ a 2 • b 2 ⊕ a 1 • b 3 ,
c5 = a3 • b2 ⊕ a2 • b3 ,
c6 = a3 • b3 .
The polynomial c(x) does not represent a 4-byte word, thus in the second phase
of multiplication it is reduced modulo x 4 + 1, i.e., we apply the following substitu-
tion: x 4 = 1, x 5 = x, x 6 = x 2 . Therefore,
a(x) ⊗ b(x) = d(x) = d3 x 3 + d2 x 2 + d1 x + d0 ,
with
[email protected]
3.7 AES—The Successor to DES 107
since
⎡ ⎤⎡ ⎤
{02} {03} {01} {01} {0e}
⎢ {01} {02} {03} {01} ⎥ ⎢ ⎥
a(x) ⊗ a(x) = ⎢
−1 ⎥ ⎢ {09} ⎥ = {01}.
⎣ {01} {01} {02} {03} ⎦ ⎣ {0d} ⎦
{03} {01} {01} {02} {0b}
Another polynomial over GF(256), applied in AES, is the following: a(x) =
{01}x 3 + {00}x 2 + {00}x + {00} = x 3 . Multiplying an arbitrary polynomial b(x) =
b3 x 3 + b2 x 2 + b1 x + b0 by a(x) can be described by the matrix equation
⎡ ⎤⎡ ⎤ ⎡ ⎤
{00} {01} {00} {00} b0 b1
⎢ {00} {00} {01} {00} ⎥ ⎢ b1 ⎥ ⎢ b2 ⎥
a(x) ⊗ b(x) = ⎢ ⎥⎢ ⎥ ⎢ ⎥
⎣ {00} {00} {00} {01} ⎦ ⎣ b2 ⎦ = ⎣ b3 ⎦ ,
{01} {00} {00} {00} b3 b0
which corresponds to a cyclic byte shift of an input word by one to the left.
Beside the above-mentioned operations, the AES algorithm also uses the follow-
ing affine transformation over GF(2):
⎡ ⎤
b0
⎢ ⎥ ⎡ ⎤⎡ ⎤ ⎡ ⎤
⎢ b1 ⎥ 1 0 0 0 1 1 1 1 b0 1
⎢ ⎥ ⎢
⎢ b ⎥ ⎢ 1 1 0 0 0 1 1 1 ⎥ ⎢ b1 ⎥ ⎢ 1 ⎥
⎥⎢ ⎥ ⎢ ⎥
⎢ 2⎥ ⎢
⎢ ⎥ ⎢1 1 1 0 0 0 1 1⎥ ⎢ ⎥ ⎢ ⎥
⎥ ⎢ b2 ⎥ ⎢ 0 ⎥
⎢ b3 ⎥ ⎢
⎢ ⎥ ⎢1 1 1 1 0 0 0 1⎥⎢ ⎥ ⎥ ⎢ ⎥
⎢ b3 ⎥ + ⎢ 0 ⎥
⎢ ⎥=⎢
⎢ b4 ⎥ ⎢ 1 1 1 1 1 0 0 0 ⎥ ⎢ b4 ⎥ ⎥ ⎢ ⎢ ⎥
⎥ ⎢0⎥
⎢ ⎥ ⎢
⎢ b ⎥ ⎢ 0 1 1 1 1 1 0 0 ⎥ ⎢ b5 ⎥ ⎢ ⎥ ⎢ ⎥
⎢1⎥
⎥
⎢ 5⎥ ⎣ ⎦ ⎣ ⎦ ⎣
⎢ ⎥ 0 0 1 1 1 1 1 0 b6 1⎦
⎢ b6 ⎥
⎣ ⎦ 0 0 0 1 1 1 1 1 b7 0
b7
[email protected]
108 3 Foundations of Symmetric Cryptography
Of course, there exists the inverse function to the above affine transformation
given by
⎡ ⎤
b0
⎢ ⎥ ⎡ ⎤ ⎛⎡ ⎤ ⎡ ⎤⎞
⎢ b1 ⎥ 0 0 1 0 0 1 0 1 b0 1
⎢ ⎥ ⎢
⎢ b ⎥ ⎢ 1 0 0 1 0 0 1 0 ⎥ ⎥⎜
⎜⎢ b1 ⎥ ⎢ 1 ⎥⎟
⎢ ⎥ ⎢ ⎥⎟
⎢ 2⎥ ⎢
⎢ ⎥ ⎢0 1 0 0 1 0 0 1⎥ ⎜⎢ ⎥ ⎢ ⎥⎟
⎥ ⎜⎢ b2 ⎥ ⎢ 0 ⎥⎟
⎢ b3 ⎥ ⎢
⎢ ⎥ ⎢1 0 1 0 0 1 0 0⎥ ⎜⎢ ⎥ ⎢ ⎥⎟
⎥ ⎜⎢ b3 ⎥ + ⎢ 0 ⎥⎟
⎢ ⎥=⎢
⎢ b4 ⎥ ⎢ 0 1 0 1 0 0 1 0 ⎥ ⎜ ⎥ ⎢ ⎥ ⎢ ⎥⎟
⎜⎢ b4 ⎥ ⎢ 0 ⎥⎟
⎢ ⎥ ⎢
⎢ b ⎥ ⎢ 0 0 1 0 1 0 0 1 ⎥ ⎜⎢ ⎥ ⎜ ⎥ ⎢ ⎥⎟
⎢ b5 ⎥ ⎢ 1 ⎥⎟
⎢ 5⎥ ⎣ ⎦ ⎝ ⎣
⎢ ⎥ 1 0 0 1 0 1 0 0 b6 ⎦ ⎣ 1 ⎦⎠
⎢ b6 ⎥
⎣ ⎦ 0 1 0 0 1 0 1 0 b7 0
b7
⎡ ⎤⎡ ⎤ ⎡ ⎤
0 0 1 0 0 1 0 1 b0 + 1 b2 + b5 + b7 + 1
⎢ 1 0 0 1 0 0 1 0 ⎥ ⎢ b1 + 1 ⎥ ⎢ b0 + b 3 + b 6 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 1 0 0 1 0 0 1 ⎥ ⎢ b2 ⎥ ⎢ b1 + b4 + b 7 + 1 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ 1 0 1 0 0 1 0 0 ⎥ ⎢ b3 ⎥ ⎢ b0 + b 2 + b 5 ⎥
=⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎥⎢ ⎥=⎢ ⎥
⎢ 0 1 0 1 0 0 1 0 ⎥ ⎢ b4 ⎥ ⎢ b1 + b3 + b6 ⎥
⎢ 0 0 1 0 1 0 0 1 ⎥ ⎢ b5 + 1 ⎥ ⎢ b2 + b4 + b7 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎣ 1 0 0 1 0 1 0 0 ⎦ ⎣ b6 + 1 ⎦ ⎣ b0 + b3 + b5 ⎦
0 1 0 0 1 0 1 0 b7 b1 + b3 + b6
hence
b0 = b2 + b5 + b7 + 1,
b1 = b0 + b3 + b6 ,
b2 = b1 + b4 + b7 + 1,
b3 = b0 + b2 + b5 ,
b4 = b1 + b3 + b6 ,
b5 = b2 + b4 + b7 ,
b6 = b0 + b3 + b5 ,
b7 = b1 + b3 + b6 .
The encryption standard AES [46] is a block cipher which is a variant of the larger
collection of ciphers called Rijndael. The AES standard supports a symmetric-key
cipher transforming a 128-bit block of a plaintext into a ciphertext block of the same
size. In the encryption process the key length varies between 128, 192 and 256 bits
(16, 24 and 32 bytes). Rijndael can use also other key lengths and plaintext block
sizes but AES does not allow such cases.
[email protected]
3.7 AES—The Successor to DES 109
The input and output of the AES algorithm are 128-bit sequences, called blocks
of size 128 (the size of a block is the number of bits occurring in this block). A cipher
key for the algorithm is a 128-, 192- or 256-bit sequence. Bits in these sequences
are enumerated starting with 0 up to the number smaller by one than the sequence
length. Bit numbers in a sequence are called indices of the bits.
The basic unit of encryption in the process of the AES algorithm is a byte, a se-
quence of eight bits. Input, output and key sequences are divided into groups con-
sisting of eight consecutive bits, forming tables of bytes. Therefore, if each of an
input, an output and a cipher key is considered as a table of bytes, denoted by a,
then it is possible to access elements of this table by their indices. So an element
from a table a is given by some an (or a[n]), where 0 ≤ n ≤ 15 for the input and
output blocks and 0 ≤ n ≤ 15, 0 ≤ n ≤ 23 and 0 ≤ n ≤ 31 for the block of the cipher
key of size 128, 192 and 256, respectively.
The value of each byte, denoted by {b7 b6 b5 b4 b3 b2 b1 b0 }, is determined by
bits forming a given byte. The following notation is considered as the polynomial
representation of elements from the Galois field GF(256)
8
b7 x 7 + b6 x 6 + b5 x 5 + b4 x 4 + b3 x 3 + b2 x 2 + b1 x + b 0 = b8−k x 8−k .
k=1
For example, the byte with the value {10000011} corresponds to the polynomial
x 7 + x + 1 over GF(2).
In practice, to denote the value of a byte it is easier to use the hexadecimal rep-
resentation, where eight bits of one byte are replaced by two hexadecimal digits,
according to the following table:
[email protected]
110 3 Foundations of Symmetric Cryptography
where indices of bytes are related to the order of bit occurrences according to the
table:
This method of creating a table of bytes is also applicable to 192- and 256-bit
key sequences.
Internal operations executed by the AES algorithm during encryption and decryp-
tion processes are performed on a two-dimensional table of bytes, called the state.
The state is a table consisting of 4 rows, each with Nb bytes, where Nb is the length
of a plaintext block divided by 32. Elements of the state are denoted by sr,c or s[r, c],
where r stands for a row number of the state, c is a column number and
0 ≤ r ≤ 3, 0 ≤ c ≤ Nb − 1.
At the beginning of the encryption/decryption procedure, the input table in is
copied to the state table according to the equation
s[r, c] = in[r + 4c], 0 ≤ r ≤ 3, 0 ≤ c ≤ Nb − 1,
and after that the state table is copied to the output table out, according to the equa-
tion
out[r + 4c] = s[r, c], 0 ≤ r ≤ 3, 0 ≤ c ≤ Nb − 1.
Four bytes of each column from the state table form a 32-bit word and a row num-
ber r is an index of four bytes of each word. Therefore, we can look at the state as a
one-dimensional table w of 32-bit words, consisting of 4 elements: w0 , w1 , w2 , w3
(w[0], w[1], w[2], w[3]), where
w0 = s0,0 s1,0 s2,0 s3,0 ,
w1 = s0,1 s1,1 s2,1 s3,1 ,
w2 = s0,2 s1,2 s2,2 s3,2 ,
w3 = s0,3 s1,3 s2,3 s3,3 .
According to the standard, the AES algorithm transforms input and output blocks
and the state table of length 128, which means that Nb = 4. A cipher key K can be
[email protected]
3.7 AES—The Successor to DES 111
Under the standard, these are the only possible combinations of the parameters.
During encryption and decryption procedures in the AES algorithm, some num-
ber of rounds is performed and each of them consists of four different transforma-
tions executed on bytes from the state table.
The formal parameters of this procedure are: the table key, which represents the
encryption key, the table w, and the parameter Nk. The function SubWord() takes
a 4-byte word as an input, applies to each byte the substitution S-box, i.e., it com-
putes the multiplicative inverse of a given byte in GF(256), and finally executes the
afore mentioned affine transformation on the so-computed inverse. In the encryption
algorithm, the procedure SubBytes(), operating on bytes instead of words, is the
counterpart of the SubWord() function.
[email protected]
112 3 Foundations of Symmetric Cryptography
On the other hand, the function RotWord() permutes an input word [a0 , a1 ,
a2 , a3 ] cyclically and outputs [a1 , a2 , a3 , a0 ]. The so-called round constant Rcon[i]
is a table containing words
Rcon[i] = {02}i−1 , {00}, {00}, {00} , i = 1, 2, . . .
whose first byte is given by the i-th power of the element {02} in the field GF(256).
Therefore,
i 1 2 3 4 5 6 7 8 9 10
{02} i−1 {01} {02} {04} {08} {10} {20} { 40} {80} {1b} {36}
It follows from the algorithm that the first Nk words of the extended key w[0],
w[1], . . . , w[Nk − 1] constitute the encryption key key. Every subsequent word
w[i] is equal to the sum modulo two of the previous word (w[i − 1]) and the
word occurring Nk positions before (w[i − Nk]). In case of words whose indices are
multiples of Nk, first, the word w[i-1] is transformed by functions RotWord()
[email protected]
3.7 AES—The Successor to DES 113
and SubWord(), then the round constant Rcon[i/Nk] is added modulo two to
the result, and, finally, the word w[i-Nk] is added modulo two to the outcome.
It should be noticed that if the length of the encryption key equals 256 bits, i.e.,
Nk = 8, and i − 4 is a multiple of Nk, then before determining w[i] the function
SubWord() must be applied to the word w[i-1]. It is also worth mentioning that
the XOR operation corresponds to addition in the field GF(256).
The formal parameters of the program are two 16-byte tables: in and out, as
well as a table w storing 4*(Nr+1) 4-byte words, which are the auxiliary keys for
each round (Table 3.12). The state, a 16-byte table on which some cryptographic
transformations are performed, is an important local variable of the program.
At the beginning, an input block in is copied to the state in the way presented
before. Then the procedure AddRoundKey() is applied. Its operation consists of
adding modulo two a round key to columns of the state, which is described math-
ematically as follows:
s0,c , s1,c , s2,c , s3,c = [s0,c , s1,c , s2,c , s3,c ] ⊕ wround∗Nb + c,
0 ≤ c < Nb, 0 ≤ round < Nr.
[email protected]
114 3 Foundations of Symmetric Cryptography
Next, the transformation ShiftRows() shifts the last three rows of the state
cyclically by one, two and three to the left, i.e., it modifies the state according to
the equation
sr,c = sr,(c+r) (mod 4) , 0 ≤ r ≤ 3, 0 ≤ c ≤ 3.
Finally, the procedure MixColumns() works on columns of the state, re-
garding them as polynomials of degree at most 3 over GF(256) which are to be
multiplied modulo x 4 + 1 by the polynomial {03}x 3 + {01}x 2 + {01}x + {02}.
This operation, denoted by the symbol ⊗, has already been described.
Hence, the procedure MixColumns() performs the following operations:
s0,c = {02} • s0,c ⊕ {03} • s1,c ⊕ s2,c ⊕ s3,c ,
s1,c = s0,c ⊕ {02} • s1,c ⊕ {03} • s2,c ⊕ s3,c ,
s2,c = s0,c ⊕ s1,c ⊕ {02} • s2,c ⊕ {03} • s3,c ,
s3,c = {03} • s0,c ⊕ s1,c ⊕ s2,c ⊕ {02} • s3,c .
where 0 ≤ c ≤ 3.
All rounds are identical but the last one, in which the function MixColumns()
is not executed. The encryption algorithm finishes with copying the state to the
table out.
[email protected]
3.7 AES—The Successor to DES 115
[email protected]
116 3 Foundations of Symmetric Cryptography
In this version another set of round keys is used, thus applying this algorithm for
decryption requires to be modified the procedure KeyExpansion by appending
two loop instructions at the end of the code:
[email protected]
3.8 Generalizations and Refinements of DES, IDEA and AES 117
[email protected]
118 3 Foundations of Symmetric Cryptography
key. In the case of the IDEA algorithm fifty-two 16-bit subkeys, used as an 832-bit
secret key, will protect 64 bits of the message. On the other hand, algorithms AES-
128, AES-192 and AES-256 apply eleven, thirteen, and fifteen 128-bit subkeys,
respectively, thus using these sets of subkeys as secret keys we are able to encrypt a
128-bit data block using keys of size 1408, 1664, and 1920 bits, respectively.
[email protected]
Chapter 4
Foundations of Asymmetric Cryptography
This chapter presents asymmetric key cryptography, also known as public-key cryp-
tography. It introduces the first asymmetric algorithm, invented by Diffie and Hell-
man, as well as the ElGamal algorithm. Moreover, we describe in detail a very
well-known example of an asymmetric cryptosystem called RSA.
[email protected]
120 4 Foundations of Asymmetric Cryptography
key computations are substantially more time consuming than those in symmetric
cryptography.
This algorithm was published in 1976 by Whitfield Diffie and Martin Hellman [31].
Its cryptographic power is based on the problem of computing the discrete logarithm
in Zn (discussed in Chap. 2).1 The original version of the algorithm can be used only
for distribution or exchange of (usually symmetric) session keys and cannot be used
for encryption. However, we present it here due to its historical value and also as
an introduction to the ElGamal algorithm. The latter is a well-known cipher. Diffie-
Hellman key exchange is also widely used in Web security with SSL (Socket Layer
Security) and TLS (Transport Layer Security) protocols, and in the IPSec protocol
key exchange framework.
Let us suppose that two entities (denoted by A and B) want to communicate with
each other by means of some symmetric algorithm that requires a secret key k which
is a natural number.
[email protected]
4.3 The ElGamal Algorithm 121
except A and B respectively knows the integers x and y necessary for determin-
ing k. It would be possible to compute the value of k if one could extract x from the
equation X = g x mod n or y from Y = g y mod n. However, as we already pointed in
Chap. 2, this is infeasible now for appropriately chosen sufficiently large integers.
There is no proof to date that either the Diffie-Hellman Problem (DHP) or the Dis-
crete Logarithm Problem (DLP) is a hard problem. The DHP is conjectured (but not
proven) to be equivalent to the DLP.2
The Diffie-Hellman algorithm was patented in the US but its patent expired in
1997. Therefore, the algorithm can be used without any restrictions.
The time complexity of this algorithm depends on modular exponentiation and
equals O(l 3 ), where l is the bit length of the parameters used.
Integers g and p may be commonly known and together with the number y they
form the public key. The private key is given by x (of course, we still have to know
the numbers g and p).
Let us suppose that we want to encrypt a message M (M < p) with the public
key (g, p, y).
[email protected]
122 4 Foundations of Asymmetric Cryptography
1. Compute the inverse of a x mod p ((a x )−1 mod p); let us notice that due to the
primality of p, such an inverse always exists.
2. Compute b · (a x )−1 mod p.
3. This value is equal to the plaintext M (M = b · (a x )−1 mod p).
−1 −1
b · ax mod p = y k · M · a x mod p
k x −1 −1
= gx · M · gk mod p = g xk · M · g kx mod p.
Example 4.1 Let p = 37, g = 7 and x = 6. Then y = g x mod p = 4. The public key
is thus given by the triple (g, p, y) = (7, 37, 4), and the private key by (g, p, x) =
(7, 37, 6). Let us take k = 7. (It is prime, therefore GCD(k, p − 1) = 1.) Let M = 26
be a plaintext. We compute a = g k mod p = 28 and b = y k · M mod p = 13. The
ciphertext is given by the pair (28, 13). In order to decrypt the ciphertext, we have
to compute (a x )−1 mod p = 2. Now, we compute b · (a x )−1 mod p = 26. Finally,
b · (a x )−1 mod p = M.
The cryptographic power of the algorithm is based, like D-H above, upon the Dis-
crete Logarithm Problem. The problem of breaking the ElGamal encryption scheme,
i.e., recovering M given g, p, y, a, and b, is equivalent to solving the Diffie-Hellman
problem. The security of the ElGamal scheme is said to be based on the Discrete
Logarithm Problem, however, their equivalence has not been proven. It is not known
if there exists an efficient algorithm able to recover the message M, given its cipher-
text and the public key.
The ElGamal algorithm has never been patented, since from its beginning it was
covered by the patent protection of the Diffie-Hellman algorithm. Since the patent
for the latter expired in 1997, the ElGamal algorithm was for some time the only
asymmetric cryptosystem not protected by any patent.
Similarly to the case of the Diffie-Hellman algorithm, the time complexity of
the ElGamal encryption algorithm requires two modular exponentiation and it is
O(l 3 ), where l is the bit length of the parameters used. Decryption requires only
one exponentiation. The ElGamal encryption algorithm is probabilistic, meaning
that each plaintext can be encrypted to many possible ciphertexts. One consequence
of this is that an ElGamal ciphertext is twice as long in bit length as its plaintext.
[email protected]
4.4 The RSA Algorithm 123
Below, we present methods to generate keys for encrypting and decrypting mes-
sages.
The cryptographic power of the RSA cryptosystem is based upon the factoriza-
tion problem. If someone could factorize the number n, being a part of the corre-
sponding public key, then they would be able to obtain d, being a part of a private
key. Thus the integers p and q need to be carefully chosen. One of the choice criteria
is to take numbers that are not too close to each other. (Otherwise, it would be easy
to find them by looking for primes close to the square root of n.) Also, when choos-
ing the integer e, one can follow some recommendations that increase the speed of
m
the algorithm. In general, it is advised to take a prime in the form 22 + 1. (In bi-
nary representation such numbers have only two bits equal to 1, while the other bits
are equal to 0, therefore the arithmetic operations performed on such integers are
optimally fast.)
[email protected]
124 4 Foundations of Asymmetric Cryptography
Let a pair (e, n) be a public key and a pair (d, n) a private one.
Let us suppose that we want to encrypt a message given by an integer M (M < n).
The corresponding ciphertext is equal to S = M e mod n. In order to decrypt it, we
compute S d mod n.
The following transformations prove the correctness of the algorithm, i.e., that
M = S d mod n.
Let us recall that e · d = 1 mod(p − 1) · (q − 1), which means that for some integer
k the following equation holds:
e · d = 1 + k · (p − 1) · (q − 1).
Let us also recall that if p and q are primes, then
Φ(p · q) = (p − 1) · (q − 1),
where Φ(p · q) is the value of the Euler function applied to the product p · q.
We obtain
e · d = 1 + k · (p − 1) · (q − 1) = 1 + k · Φ(p · q).
Now, let us recall Euler’s theorem discussed in Chap. 2. It states that for any two
co prime natural numbers n and a, the following equation is valid:
a Φ(n) = 1 mod n.
If n = p · q, then we get:
a Φ(p·q) = 1 mod p · q,
hence
a (p−1)·(q−1) = 1 mod p · q.
Now, taking into account all these preparations and after a suitable substitution
we get:
d
S d mod n = M e mod n = M e·d mod n
= M 1+k·Φ(p·q) mod n = M · M k·Φ(p·q) mod n
k
= M · M k·Φ(n) mod n = M · M Φ(n) mod n
= M · 1k mod n = M mod n = M.
These equations hold when GCD(M, n) = 1 (the assumption in Euler’s Theo-
rem). Otherwise, it would be easy to find the common divisor of M and n, by the
Euclidean Algorithm. This would have to be either p or q. The number n would get
factorized and the algorithm with the given key would get broken. However, it has
been proven that also for M and n with a common divisor, the equality guarantee-
ing the algorithms correctness holds. Also, it has been proven that the probability of
generating a message not coprime with n is close to 0.
Let us notice that we have assumed M < n. In the case when a plaintext is longer
than n, we can break it into blocks and encrypt it blockwise.
[email protected]
4.4 The RSA Algorithm 125
Example 4.2 Let us consider the following example of execution of the RSA algo-
rithm.
Let p = 37 and q = 71 (both integers are prime).
Then, we get their product n = p · q = 2627. According to the afore mentioned
m
recommendations, we take e in the form 22 + 1 for m = 2, hence e = 17.
The integer d satisfying the equation d · e = 1 mod(p − 1) · (q − 1), so the inverse
of e modulo (p − 1) · (q − 1), is equal to 593.
Therefore, a public key is given by the pair (e, n) = (17, 2627), and a private key
by (d, n) = (593, 2627).
Let us take a plaintext M = 258566522. Of course, this number is greater than
2627.
Thus, we divide it into 3-digit blocks M = m1 m2 m3 , where:
m1 = 258,
m2 = 566,
m3 = 522.
Following the algorithm, we raise these blocks to the power e modulo n. We get
s1 = me1 mod n = 258e mod n = 813,
s2 = me2 mod n = 566e mod n = 1840,
s3 = me3 mod n = 522e mod n = 1619.
The ciphertext S is thus the following: 813–1840–1619 (it is necessary to sepa-
rate encryption values for each block in order to prevent ambiguity, e.g., the cryp-
togram of the plaintext 121222444 encrypted as stated above: 1691592925 could
be read as 1691–592–925 or 169–1592–925. Of course, the decrypted messages are
then different, they are equal to 121222444 and 228889444, respectively).
If we decrypt consecutive blocks of the ciphertext with the key (d, n), then we
obtain consecutive blocks of the plaintext M:
s1d mod n = 813d mod n = 258 = m1 ,
s2d mod n = 1840d mod n = 566 = m2 ,
s3d mod n = 1619d mod n = 522 = m3 .
To sum up, the RSA algorithm is the most popular and widely known asymmetric
cryptosystem. Its cryptographic power has been thoroughly examined.5 Basic RSA
security relies on the intractability of the integer factorization problem. The problem
of computing the RSA decryption exponent d from the public key (e, n), and the
problem of factoring n, are computationally equivalent.6
Numbers p and q used for generating the public and private keys can be chosen
in such a way that there is no feasible algorithm known for breaking RSA. Due to
[email protected]
126 4 Foundations of Asymmetric Cryptography
[email protected]
Chapter 5
An Electronic Signature and Hash Functions
This chapter presents one of the most important uses of cryptography today—
electronic signature algorithms.1 This is a relatively new alternative to traditional
handwritten signatures on paper documents. The electronic signature, analogous to
the handwritten signature, is used for signing electronic documents. It can be used
online for authentication.
Section 5.2 presents cryptographic hash functions, as used nowadays by the sig-
nature schemes. In the last decade these have got a lot of attention in both academia
and industry, due to their widespread vital applications and the research challenges
associated with them.
1 The interested reader can find more on electronic signature in [68, 79, 92]. Legal aspects of an
e-signature and its usage in administration across the globe can be read about in [5, 65, 66].
[email protected]
128 5 An Electronic Signature and Hash Functions
[email protected]
5.1 Digital Signature Algorithms 129
Fig. 5.1 The idea of a digital signature realized with an asymmetric algorithm
In asymmetric cryptography two keys are used. A private key, known only to the
owner, serves in general to decrypt the data encrypted by a public key. The private
and public keys are essentially a matching pair, which means that the data encrypted
by a certain public key can be decrypted only by the corresponding private key.
In the last chapter it was mentioned that some asymmetric algorithms have the
property that the data can be encrypted by a private key, then using the correspond-
ing public key the data can be decrypted. Let us have a closer look at the scheme of
operation (Fig. 5.1).
In general signing a document means transforming it using the signatory’s private
key. Everyone knowing the corresponding public key can verify the signature (using
a suitable transformation). So, in practice everyone can do it. The point is not to keep
secret the signed data. If we can verify the signature with the public key of a certain
person it means that only the owner of the corresponding private key was able to
encrypt the data properly. This subsection presents in detail three digital signature
algorithms using asymmetric cryptography: RSA, ElGamal and DSA.
Let the pair of numbers (e, n) be the public key according to the RSA algorithm
(see Sect. 4.4), and the pair of numbers (d, n) be the private key. For some prime
numbers p and q, the following hold:
1. GCD((p − 1) · (q − 1), e) = 1,
2. d · e = 1 mod(p − 1) · (q − 1),
3. n = p · q.
Let us recall that RSA is a cryptosystem with the property that you can also
encrypt data with your private key. Suppose we want to digitally sign a message
represented as a number M (M < n).
The signature is the number S = M d mod n. To verify the signature you can com-
pute S e mod n and check whether the result is equal to M.
The cryptographic power of the RSA digital signature algorithm, as in the case of
RSA encryption, is based on the hardness of factorization of large natural numbers
(see Sect. 2.5.1).
Example 5.1 Let us consider another example of using the RSA algorithm to gener-
ate an electronic signature. Take p = 53 and q = 41 (both numbers are prime num-
n
bers). Then the product n = p · q = 2173. As e take the number 22 + 1 for n = 2,
[email protected]
130 5 An Electronic Signature and Hash Functions
The ElGamal public key encryption algorithm was presented in the previous chapter.
Let us introduce its modification used in digital signatures. Let us recall the key
generation algorithm:
The numbers g and p can be made publicly available and together with number
y they form the public key (g, p, y). The private key is the number x (as we know g
and p anyway, the private key can be the triple (g, p, x)). Suppose we want to sign
a document M (M < p) using the private key (g, p, x).
[email protected]
5.1 Digital Signature Algorithms 131
3. Using the extended Euclidean algorithm, find the number b such that: M =
(a · x + k · b) mod(p − 1).
4. The signature is (as in the encryption algorithm) the pair of numbers: (a, b).
Notice that the random number k should be different in every run of the signing
algorithm.
Example 5.2 Let us take the private key (g, p, x) = (2, 11, 8). It is easy to com-
pute the public key (g, p, y) = (2, 11, 3). We will sign the message M = 5. For the
random number k take 9 (of course gcd(10, 9) = 1).
Compute a = g k mod p = 29 mod 11 = 6.
Determine b using the expanded Euclidean algorithm from the following equa-
tion:
M = (a · x + k · b) mod(p − 1) :
5 = (6 · 8 + 9 · b) mod 10
b = 3.
The signature is the pair (a, b) = (6, 3).
To verify the signature we check the following equation for the numbers just
calculated:
y a · a b = g M mod p :
36 · 63 = 25 mod 11.
The Digital Signature Algorithm was published by the US National Institute of Stan-
dards and Technology (NIST) in 1991 as the Digital Signature Standard (DSS), ap-
proved as specified in [32] and expanded as [33] in 2009. It is available free of
charge. It is a variant of the ElGamal signature algorithm. Here we present in brief
the main idea of DSA.
It starts off with specially selected random large integers p, q and g. The NIST
standard specifies the (p, q) bit-lengths as (1024, 160), (2048, 224), (2048, 256),
p−1
or (3072, 256). g is usually set to 2 q mod p.
Every user receives (or chooses randomly) its own individual secret key x (from
the interval between 0 and q) and computes y = g x mod p. This is the user’s public
key, as in the ElGamal algorithm. The digital signature on a document M, using an
[email protected]
132 5 An Electronic Signature and Hash Functions
auxiliary (secret) randomized every time number k (of the same size as q), is a pair
integers (r, s) satisfying:
r = g k mod p mod q,
M +x ·r
s= mod q.
k
To verify the signature one checks whether
M r
r = g ( s mod q) · y ( s mod q) mod p mod q.
Note that the computations are more complicated than in the ElGamal encryption
algorithm. As private keys in this system big enough numbers should be used in or-
der to prevent forgery of the signature by trying one by one every possible candidate
as a key (the brute force attack).
If the key was a 2-digit number it would not be difficult to try out every candidate
from 0 to 99. If the key has, for example, 60 decimal digits the best networked
computers nowadays are not able to try out each candidate one by one. It would
require more than a couple of years of work. The public key should be a number for
which it is infeasible to compute its discrete logarithm, using the asserted parameters
g and p.
Currently, the private key for DSA should have at least the length of 160 bits, and
the public key at least 1024 bits.
The size of q is fixed in the algorithm DSA (as per [32]) at 160 bits, while the
size of p can be any multiple of 64 between 512 and 1024 bits inclusive. [32] does
not permit primes p larger than 1024 bits. Along with some minor revisions, and
reflecting advances in technology, [33] recommends that it is prudent to consider
larger key sizes. It allows the use of 1024, 2048, and 3072-bit p, and the (p, q)
pair lengths of (1024, 160), (2048, 224), (2048, 256), and (3072, 256). DSA pro-
duces digital signatures of length twice the size of q, i.e., of 320, 448, or 512 bits,
respectively.
Also [33] adopted the RSA algorithm, as specified in [1] and [81] (version 1.5
and higher) for the computation of digital signatures, and the Elliptic Curve Digital
Signature Algorithm (ECDSA), as specified in [2], with a minimum key size of
160 bits (producing digital signatures that are twice the length of the key size).
ECDSA computations are designed in the arithmetic of certain special groups of
points lying on carefully selected elliptic curves.
The idea of a digital signature described above faces some considerable incon-
venience. The algorithms of asymmetric cryptography take a great deal of time.
Encrypting (signing) large data incurs a large computational overhead. Such com-
plications can be solved by using the cryptographic hash functions.
[email protected]
5.2 Cryptographic Hash Functions 133
of breaking them, have been actively studied and experimented on for the last
2 decades, with some very interesting developments quite recently. This section
gives the current (as of August, 2013) account. Three algorithms are presented and
discussed in more detail: MD5, SHA-1, and SHA-3/Keccak.
The hash algorithms produce hash values (a.k.a. digests, or fingerprints) of mes-
sages. In general, the hash values are used to detect whether messages or files have
been changed since the hash values were generated.2 Examples of well-known usage
include: Unix passwords storing, data validation, authentication of software pack-
ages, file identification in peer-to-peer networks, video file references on YouTube,
implementations in widely used security protocols and systems like TLS, SSL, PGP,
IPsec, Bitcoin, etc. Digital signature schemes provide one more example.
A document of any size is processed by a cryptographic hash function into some
fixed-size (relatively small) hash in such a way that the transformation is compu-
tationally one-to-one. This means that the function does not need to be one-to-one
(some different documents may get the same hash value), but it must be infeasible
to find any two documents which get the same hash. In general, good cryptographic
hash functions are designed in such a way that there is no formal proof of this prop-
erty, and the security of widely used hash functions nowadays is based on the fact
that so far no one has found any feasible algorithm able to construct two different
documents with the same hash. In this respect the status of the problems of breaking
currently good hash functions is the same as that of the factorization and discrete
logarithm problems.
Digital signing using a hash function is a two-step process (Fig. 5.2):
1. The signatory processes the message to be signed into some fixed size form using
a hash function.
2. The signatory transforms the hash with his own private key according to the
signing algorithm.
This way one can sign data of any size, e.g., a one-sentence e-mail or a file of size
100 MB.
Hash functions are one-way functions. This means that in practice no message
can be retrieved from its hash. It is not difficult to notice that this method of elec-
tronic signing prevents us from decrypting the document with a public key. It is
necessary to attach a signed document to the data which form the digital signature
on it. Then the signature is verified in the following three steps:
[email protected]
134 5 An Electronic Signature and Hash Functions
[email protected]
5.2 Cryptographic Hash Functions 135
Thanks to this, SHA-1 and SHA-2 are less susceptible than the MD5 algorithm
to the brute force attack (searching the entire space) or differential cryptanalysis.
Moreover, in MD4 and MD5 some weaknesses have been discovered which in some
cases enable us to find collisions, i.e., two different messages with the same hash.
There have been cryptanalytic attacks on SHA-1. Its credibility is not considered
high now.
Breaking a hash function means showing that it does not have one of the above
three defining properties, or any of them. In [100] three Chinese researchers pub-
lished an effective method of finding two distinct messages with the same MD5-hash
value. A pair of different documents with meaningful realistic contents and the same
MD5-hash value were demonstrated in 2008, see [98].
The method finds also collisions in SHA-1 requiring an estimated 269 SHA-1
evaluations, reduced recently to 261 (see [97]). This is much faster than the birthday
brute force attack, but still is not considered feasible with the currently available
technology.
SHA-2 is a family of four hash algorithms: SHA-224, SHA-256, SHA-384, and
SHA-512, with output hash of size 224, 256, 384, and 512 bits, respectively. It was
published and specified by the US NIST Federal Information Processing Standard
in 2001 (superseded by [45]). The longer hash is intended to make the algorithm
harder to break.
Many experts claim that practical breaking SHA-1 is just a matter of time. For
that reason more often the functions from SHA-2 are used. These have a much larger
security margin, although their algorithms are derived from SHA-1. So far, the best
known cryptanalytic results on them break only some of their much round-reduced
variants: preimage resistance for 41 out of 64 rounds of SHA-256, collision resis-
tance for 24 rounds of SHA-256, and preimage resistance for 46 out of 80 rounds of
SHA-512; see [6].
The birthday problem is the following: How many people must be selected to have
with probability greater than 0.5 at least two of them celebrating their birthday on
the same day?
For simplicity, we assume a year has 365 days. We ignore February 29, we ignore
twins, and any seasonal irregularities in birth statistics. Possible small corrections
reflecting those circumstances would not really make a significant change. The an-
swer is: only 23. Despite an intuitive impression that many more must be required.
That is why it is called a paradox.
The computations justifying the answer are not difficult. Suppose we number the
participants of our experiment with 1, . . . , 365. We assume we start off with 365 per-
sons. Thus every group of m participants can be identified with an m-element se-
quence of numbers. Such a sequence is called an m-element variation with possible
repetitions from the 365-element set. There are 365m such sequences (variations).
[email protected]
136 5 An Electronic Signature and Hash Functions
Consider the event opposite to the one we are interested in. That is, look for such
groups of participants in which there is no pair with the same birthday. Sequences
representing such groups are the m-element variations with no repetitions from the
365!
365-element set. There are (365−m)! such sequences.
Therefore the probability of the event opposite to the one we are looking for is
(365−m)!·365m
365! . Already for m = 23 this number is less than 0.5. It is about 0.493.
Thus the probability of occurrence of an event described in the paradox is bigger
than 0.5. Notice that for m = 22 these numbers are about 0.52 and 0.47, respec-
tively.
The birthday paradox has interesting consequences in cryptanalysis of hash func-
tions. In general one can think of it in terms of probability theory. Consider an urn
containing m hash values (balls numbered with all possible hash values of an n-bit
hash function). One hash value (ball) is drawn randomly, its value is observed, it is
then placed back in the urn (drawing with replacement), and the selection process
is repeated. If m is sufficiently large, then with high probability a repeated element
1 √
will be encountered after approximately m 2 ( m) selections. This result is appli-
cable to all n-bit hash functions with m = 2n . The process can be parallelized with
a factor r speedup on r processors.3
Given an n-bit hash function h, the brute force method to search for a collision is
by simply evaluating the function h at different inputs one-by-one chosen randomly
(or pseudorandomly) until the same hash value is found twice. Due to the birthday
1 √
paradox result, we can expect to obtain such a pair after approximately (2n ) 2 ( 2n )
evaluations of h at different arguments on average.
In other words, for an n-bit hash function, there are 2n different hash values.
n
If these are all equally probable, then it would take approximately 2 2 attempts to
generate a collision using brute force. For example, if a 160-bit hash function is
used, there are 2160 different outputs. If these are all equally probable, then it would
take approximately 280 attempts to find a collision using brute force.
The MD5 hash algorithm was introduced by Rivest [99] without mathematical proof
that it is a good one-way cryptographic hash function. MD-5 is not recommended
for use anymore for any purpose requiring collision-resistance, as its collision-
resistance has been shown to be weak, as pointed out above. The algorithm takes a
message in the form of a bit sequence M = m0 , . . . , mb−1 of any practical length b,
and returns a 128-bit hash. Processing the message into a hash proceeds in four
steps. The data in each step processed in 512-bit blocks divided into sixteen 32-bit
words.
[email protected]
5.2 Cryptographic Hash Functions 137
Fig. 5.3 The block scheme of processing the message in steps 2 and 3
• Step 1. The message is padded with additional bits in such a way that its length
is 64 bits shorter than a multiple of 512 bits. The additional bits are appended
even when the above mentioned condition is fulfilled, i.e., if b ≡ 448 (mod 512),
where b means the initial length of the message. In such a situation the addi-
tion has length between 1 and 512 bits. First a single bit 1 is appended, then all
zeros.
• Step 2. The remaining 64 bits represent the initial length of message M. If
the initial length of M is bigger than 264 (which is practically impossible:
264 = 18446744073709551616), then take its remainder modulo 264 . As a re-
sult we get L 512-bit blocks Y0 , Y1 , . . . , YL−1 , where each block can be divided
into sixteen 32-bit words.
• Step 3. The MD5 algorithm operates one of four variables A, B, C, and D, stored
in four 32-bit registers according to the block scheme shown in Fig. 5.3 These
variables have the initial values (written in hexadecimal):
A = 01234567, B = 89abcdef, C = fedcba98, D = 76543210.
• Step 4. In this step four auxiliary functions are used each of which takes
three 32-bit words and outputs one 32-bit word. These are the following func-
tions:
F (X, Y, Z) = (X and Y ) or (not X) and Z , (5.1)
G(X, Y, Z) = (X and Z) or Y and (not Z) , (5.2)
H (X, Y, Z) = X xor Y xor Z, (5.3)
I (X, Y, Z) = Y xor X or (not Z) . (5.4)
These functions work on suitable bit blocks X, Y, Z according to the array:
XY Z F GH I
0 0 0 0 0 0 1
0 0 1 1 0 1 0
0 1 0 0 1 1 0
0 1 1 1 0 0 1
1 0 0 0 0 1 1
1 0 1 0 1 0 1
1 1 0 1 1 0 0
1 1 1 1 1 1 0
[email protected]
138 5 An Electronic Signature and Hash Functions
In this step the 64-element array T [1..64] is used, consisting of the following
integers (written in hexadecimal):
where i is given in radians and E(·) means the largest integer not greater than the
expression in brackets. Let M[0, 1, . . . , N − 1] stand for 32-bit words of the padded
messages L 512-bit blocks. In this case N = 16 · L, and every block Yq consists of
16 words M[j ], j = 0, 1, . . . , 15. In this step each 16-word block Yq is processed
as follows:
for q := 0 to L − 1 do
for j := 0 to 15 do
X[j ] := M[16 · q + j ]; (copy the next word into array X.)
AA := A; BB := B; CC := C; DD := D; remember the initial values of regis-
ters ABCD
Here (B) <<< s means the 32-bit word obtained by the cyclic shift of word
B of s positions to the left, the variables a, b, c and d mean also some 32-bit
words, F is the function determined by formula (5.1), T is the array defined
above, and + denotes addition of 32-bit words without carrying (addition
modulo 232 ).)
[email protected]
5.2 Cryptographic Hash Functions 139
[email protected]
140 5 An Electronic Signature and Hash Functions
The algorithm outputs 128-bit message digest M, that is the content of the last
computed registers ABCD. The MD5 algorithm is easy to implement on 32-bit pro-
cessors, and computation is fast. It is a corrected version of the MD4 algorithm, in
which some weaknesses were shown. The MD5 algorithm had been considered very
strong until the work [100].
The SHA-1 algorithm, similar to MD5, was designed by the NIST in cooperation
with NSA and published as a federal standard FIPS PUB 180 in 1993. The abbrevi-
ation SHA stands for: secure hash algorithm. The input is a message of any length
less than 264 (18446744073709551616) bits, and the output is a 160-bit hash value.
• Step 1. The message is padded in the same way as in the MD5 algorithm.
• Step 2. At the end of this message 64 bits are added, including the information
about the length of the message before padding (Fig. 5.4). These bits are treated as
a binary number, written in a processor convention used in Sun computers, where
the most significant byte of the word is located in the first position (unlike in Intel
processors), which probably speeds up the rate of processing. After this activity
the message from which the hash is executed consists of n 512-bit blocks. Every
block is treated as sixteen 32-bit words: M = M[0], M[1], . . . , M[16n − 1]. Then
initialize the auxiliary variables h1 , h2 , h3 , h4 , h5 :
h1 = 67452301
h2 = efcdab89
h3 = 98badcfe
h4 = 10325476
h5 = c3d2e1f0
and take the following values for the constants y1 , . . . , y4 :
y1 = 5a827999
y2 = 6ed9eba1
y3 = 8f1bbcdc
y4 = ca62c1d6.
• Step 3. This step is the main loop of the algorithm in which the n 512-bit blocks
are processed. For i = 0, 1, . . . , n − 1 every block of sixteen 32-bit words is
copied into the temporary memory X[j ] := M[16i + j ], 0 ≤ j ≤ 15 and ex-
panded into an 80-word block: for j = 16, 17, . . . , 79 do
X[j ] := X[j − 3] ⊕ X[j − 8] ⊕ X[j − 14] ⊕ X[j − 16] <<< 1 .
[email protected]
5.2 Cryptographic Hash Functions 141
Fig. 5.4 The block scheme of processing the message in steps 2 and 3
[email protected]
142 5 An Electronic Signature and Hash Functions
The following operations were used by the algorithm: + addition modulo 232 ,
⊕ addition modulo 2, U <<< s cyclic shift of the word U s places to the left. In
the process the following functions are used:
f (u, v, w) = (u and v) or ( not u) and w ,
g(u, v, w) = (u and v) or (u and w) or (v and w), (5.5)
h(u, v, w) = u xor v xor w.
The presented algorithm gives a 160-bit hash, that is 32 bits longer than that of
MD5, which is more secure. Both algorithms were designed for 32-bit processors.
SHA-1 is easier to implement but its execution takes roughly 25 % more time than
MD5.
5.2.5 Keccak/SHA-3
[email protected]
5.2 Cryptographic Hash Functions 143
Table 5.1 Preimage and collision attacks on the SHA-3 finalists with the highest number of broken
rounds
Function Attack Broken Rounds Complexity Reference
line [72], a draft for public comments is to be announced by October, 2013, and
the final SHA-3 US FIPS standard publication is expected by mid-2014. Although
SHA-2 is still considered secure and recommended by NIST, SHA-1 is recom-
mended only for some applications that do not require collision resistance, see [71].
Table 5.1 shows the cryptanalytic attacks against the SHA-3 competition finalists
known so far. The attacks listed here are those with the highest number of rounds
reached in a given class of the attack. The total number of rounds is shown next to
the number of broken rounds.
The rest of this section presents the Keccak algorithm. (All details can be found
in the original specification [15].)
Keccak uses the sponge construction [14]. Keccak has two main parameters r
and c, called bitrate and capacity, respectively. The sum of these two parameters
makes the state size, which Keccak operates on. In the SHA-3 proposal the state
size is 1600 bits. Different values for bitrate and capacity give trade-offs between
speed and security. A higher bitrate gives a faster function at the expense of a lower
security.
For the variants proposed to the SHA-3 contest, the value of the parameter c
is equal to the hash length multiplied by 2. For example, the SHA-3 candidate with
512-bit hash length is Keccak with c = 1024 and r = 576 (r + c = 1600). We denote
the variants proposed as the SHA-3 submission candidates by Keccak-224, Keccak-
256, Keccak-384, and Keccak-512. (The number at the end of the name specifies
the hash length.)
The number r of message bits processed per block permutation depends on the
output hash size. The rate r is 1152, 1088, 832 or 576, for 224, 256, 384 and 512-bit
hash sizes, respectively (with 64-bit words). To ensure the message can be evenly
divided into r-bit blocks, it is padded with a 1 bit, zero or more 0 bits, and a final 1
bit. A state can be visualised as an array of 5 × 5 lanes, where each lane is a 64-bit
word, see Fig. 5.5. The initial 1600-bit state is filled with 0’s.
[email protected]
144 5 An Electronic Signature and Hash Functions
The state size determines the number of rounds in Keccak-f block permutation
function. For the default 1600-bit state, there are 24 rounds. All rounds are the same
except for round constants. Each round consists of the following 5 steps.
Round(A,RC) {
Θ step
C[x] = A[x,0] xor A[x,1] xor A[x,2] xor
A[x,3] xor A[x,4], forall x in (0...4)
D[x] = C[x-1] xor rot(C[x+1],1),
forall x in (0...4)
A[x,y] = A[x,y] xor D[x],
forall (x,y) in (0...4,0...4)
ρ step forall (x,y) in (0...4,0...4)
A[x,y] = rot(A[x,y], r[x,y]),
π step forall (x,y) in (0...4,0...4)
B[y,2*x+3*y] = A[x,y],
λ step forall (x,y) in (0...4,0...4)
A[x,y] = B[x,y] xor ((not B[x+1,y]) and B[x+2,y]),
ι step
A[0,0] = A[0,0] xor RC
return A }
Here, index arithmetic on the first two indices x and y is performed modulo 5.
A denotes the complete permutation state array and A[x,y] denotes a partic-
[email protected]
5.2 Cryptographic Hash Functions 145
[email protected]
Chapter 6
PGP Systems and TrueCrypt
PGP was in some sense a response to the US government policy which wanted to
relax the laws which guaranteed the privacy of different forms of interpersonal com-
munication (traditional post, telephones and e-mails) in order to enable the police
and other services to carry out surveillance of suspected criminals. American soci-
ety became more sensitive to their rights guaranteed by the constitution. The public
was afraid that the new technology could lead to abuse and the laws to prosecute the
criminals can turn against ordinary citizens, e.g., during election campaigns.
Currently PGP is the most modern, well-known and commonly used crypto-
graphic system all over the world. Even the most advanced computer users are sat-
isfied with operating PGP.
[email protected]
148 6 PGP Systems and TrueCrypt
The first commonly known and used PGP version was PGP 2.3a—the version
available on the market since 1993. In this version, as in later versions until PGP 5.0,
RSA was used as the asymmetric encryption algorithm, IDEA as the symmetric ci-
pher, and MD5 as the one way function. The 2.3a version enabled generation and
use of RSA keys of 1024-bit length. In subsequent versions of PGP the capability
of the system was increased. New encryption techniques were added and the length
of the encryption for generation and use was increased. Improvements in PGP 5 in-
cluded a new asymmetric algorithm: the Digital Signature Algorithm, DSA (known
also as DSS—Digital Signature Standard); new stronger symmetric ciphers: 3DES
and CAST; and hash functions: SHA-1 and RIPEMD-160. The DSA algorithm was
added because of patent restrictions on the RSA algorithm (the patent expired in
2000).
According to US export regulations (ITAR), which classified advanced encryp-
tion algorithms as military technology, it was not possible legally to export the PGP
software from the USA. Those regulations limited only the electronic version of the
software. The export of the printed source code (the algorithm) was not restricted
by ITAR. That is why PGP Inc. released the full PGP source code in the form of
a 14-volume book which was legally taken outside the USA and scanned by Ståle
Schumacher, the former coordinator of the international version of PGP. It took
about 1000 hours in cooperation with 70 people from across Europe. This proce-
dure was conducted to avoid any accusation against Phil Zimmermann connected
with PGP version 2.6.3i which was written in the USA and was used in Europe.
In 1998 the rights to the PGP software were bought by Network Associates Inc.
(NAI). From then on PGP enlarged its capability. From an encryption program used
mainly in e-mails, PGP transformed into a complex product which enabled the cre-
ation of private virtual encryption networks, the use of X.509 protocols and the
encryption of logical disks.
In 1998–2001 the PGP software produced by NAI was a commercial product.
It also supported other functions besides signing and encrypting data. Subsequent
PGP versions included among other things software to secure a Windows system. In
May 2001 Phil Zimmermann left NAI, because he disagreed with the corporation’s
use of PGP. In 2002 NAI announced the suspension of commercial support for PGP
as encryption software. In August 2002 the PGP product line was finally sold by
NAI to the newly established PGP Corporation.
Currently, the rights to the PGP software are owned by Symantec Corporation,
which offers a wide range of products designed to ensure a suitable level of security
of computer systems. Some of the proposed solutions are listed below:
1. PGP Universal Gateway Email—an application that provides centrally managed
e-mail encryption in order to secure communication with customers and partners.
2. PGP Desktop Email—software that is used in desktop computers and laptops. It
offers automatic e-mail encryption. The application works as a proxy server, and
automatically detects keys and certificates of two e-mail encryption standards
used globally: OpenPGP and S/MIME.
3. PGP Universal Server—an application that provides organizations with a single
console to manage multiple encryption applications from the PGP Platform.
[email protected]
6.1 PGP System 149
4. PGP Key Management Server—a system that provides companies with tools to
manage encryption keys. It enables centralized management of cryptographic
techniques in a whole enterprise.
[email protected]
150 6 PGP Systems and TrueCrypt
Fig. 6.2 The execution of the encryption service using a PGP system
of that message. The encryption of the digest is executed using the RSA algorithm
and the private key of the sender KRa. To the encrypted digest ER(KRa, H (M)) the
message M is attached. After compressing the data, it is sent to the recipient.
At the receiving end the decompression of the data takes place, resulting in the
message with the encrypted extract; and these two components are separated. The
encrypted result of hashing the message M is decrypted by the public key of the
sender, using the operation DR(KUa, ER(KRa, H (M))) = H (M) and simultane-
ously the extract of the unencrypted message M is computed. Comparing these
shortcuts determines the authenticity of the received message.
In a PGP system the method of executing a digital signature is a combination
of the RSA and MD5 algorithms. Assuming the reliability of the RSA system, the
recipient of the message has a guarantee that only the owner of the private key KRa
can have created the extract H (M) of the message M if the signatures received and
reproduced based on the received message are the same.
The principle of the execution of the message encryption service using PGP sys-
tem is illustrated in Fig. 6.2. The service encrypts messages to be sent by e-mail or
saved to a disk. Encryption uses the IDEA algorithm with a 128-bit key working in
the encryption mode with feedback with the initial vector in the form of the zero
sequence. The key Ks is a one-time key generated randomly for each message and
which accompanies the given message.
During the execution of this service the sender edits the message and then ran-
domly generates a 128-bit number, which is the key Ks to the encryption and de-
cryption of the message. The compressed message Z(M) is encrypted, resulting in
the message cryptogram y = EI(Ks, Z(M)). At the same time the key Ks is en-
crypted using the RSA algorithm: x = ER(KUb, Ks). The data is sent to the re-
cipient, beginning with x. At the receiving side the recipient decrypts the session
key Ks = DR(KRb, x), and then the compressed message Z(M) = DI(Ks, y). The
last stage of receiving the encrypted message is the decompression of the mes-
sage M.
It is worth noticing that using the RSA system facilitates the distribution of the
keys and guarantees that only the recipient can decrypt the key Ks of the cryptogram.
That is why the PGP system proposes the usage of three kinds of keys for RSA:
[email protected]
6.1 PGP System 151
Fig. 6.3 The execution of the encryption and authentication service using a PGP system
[email protected]
152 6 PGP Systems and TrueCrypt
code. In this way the size of a message expands by 33 %, but using compression
compensates for this inconvenience to a certain extent.
E-mail also imposes some limitations on the length of messages, which should
not consist of more than 50 kilobytes. In such a situation every longer message must
be divided into smaller parts and every part must be sent separately. The PGP system
executes such a segmentation and defragmentation (desegmentation) automatically.
Below we briefly present the installation process and capabilities of the PGP system
in its free version PGPTM Desktop Version 10.2 for Windows offered by Symantec
Corporation. The necessary installation files and information can be found at www.
pgp.com. The installation process starts in a standard way, by running the file
PGPDesktopWin32-10.2.0MP3.
Installation uses Wizard and can easily be performed even by beginners. At some
point the system displays a dialog box asking whether encryption keys have been
generated, or it will even find the keys, provided they have been generated and
reported to one of the PGP servers.
In case the keys have not been generated, the system is capable of generating
keys in different cryptosystems and of different sizes. Keys for the RSA algorithm
may be up to 4096 bits long. During the key generation process we input, among
other things, the applied encryption system (one has to remember that RSA is not
supported by some older PGP versions). It is also possible to limit the lifetime of
the key, e.g., for one year (see Figs. 6.4, and 6.5).
Next, we enter the password for our key. Let us pay attention to the security
level of the given password that is signalled by the computer. The password should
[email protected]
6.1 PGP System 153
[email protected]
154 6 PGP Systems and TrueCrypt
When generated, public and private keys are stored in special files: pubring.pkr
and secring.skr. After the generation process the generator finishes its work and
suggests to restart the computer.
In order to manage encryption keys, the PGP Desktop file should be run, which
makes the program display a dialog box (Fig. 6.7).
The dialog box lists all currently available encryption keys. They may be pairs
of keys (private and public) or public keys of our friends, co-workers or business
partners.
In the Tools menu an Options bookmark is available, which allows us to config-
ure the encryption program system. Setting a suitable configuration is crucial for
efficient and proper use of the program.
For example the General/My Passphrase section is responsible for the temporary
automatic use of an unencrypted key. Options available within this section allow to
store passwords to keys (during a whole session of cooperation with the program or
temporarily, for example, for two minutes). Moreover, it is possible to set a require-
ment for typing the password each time when using a given encryption key. This
option is the most secure (Fig. 6.8).
[email protected]
6.1 PGP System 155
The PGP program allows us to export encryption keys outside the system. This
is needed for two reasons. First, if we want to receive encrypted mail, we have to
share our public key with others. Second, it may happen that we want to keep our
private key somewhere else than on our computer (a CD, etc.).
In order to export an encryption key we can use the Export option when we
simply click the key with the right mouse button (Fig. 6.9). The key can also be sent
directly via e-mail by means of the Send to/Mail Recipient option (Fig. 6.10).
The software allows us to export both a public key and a pair of keys. The ex-
ported key is kept in a text file with a .asc extension.
[email protected]
156 6 PGP Systems and TrueCrypt
Now, we can display its contents, e.g., using Notepad. Let us look at the key size.
Keeping in mind that an arbitrary ASCII character is represented by eight bits in the
binary system, it is easy to see that the key size is large.
lQPGBE9E+dEBCAC5Vhwo14lITIE/eJD8ZI+vZcynrQtD8qwjSoI4zKVYiaU32tnK
PcXmJN5EDMk0vhRufFmnN5QIXhzJ49klYCngxGtUrhHZNCrD4U95m/OYx0ZhZl0h
ch3mIkgzMqxCFP56FYozaKSC3qLvhB89RGGC0PEeacoj4ZpAueRKir6lhzubT/vk
wVEFXDvvWDO7yRb79XymYu0juQsp6E1scj0fWlfkN9B5bFGRgqGx7WXAxBrFCQH9
K4D10YWCfP7Nbb7cnnNFOCa9UEWUO6qMC5wwPlfVS5s2X6853Gs1JnE5XuvebQI0
ZCs8r8bcq8H9gjAQ/nqyc9QzbP3iSlyTy/4rABEBAAH+CQMC35dK5QUJelCYY2bU
FVt+52ESfLhVrmQ5kfyAMrRwprneHTKbYE8oG1XtS5s/me7RdynrJpdHhFXxFz+b
M2pGeGyEDliQgfY2BeW+1wOMGW6er2UIFg2cG45DFK6PYcPeAhCCxVD594YSCGev
XL0F1wOEzd9HOEO9zSqcYZ3dbMT5lUKMWSUcVMJSipESA0/QM4ZUMi/TDQZPnnlt
PL1P0SgjWgtxMKVDLx64uocPJsVXEDzpJeARRDtnybCFTvz7RutAT50y/fYHmpky
aG/Czwi/IKPooP0GgIicSoJMS3wGDrKhgWADyolGEG/jwwmmO89A5/7wVAEi8kpK
qaJeyVrsEZkpDXm4bp0AGtN9KTm4vATlqMSentfVAgvekoYB29Jsdh54sJr1sXjF
ethet2l5vfLtfRT6DcWAL5VXryKhtjPFr9WWBkOTKF2zfSS1IG2Spn6VY7SdDgf5
vdOcKjVFd1cAea7g/JV331RN8LBb+hA/R5Ic2xtsPapqhtBm/C/CxlbAGWj4+aKv
HfaE0IgjGHQmn+lG88EukqpkB/sRiu1ZHnzthXG4tH8WRG6YtBwnrg6hRcQgQSm+
YLGSzBwStGE7uLTQbaAp5cxssL21AO+IbEmHbMock1//nUF213OLb6LVoTB33H49
/gx7ERX6sfnL4vhNvopptBhxOw+WjLFZWbn68agQR2ybiwPN45NsD1/ZgNM85YFA
bhd9ROAsPrfIfADXL8hdVc2+/CE+xJ3HecnfS2OopGJ1z8sh4y4GpWDinEZKLCH0
j/+yPmqsWtXKIMhcz9t/Oiqd0iBaPKxYNx7KHaWSq1qiO+vKx1nKIz1Jl/1v2Zfj
LYwEFotshi5KxOYv8wcpCCMP+28cG8TH2krnCJOjN9DbPlSyGFjIOKE5gLiRYfRO
O8TTXeY/szgCtB9NaXJlayA8Y3J5cHRvZ3JhcGh5QGdtYWlpbC5jb20+nQPGBE9E
+dIBCADGUHUgcSE/MVp/zzvX3g5NXIEzPYJlIvgJBo2kJGJmvgeruHODEAF2sBX1
LhdHFWgaFn2fC4wdnOhQyx3+LOjb8TBdGu1CgHDhUYoWCe1nw1avywvrDZeJcTrs
E2N4Jpdfd+KvH13q8yH7PlJntFwIda2LSE0hFQpUR/ozL8JPyCLNr9LrDWO+1Xsm
6DWqJL7Pyf166GxPSrvVUlCE8L1FOOkYzoAmyZVwtp0OokYEtSM/gU2F0usnJYR2
SX926hzoKX7VQt+PmuRYPY8xOrzbW6KXh2bDJfW+MKoR/sPLIAUQOEoe0MMYLIM6
mMkMqRyxrUDYOw+6HqvK+tkZ60H1ABEBAAH+CQMCfGrVlSCirUmYzNOyHsWzl6lD
pAmgNOgEL2GUbWBBLBVYeXJl0U27+KZqamdh5Ob6tj4gQMHCobKRj9WmfB7TSH2O
SsqPsPsTrLjoJtwhDs5XUzJyz1Lv07io8jnMEf0EDR9D0JpXgz+nfY8dRYaUGiF7
c5c1Wlzyw65hrLQFcODeNtY2eHSQ6NS2QOIeFFa5lvyHYA+2E0XKVgLN521Kgn1T
bhy0lWQpuw/cnbLZdKfe7NS6m6QcWRUzYesbAX9yZ43DUOCGuU5h9IEXetZNxPdn
EkDvaj8zsXLtYm9TuVAq+a4P2UrFHI/aghx6dcSxvQv0DyFnS4ej8FdZZa6UGNGA
ZT39TEtRXBAA7TjQZk/4JXaMq8XV4oVgGgXPn25a1lSrOL6n/qRNhippsRO6pEGd
Sza/+xgJzsWacrfgykPBQuqoaDHHyFDGYkN68J4I7+zU6lvcvPnvN0ZnGf+jq6DE
6PUSyDf47WcJj7LjxgHVNj/En5zQvepA54FDvMiljGwtcWvsU/QZ6ID9zNLPfOxc
pKC23ryt2Ziyo4mZD9fFf6/cowHReQU40YGr4ZW/SfYovM2k0DaL2ChIfHWfGE9y
aCeMsWTloGlXeLYJJNcvcALfdrGqmRaEjwKcS+48ude29ZP86+uU8v7qLnAzjeId
EXFXwSF+jIINi8U/+Q9j3FnS5Ds5BlzKW2aOcBAeEzX+T4kSlmusGI/TFhRh5nL6
LNpD8lYj3xe1lffoOe5Ei2v2alERECVCioJBecrgU6BFXok4gzROxPYj8KbPXkTH
JQbQ9mMkSFEslk1I5yEMBOC9fs8vNFrudyfMGX3yOzNTtqM4ndFzQNlr9EoFQ6s4
x9tPrvX+KWzbuumJb69+C/kzUb9E0YqwFSzdX5RtTgt6KPd3kAie4+qgk7kzHGOo
kiLE
=kx8E
-----END PGP PRIVATE KEY BLOCK-----
[email protected]
6.1 PGP System 157
mQENBE9E+dEBCAC5Vhwo14lITIE/eJD8ZI+vZcynrQtD8qwjSoI4zKVYiaU32tnK
PcXmJN5EDMk0vhRufFmnN5QIXhzJ49klYCngxGtUrhHZNCrD4U95m/OYx0ZhZl0h
ch3mIkgzMqxCFP56FYozaKSC3qLvhB89RGGC0PEeacoj4ZpAueRKir6lhzubT/vk
wVEFXDvvWDO7yRb79XymYu0juQsp6E1scj0fWlfkN9B5bFGRgqGx7WXAxBrFCQH9
K4D10YWCfP7Nbb7cnnNFOCa9UEWUO6qMC5wwPlfVS5s2X6853Gs1JnE5XuvebQI0
ZCs8r8bcq8H9gjAQ/nqyc9QzbP3iSlyTy/4rABEBAAG0H01pcmVrIDxjcnlwdG9n
cmFwaHlAZ21haWlsLmNvbT6JAXIEEAECAFwFAk9E+dEwFIAAAAAAIAAHcHJlZmVy
cmVkLWVtYWlsLWVuY29kaW5nQHBncC5jb21wZ3BtaW1lCAsJCAcDAgEKAhkBBRsD
AAAABRYAAwIBBR4BAAAABhUICQoDAgAKCRCnWUFHBTNOTfyqB/wLm3SRzvFpzWA5
VigvmKEPbXT2Rh5oLpw2hGY13wuQsE1CuvIzw+oICunkSUEPuznq0dFr9mpMvA/r
Hr+zxqd+Ang9jZZHPS/VjGu8se7n1q3d3oW7H/8w7WDKer76bDWnUWV9q0yImjfb
0k0xwVguksPGydJrElI/BFcuTudhNZyna+6o4/YyiVqzpvWZiNuHRzVeTDdQMI0o
ayIrPxfrRuCHkomDJBeRHWZ9WaWY1rMJWF+wk1OhxVYTUeW3muJzMMDBGzWeOHBa
Vas8Kp9i9UOPAUR1u3gx2VQkTe6F/enkNdHoILWcM2aDyqest0WljOboMFuSZkc3
mCNFF+SEuQENBE9E+dIBCADGUHUgcSE/MVp/zzvX3g5NXIEzPYJlIvgJBo2kJGJm
vgeruHODEAF2sBX1LhdHFWgaFn2fC4wdnOhQyx3+LOjb8TBdGu1CgHDhUYoWCe1n
w1avywvrDZeJcTrsE2N4Jpdfd+KvH13q8yH7PlJntFwIda2LSE0hFQpUR/ozL8JP
yCLNr9LrDWO+1Xsm6DWqJL7Pyf166GxPSrvVUlCE8L1FOOkYzoAmyZVwtp0OokYE
tSM/gU2F0usnJYR2SX926hzoKX7VQt+PmuRYPY8xOrzbW6KXh2bDJfW+MKoR/sPL
IAUQOEoe0MMYLIM6mMkMqRyxrUDYOw+6HqvK+tkZ60H1ABEBAAGJAkEEGAECASsF
Ak9E+dMFGwwAAADAXSAEGQEIAAYFAk9E+dIACgkQX+Ea4xxSV5VSNgf/eWAxfG/g
L8HLHn0/vFcJnkSr0g5Wij2zs2shSu9U9Ajd4NO4vTtkoWb8h8Eeiu5FS8uX90dQ
dwutb65P97wu09N9MwvJXr/ok3uHAbZRLpCgOAEZ6jViqRBQ07vHL5hjU/vZKPlk
kB/xwztoGEN6z9P9lUi00xTkFGxMGWj0Zmm5VTsVHn2IGqLtkXmd1oVnREqvi/RW
S15kgINv8xO+anDjho7bFAbZT5oRtr0YsLD1ar0EKrnYWmlNWyGdyuIkUKEcUdbb
Fdf7Ktz0QsBq0ZEJnVasKjyRXcggEZp3eWcOLSCdRW6ZBHn+xJBlposHeP8fPnsL
VwTkPIE2PT7BaQAKCRCnWUFHBTNOTS3CCACE7TKgRNP7ojQDKJLSzimWOxHK5c0Y
bqEj+kqF16X+ammS6JaN/mJZFwTgNpp2oN0cnfVzufia5OQOOM0qM9vGZL220QVo
rdQKPAtTSA9X/fV3WWnbgbLmehE8SMOfD6EZYcXN0WP5g6Caj1T6P416HD3GNnbI
Lpvy2puAbBTysq0iq6IVN32ETNtf77Q+7K4MQik6l7CiP+3eUHj0X7KNEGnTfqbO
KmzBOhycuL62AEodu7uzX76glKXh9GvRJE3m7cj3wBwnvFnecFqw7XRV2pRxM86q
YpYJStGxYaEIUI3eENVegtRQ6CnX4h1H29DOu5fKweYH5xGKOs7HMidv
=S1KX
-----END PGP PUBLIC KEY BLOCK-----
In this way, exported keys can be stored on any memory devices or sent via e-
mail.
If we want to know the public keys of other users with whom we wish to com-
municate in an encrypted way, then the keys need to be downloaded by clicking
Import in the menu Keys. Launching this option allows us to add a new key to our
resources (keyring). This can be realized by indicating the location where the key
in question is stored (this may be a file sent to us by someone else). Import/export
of keys from/to other computers is also possible by copying the afore mentioned
special files secring.skr and pubring.pkr.
After several such operations we are able to encrypt messages with the obtained
keys.
[email protected]
158 6 PGP Systems and TrueCrypt
We can learn about the properties of a given key by selecting it and clicking the
option Properties in the menu Keys (Fig. 6.11).
A dialog box with information about settings and properties of the key is dis-
played. Using it we can check which algorithm encrypts the key, its size, its lifetime,
when it was created, etc. We can also see the key fingerprint (the numerical value of
the key transformed by a hash function) given in its hexadecimal representation or
as a text (using the appropriate set of words).
The PGP program allows us to encrypt files of any format. Since the process of
encrypting and signing text files is simple, we present it below.
In order to encrypt a file displayed in the window of a given folder, we click its
icon with the right mouse button. Next, we choose PGP and then Secure from the
options.
The file silent.txt we will encrypt contains the following text in the ASCII code
(Fig. 6.12):
[email protected]
6.1 PGP System 159
After running the Encrypt option (Fig. 6.13), the PGP program starts to encrypt
the file.
It displays a dialog box (Fig. 6.14), in which we have to input the key with which
the document should be encrypted. The upper part of the box contains the keys we
know.
The file encrypted in this way is saved in a special format chosen from among
options for the output file. The text contents of the file is changed to a cryptogram
(Fig. 6.15).
This file can be decrypted (provided we have the private key symmetric to the
one with which we encrypted the plaintext) by selecting the file and clicking the
appropriate option PGP—Decrypt/Verify.
[email protected]
160 6 PGP Systems and TrueCrypt
After this is done, we need to type the password for the key used for encryption
in the displayed dialog box.
If the document is encrypted with a key for which we do not have a symmetric
one, the program informs us about the failure of decryption.
The PGP program enables electronic signing and verification of files of any for-
mat. Since signing a text file are simple, below we describe the processes. To sign
a file displayed in the window of an appropriate folder, we have to click on its icon
with the right mouse button. Then we select PGP and Sign from the options.
After selecting the option PGP—Sign the program asks first with which key (a
private one according to principles of asymmetric cryptography) we want to sign the
message (in case there is more than one key available) and it requests the appropriate
password for this key.
Verification of the signature is executed by, among other things, double clicking
on the file or selecting the appropriate option from the menu.
Let us notice that together with the confirmation of the authenticity of the signa-
ture the date of its creation is also displayed (Fig. 6.16). Recall that verification of
the file is possible provided the signed file is located in the same folder as the file
containing the signature. If the main file is missing, the system informs us about the
failure whenever we try to verify the signature.
If we change the contents of the already signed file, the signature will be consid-
ered invalid (Fig. 6.17).
[email protected]
6.1 PGP System 161
The PGP system supports certification of encryption keys. This is achieved by build-
ing a web of trust. One can use only those keys that have been signed by trusted
participants. Certification is performed by signing a given public key with a key of
another trusted person. The user who is signing the key must determine whether
they trust the other user or not.
In order to sign somebody’s key, we have to import it to our keyring and select
the Sign option from the All Keys menu (Fig. 6.18).
In the dialog box we confirm selection of the key used for certification (signa-
ture). By clicking the option More Choices, we can additionally configure the cer-
tificate. Available options include Exportable for export of the signature along with
the key (this option is recommended, as it is very important for creating an adequate
trust chain), Non-Exportable for no export opportunities, and determining timelife
limits for the certificate in question (Fig. 6.19).
Each key can be certified many times. If we want to create a large mutual trust
group, then each entity can certify keys of the other users from the group (Fig. 6.20).
[email protected]
162 6 PGP Systems and TrueCrypt
[email protected]
6.2 FireGPG and Enigmail 163
[email protected]
164 6 PGP Systems and TrueCrypt
6.3 TrueCrypt
TrueCrypt is today one of the best commonly available applications used to pro-
tect data from being read by unauthorized persons. The system secures the data by
encrypting it using one of three algorithms: AES, Serpent, and Twofish, or even a
combination of them. It is worth recalling that these algorithms are considered very
strong. This means that no other method has been found so far to break the code
than to find the correct password by brute force or a dictionary attack. It is free
open-source software which can compete very well with commercial applications
for data protection. TrueCrypt enables us to create encrypted files of any size, how-
ever limited to the capacity of the medium, and also enables us to encrypt a disk
partition. From the fifth version, the program makes it possible to encrypt a system
partition. TrueCrypt is available for Windows and Linux systems and from the fifth
version also for Macintosh. Its basic functions, namely the formation of encrypted
volumes and the encryption of a partition, are available for all platforms, however
the Windows version has the best functionality. A wizard helps the user to install the
program and the process is not difficult even for a beginner. During the installation
you can choose one of two options: the standard installation or creation of a direc-
tory where you can store the portable version of the program. (The portable version
of the application can be used on computers running Windows.) The standard in-
stallation is recommended if the user installs the program on their own computer.
This choice is essential if the partition or the system disk is encrypted. To install the
program you can decide (see Fig. 6.21) whether:
1. the program is available for all users,
2. a program shortcut is created in the Start menu,
[email protected]
6.3 TrueCrypt 165
TrueCrypt offers two forms of data encryption. A file can be created to fulfil the
container function for data or you can encrypt the whole partition. The encryption
of the system partition is a version of the second form however much modified
so we can say it is a third form of encryption. Container-files are ideal if during our
work we need to copy data between partitions and disks or to other computers. Then
instead of entering the password and copying the files from an encrypted partition,
you can copy the entire container-file.
As has been mentioned the AES, Serpent and Twofish algorithms are offered for
use in encryption (Fig. 6.22). You can choose to encrypt using different sequences of
these algorithms (using first one, then another, etc.). This can result in a very high (in
practice, even unnecessary) level of security and at the same time in overloading the
computer processor. To see how the computer can cope with the different encryption
methods choose the option Comparative Test. This test can be performed in the
RAM memory if we want to have the results independent of the speed of the hard
[email protected]
166 6 PGP Systems and TrueCrypt
disk. After the test, you can compare how fast-our processor encrypts using the
individual algorithms.
When you select an algorithm, it is worthwhile to take into account the results
of the test (Fig. 6.23)—current drives have real transfers exceeding 100 MB/s, but
the use of very strong encryption methods can slow down the computer. Although
the latest processors can encrypt your data faster, remember that speeds should be
halved, if you want to move or copy the data from one encrypted partition to another.
In this case, the processor will have to decrypt first and then re-encrypt. Furthermore,
this process can load the processor and decrease the power of the computer during
the reading/writing of data from and to the disk.
After selecting the encryption algorithm a password must be chosen (Fig. 6.24).
It must fulfil two conditions: first, it must be long. Of course, this is a protection
against the brute force method of code-breaking. The password-breaking program
checks passwords one after another, in most cases in alphabetical order. Taking into
account that the password can consist of uppercase and lowercase letters, digits and
special characters, if you extend the password by only one character it will increase
the time needed to break it a few dozen times. For example, if a very fast com-
puter is able to check 100000 passwords in a second, then breaking a five-character
password will take 22 hours, a six-character one 90 days, and a seven-character
one—more than 20 years. Second, the password should be rather complicated in
terms of linguistics. The second method of finding passwords, known as a dictio-
nary attack, uses the fact that many users to make their life easier choose easy to
remember passwords, that is, for example, words or short sentences, names, names
of places and things. Such words are easier and faster to find than random strings
even if they are longer. Different words and sequences of words are checked in a
specially prepared database called the dictionary.
The file format of the volume and its size must be fixed (see Fig. 6.25). You
can also define whether you want to create a dynamic volume—then the specified
[email protected]
6.3 TrueCrypt 167
size will be the maximum size of this volume, but if you store less data its size will
decrease. However this option should not be used because it affects in a negative way
the power of the encryption process (see Fig. 6.26). After defining all the parameters
you can start formatting the volume. If you use an existing file, the wizard will warn
again that the operation will lead not to encryption but formatting the file into a pure
volume. This is necessary because it can help to avoid tragic mistakes.
When a volume is mounted, its icon appears as another drive in My Computer
(Fig. 6.27). You can now work with it as with any other partition. All you need to do
now to encrypt the file with data is to copy the file into the newly created partition.
[email protected]
168 6 PGP Systems and TrueCrypt
This file is automatically encrypted during copying. If you want to move it just copy
it and the process goes the other way.
When you finish working with the volume choose the option Dismount—the
partition will disappear from the above list and from My Computer, and the volume
will become impossible to read (Fig. 6.28).
[email protected]
6.3 TrueCrypt 169
A disk partition can be encrypted in order to limit the risk of an unauthorized access
to its data. A password-protected partition can be invisible in the structure of the
disk files. Reading any data from the partition would be possible only when it is
activated with the appropriate password. Encrypt the partition before you save any
data there—during encryption the whole content of the partition is formatted. If you
want to encrypt a partition with files and folders move them first to another location.
Only after you encrypt and mount the partition can you store data on it. This allows
you to encrypt partitions of external and internal disks, pendrives and other memory
devices.
One of the most important functions of TrueCrypt is the possibility to encrypt
the root partition where the operating system is installed. This allows you to have
more privacy than in the case of the encryption of a partition with data, especially
if the system partition contains applications and temporary files, which happens in
most cases.
Nowadays TrueCrypt also allows you to encrypt the entire disk containing the
system partition. The only disks that can be encrypted totally are those with the
operating system.
Disk partitions should be encrypted in the traditional way—this prevents the dif-
ficulties that can occur when you change the operating system on the encrypted disk,
[email protected]
170 6 PGP Systems and TrueCrypt
moreover it allows you to choose different passwords for each partition which in-
creases data security. The security of the system partition will be described below
according to the authors of the program. Disk encryption, however, does not differ
too much and should not cause many difficulties for those who decide to protect
data in such a way.
Sometimes a user or a computer owner will be forced to give the password to secured
data. Such a situation occurs very seldom to individuals, only when a crime happens,
but sometimes an employer can insist on disclosure of a password. The TrueCrypt
authors have taken such a situation into consideration. You can try to prevent it by
creating a so-called hidden volume (Fig. 6.29).
Hidden volumes are created in standard volumes, so such a volume must be cre-
ated first. Keep in mind one thing—you must not raise suspicions that a hidden
volume exists; the standard volume should consist of some neutral data which can
be revealed without any regret. When you choose the size of the standard volume
you have to take into consideration not only the data which will be hidden but also
the data which will be placed outside the hidden part. It is templity to compare the
hidden volume to a small safe with a combination lock placed in a larger safe—so
if you want to get the data from the small safe you must force open the lock to the
larger safe. Nothing could be further from the truth! If a container with a password
that can be broken in 20 years will consists of a hidden volume with a password
that can be broken in five minutes, to get the data from the hidden partition will
take someone who knows about it . . . just five minutes. This is because to reach the
[email protected]
6.3 TrueCrypt 171
hidden volume you do not have to break the password to the standard volume. The
latter is only a cover, but not an additional protection for the hidden volume.
The operating system sees the effects of TrueCrypt the way an outsider sees the work
of an artist who creates a masterpiece of surreal black and white blocks, scattered
around the room. Only the author of the work knows which blocks are a part of the
work, and which lie on the floor for “future use”. If you ask an artist to write some
information using their own cipher then only the artist will be able to read, it-more,
only the artist knows which blocks form the cipher, and which do not. In a situation
where in one room there is only one artist, there is no problem. It is worse when two
artists use the same laboratory and different codes. The problem is that one artist
can destroy the work of the other without realizing it.
The same happens with TrueCrypt volumes. If in the basic volume there is a
hidden one even the external volume will not realise that—so during editing of the
standard external volume there is a danger of overwriting hidden data. The appli-
cation is protected against such a situation by a function called Hidden Volume
Protection.
TrueCrypt lets you enhance the security of system files by using keyfiles (Fig. 6.30).
A keyfile can be any file on your computer, or a medium, e.g. a pen drive. The key
file forms a second line of security of your data, after the password. The password
is of course obligatory, while an additional indication of the file is not (generally a
well-constructed password should be enough).
The idea of a keyfile lies in the fact that TrueCrypt reads part of it and uses it as
a password. Deciphering the file then becomes impossible without a password and
an indication of the keyfile; both elements consist of a mechanism for protecting the
volume. There can be many keyfiles (then a fragment from each volume is taken).
The lack of even one ruins the chances of decrypting its content. This can be very
useful in certain situations. There can be many examples—for example, students
who finish school encrypt the only copy of pictures from the last school trip in the
volume, created on the basis of as many keyfiles as there are students. Each student
receives a keyfile. The volume is duplicated on CDs—everyone gets a copy of the
encrypted pictures, but no one will be able to use it until they all meet again.
The necessity to gather all the keyfiles, however, as it can be seen clearly from
the example, has a fundamental fault—we must assume that none of the files is lost,
damaged, or modified (the first megabyte of the file counts). Furthermore, since any
file can become a keyfile, there is a risk that the location of the file could simply be
forgotten.
[email protected]
172 6 PGP Systems and TrueCrypt
The best way to use a keyfile is to save it on any storage medium (CD, pen
drive, memory card, memory of a mobile phone) and put it in a safe place. You
can also use one keyfile for many volumes. This method prevents it from being lost
and even though technically it should be considered as less safe, it is probably the
most convenient. We advise you against storing a keyfile and a container on the
same medium, especially if there are only files stored on it—the reasons are rather
obvious.
6.3.6 Summary
TrueCrypt is a powerful encryption tool, which gives its users lots of options in
the field of data security. It is a comprehensive application that allows creation of a
single container-file as well as encryption of an entire partition (including the system
partition). The program is considered to be very stable and reliable—practically no
one reports the program hangs, let alone loss of data (excluding the user’s mistakes).
TrueCrypt cooperates with the user to secure the data. It has great potential, but
should be wisely used: the effectiveness of the program depends on the user—the
choice of a strong password and also the keyfiles. The program warns the user to
take all necessary precautions. Some precautions will influence the effectiveness of
the data security and some can prevent its loss. The risk of losing information is
minimal when the warnings and instructions are applied.
[email protected]
6.3 TrueCrypt 173
TrueCrypt is available free of charge. More importantly, the authors of the pro-
gram make it clear on their web site that they do not have the slightest intention to
commercialize it (as happens with many popular free programs). In the FAQ sec-
tion on the TrueCrypt official website the question was asked Will TrueCrypt be
open-source and free forever? The answer is Yes, it will. We will never create a
commercial version of TrueCrypt, as we believe in open-source and free security
software.
The advantages of the program:
• the program is free,
• it has the strongest current encryption algorithms,
• it is available for various operating systems (Windows, Linux, Mac),
• keyfiles can be used,
• the high stability of the program,
• it is portable—it can be run from a USB flash drive
• the ability to encrypt a disk or a system partition,
• clear interface,
• there are warnings and messages to prevent accidental mistakes,
• very good documentation on the official website.
The disadvantages of TrueCrypt:
• need to create and memorize the longest and most complex passwords,
• there is a risk of data loss in case you forget your password (or if a keyfile is lost),
• the load on the computer processor during the encryption/decryption of informa-
tion,
• time-consuming operations, especially formatting large partitions (in some ex-
treme cases, this process may take longer than a day, on average a dozen min-
utes).
[email protected]
Chapter 7
Public Key Infrastructure
This chapter briefly looks at a PKI network security infrastructure and its basic ser-
vices: entity authentication, message integrity, and confidentiality. It presents a PKI
structure, its basic components, and the tasks of Registration Authority (RA), Cer-
tification Authority (CA), key repositories, certificates and Certificate Revocation
Lists (CRLs).
[email protected]
176 7 Public Key Infrastructure
keys accessible to the other. You may do so using a web site, an e-mail or any other
form of electronic exchange.
A threat is that intruders can replace the transmitted public keys by their own.
Unknowingly using an inappropriate public key causes incorrect authorization of the
partner you communicate with. A Trusted Third Party is one of the possible ways to
make the information exchange system reliable and appropriately secure. Its main
function is to confirm the authenticity of public keys owned by users communicating
in the system.
A TTP can also inform us about any change of the keys in case of loss or theft.
This is why the idea of a Public Key Infrastructure was born. The three main com-
ponents of the structure are:
• a Registration Authority (RA) verifies and registers the user’s personal data,
• a Certification Authority (CA) issues digital certificates which testify to the au-
thenticity of a given person and their public key. Certification is preceded by the
applicant’s identification process,
• a Repository of certificates, keys and Certificate Revocation Lists (CRLs).
The idea of a PKI system is based on digital certificates issued by a CA. These
certify the authenticity of asymmetric cryptographic keys owned by a given person.
A digital certificate is an electronic document containing data which bind a per-
son and keys for generating an electronic signature and verifying its authenticity.
This gives the opportunity to verify the identity of a given pair of keys’ owner (a le-
gal person, a server, a website or a computer device). Detailed rules for building
certificates are specified by international standards. One of them, and currently the
most widely used is the X.509 standard.
Each certificate meeting the X.509 standard requirements contains the following
fields:
• a version number—defines the version of the certificate format,
• a serial number—the unique serial number of the certificate,
• an algorithm identifier—defines the algorithm used for signing a certificate and
the algorithm parameters,
• a drawer—contains the name of the Certification Authority which issued the cer-
tificate, and its duration of validity—stated as two dates; the certificate is not valid
before the starting date and after the expiry date,
• a person (user)—defines the person who received the certificate,
• public key—contains the user’s public key and defines the algorithm used by this
key,
• the signature of the Certification Authority—each certificate is electronically
signed by the Certification Authority it was issued by,
• a hyperlink to a website where one may download the CRL list.
[email protected]
7.3 Trusted Third Party, Certification Process 177
Since an Intruder can create a virtual Certification Authority you should ask the
question: who testifies the authenticity of this kind of institution? It appears that Cer-
tification Authorities also need authentication. They are certified by other authorities
specially assigned to this purpose by relevant legal and technological provisions in
a given country. Finally it is obvious that the root Certification Authority certifies
itself.
The Certification Authorities’ hierarchy, appointed by law as we mentioned be-
fore, forms what is usually called a certification path. Below a few possible schemes
of certification paths are presented—Figs. 7.1, 7.2, 7.3 and 7.4, cf. [68]. Notation
used in depiction: CAn —certification authority, Enm —end user.
The certificate shown in Fig. 7.5 (a printscreen from Internet Explorer) was is-
sued by Comodo Client Authentication and Secure Email CA for some e-mail ad-
dress. It provides information about what CA issued the certificate, for whom, and
[email protected]
178 7 Public Key Infrastructure
its lifetime window. The button Install the certificate makes a local copy of the cer-
tificate and places it in the relevant folder.
The Details tab (Fig. 7.6) contains all fields required by the certificates protected
for a chosen certificate: its serial number, etc. Choosing each of the elements you
may verify the information (e.g., a public key) or copy this information to a file.
Verification of a certificate consists of tracing its trust path, to a root authority
which is authorised by the relevant provisions. The authority certifies itself. The
Certification path (Fig. 7.7) shows us the certification path and the certificate sta-
tus. Signature verification consists remotely verifying the consecutive signatures
along the path chain of certificates. This action continues until the CA reaches a
so-called trust point. The trust point is specified by national policy and it is usu-
[email protected]
7.3 Trusted Third Party, Certification Process 179
ally a self-signed certificate of the Main Certification Authority. The chain begins
with a subscriber’s certificate and ends with a certificate of the Main Certification
Authority. If a certificate has expired or been canceled, a person who receives a
digitally signed message is automatically informed about the certificate expiry. The
information about the certificate expiry appears in the certification trust path.
EU law recognizes the concept of advanced electronic signature and qualified
certificate. They have different legal effects. An advanced signature based on a qual-
ified certificate has legal effects completely equivalent to a handwritten signature.
Below a brief characterization of qualified certificates is presented. Qualified certifi-
cates were introduced and defined by [39].
The validity lifetime of a qualified certificate is restricted to a maximum of two
years. A qualified certificate must contain the following fields:
1. the certificate’s serial number,
2. an indication that the certificate was issued as a certificate qualified to be used
according to a specified certification policy,
3. the subject providing certification services, the subject issuing certificate, and the
country where the subject is located, as well as a subject’s identification number
in a registry of qualified subjects providing certification services,
4. name and surname or a nickname of the certificate’s owner. Usage of a nickname
must be clearly indicated,
[email protected]
180 7 Public Key Infrastructure
7.4 PKI
The main task of a PKI, with its digital signature and the above-described certificate
systems, is to enhance the system security.
Figure 7.8 presents an exemplary PKI environment. Its most important compo-
nent is the main Certification Authority. As we have already seen there may be many
certification authorities but usually each of them, if it is required by law, is certified
by the main authority. Each certification authority performs the role of a trusted third
party.
The Policy Management Authority (PMA) is usually a group of specialists who
create the rules under which certification services are provided by Certification Au-
[email protected]
7.4 PKI 181
[email protected]
182 7 Public Key Infrastructure
• The validity of the certificate expires. This is a common situation connected with
the time limit. Without serious formalities and in a short time the change of keys
takes place.
• The private key (certified) has got compromised (stolen, lost). In such a case the
CA cancels the certificate by placing it on the CRL. The previous certificate loses
its validity and the procedure to issue a new certificate starts. The worst case
is the compromising of the root CA private key. In such a situation the whole
infrastructure should be rebuilt.
Mutual certification—in this case there is no superior international CA; the trust
is shared between the different PKIs. The root CAs from different PKIs certify each
other. This can be one-way or two-way certification.
Certificate revocation—this situation occurs when, e.g., the private key is re-
vealed, or personal data of the user (the name) is changed, or the employee leaves
the firm where he was given the certificate. The method uses the CRL, periodically
published in the repository where the certificates are stored. Every certificate has its
own unique serial number. The CRL contains the list of identifiers of all canceled
certificates and the timestamp.
Recovery of a key—in some PKIs there is an option to store some pairs of keys
with access to them in case of key destruction. The most important feature is to
ensure that the private keys can be recovered only by the owner.
Most software used today to secure computer systems enables cooperation with
PKI. These standards include:
• SSL (Secure Sockets Layer)—uses private keys and PKI to encrypt data. It is used
for example by Internet Explorer and other browsers. Many websites use SSL to
secure the privacy of such data as credit card numbers. Formally, websites which
use the SSL protocol start their domain names with https instead of http.
• S/MIME (Secure Multipurpose Internet Mail Extensions)—is a secure extension
of the popular e-mail standard MIME. The goal of the S/MIME project was to
enable the transmission of messages ensuring privacy.
• SET (Secure Electronic Transaction)—allows secure transactions to be carried
out without direct contact with the Internet, using credit cards. It is supported
by the two biggest credit card organizations VISA and MasterCard, and also by
IBM. SET extends the opportunities of SSL by introducing the identification of
the other side—the client. The protocol contains the identification mechanisms of
two parties. The possibility for a salesman to see the number of a credit card is
eliminated—encrypted credit card numbers are transferred directly to the organi-
zation responsible for the service.
• IPSec (IP Security)— ensures the confidentiality of packet exchange on the level
of an internet protocol. IPSec has two modes of encryption: Transport and Tunnel.
The Transport mode encrypts only part of the packet data and leaves the headers
untouched. More secure is the Tunnel mode which encrypts the packet data and
the headers. For the correct working of IPSec, public key exchange is required.
[email protected]
7.5 Certificates, Keys and Management 183
There are many vendors offering certificate services on the market. Each of them
enables different kinds of public key certificates to be downloaded. Among unqual-
ified certificates there are free certificates, which can be downloaded by any person
who has his/her own e-mail account. Below we present the process of downloading
such a free certificate and its configuration in the browser.
Generating and installing your own free certificate from some chosen CA begins
with downloading and installing the root certificate of the CA.
How a certificate is generated and downloaded from the CA’s website depends to
some extent on the selection of the CA. Various procedures can be applied. Some-
times this can be as simple as just downloading a form filled in on-line. Below we
present a more elaborate, but much more secure process consisting of six steps. It
includes a kind of verification of the user’s identity.
On the CA’s website find and select the Certificate of CA Main Office. In the
dialog window to download the files you can select Open, and then confirm with
the OK button. On the screen the window Certificate Manager appears. Then you
install the certificate in the operating system. Select the option Install the certificate.
Using the default settings of the repository, accept the next steps in the following
windows of the wizard. In the last window called the Certificate Manager Import
Wizard select Finish. The computer reports the correct installation of the certificate.
In the window Certificate Manager you can see the installed certificate by choosing
the tab Main trusted certificates drawers. Then in the same way you install the UC
Certificate class I. To generate your own certificate using the internet service you
have to configure your e-mail program. The process of generating and installing
your own certificate consists of six stages. Generating the certificate you begin by
finding a suitable certificate among those offered by the Center and selecting the
Download the certificate button (the offer for individual clients). Notice whether it
is free or paid.
• Stage 1. You fill in all the fields on the form according to the instructions. Before
going to the next Stage check that the form has been filled incorrectly.
• Stage 2. Finishing Stage 1 causes the completed form to be sent to the CA. The
CA then sends to your e-mail address a message containing the address of a web
page where you have to go in order to continue the certification. The CA checks
the authenticity of your electronic address. To continue the process of generating
the certificate you choose the address which is added to the message.
[email protected]
184 7 Public Key Infrastructure
In order to configure the certificate, open MS Outlook Express, in the main menu
choose Tools—Accounts.
Then, choose the tab Mail and check with one click your own account, and click
the Properties button (Fig. 7.11).
On the screen there is a window where you have to select the tab Security
(Fig. 7.12). In the window you have two sections. The first one: Signing certifi-
cate is responsible for signing e-mails, the second one is responsible for encrypting
[email protected]
7.5 Certificates, Keys and Management 185
[email protected]
186 7 Public Key Infrastructure
the messages. If in both cases the fields are empty, click the button Select in the first
section. The window Selection of the certificate appears.
In the Selection dialog window of the certificate you check your own certificate
(Fig. 7.13) and confirm with the OK button. Next, click the Select button in the
[email protected]
7.5 Certificates, Keys and Management 187
second section and do the same activities as in the first section. Your certificate is
now properly configured.
Access to the certificates of other people is essential to encrypt the e-mails to
them and also to verify their electronic signatures. There are several options to get
the certificates (the public keys) of other people. Below we present each of them.
The easiest way to obtain the certificate of another person is to receive a signed
message using the digital key of the sender. MS Outlook Express on getting the
message automatically adds the certificate of the sender to your address book (on
condition that the sender is added to the address book).
The other way to obtain the certificates of other people is to import the certifi-
cates and store them on your disk using Certificate Manager. In the main menu of
MS Outlook Express select Tools and click Options. Next, in the tab Security click
Digital identifiers. On the screen you will see the window of the Certificate Manager.
Click the Import button, and in the newly opened window of Certificate Manager
Import Wizard click Next.
In the next step, write in the access path of to the files with certificates or click
the Scan button (Fig. 7.14) and mark the file with certificates. Next, click the Open
button. In order to go to the next window, click the Next button.
The next dialog window lets you choose the repository (Fig. 7.15), where you
will store your certificate.
You have two possibilities: the first allows the computer to choose the repository
automatically on the basis of the certificate’s type; the second allows you to choose
the repository yourself. You can use the second option by clicking the round field
of Place all the certificates in the following store, and choose the Browse button
(Fig. 7.16). You choose the repository and click the OK button. In order to finish
the installation, click the Next button. In the dialog window you will see all the
information about the imported certificate. Then, click the Close button.
You can also use an LDAP server to import the certificates. You can use this
method when you know the address or the name of the LDAP server which stores
the certificate of the person with whom you want to correspond. The certificates of
people who used the service from the Certification Center are available on the server.
[email protected]
188 7 Public Key Infrastructure
[email protected]
7.5 Certificates, Keys and Management 189
To import certificates from the LDAP server you first have to configure it in your
e-mail program. From the main menu choose Tools and click the option Accounts
(Fig. 7.17). In the window which appears on the screen, click the tab Directory
Service and click the Add button, Directory Service.
On the screen there will be the dialog window of the Internet Connection Wizard,
where you write the name of the LDAP server (Fig. 7.18).
In the next window the wizard asks you if you want to check the e-mail addresses
using directory services. Click the window Yes, and then the Next button. The next
window informs you about the correct configuration of directory services, and by
clicking the Finish button you end the installation. Then, marking the appropriate
LDAP server in the dialog window Internet accounts you click the Properties button.
In the newly opened window you click the tab Advanced and the section Search. In
the field Search base you write the required parameter of search characteristics for
the given LDAP server. Click the OK button, finish settings and close the window.
[email protected]
190 7 Public Key Infrastructure
To import the certificates from the LDAP server, open the address book and click
the Find people button, or choose from the main menu Edit, and then click Find
people. The dialog window Finding people opens.
Next, in the field Search, choose from the list the name of the catalog service
defined by yourself. Fill in one of the fields: the Name or the E-mail address, which
are the criteria used in searching for the certificate. Next click the Find now button.
When you finish searching, the found certificate appears. Click the Add button and
import the found certificate.
Using an internet service is the easiest way to import the certificates. The only
requirement is that the recipient must have the certificate of the main CA in its own
certificate base. To get the certificate, connect with the chosen service, click the
link Verify the certificate, and choose the type of service. In our case it will be Test
security of e-mails. Then fill in one of two fields: the E-mail address or the Serial
number, and click the Check button.
After choosing the format for Internet Explorer the window opens with the ques-
tion, what you want to do with this file. Choose the option Open this file with the
current location, and then click the OK button.
If the certificate is installed properly a dialog window appears which presents
all the information concerning the imported certificate. The profile of certificates
issued by the Center conforms to recommendations of EU Law on electronic sig-
natures. Because the Center gives the certificates to different subscribers, who may
use them in many areas of activities, the Center may generate certificates with dif-
ferent profiles (which are defined for different types of certificates) as regulated by
the Center’s certification policy.
The simplest way to cancel a certificate is to visit the website of the Center and click
the link Cancel the certificate.
In the displayed window, you can choose the type of service, and type in your
e-mail, the password and the reason for cancellation; you then click the Cancel the
certificate button. The next window informs you about the cancellation of the certifi-
cate and about the publication of your certificate on the list of canceled certificates.
The lists of canceled and suspended certificates are stored in a special repository.
The repositories of information use a directory system. The recipients of certificate
services can have certificates issued, access the lists of suspended and canceled cer-
tificates and also electronic documents which are currently and previously in force
about the Certification Code of Conduct and the Certification Policy. The repository
is managed by the Center. Certification Authorities publish certificates, and the lists
of suspended and canceled certificates in the Repository.
The Center allows publication of information in the Repository, in accordance
with proper Certification Policy and valid legislation. The list of canceled and sus-
pended certificates published in the repository consists of:
[email protected]
7.5 Certificates, Keys and Management 191
[email protected]
Chapter 8
Cryptographic Protocols
This chapter gives some examples of cryptographic protocols that are interesting
and important from practical, theoretical, historical and didactical points of view.
It also presents the problem of the correctness and security of such protocols. It is
now known that several important cryptographic protocols, which were still in use
not so long ago, had some significant faults. It is worth analyzing them in order
to understand how surprising, at the first glance, attacks can be and how obvious
they become after the analysis. We are going to look at the very instructive history
of some versions of the Needham-Schroeder protocol for entity authentication in
computer networks—a story that illustrates very well all the most important issues.
Methods for verifying protocols (not only cryptographic ones) have been an area of
active research and practical applications in both academia and industry. One can
learn more about it from the website http://www.lsv.ens-cachan.fr/spore devoted to
cryptographic protocols.
Cryptographic protocols—algorithms that realize goals important for providing
security of electronic transactions and documents being sent—are widely applied in
computer networks, particularly in public key infrastructure systems during data ex-
change. Such protocols are widely applied as essential components of large systems,
such as commonly used communication systems. As examples of such protocols
consider Kerberos, SSL and Zfone.1
In general, a protocol is a concurrent program run on computers (or just on pro-
cessors) working together. Such programs carry out concurrent processes (some-
times called parallel or simultaneous—in contrast to sequential processes, i.e., those
whose program instructions are executed sequentially on one processor). One can
consider such processes as some number of sequential processes communicating
with each other from time to time by data (parameters) exchange or by using com-
mon resources. Cryptographic protocols are those that use encryption.
A cryptographic protocol can also be defined as a concurrent algorithm, deter-
mined by a sequence of actions performed by two or more entities, that allow one
[email protected]
194 8 Cryptographic Protocols
to realize a specified goal, with certain actions being performed by means of cryp-
tographic algorithms.
A protocol specification should contain:
1. the number of entities participating in the protocol,
2. the nature of their participation,
3. the aim of the protocol,
4. the actions of which the protocol execution comprises.
The main goals that should be achieved by cryptographic protocols can be:
1. mutual authentication of communicating entities,
2. confidentiality of sent information,
3. integrity of sent messages,
4. session key distribution.
Actions performed by the entities during a protocol execution can be divided
into internal and external ones. By external actions we mean those involving mu-
tual transmission of information between the entities. Specification of these actions
must define a definite source (sender) of each piece of information, a receiver (re-
cipient) of the information and of course its content, indicating respectively which
parts of the information have to be encrypted and how. Internal processes are all the
other actions that each entity performs on their own during the protocol realization.
These include, for example, generating new confidential information, encryption
and decryption of cryptograms, comparing parameters or performing mathematical
operations on parameters held locally.
Applying protocols in security systems must fulfill several requirements:
1. each user has to know the protocol and execute in the correct sequence all the
actions of the protocol,
2. each user has to agree to use the protocol,
3. each action of the protocol must be precisely defined, so that the users cannot be
confused about the method or the order of their executions.
[email protected]
8.2 Reliability 195
8.2 Reliability
Since cryptographic protocols are usually relatively short and simple, an informal
reasoning is often applied in order to justify their reliability and to convince all their
users that the protocols meet the declared goals. However, when a protocol can be
performed simultaneously (concurrently, in parallel) several times and its executions
can interleave on the same computers and the role of some entity may alternate in
different executions (she may act as an initiator or as a responder), then the analysis
of such a protocol gets very difficult. Asynchronous composition and interleaving
runs are complicated enough, additionally one has to take into account the analysis
of individual entities’ knowledge at various stages of each run of the protocol. In
other words, knowledge about private keys and freshly sent/received information
has to be taken into considerations.
[email protected]
196 8 Cryptographic Protocols
Some of the presented protocols, seemingly correct, turned out to have flaws. The
problem lies in possible protocol runs or their interleavings which were unexpected
by the authors of these protocols. Such behaviours or interleavings of behaviours
are called attacks. However, an attack does not always mean a discrediting error and
a complete compromise of the considered protocol.
For this reason, there is the challenging motivation for researchers and engineers
to develop methods to verify protocol correctness. This is a non-trivial task, since it
is not easy to define formally the objective of verification and the property of cor-
rectness. Different protocols are used for different purposes and are specified in dif-
ferent languages. Therefore, it is not clear whether one formalism could describe all
possible cases. Let us mention only that the first methods in this area concerned ver-
ification by means of specially constructed deduction systems, called BAN authen-
tication logics (Burrows-Abadi-Needham [23]). Since the early 1990s, they have
been used to detect flaws in entity authentication protocols. However, it has turned
out that even positively verified protocols may still be vulnerable to attacks. Over
the last two decades, researchers from numerous academic and commercial centers
have been extensively developing methods for cryptographic protocol analysis with
the aim of constructing tools for automatic or semi-automatic verification of the
basic properties of such protocols, as well as tools for their systematic design and
validation. One of the most interesting verification methods is the technique called
model checking. This issue will be the presented in the next sections.
In 1978 Needham and Schroeder [69] published a pioneering paper in the area of
authentication protocols. Its authors presented an idea of using cryptographic tech-
niques to solve the problem of entity authentication in network communication.
They also proposed schemes of authentication protocols that use symmetric and
asymmetric cryptography.
In what follows, symbols A and B denote the identifiers of two users who wish
to communicate securely with each other. The symbol S stands for a server—a third
party that is fully trusted by the users. By EKA (X) we mean a ciphertext containing
a message X encrypted with the public key of user A, while E KA (X) denotes the
respective ciphertext encrypted by A’s private key.
The entity authentication protocols use so-called nonces, i.e., unique and non-
repeatable large pseudo-random numbers generated and used for only one execu-
tion of a protocol or communication session. The term nonce is an abbreviation of
number used once.
The randomness of these numbers aims to ensure that no one has ever known or
used any of them before, and in practice (i.e., with a sufficiently high probability) it
is unfeasible for anybody to reconstruct the used nonce. In this sense it is said that
the information is fresh. Such numbers will be denoted by NA (a nonce generated
by A) and NB (a nonce generated by B). Typically, a nonce serves as a time-variant
parameter to prevent unauthorized or undetectable replay.
[email protected]
8.2 Reliability 197
[email protected]
198 8 Cryptographic Protocols
Due to the structure of data transfer used in the protocol and the properties of
asymmetric cryptography, after executing the protocol participants A and B declare
mutual authentication successful. Let us also pay attention to the fact that after the
protocol execution both users can also be sure that they are the only holders of the
numbers NA and NB and they can use them as identifiers of the current session in
further communication.
Let us notice that the above protocol can be simplified. Assuming that each user
already knows the public key of the other entity, the protocol can be presented in
three steps (Fig. 8.2):
1. A → B : EKB (NA , A)
2. B → A : EKA (NA , NB )
3. A → B : EKB (NB )
The story of this protocol is very instructive. It was used in practice in its original
version for 17 years. However, in 1995 it turned out that the protocol can be broken.
Gavin Lowe, a professor at the University of Cambridge, presented an attack on the
protocol, i.e., a run of it that does not fulfill the aim of the protocol, namely mutual
authentication. See [64].
The attack is performed by an intruder denoted by I . Below we present the attack
given by Lowe. After its execution one of the entities is deceived as to the identity
of another participant.
α1. A → I : EKI (NA , A)
β1. I (A) → B : EKB (NA , A)
β2. B → I (A) : EKA (NA , NB )
α2. I → A : EKA (NA , NB )
α3. A → I : EKI (NB )
β3. I (A) → B : EKB (NB )
The above run consists of two simultaneous interleaving executions of the proto-
col. Steps α correspond to communication of an honest user A with an intruder I ,
who impersonates A (we denote it by I (A)) during steps β. In the step α1, A starts
communicating with I . The latter, however, abuses A’s confidence and improperly
uses the nonce NA , given to I by user A, in order to start a session with B (the
step β1). According to the protocol, B sends a ciphertext EKA (NA , NB ) to I (be-
lieving it is A). Of course, I is not able to decrypt this ciphertext, since it does not
know the private key of A. Therefore, the intruder forwards the message to A (the
[email protected]
8.3 Needham-Schroeder Symmetric Key Protocol 199
step α2). Unaware that anything is wrong, A decrypts the ciphertext, obtains the
number NB , encrypts and sends it to I (the step α3). Now, I is able to decrypt the
message and knowing the value of NB sends it to B (the step β3). After that, B
is convinced he is communicating with A, while in fact B exchanges information
with the intruder I . In further conceivable communication, the intruder may use the
numbers NA and NB , for example, to deceive B. An attack like this, using an honest
user’s information is called a replay attack.
A fixed version of the protocol, also developed by Lowe in [64], is as follows:
1. A → B : EKB (NA , A)
2. B → A : EKA (NA , NB , B)
3. A → B : EKB (NB )
The modification affects the second step. Simply adding the responder’s identifier
B to the ciphertext EKA (NA , NB , B) excludes the possibility of its deceptive use by
a potential intruder. This, as it may seem, easy correction defends the protocol from
the attack presented above and from any attacks known previously. The Needham-
Schroeder protocol revised by Lowe has successfully passed all correctness tests
invented so far. At the same time, this version of the protocol is the favorite toy
example tested in the best academic and corporate research centers by new programs
and tools for cryptographic protocol verification.
Needham and Schroeder also proposed a protocol in which entities establish sym-
metric keys for use in the current session. Moreover, the protocol needs to provide
mutual authentication. Let us suppose that A and B do not know each other. In par-
ticular, they do not know each other’s public keys; however, they can take advantage
of a trusted entity (represented usually by a server, not necessarily a human). Before
communication each participant specifies a cipher and a secret key used for secure
communication with the server. The protocol is as follows:
1. A → S : A, B, NA
2. S → A : EKA (NA , B, K, EKB (K, A))
3. A → B : EKB (K, A)
4. B → A : EK (NB )
5. A → B : EK (NB − 1)
User A requests a session key from the server in order to start communication
with B. Therefore, A sends to the server its name (identifier), the identifier of B, and
a fresh nonce generated by A. This nonce will later allow A to verify whether the
response of the server is a repetition of any previous request. The server generates
a key and prepares an encrypted package consisting of the nonce generated by A,
the identifier of B, the key, and the same key along with the identifier of A (the so-
called ticket)—both encrypted with the secret key of B. The whole package is sent
[email protected]
200 8 Cryptographic Protocols
by the server to A, who is the only one able to decrypt this message. However, user
A cannot decrypt the ticket, which is forwarded by A to B. The latter is informed
that A wants to start a communication session. B obtains the symmetric key to be
used in the session. In order to find out whether A is still alive and whether A is
ready for communication and has the right key, B sends its own nonce encrypted by
the key just proposed by A and verifies that A is able to decrypt it, transform and
encrypt this nonce.
Thus, A and B have established a one-session key. Moreover, they know that
the communicating entities are really A and B. This knowledge follows from the
assumption that they are the only ones who are able to decrypt the key encrypted
by the trusted third party. Furthermore, they know that all information being sent is
fresh, i.e., A knows that the information obtained from the server constitutes a reply
to its last request to establish communication with B. Since user A has proven that
it knows the shared session key, this is known to B. Nonetheless, the protocol is cur-
rently considered as incorrect. Why? In the practice of encrypted communication,
it is assumed that the key is established once in a session and it stays undisclosed
during this session only. Everlasting secrecy is not assumed. First, the key may hap-
pen not to be strong enough and insufficiently resistant to possible future attacks,
and thus it could be broken through extensive computations. Secondly, no user has
full control over its own computer. For instance, in case of a disk failure a computer
may be serviced in a repair center and it may turn out that a session key used several
weeks ago lies in a swap file. Security of communication channels is usually based
on the fact that knowledge of used key that was already applied is useless—the
exchange of messages is over and a potential new session should use a new key.
Let us look more closely at the above protocol. In step 3 A sends to B a session
key K encrypted with the key KB , which is not known to A. Let us suppose that
the intruder I was able to find some traces of an old session some time after it had
taken place; for this session I knows both the ticket with the encrypted key and the
key itself. Moreover, let us assume that I can impersonate A in the network. I can
now repeat the protocol twice, starting with step 3:
3. I (A) → B : EKB (K, A)
4. B → I (A) : EK (NB )
5. I (A) → B : EK (NB − 1)
In step 3 the encrypted key along with the identifier of A to B. Then user B con-
siders this to be an attempt of A to start a new communication session, so in step 4 B
wants to check that the receiver also knows the session key. B cannot verify whether
A or I is the receiver of the message and the holder of the session key. Therefore,
B gets deceived. The key being repeated twice does not make B suspicious—for
at least two reasons. First, B does not keep used session keys. On the contrary, the
possibility of reusing them is risky and dangerous, so they should be deleted imme-
diately after being used. Secondly, the former execution of the protocol could have
been unfinished. It may have happened that A had wanted to communicate with B,
but the session was not established. Maybe there were some disturbances, maybe
A changed its mind, maybe, finally, there was not enough time for communication.
[email protected]
8.4 Timestamps 201
And now B does not know whether such a session key has ever been proposed or
used.
What can we do about it? For example, introduce timestamps.
8.4 Timestamps
Nonces are used in order to provide a kind of marker of each execution of a proto-
col. Nonetheless, nothing prevents us from repeating or resuming the protocol after
a long break—the notion of time does not occur in the above protocol at all. In order
to avoid a replay attack one can assume that cryptographic keys are not fixed once
and forever, but they have some definite lifetime. When the time expires the keys
have to be refreshed, i.e., generated once more. Usually this is done by a server of
a specialized service provider, called a trusted third party. The generated key can
be equipped with the exact date and time of its creation and a certificate including
all important information, for example the lifetime window. Issues concerning syn-
chronization of the clocks of the participants who use such dated keys can be solved,
for example, by special technical components supplied by the service provider.
A timestamp is a sequence of characters denoting and recording the actual date
and exact accurate time at which a certain message was created, modified, stored,
or sent. A digital timestamp can be appended automatically to a message file. The
problem is that the local system administrator can reset the system clock to any
value he or she likes. One can generate timestamps that have nothing to do with
the actual real time that the message is processed. Trusted timestamping is a reli-
able service which sets the actual exact time in such a way that no one can alter it
without detection once it has been recorded, provided that the timestamper’s secu-
rity and integrity is never compromised. Usually, the service involves management
infrastructure to collect, process and renew timestamps, together with publicly avail-
able digital timestamp certificates, revocation lists, and verification procedures. The
most accurate timekeeping devices are atomic clocks, which are accurate to seconds
in many millions of years, and are used to calibrate other timekeeping instruments.
A message being timestamped does not have to be released to anybody to create a
timestamp. It suffices to timestamp its hash (fingerprint) value. In the cryptographic
protocol context, timestamps are typically used for marking freshness of protocol
step messages, preventing replay of old ones. That is why nonces were introduced
above as a kind of time-relevant parameter. In some cases, a time-relevant parameter
can be just the numbering of events. Then a date-and-time format is not necessary.
See [3, 8, 37, 102] for basic security requirements for effective use of trusted
timestamps as a reliable time source that is provable to any interested party.
The most famous and currently most often used in practice authentication pro-
tocol that uses timestamps (timed entity authentication protocol) is Kerberos (see
[68]). We present it in detail in Sect. 8.6. Here, we only point out that timestamps
can play a role similar to the nonces in the Needham–Schroeder protocol.
1. A → S : A, B, NA
2. S → A : EKB (K, L, A), EKA (NA , B, K, L)
[email protected]
202 8 Cryptographic Protocols
[email protected]
8.6 Kerberos System 203
In order to prevent such attacks, one can apply certificates. If A cannot obtain the
public key of B via a trusted channel, they have to rely on a certificate issued by a
trusted certification authority.
[email protected]
204 8 Cryptographic Protocols
In the following example, a trusted party acts as a server called the Authentica-
tion Server (AS) and as a server that assigns tickets—the so-called Ticket Granting
Server (TGS). By EKAB (A[address], TA ) we mean a package from a user A con-
taining the name of this user, possibly its address, and a timestamp encrypted with
a secret key shared by users A and B. The symbol NA stands for some pseudo-
random number of A; the lifetime is a suggested validity period of the session key.
The timestamp is denoted by TA .
The authentication protocol enables mutual authentication of users. It is assumed
that users A and B wishing to run the one–way or mutual authentication procedure
share a secret key KAB . Figure 8.3 illustrates a simplified version of the protocol.
In order for A’s identity to be authenticated by B, the user A prepares so-called
authentication package which includes: its name (possibly its address) and a times-
tamp TA . The package is encrypted with the key KAB shared by A and B, and then
it is sent to B. The latter decrypts the received package and checks whether it re-
ally contains the name of A. If the address of the sender is included in the package,
then it is possible to verify whether this address corresponds to the address from
which the message was received. Next, user B checks the validity of the package
(if it has not expired) by comparing the timestamp with the current time. If mutual
authentication is required, then the user B executes an established operation on the
timestamp obtained from A (increases it by a specified value), encrypts the result
with the key shared with A, and sends it to the latter. A decrypts the received mes-
sage, checks whether the timestamp was modified by the set value. Executing the
protocol above, the entities verify each other identity. The authentication protocol
is based on the assumption that the parties performing the protocol share the secret
key KAB . If this assumption is not satisfied, then the protocol cannot be executed.
If the user A were able to send the secret key KAB to user B via a trusted channel,
then the problem would be solved. In order to send a secret session key, the key
distribution protocol is used.
The key distribution protocol (Fig. 8.4) assumes that in the network there exists
a trusted computer, which serves as a center of key distribution and key genera-
tion (denoted below by C). Each user shares with the center a secret key, called the
primary key of the user (for A it is KAC , for B—KBC ). When user A wants to com-
municate with user B, A sends to the key distribution center a request to generate a
session key for them.
The center generates a key KAB and two messages: the first one, denoted by
CAB , is called the certificate, while the second, denoted TAB , is called the ticket.
[email protected]
8.6 Kerberos System 205
The certificate contains, among other things, the session key KAB intended for users
A and B, and it is encrypted with a key KAC shared by A and the center. The ticket
includes KAB , and it is encrypted with a key shared by B and the center, namely
KBC . These two messages are received by A. Then, applying the authentication
protocol, the user A decrypts the certificate using its main key KAC and they get the
session key KAB from the certificate. A prepares an authentication package for B,
encrypting it with the session key KAB , and sends it along with the ticket obtained
from the center. Now, the user B is able to decrypt the ticket with its main key KBC
and to get the session key KAB . Therefore A and B may share a secret key and it is
possible to carry out an authentication process.
In the key distribution protocol, a request for session key generation, which is
sent by A to the center, contains, beside the names (and possibly addresses) of users
A and B, some random number NA and a suggested lifetime of the session key L.
Such a solution is meant for protection against replay attacks. The idea is to pre-
vent an intruder impersonating the center from sending to A a certificate that has
already been used by the real center and intercepted by the intruder. Each request of
A has to be answered with a certificate containing the same number that is included
in the request. Since each user may send several requests for a session key, data
sent in the certificate includes the name of the end-user. The username included in
the certificate informs A which request has been answered with this certificate. The
latter also contains the lifetime of the session key. The ticket sent to A (and ulti-
mately to B) contains, among other things, the name of A. The user B can compare
this name with the name included in the authentication package. The situation with
the address is analogous. Moreover, the ticket contains the session key KAB and its
lifetime.
A single sign-on protocol (Fig. 8.5) is used in order to replace weak keys (usu-
ally passwords readily used by humans) by strong random cryptographic keys. The
protocol is based on sharing of a secret password by all the users. This may be, for
example, a shared key (e.g., KAAS ). The server knows the passwords of all users
and shares the secret key with the TGS. The task of the authentication server is to
generate keys for users who share these keys with the TGS. The protocol works
analogously to the key distribution protocol. The user A requests the authentication
server to generate a key for them and the TGS. The authentication server generates
a key KAT GS and sends it as one of the components of the certificate CAT GS of the
TGS encrypting it with the key of A. The key KAT GS is included also in the TGS
ticket TAT GS , which is encrypted with a key KAST GS shared by the authentication
server and the TGS, and sent along with the certificate. The remaining information
sent within the protocol is used in the same way as in the case of the key distribution
protocol.
[email protected]
206 8 Cryptographic Protocols
Now, after having encrypted the certificate with its key, the user A shares the
secret key KAT GS with the TGS. By means of this key A encrypts the authentication
package and sends it to the TGS along with the ticket TAT GS and a request for B’s
ticket to the server. In this way the user A is authenticated by the TGS. Since the
ticket TAT GS is used by A in order to obtain a ticket to the server from the TGS, it
is called a ticket granting ticket (TGT). It is worth mentioning that the password is
not sent through the network from a client to the server, which increases the system
security.
[email protected]
8.7 Verification of Correctness of Cryptographic Protocols 207
a device that resembles a credit card. The identifier (ID token) is synchronized with
the server and its value is displayed by the device. The user enters this value at log
in. The original version of Kerberos applies techniques of symmetric encryption.
Some producers, however, implement similar public key schemes.
Kerberos was designed to operate in a particular environment, where it worked,
and was used to authenticate users working on workstations for individual entities
applying resources provided by large and secured servers. However, many comput-
ers operating on the Internet are multi-user systems. In the case of such systems
some problems arise. One of these is associated with the necessity of storing keys
and tickets in the operating system—in a multi-user environment these are exposed
to some risk related to the presence of other users in the system. Another problem
concerns diskless workstations. This means keys and tickets must be sent through
the network in plaintext, in order to keep them on the outer disk. Transmitted data
are vulnerable to interception by an intruder. When dealing with other environments,
some modifications should be carried out in order to adapt the system to specific fea-
tures of work. Kerberos Version 5 went through implementation on various types of
computers and different operating systems. Among them there are Sun computers
running Solaris, HP9000 machines running HP-UX, IBM PowerPC with the AIX
system, Macintosh computers and PCs with MS Windows.
In this section we will briefly present the most important ideas and problems con-
cerning verification of correctness of cryptographic protocols, i.e., verifying whether
they really do what their author and users expect. Nowadays, methods of verifying
software correctness form a wide area of practical and theoretical computer science.
Often, even with the best of intentions, it is hard to imagine all possible runs of a
program.
When dealing with reliability (correctness) of cryptographic protocols, we as-
sume that applied ciphers are absolutely reliable (secure). Furthermore, we also as-
sume that no one is able to read an encrypted document unless they have a proper
key. Cryptographic protocols often make use of the fact that the relevant information
has been created recently. It is said that the information is fresh. As indicated above,
freshness is ensured, e.g., by generating a new nonce each time. Again, when veri-
fying protocols we assume that an intruder cannot guess a recently generated nonce.
The use of timestamps is associated with numerous technical problems, such as
the necessity of reliable clock synchronization. Protocols that apply timestamps are
more difficult to verify. Actually, all verification methods known until very recently
consider timestamp values, i.e., the time of transaction, as yet another number used
once. Their order expresses, in some sense, the flow of time.
In order to verify cryptographic protocols, we may apply general-purpose tools
for software correctness verification that are intended for all programs, not necessar-
ily for cryptographic or concurrent ones. An overview of such tools can be found,
[email protected]
208 8 Cryptographic Protocols
for example, in [9]. However, the complexity and the importance of the problem
usually require the use of specialized tools. In general, there are four methods of
verification:
• (real and virtual) system testing,
• inductive methods,
• axiomatic (deductive) methods,
• model checking.
Testing does not usually apply to cryptographic protocols, but the other methods
do. It is worth recalling that verification need not prove correctness of the protocol.
It can indicate examples of failures or flaws in the analyzed protocol, preferably
by giving an instance of interleaving correct performances of the protocol which
result in misleading one of the entities as to the identity of the other party. Such an
interleaving is then an example of a successful attack on the protocol.
A formal definition of the property of correctness is already difficult. For in-
stance, since the aim of a protocol is to confirm identity, then this should be covered
in the protocol specification. The point is that such a formulation is given in an
everyday conversational language and there is no way in sight of expressing this
property in any formal language. But only formalized properties can be a subject of
formal verification.
[email protected]
8.7 Verification of Correctness of Cryptographic Protocols 209
formulas are true if and only if they are theorems of this logic. Without a complete
semantics users of the BAN logic were not able to prove formally that some formula
is not derivable from another one in this system. In general, such a proof consists
of constructing a model in which the first formula is false while the second one
is true together with all the axioms of this logic. The first complete and decidable
BAN-type logic was presented in [60].
The inductive method was proposed by Larry Paulson. In this method all possible
traces of protocol runs are taken into consideration. A trace is a sequence of steps of
type A sends a message M to B. The number of possible traces is infinite, since there
is no restriction on their length. Our aim is to prove that some interesting property
[email protected]
210 8 Cryptographic Protocols
8.7.4 Results
[email protected]
8.7 Verification of Correctness of Cryptographic Protocols 211
8.7.5 Summary
[email protected]
212 8 Cryptographic Protocols
[email protected]
Chapter 9
Cryptographic Applications for Network
Security
9.1.1 PEM
PEM (Privacy Enhanced Mail), the email system with the highest level of privacy,
was one of the first standards for securing email. This term was defined by the IETF
committee (Internet Engineering Task Force) in RFC 1421–1424, as a method for
[email protected]
214 9 Cryptographic Applications for Network Security
7-bit text encryption. Most often it is used in connection with the internet SMTP pro-
tocol (Simple Mail Transfer Protocol), but also other email protocols (e.g. X.400).
The main characteristics of PEM are:
• It is not limited to a definite server or software and allows cooperation between
many different systems.
• It is compatible with a simple insecure email.
• It enables the security of email privacy in newsgroups.
• It is compatible with the different methods of key management.
• It is compatible with many protocols, email systems and email applications.
PEM supports all the essential email security functions: security and privacy,
authentication, message integrity, undeniability, key management.
Sending a PEM message takes place in four stages:
1. Standardization—the transformation of the message from the format of the email
program into the standard PEM format, which is recognizable on each platform.
2. Insertion of the information which enables us to check the cohesion of the mes-
sage and the authentication of its author.
3. Encryption (optional).
4. Transmission coding (optional).
Receiving the PEM message is a complicated operation, so every implementation
does it instead of the user. Receiving the message consists of 5 stages:
1. Decoding—the reverse of coding if it was used in the message.
2. Decryption—if the message was encrypted then it must be decrypted.
3. Checking the cohesion and the authenticity of the message.
4. Transformation from the PEM format into a suitable form of the recipient email
program.
5. Disposal of the message—the recipient decides about the form of the saved mes-
sage (encrypted, encoded).
9.1.2 S/MIME
The S/MIME alternative system of email security is the extension of securing mech-
anisms of the MIME popular email standard (Multipurpose Internet Mail Exten-
sion). MIME, defined in 1992, is the standard used to send different types of data
via email. Traditional emails include only text. MIME specifies the standard means
of coding different data, e.g. binary files, multilanguage alphabets, pictures, sounds
and files written in special forms (e.g. compressed files). This standard enables us
to use a special set of fonts in emails. The original specification of the S/MIME
project allowed us to send the messages without sharing their secrecy. Because the
new standard is the extension of a previous one it is easy to integrate it with existing
products to send the emails.
[email protected]
9.1 Application of Cryptography to Internet Mail Systems Security 215
[email protected]
216 9 Cryptographic Applications for Network Security
We create a new message, sign it and encrypt. Then such a message is sent. The
recipient having an appropriate certificate can read the message.
9.1.3 MOSS
Together with the MIME standard, which enables us to send binary attachments by
email, the value of the PEM system was decreased. PEM was extended and a MOSS
(MIME Object Security Standard) protocol appeared. It is compatible with PEM and
also serves binary attachments of the MIME standard. But its implementation and
usage is not easy. More popular is the S/MIME standard, which is implemented in
most cases by email users.
[email protected]
9.2 Security of Document Interchange 217
In such a way arose the need to develop a system which can be used to connect
some firms, independently from the local system. EDI, Electronic Data Interchange,
thus originated.
9.2.1 EDI
This product is a system for electronic commercial information interchange in the
form of orders, invoices, and consignment notes. It is used in a client-seller system.
It enables us to send orders directly into supplier computers. It coordinates the de-
livery and generates the invoices. It works on the principle of saving the message
and sending it into the proper recipient as in the case of email. Using an EDI system
reduces the cost of work and decreases the number of mistakes during the exchange
of documents in person. This system is implemented in firms connected with distri-
bution, bookkeeping, finance, production, storage, transport and shipping.
The first versions of the EDI system would define standard documents, which
forced the users to generate their own personal forms. New versions enable us to
create any documents using simple tools. The system users can operate on different
versions of the internal software. EDI changes automatically the document format
of the sender into the standard one. The client version is changed from the EDI
standard into the one required in the firm. In the USA, DISA (Data Interchange
Standards Association, Inc.) deals with the standardization of electronic data in-
terchange. The page http://www.disa.org is a compendium of useful information
about EDI and its structures. Information about the specification of the standard is at
http://www.x12.org. X.12 is the American document standard covering air transport,
requests for loans, consignment notes, bills. In 1979 the American National Stan-
dards Institute designated the ASC X.12 committee (Accredited Standards Commit-
tee) as responsible for the EDI standards development. X.12 ensures the compatibil-
ity and transferability of documents between different system platforms. The docu-
ments sent from home PC computers are smoothly read by mainframe or Macintosh
systems. The international standard for electronic data interchange is UN/EDIFACT
(United Nations/Electronic Data Interchange for Administration, Commerce and
Transport). EDI INT is the suitable standard for the Internet.
Most corporations noticed that the cost of EDI implementation in the Internet
is smaller than building their own large systems. The Internet serves as a place for
exchanging commercial information. The costs of installation are lower and most
businesses have Internet access. As a result smaller businesses, which traditionally
found the costs of EDI implementation to be too much, can now economically use
this facility to conduct transactions with their partners where before it would only
have been possible via email.
9.2.2 OpenEDI
ISO (International Organization for Standardization) and IEC (International Elec-
trical Committee) created the Open-EDI committee. The aim of the committee is
[email protected]
218 9 Cryptographic Applications for Network Security
to help with business contacts over the Internet and to ensure suitable security.
Open-EDI uses the Internet as the electronic platform for business information inter-
change. Thanks to modern standards they eliminate the need for the conversion and
the translation of sent documents. The Internet helps to reduce the implementation
of both costs and equipment to businesses. Despite the reduced cost and reduction
of equipment required, the Internet delivers a very high value service. The diversity
of the applications offers many possibilities. By email the inquiries can be sent, and
then new contacts can be made.
Most systems develop integration with the Internet but face the difficulty con-
nected with the transferability of the documents and the standards between the
previous users of EDI and others with whom they had no contact. There are ser-
vices which ensure the appropriate conversion. The most common conversion is the
SMTP email protocol. The fast growth of technology leads to the unification of the
standards.
9.2.3 OBI
Another solution can be OBI (Open Buying on the Internet). It is a protocol com-
piled by American Express and Supply Works in order to carry out WWW trans-
actions in real time. Microsoft, Netscape, Oracle, Open Market and many others
support this specification. The aim of this project is to reduce the cost and to im-
prove the customer shopping experience by improving the level of service. Using
the OBI protocol gives many benefits like EDI. The structure of the documents and
the methods of sending the data use the EDI X12-850 specification. Transactions
require electronic authorization, so the firms receiving the orders can verify their
authenticity.
Some specific standards have arisen for proper lines of business. The best known is
SWIFT (Society for Worldwide Interbank Financial Telecommunications)—the in-
terbank settlement system. In Europe the ODETTE standard appeared (Organization
for Data Exchange by Teletransmission in Europe) because of the car industry. The
United Nations decided to continue the EDI standard based on a uniform pattern for
different business documents. The blocks of combining information should always
be put into specific places in documents, and information fields should be filled
in according to the Trade Data Elements Directory. In 1986 working group No. 4
RKG/ONZ, which deals with this technology, for the first time used the name United
Nations Electronic Data Interchange for Administration, Commerce and Transport,
the UN/EDIFACT or EDIFACT for short. EDIFACT concerns only the message
structure not the transmission. It uses 5 basic tools:
[email protected]
9.2 Security of Document Interchange 219
EDI is the system where the application of the sender takes the information from
its own database, places it encoded in a proper structure, and sends it through the
telecommunications network to the recipient. The application of the recipient re-
ceives, translates and sends the content of the message to its own database. The
computer systems of the sender and the recipient can be different and it is important
to read and interpret the sent structure. To properly use Electronic Data Interchange
it is important to define the structure of the electronic message. The message in-
cludes all the data of a traditional document, arranged in a proper form. When the
structure of this message is settled we have the following steps of message inter-
change (Fig. 9.3).
1. In the internal system of the A firm there is the set of data. Appropriate software
generates the intermediate form, the so-called internal message.
2. The internal message is converted into the arranged standard of the data inter-
change and ensured using suitable translating applications.
3. The translated message is sent into the system of the B firm.
4. The message in the EDI standard is changed into a proper intermediate form
interpreted by the system of the B firm.
5. The internal message is fetched by the application of the B firm.
[email protected]
220 9 Cryptographic Applications for Network Security
Fig. 9.3 The circulation of the document using the EDI standard
All stages are executed automatically, the duration of sending the message is
incomparably shorter than the traditional form of a document interchange.
This subsection presents SSH (Secure Shell) and SSL (Secure Sockets Layer) pro-
tocols as the network information security mechanisms. It describes the protocols’
operating principles and their practical implementations.
9.3.1 Introduction
Servers in the environment of TCP/IP protocols provide services through the ports.
Protocol ports are labeled with integers from 1 to 65535. When a connection is
established between two computers, a so-called socket is created on both machines.
The socket is closely associated with the port number assigned to the application.
A socket may be compared to a telephone and a port to a telephone number. The
most popular services have fixed permanent numbers and software companies agree
in this respect. The most common ports are: 80, http (WWW) server; 21, FTP server;
and 22, SSH server.
An architecture which is often used on the Internet is the client-server architec-
ture. In this method the server provides services to a number of clients, therefore it
is characterised by a respectively high efficiency. Clients are those that use HTTP
services or display WWW sites, and servers accomplish their requests and provide
relevant sites. Servers are able to accomplish different types of services. They make
calculations, store files, verify logging into a system, or they act as a print server.
[email protected]
9.3 Computer Network Security—SSH and SSL Protocols 221
The Internet allows us to connect with and use remote computers and servers.
Until recently the most common method was to use the telnet protocol based on
port 23. The method is based on a client-server architecture. A user who wants to
connect is a client (telnet application), a computer which provides this service is a
server (telnet daemon). The service used to be very popular but it has one disadvan-
tage. The user name, password and transmitted text are unencrypted; so, a potential
phisher may capture this information. Figure 9.4 shows a captured TCP/IP frame of
the telnet protocol. Everyone can see the content of a message in this way.
A service extended by the ability to encrypt connections is the SSH protocol using
port 22. The user who establishes the connection is the client (SSH application is
required), a remote computer is the server (SSHD daemon is required).
There are two versions of SSH available. It is important to note that the protocol
versions are not compatible with each other. The SSH Communications Security
Company (http://www.ssh.com) does not recommend the use of SSH1 for security
reasons.
The SSH1 protocol assumes that the server accepting SSH connection possesses
a unique RSA key (host key). Its length is 1024 bits. An additional key (server
key), the length of which is 768 bits, is generated at the time of starting the SSH
daemon. This key is reproduced periodically after each use. The client connecting
with the server receives a pair of keys. On the grounds of the host key, the client
verifies the server identity (checks if the obtained key is in the local database—if not,
the client fetches the key). Then a random 256-bit key (session key) is generated.
[email protected]
222 9 Cryptographic Applications for Network Security
This key is enciphered with the host key and server key and sent to the server. The
server deciphers the key with its own keys. The obtained session key is used to code
connections symmetrically.
Among all algorithms used for coding, there is the 3DES algorithm. The algo-
rithm is chosen by the client.
Identification of users may proceed according to the following rules:
1. If the computer’s name, used by the client to log in, is in hosts.equiv or
shosts.equiv file on the server and the user’s name is the same as the computer’s,
then the user logs in correctly.
2. If on the server in the user’s home directory there are .rhosts or .shosts files and
if they contain the computer’s name (from which the client is connected) and the
user’s name, then the user logs in correctly either.
Because both of these methods are unreliable they aren’t usually used. Another
method of authentication is a mechanism which uses the public key. On the server
there is a list of public keys which are used for connecting. The client determines
the key which is used to authenticate its credibility. If the key is on the list, the
server generates a random value and enciphers it with the key. If the client receives
the same value after deciphering then its credibility is authenticated. To make the
authentication algorithm usable, one must copy the public key to a relevant file of
the home directory on a remote machine.
Another well-known authentication method is to use an agent program. If the user
wasn’t authenticated with any of the previously mentioned methods, a password is
required.
SSH-2 version has been significantly improved in comparison with the SSH-1
version. In the new version it is possible to use any data encryption methods and four
different ways to identify the user, while SSH1 supports only a fixed list of several
encryption methods and two different ways to recognize the user (RSA key and the
usual password). Secure Shell was designed to secure remote terminal connection
and transmission of confidential files. This protocol can tunnel any TCP sessions
through a single Secure Shell encrypted connection (Fig. 9.5).
Tunneling allows us to protect the communication of other applications and pro-
tocols without modifying the applications themselves. We use it to transmit data
packets through networks using protocols different from the broadcasting and re-
ceiving network. Thus we create a virtual channel running through the area of the
intermediary network. Using tunneling, we still may use applications which do not
enable an adequate level of security, such as e-mails, in a safe way. SSH-2 is an
open and well-documented standard. SSH-2 protocol supports the strongest encryp-
tion algorithms. It provides data integrity through Hash Message Authentication
Codes (HMAC). However, the use of a public key infrastructure compatible with
the X.509 standard and public key certificates provides security at the appropriate
level. In the case of using certificates there is no need to replace the SSH public key
separately in each of the servers, the server must only trust the CA which issued the
certificate.
[email protected]
9.3 Computer Network Security—SSH and SSL Protocols 223
[email protected]
224 9 Cryptographic Applications for Network Security
If we want to connect to the server from a computer with an operating system from
the Unix/Linux family, we carry out the command: ssh-l user serwer.pl??
SSH is an application running in text mode, we call it with the -l user parameter
by giving the user name to our server and the server name or IP address. In the
Windows environment we can use the free application Putty (Fig. 9.7).
[email protected]
9.3 Computer Network Security—SSH and SSL Protocols 225
Logging in for the first time to a remote computer without its public key, we
receive a message about the possibility of downloading the key with a warning that
if a user is not sure of its authenticity the connection may be terminated (Fig. 9.8).
After downloading the public key one can log in safely (Fig. 9.9).
Figure 9.10 shows the record of the connection’s text version. At the beginning
the application introduces itself, announces which of the SSH versions operates: ap-
plication operates SSH-1 version (1.5 record) and SSH-2 (2.0 record). Then reads
the configuration and connects to a remote server (mp) on 22 port. When the connec-
tion is established, a negotiation between the client and the server starts. The version
of the protocol is determined and then keys exchange and number generation starts.
After accepting the keys, one is ready to log in to a remote system.
In Fig. 9.10 we see a single TCP/IP frame with a message record in the SSH
protocol. The whole message is encrypted, we cannot get to know its content, only
the sender and the recipient.
[email protected]
226 9 Cryptographic Applications for Network Security
[email protected]
9.3 Computer Network Security—SSH and SSL Protocols 227
3. Verification of server identity on the basis of received information. (In the above
points the asymmetric cipher is chosen from the mutual set.)
4. Exchange of session keys, generated at random.
5. Beginning of transmission encrypted by generated keys.
In order to encrypt tunneled data in SSL the asymmetric cipher is used, agreed
during the initial data exchange. The encryption key is generated at random for every
connection.
SSL guarantees:
• Privacy—connection is encrypted,
• Authorization—the client and the server determine their own identity,
• Integrity of sent data—by the checksum.
A description of the SSL protocol (commercial version) is available from
http://wp.netscape.com/eng/ssl3/. Its free equivalent is OpenSSL http://www.
openssl.org/.
When do we use a coded connection? The SSL protocol is one of the methods of-
fering encryption for the security of financial transactions. Transactions using SSL
are fast and transparent for the users. We often encounter this solution while using
credit cards during logging into an e-bank. Today most banks have WWW interfaces
which allow us to use bank resources. We purchase products by electronic transac-
[email protected]
228 9 Cryptographic Applications for Network Security
tions. Such solutions appear also in systems which need verification/logging of the
users.
1. During SSL connection the browser’s WWW address starts from https://; and
initiates the connection on port 443 of the server instead of 80.
2. In the Internet Explorer browser in the right part of the status bar there is a small
closed yellow padlock. If we stop the cursor above the padlock, the information
of the length of the asymmetric key is highlighted. After clicking on the padlock
we can see the certificate of the server authorisation.
3. In the browsers from the Netscape family the padlock is all the time shown in the
left part of the status bar, during the SSL connection the padlock is closed.
Most servers use 128-bit keys. Current versions of the browsers support such
encryption.
The security consists of these elements: strong cryptographic algorithms and
well-designed protocols. The experts agree that SSL from the cryptographic point
of view is very good. The weakest link is unfortunately the human. SSL informs the
user about its state using the lock icon. The closed lock means that the browser is
connected with some server. The task for the user is to verify the certificate of the
server. There are some dangers which can violate the security of SSL and these are
attacks on the service of the domain names (DNS). If the cyber-imposter imitates the
name of the computer from the URL into an IP address which is under her control,
and if she receives a certificate from one of the CA’s, she may provide services at an
appropriate level of security, while the user would have no idea what happened.
The following two figures show intercepted TCP/IP frames. In Fig. 9.12 use of
the SSL protocol is visible and the data are incomprehensible—encrypted. Fig-
ure 9.11 presents the use of the HTTP protocol, where data is sent as plain text.
If a user decides on unencrypted connection, the user should be aware of the risk of
data interception.
[email protected]
9.4 Wireless Network Security 229
The 802.11 wireless network standard assumes the use of the WEP encryption pro-
tocol. Such a protocol was designed to ensure the security of sent data and especially
its confidentiality. The WEP protocol is used during authentication of communicat-
ing entities and in order to support the confidentiality of transmission. The protocol
[email protected]
230 9 Cryptographic Applications for Network Security
uses symmetric encryption with the algorithm RC4 presented previously. Since this
is the asymmetric key stream cipher it is required that the key used by the client is
the same as the key used by an access point. Unfortunately, the required length of
the RC4 key is 40 bits. Usually in practical use of the WEP protocol, because of the
low security level connected with such a short key length, 104-bit keys are also used.
Use of the symmetric algorithm in WEP causes the problem of key distribution.
The process of encryption using the RC4 algorithm for the WEP algorithm runs
as follows:
1. In the first step the checksum is calculated (Integrity Check Value), from the data
packet which will be encrypted. CRC-32 algorithm is used.
2. The device which sends the data generates a 24-bit random initial vector (IV).
3. The submission of this vector together with the secret key at a proper length
creates the encryption key for the RC4 algorithm, used to encrypt the data trans-
mission.
4. With the use of the RC4 algorithm a pseudorandom sequence RC4(IV, k)) is
created.
5. The packet of sent data is encrypted with calculated checksum (M, CV(M)).
6. After the encryption process we receive a cryptogram
C = (M, ICV(M))A(RC4(IV, k)).
7. To encrypt the data the IV vector and the whole pair (IV, C) is added and the
sum is sent to the wireless network.
In order to decode the message the recipient has to know the secret IV vector and
the k key. The key is added in the explicit way to a cryptogram.
Despite wide usage, the WEP protocol has some essential weaknesses excluding
it from algorithms which can be recognized as secure. The faults allow very quick,
effective attacks on networks protected by this algorithm.
It is proved that the used length of the initial vector is too short and there is a
danger that many sent packets use the same vectors. The calculations show that it is
enough to have 5000 packets and the IV vector repeats itself with 50 % probability.
Additionally, because of faults in the software of some access points, the keys can
be written as casual ASCII character strings which results in a space reduction of
admitted keys to about 2 million keys. Of course this means that a network protected
with such a key is open to brute-force attacks.
For many years there has been free software available on the Internet to monitor
wireless transmission within a few minutes in order to get a proper set of information
which can be enough to break the protocol. The discussed method was compiled by
specialists from Technische Universitaet Darmstadt.
Because of the very weak security of the WEP protocol, the WPA protocol was
proposed (WiFi Protected Access). This protocol was designed to cooperate with
[email protected]
9.4 Wireless Network Security 231
[email protected]
References
1. ANSI X9.31. Digital Signatures Using Reversible Public Key Cryptography for the Financial
Services Industry (rDSA) (1998)
2. ANSI X9.62. Public Key Cryptography for the Financial Services Industry: The Elliptic
Curve Digital Signature Algorithm (ECDSA) (1998)
3. ANSI X9.95. Trusted Time Stamp Management and Security, USA (2009). https://www.x9.
org/news/pr050701
4. Agrawal, M., Kayal, N., Saxena, N.: PRIMES is in P. Ann. Math. 160(2), 781–793 (2004)
5. Anderson, R.J.: Security Engineering: A Guide to Building Dependable Distributed Systems,
2nd edn. Wiley, New York (2008)
6. Aoki, K., Guo, J., Matusiewicz, K., Sasaki, Y., Wang, L.: Preimages for step-reduced SHA-
2. In: Advances in Cryptology—Asiacrypt 2009. Lecture Notes in Computer Science, vol.
5912, pp. 578–597. Springer, Berlin (2009)
7. Aumasson, J.P., Henzen, L., Meier, W., Phan, R.C.W.: SHA-3 proposal BLAKE. http://www.
131002.net/blake/
8. Barker, E.: Recommendation for Digital Signature Timeliness. NIST Special Publication
800-102, National Institute of Standards and Technology, USA (2009)
9. Basin, D., Wolff, B.: Theorem Proving in Higher Order Logics. LNCS, vol. 2758. Springer,
Berlin (2003)
10. Bella, G., Longo, C., Paulson, L.C.: In: Basin, D., Wolff, B. (eds.) Theorem Proving in Higher
Order Logics. LNCS, vol. 2758, pp. 352–366 (2003)
11. Bella, G., Massacci, F., Paulson, L.C.: Verifying the SET registration protocols. IEEE J. Sel.
Areas Commun. 21(1), 77–87 (2003)
12. Bellare, M., Garay, J., Hauser, R., Herberg, A., Krawczyk, H., Steiner, M., Tsudik, G., Waid-
ner, M.: iKP—a family of secure electronic payment protocols. In: Proceedings of the 1st
USENIX Workshop on Electronic Commerce (1995)
13. Bernstein, D.J.: Second preimages for 6 (7? (8??)) rounds of Keccak? NIST mailing list
(2010). http://ehash.iaik.tugraz.at/uploads/6/65/NIST-mailing-list_Bernstein-Daemen.txt
14. Bertoni, G., Daemen, J., Peeters, M., Van Assche, G.: Cryptographic Sponges (2012). http://
sponge.noekeon.org
15. Bertoni, G., Daemen, J., Peeters, M., Van Assche, G.: Keccak sponge function family main
document. http://keccak.noekeon.org/Keccak-main-2.1.pdf
16. Bhattacharyya, R., Mandal, A., Nandi, M.: Security analysis of the mode of JH hash function.
In: FSE 2010. Lecture Notes in Computer Science, vol. 6147, pp. 168–191. Springer, Berlin
(2010)
17. Biham, E., Shamir, A.: Differential cryptanalysis of DES-like cryptosystems. J. Cryptol. 4(1),
3–72 (1991)
18. Biham, E., Shamir, A.: Differential cryptanalysis of the full 16-round DES. In: Crypto. Lec-
ture Notes in Computer Science, vol. 740, pp. 487–496. Springer, Berlin (1993)
[email protected]
234 References
19. Biham, E., Boneh, D., Reingold, O.: Breaking generalized Diffie–Hellman modulo a com-
posite is no easier than factoring. Inf. Process. Lett. 70, 83–87 (1999)
20. Biham, E., Dunkelman, O., Keller, N.: A new attack on 6-round idea. In: FSE 2007. Lecture
Notes in Computer Science, vol. 4593, pp. 211–224. Springer, Berlin (2007)
21. Bos, J., Kaihara, M.E.: Playstation 3 computing breaks 260 barrier: 112-bit prime ECDLP
solved (2009). http://lacal.epfl.ch/112bit_prime
22. Bresson, E., Chevassut, O., Pointcheval, D.: The group Diffie–Hellman problems. In:
SAC’02: Revised Papers from the 9th Annual International Workshop on Selected Areas
in Cryptography, pp. 325–338 (2003)
23. Burrows, M., Abadi, M., Needham, R.: A logic of authentication. ACM Trans. Comput. Syst.
8(1), 18–36 (1990)
24. Clarke, E., Marrero, W., Jha, S.: Using state space exploration and a natural deduction style
message derivation engine to verify security protocols. In: IFIP Working Conference on Pro-
gramming Concepts and Methods (PROCOMET) (1996)
25. Break DES in less than a single day, Copacobana Rivyera Project. http://www.sciengines.
com/company/news-a-events/74-des-in-1-day.html
26. Copeland, J.: Notices of the AMS, vol. 58, pp. 1540–1542. AMS, Providence (2011)
27. Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn.
MIT Press, Cambridge (2009)
28. Crandall, R., Pomerance, C.: Subexponential factoring algorithms. In: Prime Numbers:
A Computational Perspective. Springer, Berlin (2001)
29. Levy, S.: Crypto: How the Code Rebels Beat the Government Saving Privacy in the Digital
Age. Penguin, Baltimore (2001)
30. Cryptographic Key Length Recommendation. BlueKrypt. http://www.keylength.com/en/
compare/
31. Diffie, W., Hellman, M.E.: New directions in cryptography. IEEE Trans. Inf. Theory 22(6),
644–654 (1976)
32. FIPS PUB 186. Digital Signature Standard (DSS), Federal Information Processing Standards
Publication 186, US NIST (1994)
33. FIPS PUB 186-3. Digital Signature Standard (DSS), Federal Information Processing Stan-
dards Publication 186-3, US NIST (2009)
34. Dinur, I., Dunkelman, O., Shamir, A.: Collision attacks on up to 5 rounds of SHA-3 us-
ing generalized internal differentials. Cryptology ePrint Archive. Report 2012/672 (2012).
http://eprint.iacr.org
35. Directive 1999/93/ec of the European Parliament and of the Council of 13 December 1999.
Official EU Journal L 13
36. distributed.net Project. http://www.distributed.net/DES
37. Electronic Signatures and Infrastructures (ESI); Policy requirements for time-stamping au-
thorities. ETSI TS 102 023 v1.2.2, European Telecommunications Standards Institute, Tech-
nical Specification (2008)
38. Erskine, R.: The Poles reveal their secrets: Alastair Denniston’s account of the July 1939
meeting at Pyry. Cryptologia 30(4), 294–305 (2006)
39. EU Directive 1999/93/EC on a Community framework for electronic signatures. Official
Journal L 013, P. 0012–0020, Annex II, 19/01/2000
40. Ferguson, N., Lucks, S., Schneier, B., Whiting, D., Bellare, M., Kohno, T., Callas, J., Walker,
J.: The Skein Hash Function Family (2010). http://www.skein-hash.info/sites/default/files/
skein1.1.pdf
41. FIPS PUB 46: Data Encryption Standard. National Bureau of Standards (1977)
42. FIPS PUB 46-1: Data Encryption Standard. National Bureau of Standards (1988)
43. FIPS PUB 46-2: Data Encryption Standard. National Institute of Standards and Technology
(NIST) (1993)
44. FIPS PUB 46-3: Data Encryption Standard (DES). Federal Information Processing Standards
Publications (1999). http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf
45. FIPS PUB 180-4: Secure Hash Standard. National Institute of Standards and Technology
(NIST) (2012)
[email protected]
References 235
46. FIPS PUB 197: Announcing the Advanced Encryption Standard (AES). National Institute of
Standards and Technology (NIST) (2001)
47. Goutam, P., Subhamoy, M.: RC4 Stream Cipher and Its Variants. CRC Press, Boca Raton
(2011)
48. Grajek, M.: Enigma. Bliżej Prawdy. Wydawnictwo Rebis, Poznań (2007). ISBN 978-83-
7510-103-4
49. Hodges, A.: Alan Turing: The Enigma. Burnett Books, London (1992)
50. Homsirikamol, E., Morawiecki, P., Rogawski, M., Srebrny, M.: Security margin evaluation
of SHA-3 contest finalists through SAT-based attacks (2013). Submitted for publication
51. http://www.interhack.net/projects/deschall/
52. https://www.enigmail.net/documentation/index.php
53. Internet key exchange protocol. In: RFC 2408 (1998)
54. Kahn, D.: The Codebreakers: The Comprehensive History of Secret Communication from
Ancient Times to the Internet. Scribner’s, New York (1996)
55. Khovratovich, D.: Bicliques for permutations: collision and preimage attacks in stronger
settings. Cryptology ePrint Archive, Report 2012/141 (2012). http://eprint.iacr.org/2012/
141.pdf
56. Khovratovich, D., Rechberger, C., Savelieva, A.: Bicliques for preimages: attacks on Skein-
512 and the SHA-2 family. In: Fast Software Encryption (FSE). Lecture Notes in Computer
Science Springer, Berlin (2012)
57. Kleinjung, T., et al.: Discrete logarithms in GF(p)—160 digits (2007). https://listserv.
nodak.edu/cgibin/wa.exe?A2=ind0702
58. Kleinjung, T., Aoki, K., Franke, J., Lenstra, A.K., Thome, E., Bos, J.W., Gaudry, P., Kruppa,
A., Montgomery, P.L., Osvik, D.A., te Riele, H., Timofeev, A., Zimmermann, P.: Factoriza-
tion of a 768-bit RSA modulus. In: Advances in cryptology—Crypto 2010, vol. 6223, pp.
333–350 (2010)
59. Kumar, S., Paar, C., Pelzl, J., Pfeiffer, G., Rupp, A., Schimmler, M.: How to break DES for
Euro 8980. In: 2nd Workshop on Special-Purpose Hardware for Attacking Cryptographic
Systems, SHARCS 2006, Cologne, Germany (2006)
60. Kurkowski, M.: Deduction methods of verification of correctness of authentication protocols.
Ph.D. Thesis. ICS PAS, Warsaw, Poland (2003)
61. Lai, X., Massey, J.L., Murphy, S.: Markov ciphers and differential cryptanalysis. In: Ad-
vances in Cryptology—Eurocrypt’91. Lecture Notes in Computer Science, vol. 576, pp. 17–
38. Springer, Berlin (1992)
62. Lenstra, H.W. Jr., Pomerance, C.: Primality testing with Gaussian periods (2011). http://
www.math.dartmouth.edu/~carlp/aks041411.pdf
63. Liangyu, X., Ji, L.: Attacks on Round-Reduced BLAKE. Cryptology ePrint Archive, Report
2009/238 (2009). http://eprint.iacr.org/2009/238.pdf
64. Lowe, G.: Breaking and fixing the Needham-Schroeder public-key protocol using FDR. In:
Proceedings of TACAS, pp. 147–166 (1996)
65. Mason, S. (ed.): International Electronic Evidence. British Institute of International and
Comparative Law (2008)
66. Mason, S. (ed.): Electronic Evidence, 2nd edn. LexisNexis, Butterworths (2010)
67. Matsui, M.: Linear cryptanalysis of DES cipher. In: Advances in Cryptology—Eurocrypt’93,
pp. 386–397 (1994)
68. Menezes, A.J., van Oorschot, P.C., Vanstone, S.A.: Handbook of Applied Cryptography.
CRC Press, Boca Raton (2001). Fifth printing with Errata: http://www.cacr.math.uwaterloo.
ca/hac/errata/errata.html
69. Needham, R., Schroeder, M.: Using encryption for authentication in large networks of com-
puters. Commun. ACM 21(12), 993–999 (1978)
70. NIST Special Publication 800-67 Revision 1 Recommendation for the Triple Data En-
cryption Algorithm (TDEA) Block Cipher. National Institute of Standards and Technology
(NIST) (2012)
71. NIST: NIST’s Policy on Hash Functions. National Institute of Standards and Technology
Computer Security Resource Center. http://csrc.nist.gov/groups/ST/hash/policy.html
72. NIST: Tentative SHA-3 standard (FIPS XXX) development timeline. National Institute of
Standards and Technology. http://csrc.nist.gov/groups/ST/hash/sha-3/timeline_fips.html
[email protected]
236 References
[email protected]
Index
Symbols D
2nd preimage resistance property, 134 Damm Arvid, 24
DES cipher, 77, 79, 80, 84–86, 117, 118
A DESCHALL project, 85
AES cipher, 77, 99, 100, 105, 108, 110, 111, DESX cipher, 87
117, 118 Diffie Whitfield, 85
AKS algorithm, 8, 67, 71 Diffie-Hellman problem, 76
Asymmetric cryptography, 129, 196 Discrete logarithm problem, 75
Asymmetric key cryptography, 4 Distributed.net project, 85, 97
Authentication, 194–196, 198, 201, 203, 205 Divisibility, 50, 55
Divisibility relation, 37
DSA signature algorithm, 76, 131
B
BAN logics, 196, 208 E
Biham Eli, 86 Electronic codebook mode, 87
Birthday paradox, 136 Electronic signature, 127, 128
Birthday problem, 135 ElGamal cipher, 130, 131
Bletchley Park, 33–35 Elliptic curves, 76
Enigma, 23–35
C Eratosthenes, 60
Caesar cipher, 10–13 Euclid, 60
Carmichael numbers, 67, 69 Euclidean algorithm, 47, 59–64, 103, 131
Certificate Revocation Lists, 175, 176, 182 Euclidean algorithm - extended version, 64–66
Certificates, 175, 186, 187, 190, 205 Euler’s function, 37, 55, 59
Certification Authority, 175–183, 202 Euler’s theorem, 59
Chinese Remainder Theorem, 58
F
Cipher block-chaining mode, 87
Factorization, 52, 53
Cipher feedback mode, 89 Factorization problem, 72
Clarke Edmund, 210 Feistel Horst, 78, 79
Collision resistance property, 134 Feistel network, 78, 82, 83
Computational complexity, 6–8, 10, 56, 67, Fermat’s little theorem, 59, 67, 68, 71
209 Fermat’s primality tests, 67–69
COPACOBANA project, 85 Finite fields, 37, 41, 44
Coppersmith Dan, 79
Cryptographic protocols, 193–195, 207, 212 G
Cryptography, 1, 5, 7, 10, 24, 37, 49, 59, 69, Galois fields, 41, 43, 44, 49, 50
71, 75, 127, 175 General number field sieve algorithm, 73
[email protected]
238 Index
Greatest common divisor, 37, 51, 65, 66 Rivest Ronald, 93, 96, 136
Groups, 37–42, 44, 75, 76 Rotor machines, 22, 23
Różycki Jerzy, 31
H RSA cipher, 72
Hash functions, 132 RSA Factoring Challenge, 72
Hellman Martin, 85
S
I S-boxes, 79, 80, 83
IDEA cipher, 77, 90, 117, 118 S/MIME system, 182
IPSec protocol, 182 Scherbius Arthur, 24
Session key distribution, 194
K SET protocol, 182, 210
Keccak hash function, 142–145 SHA hash function, 134
Kerberos protocol, 202, 204 SHA-1 hash function, 8, 135, 142
Kerberos system, 203, 206 SHA-3 competition, 142
Key repositories, 175 Shamir Adi, 86
Shannon Claude, 4, 18
L Sieve of Eratosthenes, 59, 60
LDAP server, 189 SSL protocol, 92, 182
Least common multiple, 37, 51 Symmetric cryptography, 3, 11, 77, 78, 86,
Lowe Gavin, 198 108, 196, 199, 200, 207, 210, 211
M T
MD4 hash function, 135, 140 Temporal logic, 209
MD5 hash function, 134–137, 140 Timestamps, 201
Miller-Rabin primality tests, 67, 69, 70 TLS protocol, 210
Model checking, 196, 208, 209, 211 Transpositions, 13, 14, 17, 18
TripleDES cipher, 86
N Trusted Third Party, 197
NSPK protocol, 197, 202 Turing Alan, 33
NSSK protocol, 199
U
P Unique factorization, 51
Permutations, 5, 9, 11, 13, 16–19, 22–24, 26, US National Bureau of Standards, 79
29, 31, 32, 80, 81, 84, 90, 93–95, 118 US National Institute of Standards and
Playfair cipher, 18, 20 Technology, 131
Polyalphabetic substitutions, 20
Polynomial rings, 46–48 V
Polynomials, 45–48, 71, 101, 103, 106, 115 Verifying of cryptographic protocols, 207
Preimage resistance property, 134 Vernam cipher, 11, 12, 93
Primality tests, 67 Vigenère cipher, 20
Prime numbers, 37, 44, 52–54, 59, 60, 66,
68–71 W
Public Key Infrastructure, 175, 176, 180, 181 WEP protocol, 92
Wheel cipher, 21, 22
R
RC ciphers, 77 X
RC4 cipher, 92–94 X.509 standard, 176
RC5 cipher, 94, 96, 100 XOR function, 11, 12, 78, 83, 84, 87, 89, 93,
RC6 cipher, 99 113
Registration Authority, 175, 176
Rejewski Marian, 31, 33 Z
Rings, 37, 40–44 Zygalski Henryk, 31