Fo CS24
Fo CS24
net/publication/323243320
CITATIONS READS
0 54,786
1 author:
Amir Herzberg
University of Connecticut
269 PUBLICATIONS 6,928 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Amir Herzberg on 30 September 2020.
Amir
c Herzberg
Comcast Professor of Security Innovations
Department of Computer Science and Engineering
University of Connecticut
i
Contents
Contents ii
1 Introduction 1
1.1 About the Foundations of Cybersecurity and this Volume . . . 1
1.1.1 First volume: an applied introduction to cryptography. 2
1.1.2 Online and lecturer resources . . . . . . . . . . . . . . . 4
1.2 Brief History of Computers, Cryptology and Cyber . . . . . . . 4
1.2.1 From classical to modern Cryptology . . . . . . . . . . . 7
1.2.2 Cryptology is not just about secrecy! . . . . . . . . . . . 8
1.3 Cybersecurity Goals and Attack Models . . . . . . . . . . . . . 10
1.4 Notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
ii
2.5.6 Random functions . . . . . . . . . . . . . . . . . . . . . 42
2.5.7 Pseudo-Random Functions (PRFs) . . . . . . . . . . . . 47
2.5.8 PRF: Constructions and Robust Combiners . . . . . . . 51
2.5.9 The key-separation principle and application of PRF . . 52
2.5.10 Random and Pseudo-Random Permutations . . . . . . . 53
2.6 Defining secure encryption . . . . . . . . . . . . . . . . . . . . . 56
2.6.1 Attacker model . . . . . . . . . . . . . . . . . . . . . . . 57
2.6.2 The Indistinguishability-Test for Shared-Key Cryptosys-
tems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
2.6.3 The Indistinguishability-Test for Public-Key Cryptosys-
tems (PKCs) . . . . . . . . . . . . . . . . . . . . . . . . 63
2.7 The Cryptographic Building Blocks Principle . . . . . . . . . . 64
2.8 Block Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.8.1 Constructing PRP from PRF: the Feistel Construction . 68
2.9 Secure Encryption Modes of Operation . . . . . . . . . . . . . . 70
2.9.1 The Electronic Code Book mode (ECB) mode . . . . . 72
2.9.2 The Per-Block Random Mode (PBR) . . . . . . . . . . 74
2.9.3 The Output-Feedback (OFB) Mode . . . . . . . . . . . 76
2.9.4 The Cipher Feedback (CFB) Mode . . . . . . . . . . . . 79
2.9.5 The Cipher-Block Chaining (CBC) mode . . . . . . . . 80
2.9.6 Ensuring CCA Security . . . . . . . . . . . . . . . . . . 82
2.10 Case study: the (in)security of WEP . . . . . . . . . . . . . . . 82
2.10.1 CRC-then-XOR does not ensure integrity . . . . . . . . 84
2.11 Encryption: Final Words . . . . . . . . . . . . . . . . . . . . . 85
2.12 Encryption and Pseudo-Randomness: Additional exercises . . . 86
iii
3.7.2 EDC-then-Encrypt Schemes . . . . . . . . . . . . . . . . 122
3.7.3 Generic Authenticated Encryption Constructions . . . . 122
3.7.4 Single-Key Generic Authenticated-Encryption . . . . . . 126
3.8 Message Authentication: Additional exercises . . . . . . . . . . 128
iv
5 Shared-Key Protocols 191
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
5.1.1 Inputs and outputs signals . . . . . . . . . . . . . . . . . 192
5.1.2 Focus: two-party shared-key handshake and session pro-
tocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
5.1.3 Adversary Model . . . . . . . . . . . . . . . . . . . . . . 193
5.1.4 Secure Session Protocols . . . . . . . . . . . . . . . . . . 194
5.2 Shared-key Entity-Authenticating Handshake Protocols . . . . 198
5.2.1 Shared-key entity-authenticating handshake protocols: sig-
nals and requirements . . . . . . . . . . . . . . . . . . . 198
5.2.2 The (insecure) SNA entity-authenticating handshake pro-
tocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
5.2.3 2PP: Three-Flows authenticating handshake protocol . 203
5.3 Session-Authenticating Handshake Protocols . . . . . . . . . . 204
5.3.1 Session-authenticating handshake: signals, requirements
and variants . . . . . . . . . . . . . . . . . . . . . . . . . 205
5.3.2 Session-authenticating 2PP . . . . . . . . . . . . . . . . 206
5.3.3 Nonce-based request-response authenticating handshake
protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
5.3.4 Two-Flows Request-Response Authenticating Handshake,
assuming Synchronized State . . . . . . . . . . . . . . . 208
5.4 Key-Setup Handshake . . . . . . . . . . . . . . . . . . . . . . . 209
5.4.1 Key-Setup Handshake: Signals and Requirements . . . . 210
5.4.2 Key-setup 2PP extension . . . . . . . . . . . . . . . . . 211
5.4.3 Key-Setup: Deriving Per-Goal Keys . . . . . . . . . . . 211
5.5 Key Distribution Protocols and GSM . . . . . . . . . . . . . . . 212
5.5.1 Case study: the GSM Key Distribution Protocol . . . . 214
5.5.2 Replay attacks on GSM . . . . . . . . . . . . . . . . . . 217
5.5.3 Cipher-agility and Downgrade Attacks . . . . . . . . . . 218
5.6 Resiliency to key exposure: forward secrecy, recover secrecy and
beyond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
5.6.1 Forward secrecy handshake . . . . . . . . . . . . . . . . 222
5.6.2 Recover-Security Handshake Protocol . . . . . . . . . . 224
5.6.3 Stronger notions of resiliency to key exposure . . . . . . 225
5.6.4 Per-goal Keys Separation. . . . . . . . . . . . . . . . . . 227
5.6.5 Resiliency to exposures: summary . . . . . . . . . . . . 228
5.7 Shared-Key Session Protocols: Additional Exercises . . . . . . 230
v
6.1.6 Hybrid Encryption . . . . . . . . . . . . . . . . . . . . . 242
6.1.7 The Factoring and Discrete Logarithm Hard Problems . 243
6.2 The DH Key Exchange Protocol . . . . . . . . . . . . . . . . . 247
6.2.1 Physical key exchange . . . . . . . . . . . . . . . . . . . 247
6.2.2 Some candidate key exchange protocol . . . . . . . . . 249
6.2.3 The Diffie-Hellman Key Exchange Protocol and Hard-
ness Assumptions . . . . . . . . . . . . . . . . . . . . . . 252
6.3 Key Derivation Functions (KDF) and the Extract-then-Expand
paradigm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
6.4 Using DH for Resiliency to Exposures: PFS and PRS . . . . . 257
6.4.1 Authenticated DH: Perfect Forward Secrecy (PFS) . . . 257
6.4.2 The Synchronous-DH-Ratchet protocol: Perfect Forward
Secrecy (PFS) and Perfect Recover Secrecy (PRS) . . . 258
6.4.3 The Asynchronous-DH-Ratchet protocol . . . . . . . . . 259
6.4.4 The Double Ratchet Key-Exchange protocol [to be com-
pleted] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
6.5 Discrete-Log based public key cryptosystems: DH and El-Gamal 262
6.5.1 The DH PKC . . . . . . . . . . . . . . . . . . . . . . . . 262
6.5.2 The El-Gamal PKC . . . . . . . . . . . . . . . . . . . . 264
6.5.3 Homomorphic encryption and re-encryption. . . . . . . 265
6.6 The RSA Public-Key Cryptosystem . . . . . . . . . . . . . . . 267
6.6.1 RSA key generation. . . . . . . . . . . . . . . . . . . . . 267
6.6.2 Textbook RSA: encryption, decryption and correctness. 268
6.6.3 The RSA assumption and security . . . . . . . . . . . . 270
6.6.4 RSA with OAEP (Optimal Asymmetric Encryption Padding)271
6.7 Public key signature schemes . . . . . . . . . . . . . . . . . . . 272
6.7.1 RSA-based signatures . . . . . . . . . . . . . . . . . . . 274
6.7.2 Discrete-Log based signatures . . . . . . . . . . . . . . . 276
6.8 Additional Exercises . . . . . . . . . . . . . . . . . . . . . . . . 277
vi
7.3.3 Secure extensibility principle and TLS extensions . . . . 305
7.3.4 SSLv3 to TLSv1.2: DH-based key exchange . . . . . . . 307
7.3.5 SSLv3 to TLSv1.2: session resumption . . . . . . . . . . 309
7.3.6 Client authentication . . . . . . . . . . . . . . . . . . . . 312
7.4 State-of-Art: TLS 1.3 . . . . . . . . . . . . . . . . . . . . . . . 314
7.5 TLS/SSL: Additional Exercises . . . . . . . . . . . . . . . . . . 315
vii
9.2 Phishing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
9.3 Usable Defenses against Phishing . . . . . . . . . . . . . . . . . 384
9.4 Usable End-to-End Security . . . . . . . . . . . . . . . . . . . . 384
9.5 Usable Security and Authentication: Additional Exercises . . . 384
Index 397
Bibliography 405
viii
Acknowledgments
While this is still a work-in-progress, I realize that I should better begin ac-
knowledging the people who help me, to minimize the unavoidable errors of
omission where I forget to thank and acknowledge help from friends and col-
leagues. So I am beginning now to write down these acknowledgments; please
let me know if you notice any omissions or mistakes, and accept my apologies
in advance.
I received a lot of help from my teaching assistants (TAs) in the University
of Connecticut (UConn): Sam Markelon (2019) and Justin Furuness (2018). I
am also grateful for my TAs for the similar course I gave earlier in Bar Ilan
University: Hemi Leibowitz, Haya Shulman and Yigal Yoffe.
I also received great comments and many corrections, suggestions and help
from professors and colleagues who have read and/or used the text. Anna
Gorbenko and Jerry Shi taught the course together in Spring 2020, and gave me
incredible amount of feedback on both text and lectures; Anna also collected
an amazing number of comments and suggestions from many students, it’s
amazing how she knows to make students so engaged! Shaanan Cohney kindly
sent me the LaTeX source code for Figure 2.33, taken from [45].
I am also grateful to the many students and other readers, mainly in the
University of Connecticut, who have been tolerant of my innumerable mistakes
and pointed many of them out to me, directly or (more commonly) via Anna.
This really helps. Sara Wrotniak gave especially helpful feedback and sugges-
tions, including some useful text (already formatted in Latex, too!); this was
so helpful that I’ve asked Sara to do a more in-depth review, and she helped
even much more, I’m very grateful.
I have no doubt that I already forgot to mention some specific important
contributors; please let me know and I’ll also fix this error... and probably
introduce another one. Oh well.
Many thanks to all of you, and further help would be greatly appreciated!
ix
Chapter 1
Introduction
1
or for self-study; in both cases, a set of presentations is available and may
be useful for lecturers and students. The textbook also contains a significant
number of exercises, solutions and examples, although adding even more is
clearly desirable. Lecturers may receive some more exercises and solutions by
writing to the author.
An important goal of the foundations is to try to help readers develop the
adversarial thinking that allows the cybersecurity expert to avoid and identify
vulnerabilities - even subtle ones - in practical systems. To achieve this, we
combine discussion of informal design principles and of practical systems and
their vulnerabilities, with presentation of key theoretical tools and definitions.
There is a wide variety of different tools and techniques used to ensure
cybersecurity, and obviously, we will not be able to cover all of them. The
current plan is to focus on two volumes and central topics. In this, first, volume,
we focus on applied cryptography. Volume 2 focuses on network security [93],
specifically, Internet and web security, with much of the discussion focusing on
non-cryptographic aspects.
Some of the other important topics, that we currently don’t plan to cover,
include software security, including malware, secure coding, and more; privacy
and anonymity, operating systems and computer security, security of cyber-
physical systems and Internet-of-Things (IoT), usable security and social engi-
neering, machine learning security, information flow analysis, and more.
2
insecure practices of basing security only on intuition and/or against specific
adversary strategies.
Another reason is that cryptography is used in almost every area of cyber-
security - and definitely in network security, the focus of the next volume.
This allows us, in this volume, to introduce aspects from some of these other
areas, mainly network security, privacy, usable security and social engineering.
Indeed, in the second volume, we often take advantage of the first volume.
In fact, many of the principles we present in the first volume, apply also to
network security and other areas of cybersecurity.
The final reason is scheduling and prerequisites. While modern cryptogra-
phy is based on both mathematics and on the theory of computing, I believe
that the most important and applied aspects do not require extensive, in-depth
background in these (or other) areas.
My goal is to make this volume useful even to a student or reader who did
not learn previous math or computer-science courses, beyond what is learned
in good high-school programs. I am far from sure that I will be able to meet
this goal, but I try ; in particular, the text includes limited background on
relevant topics such as algebra, probability, and complexity theory.
Indeed, this approach may help introduce a student with these areas of math
and theory-of-computer-science. Some people find it easier to learn abstract,
theoretical topics, after a taste of their practical applications and importance.
This holds for me personally; as an undergrad, I learned computer engineering,
with emphasize on practical areas such as networking, systems and software en-
gineering, and took only the mandatory theory and math classes. This changed
only later as I learned the importance of theory and math - often ‘in the hard
way’...
Furthermore, the use of math and theory is limited to what I consider
essential for understanding - at least for some readers and lecturers. Each
specific lecturer using this textbook, or readers using it on their own, should
decide how ‘deep’ to go, e.g., whether to study each of the limited number of
proofs provided.
I hope and expect that students interested in cryptography, will follow-up,
possibly with one of the multiple excellent textbooks on cryptography; some
of my favorites are [3, 79, 80, 98, 138, 159]. However, we believe that for many
cybersecurity practitioners, these textbooks go too deep in cryptography and
theory - and do not cover enough applied aspects.
Note that, in contrast, in volume 2 (network security), I assume that the
reader has, by now, learned networking, from one of the multiple excellent
textbooks, e.g., my favorite, [112]. But one of the reasons I do not feel the
need to teach network security with precise proofs and definitions, is exactly
the reliance on this first part to prepare the reader in this way. On top of that,
the theory of network security is much more complex - and mostly does not
yet exist, and is a subject for further study.
Ultimately, my goal is to combine practice with theory, applicability with
precision, breadth with depth. Let me know how well I have achieved it - and
where can I improve!
3
1.1.2 Online and lecturer resources
These notes have a corresponding set of powerpoint presentations. These pre-
sentations, like the manuscript itself, are available for download from the Re-
searchGate website. If some presentation is not available or appears outdated,
or if these notes appear outdated, please alert me by email or by a Research-
Gate message - I may have forgotten to update.
Lecturers are welcome to use these notes and presentations; I will appreci-
ate, however, if you let me know. I can also provide some additional resources
to lecturers such as (additional) exercises and solutions.
I appreciate feedback, esp. corrections and other suggestions for improve-
ments and places where clarifications are needed; don’t hesitate, if you didn’t
understand, it is my fault, not yours, tell me and I will improve. Finally, I wel-
come also contributions, esp. additional exercises and/or solutions. Thanks!
4
The Encryption World: basic terms
key key
plaintext ciphertext plaintext
Encrypt Decrypt
Bob
Alice Eve
(eavesdropper)
Figure 1.1: Encryption: terms and typical use. Alice needs to send sensitive
information (plaintext) to Bob, so that the information will reach Bob - but re-
main confidential from Eve, who can eavesdrop on the communication between
Alice and Bob. To do this, Alice encrypts the plaintext; the 15 encrypted form
is called ciphertext, and Eve cannot learn anything from it (except its size).
However, Bob can decrypt the ciphertext, which recovers the plaintext.
Germans; and both sides invested in cryptanalysis - with much greater successes
to the allies, luckily.
The well-known Enigma machine was used throughout the war. Early mod-
els of the Enigma machine, captured and smuggled from Poland to Germany,
were used to construct complex, special-purpose devices called Bombe, that
helped cryptanalysis of Enigma traffic.
The somewhat-less known Lorenz encryption devices were introduced later
during the war, and no complete device was available to cryptanalysts. This
motivated the design of Colossus, the first fully functional computer, by Tommy
Flowers. Namely, Collossus was the first practical device that could be pro-
grammed for arbitrary tasks, rather than only perform a predefined set of tasks
or computations.
The fact that Collossus was the first applied, programmable (or ‘real’) com-
puter, is important historically - but was also of immense importance during
the War. Since Colossus was programmable, it was possible to test many possi-
ble attacks and to successfully cryptanalyze (different versions of) Lorenz and
other cryptosystems.
One critical difference between the Colossus and more modern computers, is
that the Colossus did not read a program from storage. Instead, setting up the
program for the Colossus involved manual setting of switches and jack-panel
connections. This is much less convenient, of course; but it was acceptable
for the Colossus, since there were only a few such machines and only a few,
simple programs, and the simplicity of design and manufacture was more im-
portant than making it easier to change programs. Even this crude form of
‘programming’ was incomparably easier than changing the basic functionality
of the machine, as required in special-purpose devices - including the Bombe
used to decipher the Enigma.
5
The idea of a stored program was proposed already in 1936/1937 - by two
independent efforts. Konard Zuse briefly mentioned such design in a patent
on floating-point calculations published at 1936 [174], and Alan Turing defined
and studied a formal model for stored-program computers - now referred to
as the Turing machine model - as part of his seminal paper, ‘On Computable
Numbers’ [161]. However, practical implementations of stored-program com-
puters appeared only after WWII. Stored-program computers were much easier
to use, and allowed larger and more sophisticated programs as well as the use
of the same hardware for multiple purposes (and programs). Hence, stored-
program computers quickly became the norm - to the extent some people argue
that earlier devices were not ‘real computers’.
Stored-program computers also created a vast market for programs. It now
became feasible for programs to be created in one location, and then shipped
to and installed in a remote computer. For many years, this was done by
physically shipping the programs, stored in media such as tapes, discs and
others. Once computer networks became available, program distribution is
often, in fact usually, done by sending the program over the network.
Easier distribution of software meant also that the same program could be
used by many computers; indeed, today we have programs that run on billions
of computers. The ability of a program to run on many computers created an
incentive to develop more programs; and the availability of a growing number
of programs increased the demand for computers - and the impact on society
and the economy.
The impact of computers further dramatically increased when computer
networks began to facilitate inter-computer communication. The introduction
of personal computers (1977-1982), and later of the Internet, web, smartphones
and IoT devices, caused a further dramatic increase in the impact of comput-
ers and ‘smart devices’ - which are also computers, in the sense of running
programs.
This growing importance of cyberspace also resulted in growing interest in
the potential social implications, and a growing number of science-fiction works
focused on these aspects. One of these was the novel ‘Burning Chrome’, pub-
lished by William Gibson at 1982. This novel introduced the term cyberspace,
to refer to these interconnected networks, computers, devices and humans.
This term is now widely used, often focusing on the impact on people and so-
ciety. The cyber part of the term is taken from cybernetics, a term introduced
in [169] for the study communication and control systems in machines, humans
and animals.
There was also increased awareness of the risks of abuse and attacks on dif-
ferent components of cyberspace, mainly computers, software, networks, and
the data and information carried and stored in them. This awareness sig-
nificantly increased as attacks on computer systems became widespread, esp.
attacks exploiting software vulnerabilities, and/or involving malicious software,
i.e., malware. This awareness resulted in the study, research and development
of threats and corresponding security mechanisms: computer security, software
security, network security and data/information security.
6
The awareness of security risks also resulted in important works of fiction.
One of these was the 1983 novel cyberpunk, by Bruce Bethke. Bethke coined
this term for individuals which are socially-inept yet technologically-savvy.
Originally a derogatory term, cyberpunk was later adopted as a name of
a movement, with several manifestos, e.g., [106]. In these manifestos, as well
as in works of fiction, cyberpunks and hackers are still mostly presented as
socially-inept yet technology-savvy, indeed, they are often presented as pos-
sessing incredible abilities to penetrate systems. However, all this is often
presented in positive, even glamorous ways, e.g., as saving human society from
oppressive, corrupt regimes, governments and agencies.
Indeed, much of the success of the Internet is due to its decentralized na-
ture, and many of the important privacy tools, such as the Tor anonymous
communication system [57], are inherently decentralized, which may be hoped
to defend against potentially malicious governments. Furthermore, some of
these tools, such as the PGP encryption suite [76], were developed in spite of
significant resistance by much of the establishment.
7
work involved prominent researchers like Turing, and had significant impact on
development of computers, it was kept classified for many years.
This changed quite dramatically in the 1970s, with the beginning of what
we now call modern cryptology, which involves extensive academic research,
publication, products and standards, and has many important applications.
Two important landmarks seem to mark the beginning of modern cryp-
tology. The first is the development and publication of the Data Encryption
Standard (DES) [134]. The second is the publication of the seminal paper New
directions in cryptography [56], by Diffie and Hellman. This paper introduced
the radical, innovative concept of Public Key Cryptology (PKC), where the key
to encrypt messages may be public, and only the corresponding decryption key
must be kept private, allowing easy distribution of encryption keys. The paper
also presented the Diffie-Hellman Key Exchange protocol; we discuss both of
these in chapter 6.
In [56], Diffie and Hellman did not yet present an implementation of public
key cryptography. The first published public-key cryptosystem was RSA by
Rivest, Shamir and Adelment in [144], and this is still one of the most popular
public-key cryptosystems. In fact, the same design was discovered already a
few years earlier, by the GCHQ British intelligence organization. The CGHQ
kept this achievement secret until 1997, long after the corresponding designs
were re-discovered independently and published in [144]. See [121] for more
details about the fascinating history of the discovery - and re-discovery - of
public key cryptology.
This repeated discovery of public-key cryptology illustrates the dramatic
change between ‘classical’ cryptology, studied only in secrecy and with impact
mostly limited to the intelligence and defense areas, and modern cryptology,
with extensive published research and extensive impact on society and the
economy.
8
Public Key Digital Signatures
Signature Verify
Alg Sign Signature σ Alg Ver
(σ =SignA.s(m))
Alice Bob
(Ok, m) or invalid
Figure 1.2: Digital signature and verification algorithms: terms and typical
use. Alice signs message m, by applying the signing algorithm Sign using
1/10/2020 23
her private signing key A.s, resulting in the signature σ = SignA.s (m). Alice
sends the signature σ and the message m to Bob, who verifies the signature
by applying the verification algorithm Ver using Alice’s public verification key
A.v, namely, computes V erA.v (m, σ). If the result is Invalid, this implies that
σ is not a valid signature of m; if the result is Ok, then σ is valid signature,
i.e., m was indeed signed by Alice.
able to sign a document using her signature, even if the other person has seen
the sample signature, as well as signatures over other (even similar) documents.
Intuitively, digital signatures provide similar functionality to handwritten
signatures; but, of course, the documents and the signatures are strings (files)
rather than ink on paper, and the processes of signing and validating are done
by applying appropriate functions (or algorithms), as illustrated in Figure 1.2.
Specifically, the signing algorithm Sign uses a private signing key s known only
to the signer, and the validating algorithm V er uses a corresponding public
validation key v. If σ = Ss (m), i.e., σ is a signature of message m using signing
key s, then Vv (m, σ) = Ok; and for an attacker who does not know s, it
should be infeasible to find any unsigned message m0 and any ‘signature’ σ 0 s.t.
Vv (m0 , σ 0 ) = Ok. The use of digital signatures allows computer-based signing
and validation of digital documents, which is crucial to secure communication
and transactions over the Internet.
We discuss digital signatures extensively in § 6.7, and their application to
the SSL/TLS protocol in chapter 7, and to Public Key Infrastructure (PKI) in
chapter 8.
9
1.3 Cybersecurity Goals and Attack Models
In a broad sense, secure systems should protect ‘good’ parties using the sys-
tems legitimately from damages due to attackers (also known as adversaries).
Attackers could be ‘bad’ users or ‘outsiders’ with some access to the systems or
their communication. Note that attackers may often also control a (corrupted)
device which they don’t ‘own’.
There are two basic ways of protecting against attackers, prevention and
deterrence:
Prevention is a proactive approach: we design and implement the system
so that the attacker cannot cause damage (or can only cause reduced
damage). Encryption is an example of a cryptographic means to pre-
vent attacks, as it is usually used to prevent an attacker from disclosing
sensitive information.
Deterrence is a reactive approach: we design mechanisms that will cause
damages to the attacker if she causes harm, or even when we detect an
attempt to cause harm. Effective deterrence requires the ability to detect
the attack, to attribute the attack to the attacker, and to penalize the at-
tacker sufficiently. Furthermore, deterrence can only be effective against
a rational adversary; no penalty is guaranteed to suffice to deter an ir-
rational adversary, e.g., a terrorist. The use of digital signatures is one
important deterrence mechanism. Signatures are used to deter attacks
in several ways; in particular, a signature verified using the attacker’s
well-known public key, over a given message, provides evidence that the
attacker signed that message. Such evidence can be used to punish or
penalize the attacker in different ways - an important deterrent. Signa-
tures may also be provided by users, as in reviews - to deter bad services
or products, to motivate the provision of good services and products, and
to allow users to choose a good service/product based on evaluations by
peer users.
Note that deterrence is only effective if the adversary is rational, and would
refrain from attacking if her expected profit (from attack) would be less than
the expected penalty.
An obvious challenge in designing and evaluating security is that we must
‘expect the unexpected’; attackers are bound to behave in unexpected ways.
As a result, it is critical to properly define the system and to identify and
analyze any risks. In practice, deployment of security mechanisms has costs,
and risk analysis would consider these costs against the risks, taking into ac-
count probabilities and costs of different attacks and their potential damages;
however, we do not consider these aspects, and only focus on ensuring specific
security goals against specific, expected kinds of attackers.
10
(CIA). Note that integrity/authenticity and availability are separate from con-
fidentiality, and often do not involve encryption; however, they often involve
other cryptographic mechanisms, such as digital signatures, as we discussed
above (subsection 1.2.2). Furthermore, note that these three goals are very
broad, as they apply to most cybersecurity systems; when we study the secu-
rity of any given system, we should first define specific security goals for that
particular system, which will usually elaborate on these three high-level goals.
One of the fundamentals of modern cryptology, which already appears
in [56], is an attempt to understand and define a clear model of the attacker
capabilities and clear goals/requirements for the scheme/system. We believe
that not only in cryptology, but in general in security, the articulation of the
attack model and of the security requirements is fundamental to the design and
analysis of security. Indeed, we consider this the first principle of cybersecurity.
This principle applies also in areas of cybersecurity where it may not be feasi-
ble to have completely rigorous models and proofs. Yet, precise articulation of
attacker model and capabilities, as well as of the security requirements, is very
important, and helps identify and avoid vulnerabilities.
A well-articulated description of the attacker model and capabilities, and of
the security requirements and assumptions, is necessary to evaluate and ensure
security for arbitrary interactions with the adversary. The adversary is limited
in its capabilities, not in its strategy.
1.4 Notations
Notations are essential for precise, efficient technical communication, but it can
be frustrating to understand text which uses unfamiliar or forgotten notations.
This would be a special challenge for readers of this text who were not (much)
exposed to the theory of computer science; furthermore, unfortunately, there
are often multiple notations for the same concept as well as multiple conflicting
interpretation for the same notation. The author tried to choose the more
widely used and least conflicting notations, but that included difficult tradeoffs.
For example, such conflicting usage ‘forced’ the author to adopt the less-widely-
used symbol + + to denote string concatenation1 .
To try to help the reader to follow the notations in this text, Table 1.1
presents notations which we use extensively. Please refer to it whenever you
see some unclear notation, and let me know of any missing or incorrect notation.
operator; however, this symbol is used extensively elsewhere for the logical-OR operator.
I therefore use ++ for concatenation; this is an existing notation, but not much used in
cryptography.
11
Table 1.1: Notations used in this manuscript.
12
Chapter 2
Encryption and
Pseudo-Randomness
Definition 2.1 is quite general. In particular, it does not restrict the encryp-
tion and decryption algorithms, e.g., they may be randomized; and it allows
arbitrary message space M and key space K. In the rest of this chapter, we will
1A block is a term for a string of bits of fixed length, the block length.
13
Key k
Plaintext Ciphertext
m Encrypt E c=Ek(m)
Key k
Ciphertext Plaintext
c Decrypt D m=Dk(c)
Key k Key k
Plaintext Ciphertext Plaintext
m Encrypt E Decrypt D
c=Ek(m) m=Dk(Ek(m))
14
Key length l
KeyGen KG
15
2.1.1 Ancient Keyless Monoalphabetic Ciphers
In this section, we discuss several well-known, simple, weak and ancient ciphers.
These ciphers also share two important additional properties: they do not
utilize a secret key, i.e., are ‘keyless’; and they are monoalphabetic. A cipher is
monoalphabetic if it is defined by a single, fixed mapping from plaintext letter
to ciphertext letter or symbol.
The At-Bash cipher The At-Bash cipher may be the earliest cipher whose
use is documented; specifically, it is believed to be used, three times, in the
Book of Jeremiah belonging to the Old Testament. The cipher maps each of
the letters in the Hebrew alphabet to a different letter. Specifically, the letters
are mapped in ‘reverse order’: first letter to the last letter, second letter to
the second-to-last letter, and so on; this mapping is reflected in the name ‘At-
Bash’2 . See illustrated in Fig. 2.3; even if you are not familiar with the letters
of the Hebrew alphabet, the mapping may still be identified by the visual
appearance. If you still find it hard to match, that’s Ok; we next describe an
adaptation of the At-Bash cipher to the Latin alphabet.
The Az-By cipher The Az-By cipher is the same as the At-Bash cipher,
except using the Latin alphabet. It is convenient to define the Az-By cipher, the
At-Bash cipher, and similar ciphers, by a formula. For that purpose, we define
the cipher as a function of the input letter, where each letter is represented by
its distance from the beginning of the alphabet; i.e., we represent the letter ‘A’
by the number 0, the letter ‘B’ by 1, and so on, until letter ‘Z’, represented by
25. The Az-By cipher is now defined by the following encryption function:
2 The name ‘At-Bash’ reflects the ‘reverse mapping’ of the Hebrew alphabet. The ‘At’
refers to the mapping of the first letter (‘Aleph’, ℵ) to the last letter (‘Taf’), and of the
second letter (‘Beth’, i) to the second-to-last letter (‘Shin’).
16
EAz−By (m) = 25 − m (2.1)
We illustrate the Az-By cipher in the top part of Fig. 2.4; below it, we
present two similar ancient ciphers, which we next discuss - the Caesar and the
ROT13 ciphers.
A B C D E F G H I J K L M
Z Y X W V U T S R Q P O N
AzBy
N O P Q R S T U V W X Y Z
M L K J I H G F E D C B A
A B C D E F G H I J K L M
D E F G H I J K L M N O P
Caesar
N O P Q R S T U V W X Y Z
Q R S T U V W X Y Z A B C
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
ROT13
N O P Q R S T U V W X Y Z
A B C D E F G H I J K L M
The Caesar cipher. We next present the well-known Caesar cipher. The
Caesar cipher has been used, as the name implies, by Julius Caesar. It is also
a mono-alphabetic cipher, operating on the set of the 26 Latin letters, from
A to Z. In the Caesar cipher, the encryption of plaintext letter p is found by
simply ‘shifting’ to the fourth letter after it, when letters are organized in a
circle (with A following Z). The Caesar cipher is illustrated by the middle row
in Figure 2.4.
We next write the formula for the Caesar cipher. As above, we represent
each letter by its distance from the beginning of the alphabet; i.e., we represent
the letter ‘A’ by the number 0, and so on; ‘Z’ is represented by 25. This can
be conveniently written as a formular, using modular arithmetic notations; see
Note 2.1 for a brief summary of basic modular arithmetic. Namely, the Caesar
encryption of p is given by:
ECaesar (m) = m + 3 mod 26 (2.2)
17
Note 2.1: Basic modular arithmetic
Modular arithmetic is based on the modulo operation, denoted mod , and defined
as the residue in integer division between its two operands. Namely, a mod n is an
integer b s.t. 0 ≤ b < n and for some integer i holds a = b + i · n. Note that a and
i may be negative, but the value of a mod n is unique.
The mod operation is applied after all ‘regular’ arithmetic operations such as
addition and multiplication; i.e., (a + b mod n) = [(a + b) mod n]. On the other
hand, we can apply the mod operation also to the operands of addition and
multiplication, often simplifying the computation of the final result. Namely, the
following useful rules are easy to derive, for any integers a, b, c, d, n, r s.t. 0 ≤ r < n:
r mod n =r (2.3)
[(a mod n) + (b mod n)] mod n = (a + b) mod n (2.4)
[(a mod n) − (b mod n)] mod n = (a − b) mod n (2.5)
[(a mod n) · (b mod n)] mod n = a·b mod n (2.6)
ab mod n = (a mod n)b mod n (2.7)
[(a + c) mod n = (b + c) mod n] ⇔ [a mod n = b mod n] (2.8)
[a · r mod n = b · r mod n] ⇔ [a mod n = b mod n] (2.9)
For simplicity, we often write the mod n operation only at the right hand side of
an equation, but it still applies to both sides. To avoid confusion, in such situations,
it is preferable to use the congruence symbol ≡, instead of the ‘regular’ equality
symbol =, e.g., a + b ≡ c · d mod n.
We apply - and discuss - more advanced modular arithmetic in chapter 6, where we
discuss public key cryptography.
Exercise 2.1. Write the formulas for the decryption of the Caesar and Az-By
ciphers.
Exercise 2.2. Use Equations (2.4) and (2.6) to prove that a number is divisible
by 3 if and only if the sum of its decimal digits is divisible by 3; prove the similar
rule for division by 9.
Exercise 2.3. Use Eq. (2.7) to show that for any integers a, b holds ab
mod (a − 1) = 1.
The ROT13 cipher ROT13 is popular variant of the Caesar cipher, with the
minor difference that the ‘shift’ is of 13 rather than of 3, i.e., EROT 13 (p) = p+13
mod 26. Note that in this special case, encryption and decryption are exactly
the same operation: EROT 13 (EROT 13 (p)) = p. The ROT13 cipher is illustrated
by the bottom row in Figure 2.4. Instead of writing down the formula for
ROT13 encryption, as done above for Az-By and Caesar ciphers, we encourage
the readers themselves to write it down.
18
The Masonic cipher. A final example of a historic, keyless, monoalphabetic
cipher is the Masonic cipher. The Masonic cipher is from the 18th century and
is illustrated in Fig. 2.5. This cipher uses a ‘key’ to map from plaintext to
ciphertext and back, but the key is only meant to assist in the mapping, since
it has a regular structure and is considered part of the cipher.
Figure 2.5: The Masonic Cipher, written graphically and as a mapping from
the Latin alphabet to graphic shapes.
19
the following exercise shows, it is easily broken by an attacker who has access
to one known plaintext pair, i.e., a pair of (plaintext m, ciphertext Ek (m)). An
attack exploiting such pairs is called a known plaintext attack (KPA).
Exercise 2.4 (Known plaintext attack (KPA) on shift cipher). Consider the
l-bits shift cipher Ek (p) = p + k mod 2l , where p, k ∈ {0, 1}l . Suppose an
attacker can get the encryption Ek (p) of one known block p ∈ {0, 1}l . Show
that this allows the attacker to decrypt an arbitrary ciphertext c0 , i.e., find p0
s.t. c0 = Ek (p0 ).
20
A B C D E F G H I J
Y * X K L D B C Z F
K L M N O P Q R S T
G E R U + J W ! H M
U V W X Y Z . , !
P N I O Q S - V T A
if the plaintext also contains spaces and punctation marks, this can help the
attacker significantly. This type of ciphertext-only attack (CTO) is called the
letter-frequency attack.
Note that for the letter-frequency and other CTO attacks to be effective
and reliable, the attacker requires a significant amount of ciphertext.
21
In fact, this phenomenon exists for other attacks too; cryptanalysis often
requires a significant amount of ciphertext encrypted using the same encryption
key. This motivates limiting the use of each cryptographic key to a limited
amount of plaintext (and ciphertext), with the hope of making cryptanalysis
harder or, ideally, infeasible.
22
Identifier Cipher Ciphertext Plaintext Time
A Caesar JUHDW SDUWB
B AzBy ILFMW GZYOV
C ROT13 NYBAR NTNVA
D BLFMT OLEVI
E FZNEG UBHFR
F EUHDN UXOHV
Table 2.1: Ciphertexts for Exercise 2.6. All plaintexts are pairs of two simple
five-letter words. The three upper examples have the cipher spelled out, the
three lower examples hide it (’obscurity’). It does not make them secure, but
decryption may take a bit longer.
23
2.2 Cryptanalysis Attack Models: CTO, KPA, CPA and
CCA
As discussed in § 1.3 and in particular in Principle 1, security should be defined
and analyzed with respect to a clear, well defined model of the attacker capa-
bilities, which we refer to as the attack model. In this section, we introduce
four cryptanalysis attack models: CTO, KPA, CPA and CCA. These define the
capabilities of attackers trying to ‘break’ an encryption scheme.
We discussed above the letter-frequency attack, which relied only on access
to sufficient amount of ciphertext - and on knowing the letter-distribution of
plaintext messages. In subsection 2.3.1, we present exhaustive search, an attack
requiring the ability to identify correctly-decrypted plaintext (with significant
probability). Both of these attacks requires only access to (sufficient) cipher-
text, and some knowledge about the plaintext distribution (letter frequencies
or ability to identify possible plaintexts). We refer to attacks which require
only these ‘minimal’ attacker capabilities, as ciphertext-only (CTO) attacks.
In particular, ciphertext-only attacks do not require a (plaintext, ciphertext)
pair.
To facilitate CTO attacks, the attacker must have some knowledge about
the distribution of plaintexts. In practice, such knowledge is typically implied
by the specific application or scenario. For example, when it is known that the
message is in English, then the attacker can apply known statistics such as the
letter-distribution histogram Figure 2.7. For a formal, precise definition, we
normally allow the adversary to pick the plaintext distribution. Note that this
requires defining security carefully, to prevent absurd ‘attacks’, which clearly
fail in practice, to seem to fall under the definition.
In subsection 2.3.2, we discuss the table look-up and time-memory tradeoff
attacks; in both of these generic attacks, the adversary must be able to obtain
the encryption of one or few specific plaintext messages - the messages used to
create the precomputed table. We refer to an attack of this type as a chosen-
plaintext attack (CPA). We say that the CPA attack model is stronger than
the CTO attack model, meaning that every cryptosystem vulnerable to CTO
attack is also vulnerable to CPA.
Let us briefly mention two additional common attack models for encryption
schemes, which represent two different variants of the CPA attack. The first
is the known-plaintext attack (KPA) model, where the attacker receives one or
multiple pairs of plaintext and the corresponding ciphertext, but the plaintext
is chosen randomly.
Exercise 2.7 (CP A > KP A > CT O). Explain (informally) why every cryp-
tosystem vulnerable to CTO attack, is also vulnerable to KPA, and every cryp-
tosystem vulnerable to KPA, is also vulnerable to CPA. We say that the KPA
model is stronger than the CTO model and weaker than the CPA model.
24
the attacker. We adopt the common definition, where CCA-attackers are
also allowed to perform CPA attacks, i.e., the attacker can obtain the en-
cryptions of attacker-chosen plaintext messages. With this definition, trivially,
CCA > CP A. Combining this with the previous exercise, we have the com-
plete ordering: CCA > CP A > KP A > CT O.
25
Furthermore, it should be possible to efficiently identify correct decryption by
checking the output of the decryption of the ciphertext. Namely, the decoding
of an arbitrary plaintext with an incorrect key should result in clearly-invalid
plaintext, with significant probability. Exhuastive search is applicable for any
stateless encryption provided that such validation of plaintext is possible; this
is why we refer to it as a generic CTO attack.
Exhaustive search is practical only when the key space is not too large. For
now we focus on symmetric ciphers, where the key is usually an arbitrary binary
string of given length, namely the key space is 2l where l is the key length, i.e.,
the problem is the use of insufficiently-long keys. Surprisingly, designers have
repeatedly underestimated the risk of exhaustive search and used ciphers with
insufficiently long keys, i.e., insufficiently large key spaces.
Let TS be the sensitivity period, i.e., the duration required for maintaining
secrecy, and TD be the time it takes to test each potential key, by performing
one or more decryptions. Hence, the attacker can test TS /TD keys out of the
key-space containing 2l keys. If TS /TD > 2l , then the attacker can test all
keys, and find the key for certain (with probability 1); otherwise, the attacker
TS
succeeds with probability TD ·2l
. By selecting sufficient key length, we can
ensure that the success probability is as low as desired.
For example, consider the conservative assumption of testing a billion keys
per second, i.e., TD = 10−9 , and requiring the security for three thousand
years, i.e., TS = 1011 , with probability of attack succeeding at most 0.1%. We
find that to ensure security with these
parameters against brute force attack,
we need keys of length l ≥ log2 TTDS = log2 (1020 ) < 74 bits.
The above calculation assumed a minimal time to test each key. Of course,
attackers will often be able to test many keys in parallel, by using multiple com-
puters and/or parallel processing, possibly with hardware acceleration. Such
methods were used during 1994-1999 in multiple demonstrations of the vulner-
ability of the Data Encryption Standard (DES) to different attacks. The final
demonstration was exhaustive search completing in 22 hours, testing many
keys in parallel using a $250,000 dedicated-hardware machine (‘deep crack’)
together with [Link], a network of computers contributing their idle
time.
However, the impact of such parallel testing, as well as improvements in
processing time, is easily addressed by reasonable extension of key length. As-
sume that an attacker is able to test 100 million keys in parallel during the
same 10−9 second, i.e., TD = 10−17 . With the same goals
and calculation as
above we find that we need keys of length l ≥ log2 TTDS = log2 (1026 ) < 100.
This is far below even the minimal key length of 128 bits supported by the
Advanced Encryption Standard (AES). Therefore, exhaustive search is not a
viable attack against AES or other ciphers with over 100 bits.
26
decryption with the wrong key will result in seemingly-valid plaintext. Hence,
exhaustive search may often not return only the correct secret key. Instead,
quite often, exhaustive search may return multiple candidate keys, which all
resulted in seemingly-valid decryption. In such cases, the attacker must now
eliminate some of these candidate keys by trying to decrypt additional cipher-
texts and discarding a key when its decryption of some ciphertext appears to
result in invalid plaintext.
27
2.3.3 Effective key length
Cryptanalysis, i.e., developing attacks on cryptographic mechanisms, is a large
part of the research in applied cryptography; it includes generic attacks such
as these presented earlier in this section, as well as numerous attacks which are
tailored to a specific cryptographic mechanism. This may look surprising; why
publish attacks? Surely the goal is not to help attacks against cryptographic
systems?
Cryptanalysis facilitates two critical decisions facing designers of security
systems which use cryptography: which cryptographic mechanism to use, and
what parameters to use, in particular, which key length to use.
Let us focus first on the key length. All too often, when cryptographic prod-
ucts and protocols are mentioned in the popular press, the key-length in use
is mentioned as an indicator of their security. Furthermore, this is sometimes
used to argue for the security of the cryptographic mechanism, typically by
presenting the number of different key values possible with a given key length.
The number of different keys, is the time required for the exhaustive search
attack, and has direct impact on the resources required by the other generic
attacks we discussed. Hence, clearly, keys must be sufficiently long to ensure
security. But how long?
It is incorrect to compare the security of two different cryptographic sys-
tems, which use different cryptographic mechanisms (e.g., ciphers), by compar-
ing the key length used in the two systems. Let us give two examples:
28
be of great interest, and as the gap grows, there will be increasing concern with
using the cipher. The use of key lengths which are 128 bits or more leaves a
‘safety margin’ against potential better future attacks, and gives time to change
to a new cipher when a stronger, more effective attack is found.
Note that, as shown in Table 6.1, for asymmetric cryptosystems, there is
often a large gap between the real key length l and the effective key length k.
This is considered acceptable, since the design of asymmetric cryptosystems is
challenging, and it seems reasonable to expect attacks with performance much
better than exhaustive search. In particular, in most public key systems, the
secret key is not an arbitrary, random binary string.
Note that the evaluation of the effective key length, depends on the attack
model; there are often attacker with much smaller effective-key length, when
assuming a stronger attacker model, e.g., CPA compared to KPA or CTO. One
should therefore also take into account the expected attack model.
Also, notice that the effective key length measure compares based on the
time required for the attack; it does not allow for comparing different resources,
for example, time-memory trafeoff.
Normally, we select sufficient key length to ensure security against any
conceivable adversary, e.g., leaving a reasonable margin above effective key
length of say 100 bits; a larger margin is required when the sensitivity period
of the plaintext is longer. The cost of using longer keys is often justified,
considering the damages of loss of security and of having to change in a hurry
to a cipher with longer effective key length, or even of having to use longer
keys.
In some scenarios, however, the use of longer keys may have significant
costs; for example, doubling the key length in the RSA cryptosystem increases
the computational costs by about six. We therefore may also consider the risk
from exposure, as well as the resources that a (rational) attacker may deploy
to break the system. This is summarized by the following principle.
29
enough resources? Or, can encryption be secure unconditionally - even against
an attacker with unbounded resources (time, computation speed, storage)?
We next present such an unconditionally secure cipher, the One Time Pad
(OTP). The One Time Pad is often attributed to a 1919 patent by Gilbert
Vernam [166], although some of the critical aspects may have been due to
Mauborgne [26], and in fact, the idea was already proposed by Frank Miller in
1882 [25]; we again refer readers to the many excellent references on history of
encryption, e.g., [102, 155].
The One Time Pad is not just unconditionally secure - it is also an exceed-
ingly simple and computationally efficient cipher. Specifically:
Encryption: To encrypt a message, compute its bitwise XOR with the key.
Namely, the encryption of each plaintext bit, say mi , is one ciphertext
bit, ci , computed as: ci = mi ⊕ ki , where ki is the ith bit of the key.
Decryption: Decryption simply reverses the encryption, i.e., the ith decrypted
bit would be ci ⊕ ki .
Key: The key k = {k1 , k2 , . . .} should consist of independently drawn fair
coins, and its length must be at least as long as that of the plaintext.
Notice, that the key should be - somehow - shared between the parties,
which may be a challenge in many scenarios.
See illustration in Figure 2.8.
c=m⊕k
30
adversaries - like everyone else - have limited computational abilities. There-
fore, in this course, we focus on computationally-bounded adversaries.
While the key required by OTP makes its use rarely practical, we next show
a computationally-secure variant of OTP, where the key can be much smaller
than the plaintext, and which can be used in practical schemes. Of course, this
variant is - at best - secure only against computationally-bounded attackers.
31
an exact, synchronized count of the number of key bits used so far, to pre-
vent reuse of key bits (leading to exposure) and incorrect decryption. Hence,
sStream ciphers are inherently stateful.
Stream ciphers are often used in applied cryptography, and esp. in hardware
implementations, mainly due to their simple and efficient hardware implemen-
tation. Rarely, we use the OTP (or another unconditionally-secure cipher), but
much more commonly, a stream cipher with a bounded-length key, providing
‘only’ computational security. In the following section we introduce pseudo-
random generators (PRG) and pseudo-random functions (PRF), and show how
to use either of them to design a a bounded key length stream cipher.
32
PRG: intuitive definition. In this subsection, we only introduce PRGs
informally, focusing on their use in the construction of bounded-key-length
stream ciphers. Given any random input string k, a PRG fP RG outputs a
longer string, i.e., (∀k ∈ {0, 1}∗ ) (|fP RG (k)| > |k|). Furthermore, if k is a
random string (of |k| bits), then fP RG (k) is pseudo-random. Intuitively, this
means that fP RG (k) cannot be efficiently distinguished from a true random
string of the same length |fP RG (k)|. We define these concepts of efficient
distinguishing and PRG precisely quite soon, in subsection 2.5.2.
fP RG (·)
c = m ⊕ fP RG (k)
Figure 2.9: PRG-based Stream Cipher. The input to the PRG is usually called
either key or seed; if the input is random, or pseudo-random, then the (longer)
output string is pseudo-random. The state includes the current bit index i.
longer. However, we can use such a PRG to construct another PRG, whose output length is
longer (as a function of its input length). The details and proof are beyond our scope; see,
e.g., [79]).
33
In subsection 2.5.2 below, we discuss PRGs, whose definition is based on
the PRG indistinguishability test. Let us first introduce the concept of indis-
tinguishability test, one of the ingenious concepts introduced by Alan Turing.
34
Turing test, and random sequences here) and who is the ‘imitation’ (machine
in Turing test, and sequences output by function f here).
Intuitively, a pseudo-random generator is a function f whose input is a
$
‘short’ random bit string x ← {0, 1}n , and whose output a longer string f (x) ∈
{0, 1}ln s.t. ln > n, which is pseudo-random - i.e., indistinguishable from a
random string (of the same length ln ).
But what does it mean for the output to be indistinguishable from random?
This is defined by the PRG indistinguishability test, which we next define -
and which, in concept, quite resembles the Turing indistinguishability test,
although the details are different. The similarity can be seen from comparing
the illustration of the PRG indistinguishability test in Figure 2.11, to that of
the Turing test in Figure 2.10.
35
Distinguisher capabilities: Efficient algorithm (PPT). We model the
distinguisher as an algorithm, denoted D, which receives the a binary string
- either a random string or the ‘pseudorandom’ output of the PRG f - and
outputs its evaluation, which should be 0 if given truly random string, and 1
otherwise, i.e., if the input is not truly random. The distinguisher algorithm
D has to be efficient (or PPT). The terms efficient algorithm and PPT (Prob-
abilistic Polynomial Time) algorithm are crucial to definitions of asymptotic
security, which we use in this textbook6 .
Definition 2.3. We say that an algorithm A is efficient if its running time is
bounded by some polynomial in the length of its inputs. An efficient algorithm
may be randomized, in which case we say that it is in the set of Probabilistic
Polynomial Time (PPT) algorithms (A ∈ P P T ).
These definitions are widely used in computer science, in particular in the
theory of complexity. A useful property is that the set of efficient/PPT algo-
rithms remains the ssame for different ‘reasonable’ computational models, such
as different sets of basic operations and different sizes and types of storage.
εP RG
D,f (n) ≡ Pr [D (f (x))] − Pr [D (y)] (2.10)
$ $
x←{0,1}n y ←{0,1}ln
36
Negligible functions. Intuitively, f is a (secure) PRG, if all efficient (PPT)
distinguishers D have only negligible advantage εP RG
D,f (n). But what does it
mean for the advantage to be negligible? And how can we hope for the advan-
tage to be negligible or even small for very short input (seed)? If n is small,
then the distinguisher could compute the outputs for all possible inputs, i.e.,
the set F [n] = {f (x)}x∈{0,1}n ; and whenever given a string which is not in
F [n], the distinguisher can safely output 0, since it knows that this cannot be
an output of f (for any n-bit input).
There are two main approaches of dealing with this challenge in the crypto-
graphic literature, usually referred to as asymptotic security and concrete secu-
rity. We will focus on asymptotic security, since we believe that the concrete-
security definitions are a bit harder to understand and work with; as with
other advanced topics, readers are encouraged to learn them in more advanced
courses and textbooks, as well as directly in the relevant papers, e.g. [12].
Asymptotic-security requires the advantage function εP RG
D,f (n) to be negli-
gible. What does it mean when we say that a function ε : N → R is negligi-
ble? Clearly, we expect such function to converge to zero for large input, i.e.:
limn→∞ ε(n) = 0. But a negligible function is a function that converges to zero
in a very strong sense - faster than any polynomial7 .
Definition 2.5 (Negligible function). A function ε : N → R is negligible, if
for every non-zero polynomial p(n) holds:
ε(n)
lim =0 (2.11)
n→∞ p(n)
We use N EGL to denote the set of all negligible functions; we sometimes write
N EGL(n) to emphasize that the function is negligible in input parameter n.
Note that any non-zero polynomial function ε(n) - even if its values appear
to us tiny - cannot fit this definition of a negligible function, as the definition
ε(n) n→∞
requires p(n) → 0 for any polynomial p(n), and for the polynomial p(n) =
ε(n)
ε(n) we clearly have p(n) = 1.
find it more convenient and natural to consider the absolute value of the function and poly-
nomial, i.e., we do not consider a function with large negative values to be negligible; other
authors require only the positive value of the function to be small, but the two definitions
are equivalent anyway for our purposes.
37
Working with negligible functions is a useful simplification; here is one
convenient property, which shows that if an algorithm has negligible probability
to ‘succeed’, then running it a polynomial number of times will not help - the
probability to succeed will remain negligible.
The term ‘secure’ is often omitted; i.e., when we say that algorithm f is a
pseudo-random generator (PRG), this implies that it is a secure PRG.
Exercise 2.10. Let x ∈ {0, 1}n . Show that the following are not PRGs: (a)
+ parity(x), (b) fb (x) = 3x mod 2n+1 (using standard binary en-
fa (x) = x +
coding).
Solution for part (b): Notice that here we view x as a number encoded in
binary, whose value can be between 0 and 2n − 1.
A simple distinguisher Db for fb is: Db (y) outputs 1 (i.e., pseudo-random)
if y = 0 mod 3, otherwise, it outputs 0 (i.e., random). Why does this work?
If y is a random n + 1-bits string, then the probability of y = 0 mod 3 is
1
3 (actually, tiny bit less).
n+2
And what if y = fb (x), i.e., y = 3x mod 2n+1 ? If x < 2 3 , then 3x <
2n+2
2n+2 , i.e., y = 3x, and hence y = 0 mod 3. And Pr $ x< 3 ≥ 23 .
x←{0,1}n
Therefore, if y = fb (x), i.e., y = 3x mod 2n+1 , then y = 0 mod 3 with
probability at least 32 .
2 1 1
Therefore, εP RG
Db ,fb (n) ≥ 3 − 3 = 3 , which is clearly non-negligible.
38
2.5.5 Secure PRG Constructions
Note that we did not present a construction of a secure PRG. In fact, if we
could have presented a provably-secure construction of a secure PRG, satisfying
Def. 2.6, this would have immediately proven that P 6= N P , solving the most
well-known open problems in the theory of complexity. Put differently, if P =
N P , then there cannot be any secure PRG algorithm (satisfying Def. 2.6).
?
Since P = N P is believed to be a very hard problem, proving that a given
construction is a (secure) PRG must also be a very hard problem, and unlikely
to be done as a side-product of proving that some function is a PRG. Similar
arguments apply to most of the cryptographic mechanisms we will learn in this
course, including secure encryption, when messages may be longer than the
key. (The One Time Pad (OTP) is secure encryption, but its key is as long as
the plaintext.)
What is possible is to present a reduction-based construction of a PRG,
namely, construction of PRG from some other cryptographic mechanism, along
with a proof that the PRG is secure if that other mechanism is ‘secure’. For
example, see [79] for a construction of PRG f from a different cryptographic
mechanism called one-way function (which we discuss in § 4.4), and a reduction
proof, showing if the construction of f uses a OWF fOW F , then the resulting
function f would be a PRG. We will also present few reduction proofs, for
example, later in this section we prove reductions which construct a PRG from
other cryptographic mechanisms such as a Pseudo-Random Function (PRF),
see Exercise 2.13, and a block-cipher. Courses, books and papers dealing with
cryptography, are full of reduction proofs, e.g., see [79, 80, 159].
Unfortunately, there is no proof of the existence of any of these - one-way
function, PRF, block-cipher or most other cryptographic schemes. Indeed,
such proofs would imply P 6= N P . Still, reduction proofs are the main method
of ensuring the security of most cryptographic mechanisms - by showing that
they are ‘at least as secure’ as another cryptographic mechanism, typically
a mechanism whose security is well established (e.g., by failure of extensive
cryptanalysis efforts).
For example, one-way functions appear ‘weaker’ than PRGs, so may be
easier to design securely - and then use the reduction to obtain PRG. As a
more practical example, block-ciphers are standardized, with lots of cryptanal-
ysis efforts; therefore, block ciphers are a good basis to use for building other
cryptographic functions.
Let us give an important example of reduction-based proof which is specific
to PRGs. This is a construction of a PRG whose output is significantly larger
than its input, from a PRG whose output is only one-bit longer than its in-
put. Unfortunately, the construction and proof are beyond our scope; see [79].
However, the following exercise (Exercise 2.11) proves a related - albeit much
simpler - reduction, showing that a PRG G from n bits to n + 1-bits, gives also
a PRG G0 from n + 1 bits to n + 2-bits, simply by exposing one bit. In other
words, this shows that a PRG may expose one (or more) bits - but remain a
PRG.
39
Exercise 2.11. Let f : {0, 1}n → {0, 1}n+1 be a secure PRG. Is f 0 : {0, 1}n+1 →
{0, 1}n+2 , defined as f 0 (b+ +f (x), where b ∈ {0, 1}, also a secure PRG?
+x) = b+
Solution: Yes, if f is a PRG then f 0 is also a PRG. First, recall the PRG-
advantage (Equation 2.10) for distinguisher D, using ln = n + 1:
εP RG
D,f (n) ≡ Pr [D (f (x))] − Pr [D (r)] (2.12)
$ $
x←{0,1}n r ←{0,1}n+1
εP RG
D 0 ,f 0 (n + 1) ≡ Pr [D0 (f 0 (x0 ))] − Pr [D0 (r0 )] 6∈ N EGL(n)
$ $
x0 ←{0,1}n+1 r 0 ←{0,1}n+2
(2.13)
We next present a simple construction of a distinguisher D (for f ), using,
as a subroutine (oracle), a given distinguisher D0 (for f 0 ):
n o
$
D(y) ≡ Return D0 (b + + y) where b ← {0, 1} (2.14)
= Pr D0 (r0 ) (2.19)
$
r 0 ←{0,1}n+2
εP RG
D,f (n) ≡ Pr [D (f (x))] − Pr [D (r)] (2.20)
$ $
x←{0,1}n r ←{0,1}n+1
≡ εP RG
D 0 ,f 0 (n + 1) (2.22)
0
Hence, εP RG P RG
D,f (n) = εD 0 ,f 0 (n + 1), namely, f is a PRG if and only if f is a
PRG.
40
Feedback Shift Registers (FSR). There are many proposed designs for
PRGs. Many of these are based on Feedback Shift Registers (FSRs), with
a known linear or non-linear feedback function f , as illustrated in Fig. 2.12.
For Linear Feedback Shift Registers (LFSR), the feedback function f is sim-
ply the XOR of some of the bits of the register. Given the value of the ini-
tial bits r1 , r2 , . . . , rl of an FSR, the value of the next bit rl+1 is defined as:
rl+1 = f (r1 , . . . , rl ); and following bits are defined similarly: (∀i > l)ri =
f (ri−l , . . . , ri−1 ).
FSRs are well-studied with many desirable properties. However, by defini-
tion, their state is part of their output. Hence, they cannot directly be used
as cryptographic PRGs. Instead, there are different designs of PRGs, often
combining multiple FSRs (often LFSRs) in different ways. For example, the
A5/1 and A5/2 stream ciphers defined in the GSM standard combine three
linear shift registers.
f(…)
r10 r9 r8 r7 r6 r10 r5 r4 r3 r2 r1
Figure 2.12: Feedback Shift Register, with (linear or non-linear) feedback func-
tion f ().
41
Example 2.1. MS-Word 2002 used RC4 for document encryption, in the fol-
lowing way. The user provided password for the document; that password was
used as a key to the RC4 PRG, producing a long pseudo-random string which is
referred to as P ad, i.e., P ad = RC4(password). When the document is saved
or restored from storage, it is XORed with P ad. This design is vulnerable; can
you spot why?
The vulnerability is not specific in any way to the choice of RC4; the problem
is in how it is used. Namely, this design re-uses the same pad whenever the
document is modified - a ‘multi-times pad’ rather than OTP. The plaintext
Word documents contain sufficient redundancy, to allow decryption. See details
in [126].
The fact that the vulnerability is due to the use of RC4 and not to crypt-
analysis of RC4, is very typical of vulnerabilities in systems involving cryp-
tography. In fact, cryptanalysis is rarely the cause of vulnerabilities - system,
configuration and software vulnerabilities are more common.
Exercise 2.12. Using a coin, select randomly the functions below; count your
coin flips.
42
Function Domain Range 00 01 10 11 coin-flips
f1 {0, 1}2 {0, 1}
f2 {0, 1}2 {0, 1}3
How many coin flips required were required for each function?
Stream cipher using a random function. Figure 2.13a presents the de-
sign of a stream cipher using a randomly-chosen function f which is shared by
the two parties and kept secret. The design could be used either for bit-by-bit
encryption, with the random function mapping each input i to a single bit f (i),
which is then XORed with the corresponding message bit mi to form the ci-
phertext ci = mi ⊕ f (i). Alternatively, both input messages mi and the output
of the random function could be strings of some length, e.g., n, and then each
invocation of the random function will produce n pad bits, XORed with n pad
bits to produce n cipher bits.
One drawback of the use of stream ciphers is the need to maintain syn-
chronized state between sender and recipient. This refers to the (typical) case
where the input is broken into multiple messages, each provided in a separate
call to the encryption device. To encrypt all of these messages using a stream
cipher - OTP or the design in Figure 2.13a - the two parties must maintain the
number of calls i (bits or strings of fixed length). To avoid this requirement,
we can use randomized encryption, as we next explain.
43
i $
ri ← {0, 1}n
f (·)
f (·)
mi
mi
ci = mi ⊕ f (i) z }| {
ci = (mi ⊕ f (ri ), ri )
(a) Using random function f to con-
struct a stream-cipher for stateful (b) Using random function f to con-
encryption, with limited storage (a struct stateless, randomized encryp-
counter). Does not require random- tion. This construction has high com-
ization and communication-optimal munication overhead: n (random) bits
(|ciphertext| = |plaintext|. per plaintext bit.
Figure 2.13: Bit-wise encryption using random function f (·). We later improve:
replace random function by Pseudo-Random Function (PRF), and use block-
wise operations to reduce overhead; e.g., counter-mode (stateful) and OFB-
mode (randomized).
for the two parties to maintain state (of the message/bit counter i). To do this,
we use the random function to construct randomized encryption, as shown in
Figure 2.13b.
To encrypt each plaintext message mi , we choose a string ri of n random
$
bits, i.e., ri ← {0, 1}n . The ciphertext is the pair Ef (mi ) ≡ (mi ⊕ f (ri ), ri ).
Note our use of the function f as the key to the encryption; indeed, we can
think of the table containing our random mapping of each of the 2n strings in
the domain {0, 1}n to a bit, as the function - and as the key to the encryption
process.
44
ing plaintexts mj , allowing the attacker to find all the corresponding mappings
{f (rj )}j<i . Using this information, can the attacker guess f (ri )?
Now, clearly, if ri ∈ {(rj }j<i , then the attacker knows f (ri ) and can expose
mi . To address this, we clearly must use sufficiently-long random strings. But
what if ri 6∈ {(rj }j<i ?
To answer this, reconsider the process of selecting a random function, as
you did in Exercise 2.12. What we did was to select the entire table - mapping
from every element in the domain to a random element in the range - before
we applied the random function. However, notice that it does not matter if,
instead, we chose the mapping for each element ri ∈ D in the domain only on
the first time we need to compute f (ri ). Think it over!
This means, that if ri 6∈ {(rj }j<i , then the attacker does not learn anything
about f (ri ), even if it is given all of the {f (rj )}j<i values. Until we select
(randomly) the value of f (ri ), the attacker cannot know anything about it.
Therefore, the only concern we have is with the case that ri ∈ {(rj }j<i . Let
us return to this issue; what is the probability of that happening? Well since
each napping is selected randomly, simply i−1 |D| . Focusing on the typical case
where the input domain is {0, 1}n , this is i−1 2n
Therefore, if n is ‘sufficiently large’, then the maximal number of observa-
tions by the attacker would still be negligible compared to 2n - and 2in would be
negligible. For example, if the attacker can observe a million encryptions, we
‘just’ need 2n to be way larger than one million ; and considering that a million
is less than 220 , using n significantly larger than 20 - definitely for n = 120 or
even less - seems safe enough.
45
allow encryption of arbitrarily long plaintext m - requiring new n random
bits only to encrypt new plaintext, and only if the state (of the PRG)
was not retained. This is essentially what is done by the Output Feedback
(OFB) mode of operation, which we see later on, except that the OFB
mode also implements the PRG using the PRF, instead of using two sep-
arate functions (a PRF and a PRG). Figure 2.15 shows this design, using
a PRF Fk .
$
i ri ← {0, 1}n
f (·) f (·)
/n /n
mi / mi /
n n
/n /n
z }| { z }| {
ci = (mi ⊕ f (i)) ci = (mi ⊕ f (ri ), ri )
(a) Stateful block encryption with (b) Stateless, randomized block en-
Random Function f (·). cryption with Random Function f (·).
Figure 2.14: Block (n-bits) encryption using a Random Function f (·). Use
only one function application for n plaintext bits.
46
Consider an arbitrary (given) function f 00 : D → R. We have that:
47
$
i ri ← {0, 1}n
k fk (·) k fk (·)
/n /n
mi / mi /
n n
/n /n
z }| { z }| {
ci = (mi ⊕ fk (i)) ci = (mi ⊕ fk (ri ), ri )
(a) Stateful block encryption with a (b) Stateless, randomized block en-
PRF fk (·). cryption using PRF fk (·).
with (in this case, the truly-random function or the PRF). Other terms for
oracle access are ‘black box access’ or ‘subroutine access’.
48
Figure 2.16: The Pseudo-Random Function (PRF) Indistinguishability Test.
We say that function Fk (x) : {0, 1}∗ × D → R is a (secure) pseudo-random
generator (PRG), if no distinguisher D can efficiently distinguish between Fk (·)
and a random function f from the same domain D to the same range R, when
the key k is a randomly-chosen sufficiently-long binary string.
The probabilities are taken over random coin tosses of A, and random choices
$ $
of the key k ← {0, 1}n and of the function f ← {D → R}.
The oracle notation. Both AFk and Af use the oracle notation introduced
in Definition 2.7. Namely, they mean that A is given ‘oracle’ access to the
respective function (Fk () and f ()). Oracle access means that the adversary
can give any input x and get back that function applied to x, i.e., Fk (x) or
f (x), respectively
49
Why allow arbitrary key length (security parameter)? The definition
allows arbitrarily-long keys, although in practice, cryptographic standards of-
ten have a fixed key length, or only a few options. The reason that the definition
allows arbitrary length is that it requires the success probability to be negligi-
ble - smaller than any polynomial in the key length - which is meaningless if
the key length is bounded.
50
2.5.8 PRF: Constructions and Robust Combiners
The concept of PRFs was proposed in a seminal paper by Goldreich, Goldwasser
and Micali [82]; the paper also presents a provably-secure construction of PRF,
given a PRG. That is, if there is a successful attack on the constructed PRF,
this attack can be used as a ‘subroutine’ to construct a successful attack on
the underlying PRG. However, the construction requires many applications of
the PRG for a single application of the PRF. Therefore, this construction is
not applied in practice. In contrast, Exercise 2.13 shows one of many simple
and efficient constructions of a PRG from a PRF.
Exercise 2.13. Let F be a PRF over {0, 1}n bits, and let k, r ∈ {0, 1}n . Prove
that f (k) = (Fk (1) +
+ Fk (2)) is a PRG.
Practical PRF designs, therefore, do not build a PRF from a PRG - they
use simpler and more efficient constructions. The most well knows is that of
a PRF from a block cipher, which we will discuss soon after introducing block
ciphers.
Another option is to construct candidate pseudo-random functions directly,
without assuming and using any other ‘secure’ cryptographic function, basing
their security on failure to ‘break’ them using known techniques and efforts by
expert cryptanalysts. In fact, pseudo-random functions are among the crypto-
graphic functions that seem good candidates for such ‘ad-hoc’ constructions; it
is relatively easy to come up with a reasonable candidate PRF, which will not
be trivial to attack. See Exercise 2.35.
Finally, it is not difficult to combine two candidate PRFs F 0 , F 00 , over the
same domain and range, into a combined PRF F which is secure as long as
either F 0 or F 00 is a secure PRF. We refer to such a construction as a robust com-
biner. Constructions of robust combiners are known for many cryptographic
primitives. The following lemma, from [92], presents a trivial yet efficient ro-
bust combiner for PRFs, and also allows us to give a simple example of a
typical cryptographic proof of security based on reduction to the security of
underlying modules.
Proof. WLOG assume F 0 is a PRF, and we show that F is also a PRF. Suppose
to the contrary, i.e., exists some adversary A that can efficiently distinguish
$
between Fk0 ,k00 (·) and a random function f ← {D → R}.
We use A as a subroutine in the design of A0 . Adversary A0 is given
$
oracle access to a function yb0 (·), with b ← {0, 1}, where y00 (x) = Fk0 0 (x) and
51
y10 (x) = f 0 (x) where f 0 (·) is a random function from domain D to range R.
We will show that A0 efficiently distinguishes between Fk0 0 (·) and a random
function f 0 (·) from domain D to range R, in contradiction to the assumption
that F 0 is a PRF.
A0 first generates a random key k 00 for F 00 ; this allows A0 to compute the
value of Fk0000 (x), for any input x. A0 now runs A. When A asks for computation
of the oracle over input x, then A0 returns the value yb (x) = Fk0000 (x) ⊕ yb0 (x),
where yb0 (x) is the value it receives from its oracle (on input x). Namely,
y0 (x) = Fk0000 (x) ⊕ y00 (x) = Fk0000 (x) ⊕ Fk0 0 (x) = Fk0 ,k00 (x)
And
y1 (x) = Fk0000 (x) ⊕ y10 (x) = Fk0000 (x) ⊕ f 0 (x)
From Lemma 2.2, f 0 (x) ⊕ Fk0000 (x), like f 0 (x), is also a random function, which
we denote f (x). Hence, y1 (·) is a random function from domain D to range R.
Hence, if b = 0, i.e., A0 is given oracle access to a random function f 0 (x), then
A is also given oracle access to a random function f (x); otherwise, if b = 1,
i.e., A0 is given oracle access to Fk0 0 (·), then A is given oracle access to Fk0 ,k00 .
Namely, A0 returns the same value as returned to it by A, and distinguishes
between F 0 and the random function f 0 .
52
Principle 6 (Key-separation). Use separate, independently-pseudorandom keys
for each different cryptographic scheme, as well as for different types/sources
of plaintext and different periods.
The principle combines three main motivations for the use of separate,
independently-pseudorandom keys:
Per-goal keys: use separate keys for different cryptographic schemes. A sys-
tem may use multiple different cryptographic functions or schemes, often
for different goals, e.g., encryption vs. authentication. In this case, se-
curity may fail if the same or related keys are used for multiple different
functions. Exercise 2.14 above is an example.
Limit information for cryptanalysis. By using separate, independently-
pseudorandom keys, we reduce the amount of information available to
the attacker (ciphertext, for example).
Limit the impact of key exposure. Namely, by using separate keys, we
ensure that exposure of some of the keys will not jeopardize the secrecy
of communication encrypted with the other keys.
53
Random permutations. A permutation is a function π : D → D mapping
a domain D onto itself, where every element is mapped to a distinct element,
namely:
Note that a permutation may map an element onto itself, i.e., π(x) = x is
perfectly legitimate.
We use P erm(D) to denote the set of all permutations over domain D.
$
Selection of a random permutation over D, i.e., selecting ρ ← P erm(D), is
similar to selection of a random function (Equation 2.23) - except for the need
to avoid collisions. A collision is a pair of elements (x, x0 ), both mapped to the
same element: y = ρ(x) = ρ(x0 ).
One natural way to think about this selection, is as being done incremen-
tally, mapping one input at a time. Let D0 ⊆ D be the set of already-mapped
$
elements; given any ‘new’ element x ∈ D/D0 , select ρ(x) ← D/D0 .
Using this process, for a small domain, e.g., D = {0, 1}n for small n, the
selection of a random permutation ρ is easy and can be done manually - sim-
ilarly to the process for selecting a random function (over small domain and
range). The process requires O(2n ) coin tosses, time and storage. For example,
use Table 2.3 to select two random permutations over domain D = {0, 1}2 , and
notice the number of coin-flips required.
54
Figure 2.17: The Pseudo-Random Permutation (PRP) Indistinguishability
Test. We say that function Ek (x) : {0, 1}∗ × D → D is a (secure) pseudo-
random permutation (PRP), if no distinguisher D can efficiently distinguish
$
between Ek (·) and a random permutation ρ ← P erm(D) over domain D,
when the key k is a randomly-chosen sufficiently-long binary string.
εP RP
E n
A,E (n) ≡ Pr A k (1 ) − Pr [Aρ (1n )] (2.28)
$ $
k←{0,1}n ρ←P erm(D)
The probabilities are taken over random coin tosses of A, and random choices
$ $
of the key k ← {0, 1}n and of the function ρ ← P erm(D).
Block cipher as an inversible PRP (or: PRP and its inverse). The
reason that we used E to denote the candidate-PRP function, is that one
of the most important applications for a PRP is for a block cipher, one of
the most important cryptographic mechanism, with multiple standards and
many implementations, and often used as a ‘building block’ to construct other
mechanisms. Block ciphers actually use a pair of functions, (E, D), where E is a
PRP and D is the inverse function, i.e.: (∀x ∈ D, k ∈ {0, 1}∗ ) x = Dk (Ek (x)).
Intuitively, such ‘inversible PRP’ is a pair of two keyed functions (E, D), which,
for a random key, cannot be distinguished from a random permutation and its
inverse (over same domain). We will not present the definition, which is a
simple extension of Definition 2.9.
The symbols (E, D) are often used for the functions of the block cipher,
since one basic application of a block cipher is for encryption; intuitively, E is
55
‘encryption’ and D is ‘decryption’. However, as we will soon see, a block cipher
does not meet the (strong) definition of secure encryption, which we present
next.
One natural - and important - question is the relation between a PRP over
domain D, and a PRF over the same domain and range (both D). Somewhat
surprisingly, it turns out that a PRP over D is indistinguishable from a PRF
over D. This important result is called the PRP/PRF Switching Lemma, and
has multiple proofs; we recommend the proof in [156]. Note that the lemma
provides a relation between the advantage functions; this is an example of
concrete security.
Lemma 2.4 (The PRP/PRF Switching Lemma). Let E be a polynomial-time
computable function Ek (x) : {0, 1}∗ × D → D ∈ P P T , and let A be a PPT
adversary, which is limited to at most q oracle queries. Then:
P RF
εA,E (n) − εP RP
q2
A,E (n) < (2.29)
2 · |D|
Where the advantage functions are as defined in Equation 2.28 and Equa-
tion 2.25.
In particular, if the size of the domain D is exponential in the security
parameter n (the length of key and of the input to A), e.g., D = {0, 1}n , then
εP RF P RP
A,E (n) − εA,E (n) ∈ N EGL(n). In this case, E is a PRP over D, if and
only if it is a PRF over D.
Proof idea: In a polynomial set of queries of a random function, there is
negligible probability of having two values which will map to the same value.
Hence, it is impossible to efficiently distinguish between a random function and
a random permutation. The proof follows since a PRF (PRP) is indistinguish-
able from a random function (resp., permutation).
The PRP/PRF switching lemma is somewhat counter-intuitive, since, for
large D, there are many more functions than permutations. Focusing on D =
2
{0, 1}n for convenience, there are (2n ) = 22n functions over D, and ‘only’ 2n !
permutations.
Note that the loss of (concrete) security bounded by the switching lemma,
is a disadvantage in using a block cipher directly as a PRF - it would be an
(asymptotically) secure PRF, but the advantage against the PRF definition
would be larger than the advantage against the PRP definition. Therefore,
we would prefer to use one of several constructions of a PRF from a block
cipher/PRP - that are efficient and simple, yet avoid this loss in security;
see [18, 87].
See Table 2.4 for a summary and comparison of random function, random
permutation, PRG, PRF and Pseudo-random Permutation (PRP).
56
Function Key Input Output property
$
Random function f : D → R None x∈D f (x) ← R
$
Random permutation π : D → D None x∈D π(x) ← D not assigned as π(y) for y 6= x.
$ $
PRG f : {0, 1}∗ → {0, 1}∗ None x ← {0, 1}n f (x) indistinguishable from r ← {0, 1}|f (x)|
∗ $ n $
PRF f : {0, 1} × D → R k ← {0, 1} x∈D fk (·) indistinguishable from r(·) ← {D → R}
∗ $ n
PRP f : {0, 1} × D → D k ← {0, 1} x∈D fk (·) indistinguishable from random permuta-
tion over D
57
Attack type Cryptanalyst knowledge
Ciphertext Only (CTO) Plaintext distribution (possibly noisy/partial)
Known Plaintext Attack (KPA) Set of (ciphertext, plaintext) pairs
Chosen Plaintext Attack (CPA) Ciphertext for arbitrary plaintext chosen by attacker
Chosen Ciphertext Attack (CCA) Plaintext for arbitrary ciphertext chosen by attacker
Table 2.5: Types of Cryptanalysis Attacks. In all attack types, the cryptanalyst
knows the cipher design and a body of ciphertext.
58
and only them - to perform decryption, transforming the ciphertext back to
the original plaintext. However, the goal as stated may be interpreted to only
forbid recovery of the exact, complete plaintext; but what about recovery of
partial plaintext?
For example, suppose an eavesdropper can decipher half of the characters
from the plaintext - is this secure? We believe most readers would not agree.
What if she can decipher less, say one character? In some applications, this may
be acceptable; in others, even exposure of one character may have significant
consequences.
Intuitively, we require that an adversary cannot learn anything given the
ciphertext. This may be viewed as extreme; for example, in many applications
the plaintext includes known fields, and their exposure may not be a concern.
However, it is best to minimize assumptions and use definitions and schemes
which are secure for a wide range of applications.
Indeed, in general, when we design a security system, cryptographic or
otherwise, it is important to clearly define both aspects of security: the attacker
model (e.g., types of attacks ‘allowed’ and any computational limitations), as
well as the success criteria (e.g., ability to get merchandise without paying for
it). Furthermore, it is difficult to predict the actual environment in which a
system would be used; this motives the conservative design principle, as follows.
59
Except, the two persons should have the ‘same size’: assuming that a
disguise is of ‘reasonable size’ (overhead), a giant can’t be disguised to
be indistinguishable from a dwarf!
Re-disguises should be different: if we see Rachel in disguise, and then
she disappears and we see a new disguise, we should not be able to tell
if it is Rachel again, in new disguise - or any other disguised person!
This means that disguises must be randomized or stateful, i.e., every two
disguises of the same person (Rachel) will be different.
Oracle notation AEk (·) . In the IND-CPA test, we use the oracle notation
AEk (·) , defined in Def. 2.7. Namely, AEk (·) denotes calling the A algorithm,
with ‘oracle access’ to the (keyed) PPT algorithm Ek (·), i.e., A can provide
arbitrary plaintext string m and receive Ek (m).
60
IN D−CP A
Figure 2.18: The IND-CPA test for encryption, TA,hE,Di (b, n). Throughout
the test, the adversary A may ask for encryption of one or many messages m.
At some point, A sends two same length messages (|m0 | = |m1 |), and receives
the encryption of mb , i.e.: Ek (mb ). Finally, A outputs its guess b∗ , and ‘wins’
if b = b∗ . The encryption is IND-CPA if Pr(b∗ = 1|b = 1) − Pr(b∗ = 1|b = 0) is
negligible.
IN D−CP A
TA,hE,Di (b, n) {
$
k ← {0, 1}n
(m0 , m1 ) ← AEk (·) (‘Choose’, 1n ) s.t. |m0 | = |m1 |
c∗ ← Ek (mb )
b∗ = AEk (·) (‘Guess’, c∗ )
Return b∗
}
Figure 2.19: The IND-CPA test for encryption (E, D). The two calls to the
adversary are often referred to as the ‘Choose’ phase and the ‘Guess’ phase.
61
Encryption must be randomized or stateful. IND-CPA encryption must
either be randomized or stateful. The reason is simple: the adversary is allowed
to make queries for arbitrary messages - including the ‘challenges’ m0 , m1 . If
the encryption scheme is deterministic - and stateless - then all encryptions of
a message, e.g. m0 , will return a fixed ciphertext; this will allow the attacker
to trivially ‘win’ in the IND-CPA experiment. Furthermore, Exercise 2.42
shows that limiting the number of random bits per encryption may lead to
vulnerability .
Using the IND-CPA test, we now define IND-CPA encryption, similarly to
how we defined PRG and PRF, in Definition 2.6 and Definition 2.8, respectively.
We present only the definition for stateless cryptosystems, since we mostly focus
on this case.
Definition 2.10 (IND-CPA for (stateless) shared-key cryptosystems). Let
hE, Di be a stateless shared-key cryptosystem. We say that hE, Di is IND-CPA,
if every efficient adversary A ∈ P P T has negligible advantage εIN D−CP A
hE,Di,A (n) ∈
N EGL(n), where:
h i h i
εIN D−CP A
hE,Di,A
IN D−CP A
(n) ≡ Pr TA,hE,Di IN D−CP A
(1, n) = 1 − Pr TA,hE,Di (0, n) = 1
(2.30)
Where the probability is over the random coin tosses in IND-CPA (including
of A and E).
Show that both are not reasonable definitions for advantage function, by pre-
senting (simple) adversaries which achieve significant advantage for any cryp-
tosystem.
Indistinguishability for the CTO, KPA and CCA attack models Def-
inition 2.10 focuses on Chosen-Plaintext Attack (CPA) model.
Modifying this definition for the case of chosen-ciphertext (CCA) attacks
requires a further (quite minor) change and extension, to prevent the attacker
from ‘abusing’ the decryption oracle to decrypt the challenge ciphertext.
Modifying the definition for Cipher-Text-Only (CTO) attack and Known-
Plaintext Attack (KPA) is more challenging. For KPA, the obvious question
is which plaintext-ciphertext messages are known; this may be solved by using
random plaintext messages, however, in reality, the known-plaintext is often
quite specific.
It is similarly challenging to modify the definition so it covers CTO attacks,
where the attacker must know some information about the plaintext distribu-
tion. This information may be related to the specific application, e.g., when
62
the plaintext is English. In other cases, information about the plaintext dis-
tribution may be derived from system design, e.g., text is often encoded using
ASCII, where one of the bits in every character is the parity of the other bits.
An even more extreme example is in GSM, where the plaintext is the result
of the application of an Error-Correcting Code (ECC), providing significant
redundancy which even allows a CTO attack on GSM’s A5/1 and A5/2 ci-
phers [7]. In such a case, the amount of redundancy in the plaintext can be
compared to that provided by a KPA attack. We consider it a CTO attack, as
long as the attack does not require knowledge of all or much of the plaintext
corresponding to the given ciphertext messages.
Some systems, including GSM, allow the attacker to guess all or much
of the plaintext for some of the ciphertext messages, e.g., when sending a
predictable message at a specific time. Such systems violate the Conservative
Design Principle (principle 7), since a a KPA-vulnerability of the cipher renders
the system vulnerable. A better system design would limit the adversary’s
knowledge about the distribution of plaintexts, requiring a CTO vulnerability
to attack the system.
Figure 2.20: The IND-CPA test for public-key encryption (KG, E, D).
63
Where the probability is over the random coin tosses in IND-CPA (including
of A and E).
64
blocks should be simple and with well-defined and easy to test security proper-
ties. More complex schemes should be proven secure by reduction to the security
of the underlying blocks.
The advantages of following the cryptographic building blocks principle
include:
Efficient cryptanalysis: by focusing cryptanalysis effort on few schemes, we
obtain much better validation of their security. The fact that the building
blocks are simple and are selected to be easy to test makes cryptanalysis
even more effective.
Replacement and upgrade: by using simple, well-defined modules, we can
replace them for improved efficiency - or to improve security, in particular
after being broken or when doubts arise.
Flexibility and variations: complex systems and schemes naturally involve
many options, tradeoffs and variants; it is better to build all such variants
using the same basic building blocks.
Robust combiners: there are known, efficient robust-combiner designs for
the basic cryptographic building blocks [92]. If desired, we can use these
as the basic blocks for improved security.
The cryptographic building blocks principle is key to both applied and theo-
retical modern cryptography. From the theoretical perspective, it is important
to understand which schemes can be implemented given another scheme. There
are many results exploring such relationships between different cryptographic
schemes and functions, with many positive results (constructions), few nega-
tive results (proofs that efficient constructions are impossible or improbable),
and very few challenging open questions.
In modern applied cryptography, the principle implies the need to define a
small number of basic building blocks, which would be very efficient, simple
functions - and convenient for many applications. The security of these building
blocks would be established by extensive (yet unsuccessful) cryptanalysis efforts
- instead of relying on provably-secure reductions from other cryptographic
mechanisms.
In fact, most cryptographic libraries contain the four such widely-used
building blocks: the shared-key block cipher, which we discuss next; the keyless
cryptographic hash function (chapter 4); public-key encryption and signature
scheme (chapter 6). Cryptographic hash functions and block ciphers are much
more efficient than the public key schemes (see Table 6.1) and hence are pre-
ferred, and used in most practical systems - when public-key operations may
be avoided.
65
Instead, they are usually implemented using another mechanism - most often,
using a block cipher. The PRP/PRF switching lemma (Lemma 2.4) shows that
a block cipher is indistinguishable from a PRF, and hence, every block cipher is
also a PRF; however, this may involve some loss in (concrete) security, which
is bounded by the lemma - but definitely significant. Instead, one should use
one of several constructions of PRF from a block cipher, which are simple, al-
most as efficient as the block cipher - and avoid the loss in (concrete) security;
see [18, 87].
Figure 2.21: High-Level view of the NIST standard block ciphers: AES (cur-
rent) and DES (obsolete).
66
We present a simplified explanation and example of differential cryptanal-
ysis below, and encourage interested readers to follow up in the extensive lit-
erature on cryptanalysis in general and these attacks, e.g., [63, 101, 108]; [108]
also gives excellent overview of block ciphers.
Unfortunately, there is no universally-accepted definition of the exact cryp-
tographic requirements for block ciphers. Hence, their required security proper-
ties are not very well defined. We will adopt here one popular approach, which
models a block cipher as a reversible Pseudo-Random Permutation (PRP). A
(secure) block cipher is a reversible PRP, i.e., a pair of PRPs Ek , Dk over
{0, 1}n , s.t. for every message m in the domain, holds m = Dk (Ek (m)).
Namely, a block cipher is indistinguishable from a random pair of a permu-
tation and its inverse permutation. The fact that m = Dk (Ek (m)) for every
k, m ∈ {0, 1}n is called the correctness requirement - note that this is essentially
the same as presented in Def. 2.1 for encryption schemes. The fact that both
E and D are PRPs, is the security requirement.
Example 2.3. Let Ek (m) = m ⊕ k and Ek0 (m) = m + k mod 2n . Show the
corresponding D, D0 functions such that both (E, D) and (E 0 , D0 ) satisfy the
correctness requirement; and show neither of them satisfy the security require-
ment.
εP RP
= Pr AEk = 1 − Af = 1
A,E Pr
k $
f ←P erm({0,1}n
67
Now, notice that the same adversary A also distinguishes E 0 ; we leave to
the reader to substitute the values as necessary; these minimal changes are only
required until A ‘finds’ k, from that point, the solution is exactly identical.
Note that block ciphers, in particular DES and AES, are often referred to
as encryption schemes, although they do not satisfy the requirements of most
definitions of encryption, e.g., the IND-CPA test of Def. 2.10.
Exercise 2.18. Explain why a PRP and a block ciphers, fail the IND-CPA
test (Def. 2.10).
Solution: Consider Ek (m), which is either a PRP or the ‘encryption’ opera-
tion of a block cipher (i.e., a pair (E, D) of a PRP and its reverse). Then Ek (m)
is a function; whenever we apply it to the same message m, with the same key
k, we will receive the same output (Ek (m)). The attacker A would choose any
two different messages as (m0 , m1 ), confirm that c0 = Ek (m0 ) 6= c1 = Ek (m1 ),
and then use these as a challenge, to receive c∗ = Ek (mb ). It then outputs b0
s.t. cb0 = c∗.
On the other hand, we will soon see multiple constructions of secure encryp-
tion schemes based on block ciphers; these constructions are often referred to
as modes of operation. Indeed, block ciphers are widely used as cryptographic
building blocks, as they satisfy most of the requirements of the Cryptographic
Building Blocks principle. They are simple, deterministic functions with Fixed
Input Length (FIL), which is furthermore identical to their output length. This
should be contrasted with ‘full fledged encryption schemes’, which are random-
ized (or stateful) and have Variable Input Length (VIL). Indeed, block ciphers
are even easier to evaluate than PRFs, since PRFs may have different input
and output lengths.
Another desirable property of block ciphers is that they have a simple robust
combiner, i.e., a method to combine two or more candidate block ciphers into
one ‘combined’ function which is a secure block cipher provided one or more of
the candidates is a secure block cipher. This is shown in [92] and the following
exercise.
Exercise 2.19. Design a robust combiner for PRPs and for reversible PRPs
(block ciphers).
Hint: cf. Lemma 2.3, and/or read [92].
68
However, let us first recall the important case where of designing a PRP
from a PRF whose range is identical to its domain D - and which will also be the
domain (and range) of the PRP. We already discussed this case, and presented
the PRP/PRF switching lemma (Lemma 2.4), which shows that every PRF
over a domain D, is also a PRP over D, and vice verse. This holds although,
for a given key k, a PRF Fk may very welll have some collisions Fk (x) = Fk (y),
while a PRP cannot have collisions. However, the switching lemma shows that
no computationally-bounded (PPT) adversary is likely to distinguish between
a PRP and a PRF (over domain D).
Constructing a PRP from a PRF is not trivial; see the following two exer-
cises.
Exercise 2.20. Let f be a PRF from n-bit strings to n-bit strings. Show that
gkL ,kR (mL +
+ mR ) = fkL (mL ) +
+ fkR (mR ) is not a PRF or a PRP (over 2n-bit
strings).
Exercise 2.21. Let f be a PRF from n-bit strings to n-bit strings. Show that
+ mR ) = ml ⊕ fkR (mR ) +
gkL ,kR (mL + + mR ⊕ fkL (mL ) is not a PRP (over 2n-bit
strings).
We next present the Feistel construction, the most well known and simplest
construction of a PRP - in fact, a reversible PRP (block cipher) - from a PRF.
As shown in Fig. 2.22, the Feistel cipher transforms an n-bit PRF into a 2n-bit
reversible PRP.
Formally, given a function y = fk (x) with n-bit keys, inputs and outputs,
the three-rounds Feistel gk (m) is defined as:
Note that we consider only a ‘three rounds’ Feistel cipher, and use the same
underlying function Fk in all three rounds, but neither aspect is mandatory.
In fact, the Feistel cipher is used in the design of DES and several other block
ciphers, typically using more rounds (e.g., 16 in DES), and often using different
functions at different rounds.
69
Figure 2.22: Three ‘rounds’ of the Feistel Cipher, constructing a block cipher
(reversible PRP) from a PRF Fk (·). The Feistel cipher is used in DES (but not
in AES). Note: most publications present the Feistel cipher a bit differently,
by ‘switching sides’ in each round.
Luby and Rackoff [123] proved that a Feistel cipher of three or more ‘rounds’,
using a PRF as Fk (·), is a reversible PRP, i.e., a block cipher.
One may ask, why use the Feistel design rather than directly design a
reversible PRP? Indeed, this is done in AES, which does not follow the Feistel
cipher design. An advantage of using the Feistel design is that it allows the
designer to focus on the pseudo-randomness requirements when designing the
PRF, without having simultaneously to make sure that the design is also an
invertible permutation. Try to design a PRP, let alone an reversible PRP, and
compare it to using the Feistel cipher!
70
Mode Encryption Properties
Electronic code ci = Ek (mi ) Insecure
book (ECB)
$
Per-Block Ran- ri ← {0, 1}n , Nonstandard,
dom (PBR) ci = (ri , mi ⊕ Ek (ri )) long ciphertext
$
Output Feedback r0 ← {0, 1}n , ri = Ek (ri−1 ), Parallel, fast online,
(OFB) c0 ← r0 , ci ← ri ⊕ mi PRF, 1-localization
$
Cipher Feedback c0 ← {0, 1}n , Parallel decrypt
(CFB) ci ← mi ⊕ Ek (ci−1 ) PRF, n + 1-
localization
$
Cipher-Block c0 ← {0, 1}n , parallel decrypt
Chaining (CBC) ci ← Ek (mi ⊕ ci−1 ) n + 1-localization
Counter (CTR) T1 ← nonce+ +0n/2 , Ti ← Ti−1 +1, Parallel, fast online,
ci = mi ⊕ Ek (Ti ) PRF, 1-localization,
stateful (nonce)
Table 2.6: Standard Encryption Modes of Operation using n-bit block cipher
(standardized by NIST [66, 134]). The plaintext is given as a concatenation of
n-bit blocks m1 + + m2 + + . . ., where each block has n bits, i.e., mi ∈ {0, 1}n .
Similarly the ciphertext is produced as a set of n-bits blocks c0 + + ... ∈
+ c1 +
{0, 1}n , where ci ∈ {0, 1}n . For PBR, ci ∈ {0, 1}2n . PRF: improved security
if E is a PRF. nonce: must differ for every message, e.g., message counter.
71
PRF: most modes (PBR, OFB, CFB and CTR), use only the encryption func-
tion E - even for decryption. This has an important implication: they
may be implemented using a PRF instead of a block cipher. This may
have imply better security, esp. when the same key is used for an exten-
sive number of messages, due to improved concrete-security (smaller ad-
vantage to attacker). However, notice that there will not be such advan-
tage if we simply use a block cipher as a PRP, relying on the PRP/PRF
switching lemma (Lemma 2.4); we should use one of the (simple and ef-
ficient) constructions of PRF from block cipher, which avoid an increase
in the adversary’s advantage; see [18, 87]. See [15, 147].
Efficiency is important - and multi-faceted. All of the modes we present, use
one block-cipher operation per message-block, and allow parallel decryp-
tion. The OFB, CTR and PBR modes also allow parallel encryption,
or ‘random access’ decryption - decryption of only specific blocks from
the plaintext. Another efficiency consideration is offline precomputation;
in the CTR modes, we may conduct all the block-ciphers computations
offline; after receiving the plaintext/ciphertext, we only need a single
XOR operation (per block). The OFB mode has similar property but
only for encryption; decryption requires the ciphertext as input to the
block-cipher.
Integrity/authentication: Some modes, which, unfortunately, we do not
discuss, ensure both confidentiality and integrity, preventing an attacker
from modifying intercepted messages to mislead the recipient, or from
forging messages as if they were sent by a trusted sender. These include
the Counter and CBC-MAC (CCM) mode and the (more efficient) Ga-
lois/Counter Mode (GCM) mode. Other modes ensure only authenticity;
we discuss one such mode, the CBC-MAC mode, in subsection 3.5.2.
Error localization and weak integrity: In the OFB and CTR, corruption
of any number m of ciphertext bits, results in corruption of only the
corresponding plaintext bits. This may help to recover from some cor-
ruptions of bits during communication, since no additional bits are lost,
but also implies that the attacker may ‘flip’ plaintext bits by ‘flipping’ the
corresponding ciphertext bits. In CFB and CBC, corruption of a single
ciphertext block, flips a bit in one block, and ‘corrupts’ another block
- with some exceptions; this is sometimes considered as a weak form of
prtection of integrity, but the defense is very fragile and relying on it has
resulted in several vulnerabilities. See details below.
72
and correctness of encryption, i.e., m = Dk (Ek (m)) for every k, m ∈ {0, 1}∗ ,
follows immediately from the correctness of the block cipher Ek (·).
m0 m1 m2 mn
c0 c1 c2 cn
Figure 2.23: Electronic Code Book (ECB) mode encryption. Adapted from
[100].
Note: notations are not exactly consistent with text, should be fixed.
c0 c1 c2 cn
m0 m1 m2 mn
Figure 2.24: Electronic Code Book (ECB) mode decryption. Adapted from
[100]. Note: notations are not exactly consistent with text, should be fixed.
The reader may have already noticed that ECB is simply a mono-alphabetic
substitution cipher, as discussed in subsection 2.1.3. The ‘alphabet’ here is
indeed large: each ‘letter’ is a whole n-bit block. For typical block ciphers,
the block size is significant, e.g., nDES = 64 bits for DES and nAES = 128
bits; this definitely improves security, and may make it challenging to decrypt
ECB-mode messages in many scenarios.
However, obviously, this means that ECB may expose some information
about plaintext, in particular, all encryptions of the same plaintext block will
result in the same ciphertext block. Even with relatively long blocks of 64 or
128 bits, such repeating blocks are quite likely in practical applications and sce-
narios, since inputs are not random strings. Essentially, this is a generalization
of the letter-frequency attack of subsection 2.1.3 (see Fig. 2.7).
This weakness of ECB is often illustrated graphically by the example illus-
trated in Fig. 2.25, using the ‘Linux Penguin’ image [72, 170].
73
Figure 2.25: The classical visual demonstration of the weakness of the ECB
mode. The middle and the right ‘boxes’ are encryptions of the bitmap image 25
shown on the left; can you identify which of the two is ‘encrypted’ using ECB,
and which is encrypted with one of the secure encryption modes?
74
Theorem 2.1. If E is a PRF or PRP, or (E, D) is a block cipher (reversible
PRP), then (P BRE , P BRD ) is a CPA-indistinguishable symmetric encryption.
Proof. We present the proof when E is a PRF; the other cases are similar. We
also focus, for simplicity, on encryption of a single-block message, m = m1 ∈
{0, 1}n .
Denote by (P BRÊ , P BRD̂ ) the same construction, except using, instead
$
of E, a ‘truly’ random function f ← {{0, 1}n → {0, 1}n }. In this case, for any
pair of plaintext messages m0 , m1 selected by the adversary and randomness r
used for encrypting, the probability of c∗ = (r, r ⊕ f (m0 )) is exactly the same
as the probability of c∗ = (r, r ⊕ f (m1 )), from symmetry of the random choice
of f . Hence, the attacker’s success probability, when ‘playing’ the IND-CPA
game (Def. 2.1) ‘against’ (P BRÊ , P BRD̂ ) is exactly half. Note that this holds
even for computationally-unbounded adversary.
Assume, to the contrary, that there is some PPT adversary A, that is
able to gain a non-negligible advantage against (P BRE , P BRD ). Recall that
this holds, even assuming E is a PRF - however, as argued above, A suc-
ceeds with probability exactly half, i.e., with exactly zero advantage, against
(P BRÊ , P BRD̂ ), i.e., if E was a truly random function.
We can use A to distinguish between Ek (·) and a random function, with
significant probability, contradicting the assumption that Ek is a PRF; see
Def. 2.8. Namely, we run A against the PBR construction instantiated with
either a true random function or Ek (·), resulting in either (Ê P BR , D̂P BR )
or (E P BR , DP BR ), correspondingly. Since A wins with significant advantage
against (E P BR , DP BR ), and with no advantage against (Ê P BR , D̂P BR ), this
allows distinguishing, proving the contradiction.
Error propagation, integrity and CCA security Since PBR mode en-
crypts the plaintext by bitwise XOR, i.e., ci = (ri + + mi ⊕ Ek (ri )), flipping
a bit in the second part result in flipping of the corresponding bit in the de-
crypted plaintext, with no other change in the plaintext. We say that such bit
errors are perfectly localized or have no error propagation. On the other hand,
bit errors in the random pad part ri corrupt the entire corresponding plaintext
block, i.e., are propagated to the entire block. In any case, errors are somewhat
localized - other plaintext blocks are decrypted intact.
This property may seem useful, to limit the damage of such errors, but
that value is very limited. On the other hand, this property has two negative
security implications. The first is obvious: an attacker can flip specific bits
in the plaintext, i.e., PBR provides no integrity protection. Of course, we did
not require cryptosystems to ensure integrity; in particular, the situation is
identical for other bitwise-XOR ciphers such as OTP.
The other security drawback is that PBR is not IND-CCA secure. This
directly results from the error localization property. Since all the modes we
show in this chapter localize errors (perfectly, or to a single or two blocks), it
follows that none of these modes is IND-CCA secure.
75
Exercise 2.23 (Error localization conflicts with IND-CCA security). Show
that every cryptosystem where errors in one ciphertext block are localized to
one or two corresponding blocks is not IND-CCA secure.
Hint: Consider the case of three-block plaintexts; one block must not be
corrupted. This suffices for attacker to succeed in the IND-CCA game.
IV
pad0
c0 c1 c2 c3 cl
Figure 2.26: Output Feedback (OFB) mode encryption. Adapted from [100].
c0 = pad0
m1 m2 m3 ml
Figure 2.27: Output Feedback (OFB) mode decryption. Adapted from [100].
The OFB mode is illustrated in Figs. 2.26 (encryption) and 2.27 (decryp-
tion). OFB is a variant on the PRF-based stream cipher discussed in subsec-
76
tion 2.5.1 and illustrated in Fig. 2.15, and, like it, operates on input which
consists of l blocks of n bits each. The difference is that OFB uses a PRP
(block cipher) Ek instead of the PRF P RFk .
We use a random Initialization Vector (IV) as a ‘seed’ to generate a long
sequence of pseudo-random n−bit pad blocks, pad1 , . . . , padl , to encrypt plain-
text blocks m1 , . . . , ml . We next compute the bitwise XOR of the pad blocks
pad1 , . . . , padl , with the corresponding plaintext blocks m1 , . . . , ml , resulting
in the ciphertext which consists of the random IV c0 and the results of the
XOR operation, i.e. c1 = m1 ⊕ pad1 , c2 = m2 ⊕ pad2 , . . ..
Let us now define OF B − Ek (m), the OFB mode for a given block cipher
(E, D). For simplicity we define OF B −Ek (m) for messages m which consist of
some number l of n-bit blocks, i.e., m = m1 + +ml , where (∀i ≤ l)|mi | = n.
+. . .+
Then OF B − Ek (m) is defined as:
OF BkE (m1 +
+ ... +
+ ml ) = (c0 +
+ c1 +
+ ... +
+ cl ) (2.33)
where:
$
pad0 ← {0, 1}n (2.34)
padi ← Ek (padi−1 ) (2.35)
c0 ← pad0 (2.36)
ci ← padi ⊕ mi (2.37)
Offline pad precomputation The OFB mode allows both the encryption
process and the decryption process to precompute the pad, ‘offline’ - i.e., before
the plaintext and ciphertext, respectively, are available. Offline pad precompu-
tation is possible since the pad does not depend on the plaintext (or ciphertext).
This can be important, e.g., when a CPU with limited computation speed needs
to support a limited number of ‘short bursts’, without adding latency. Once the
plaintext/ciphertext is available, we only need one XOR operation per block.
77
This motivated some designers to use OFB or a similar XOR-based stream
cipher so that they could apply error correction on the plaintext. However,
this is often a bad idea, as it results in structured redundancy in the plaintext,
which may make CTO attacks easier!.
Let us give two examples. Our first example is a scenario where the parties
share only a short key k, say of 20 bits. Normally, this would imply the
communication is vulnerable - attacker may simply perform exhaustive search
to find the key. However, what if the parties only encrypt a (single) message
$
containing a new, longer random key, say k 0 ← {0, 1}n ? Applying exhaustive
search is impossible, since every one of the 220 possible values for k will output
some value for k 0 - and all would be equally likely. However, the attack becomes
trivial if the plaintext includes not only the key, but also error correction or
detection code, denoted code(·), applied to the key. In this case, the ciphertext
would be Ek (k 0 ++ code(k 0 )), and the adversary can easily check which guess of
k is correct. Note that this particular attack may also be possible if we simply
pad the plaintext using some known string, e.g., send Ek (k 0 + + 0l ).
Our second example is a very important vulnerability: a Ciphertext-Only
CTO attack on the A5/1 and A5/2 stream ciphers [7], both used in the GSM
protocol. This attack exploits the known relationship between ciphertext bits,
due to the fact that an Error Correction Code was applied to the plaintext. This
redundancy suffices to attack the ciphers, using techniques that normally can
be applied only in Known Plaintext attacks. Unfortunately, complete details
of this beautiful and important result are beyond our scope; for details, see [7].
One may wonder, why would these designers prefer to apply error correction
to the plaintext rather than to the ciphertext? One motivation may be the
hope that this may make cryptanalysis harder, e.g., corrupt some plaintext
statistics such as letter frequencies. This may hold for some codes; but we
better design such defenses explicitly into the cryptosystem and not rely on
such fuzzy property of encoding.
Another motivation may be the hope that applying error correction/detec-
tion to the plaintext may provide integrity. Note that due to the perfect bit
error localization of OFB, an attacker can easily flip a specific plaintext bit -
by flipping the corresponding ciphertext bit. If we applied error detection to
the plaintext, then corruption of a single bit will corrupt the entire plaintext.
However, since the attacker can flip multiple ciphertext bits, thereby flipping
the corresponding plaintext bits, there are cases where the attacker can mod-
ify the ciphertext in such a way as to flip specific bits in the plaintext while
also ‘fixing’ the error detection/correction code, to make the message appear
correct. We conclude the following principle.
78
an encryption mode of a block cipher also protect the integrity of the decrypted
plaintext? Both of the following modes, CFB and CBC, provide some defense
of integrity - by ensuring errors do propagate.
IV
c0 c1 c2 c3 cl
Figure 2.28: Cipher Feedback (CFB) mode encryption. Adapted from [100].
79
c0 (= IV ) c1 c2 c3 cl−1 cl
m1 m2 m3 ml
Figure 2.29: Cipher Feedback (CFB) mode decryption. Adapted from [100].
80
m1 m2 m3 mn
IV
Ek Ek Ek ······ Ek
c0 c1 c2 c3 cn
Figure 2.30: Cipher Block Chaining (CBC) mode encryption. Adapted from
[100].
c1 c2 c3 cn
Dk Dk Dk ······ Dk
c0
(IV )
m1 m2 m3 mn
Figure 2.31: Cipher Block Chaining (CBC) mode decryption. Adapted from
[100].
CBCkE (m1 +
+ ... +
+ ml ) = (c0 +
+ c1 +
+ ... +
+ cl ) (2.38)
where:
$
c0 ← {0, 1}n (2.39)
(i ∈ {1, . . . , l}) ci ← Ek (ci−1 ) ⊕ mi (2.40)
The CBC mode, like the other modes (exept ECB), ensures IND-CPA, i.e.,
security against CPA attacks, provided that the underlying block cipher is a
secure reversible PRP. However, it is not secure against CCA attacks.
Exercise 2.24. Demonstrate that CBC mode does not ensure security against
CCA attacks.
Hint: the solution is quite similar to that of Exercise 2.23.
81
Error propagation and integrity Any change in the CBC ciphertext, even
of one bit, results in unpredictable output from the block cipher’s ‘decryption’
operation, and hence unpredictable decryption. Namely, flipping a bit in the
ciphertext block i does not flip the corresponding bit in plaintext block i, as it
did in the OFB and CFB modes.
However, the flipping of a bit in the ciphertext block ci−1 , without change
to block ci , results in the flipping of the corresponding bit in the ith decrypted
plaintext block. Namely, bit-flipping is still possible in CBC, it is just a bit
different - and in order to flip a bit in the decrypted-plaintext block i, the
adversary has flip the corresponding bit in the previous block (i − 1), which
results in corruption of the decryption of block i − 1. Indeed, this kind of
tampering is used in several attacks on systems deploying CBC, such as the
Poodle attack [132]. Note also that bit flipping in the first decrypted-plaintext
block only requires flipping of the corresponding IV block - and hence does not
corrupt any plaintext block.
82
mostly in [37], relatively soon after the standard was published; yet, products
and networks supporting WEP still exist. This is an example of the fact that
once a standard is published and adopted, it is often very difficult to fix secu-
rity. Hence, it is important to carefully evaluate security in advance, in an open
process that encourages researchers to find vulnerabilities, and, where possible,
with proofs of security. To address these vulnerabilities, WEP was replaced -
possibly in too much haste - with a new standard, the Wi-Fi Protected Access
(WPA); vulnerabilities were also found in WPA, see [164].
WEP stands for Wired Equivalency Privacy; it was developed as part of
the IEEE 802.11b standard, to provide some protection of data over wireless
local area networks (also known as WiFi networks). As the name implies,
the original goals aimed at a limited level of privacy (meaning confidential-
ity), which was deemed ‘equivalent’ to the (physically limited) security offered
by a wired connection. WEP includes encryption for confidentiality, CRC-32
error-detection code (‘checksum’) for integrity, and authentication to prevent
injection attacks.
WEP assumes a symmetric key between the mobile device and an access
point. Many networks share the same key with all mobiles, which obviously
allows each device to eavesdrop on all communication. However, other vul-
nerabilities exist even if a network uses good key-management mechanisms to
share a separate key with each mobile.
Confidentiality in WEP is protected using the RC4 stream-cipher, used
as a PRG-based stream cipher as in subsection 2.5.1. The PRG is initiated
with a secret shared key, which is specified to be only 40 bits long. This
short key size was chosen intentionally, to allow export of the hardware, since
when the standard was drafted there were still export limitations on longer-key
cryptography. Some implementations also support longer, 104-bit keys.
The PRG is also initiated with a 24-bit per-packet random Initialization
Vector (IV). We use RC4IV,k to denote the string output by RC4 when initial-
ized using a given IV, k pair. More specifically, we use RC4IV,k [l] to denote
the first l bits in RC4IV,k , i.e., in the output by RC4 when initialized using
given IV, k pair.
WEP packets use the CRC-32 error detection/correction code, computed
over the plaintext message m. CRC-32 is a popular error detection/correction
code, which can detect most corruption of the message, and even allow correc-
tion of messages with up to 3 or 5 corrupted bits [109]. Specifically, to send
message m using secret key k, WEP implementations select a random 24-bit
IV, and transmit IV together with W EPk (m; IV ), defined9 as:
83
2.10.1 CRC-then-XOR does not ensure integrity
CRC-32 is a quite good error detection/correction code. By encrypting the
output of CRC, specifically by XORing it with the pseudo-random pad gener-
ated by RC4, the WEP designers hoped to protect message integrity. However,
like many other error correcting codes, CRC-32 is linear, namely, for any two
strings α, α0 ∈ {0, 1}∗ of equal length (|α| = |α0 |), holds:
We now show that this allows an attacker to change the message m sent in a
WEP packet, by flipping any desired bits and appropriately adjusting the CRC
field.
Specifically, let ∆ represent the string of length |m| containing 1 for bit
locations that the attacker wishes to flip. Given α = W EPk (m; IV ), the
attacker can compute a valid W EPk (m ⊕ ∆; IV ) as follows:
Namely, the CRC mechanism, XOR-encrypted, does not provide any mean-
ingful integrity protection.
84
As a result of these concerns, most WEP systems use only open-system
authentication mode, i.e., do not provide any authentication.
85
2.12 Encryption and Pseudo-Randomness: Additional
exercises
Exercise 2.25. ConCrypt Inc. announces a new symmetric encryption scheme,
CES. ConCrypt announces that CES uses a 128-bit keys and is five times faster
than AES, and is the first practical cipher to be secure against computationally-
unbounded attackers. Is there any method, process or experiment to validate or
invalidate these claims? Describe or explain why not.
Exercise 2.26. ConCrypt Inc. announces a new symmetric encryption scheme,
CES512. ConCrypt announces that CES512 uses a 512-bit keys, and as a result,
is proven to be much more secure than AES. Can you point out any concerns
with using CES512 instead of AES?
Exercise 2.27. Compare the following pairs of attack models. For each pair
(A, B), state whether every cryptosystem secure under attack model A is also
secure under attack model B and vice versa. Prove (if you fail to prove, at least
give compelling argument) your answers. The pairs are:
1. (Cipher-text only, Known plain text)
2. (Known plain text, Chosen plain text)
3. (Known plain text, Chosen cipher text)
4. (Chosen plain text, Chosen cipher text)
Exercise 2.28. Alice is communicating using the GSM cellular standard, which
encrypts all calls between her phone and the access tower. Identify the attacker
model corresponding to each of the following cryptanalysis attack scenarios:
1. Assume that Alice and the tower use a different shared key for each call,
and that Eve knows that specific, known message is sent from Bob to Alice
at given times.
2. Assume (only) that Alice and the tower use a different shared key for
each call.
3. Assume all calls are encrypted using a (fixed) secret key kA shared between
Alice’s phone and the tower, and that Eve knows that specific, known
control messages are sent, encrypted, at given times.
4. Assume (only) that all calls are encrypted using a (fixed) secret key kA
shared between Alice’s phone and the tower
Exercise 2.29. We covered several encryption schemes in this chapter, in-
cluding At-Bash (AzBy), Caesar, Shift-cipher, general monoalphabetic substi-
tution, OTP, PRG-based stream cipher, RC4, block ciphers, and the ‘modes’
in Table 2.6. Which of these is: (1) stateful, (2) randomized, (3) FIL, (4)
polynomial-time?
86
Exercise 2.30. Consider use of AES with key length of 256 bits and block
length of 128 bit, for two different 128 bit messages, A and B (i.e., one block
each). Bound, or compute precisely if possible, the probability that the en-
cryption of A will be identical to the encryption of B, in each of the following
scenarios:
1. Both messages are encrypted with the same randomly-chosen key, using
ECB mode.
2. Both messages are encrypted with two keys, each of which is chosen ran-
domly and independently, and using ECB mode.
3. Both messages are encrypted with the same randomly-chosen key, using
CBC mode.
4. Compute now the probability the the same message is encrypted to the
same ciphertext, using a randomly-chosen key and CBC mode.
Exercise 2.31. Present a very efficient CPA attack on the mono-alphabetic
substitution cipher, which allows complete recovery of arbitrary messages, using
the encryption of one short plaintext string.
Exercise 2.32 (PRG constructions). Let G : {0, 1}n → {0, 1}n+1 be a secure
PRG. Is G0 , as defined in each of the following sections, a secure PRG? Prove.
1. G0 (s) = G(sR ), where sR means the reverse of s.
2. G0 (r + + G(s), where r, s ∈ {0, 1}n .
+ s) = r +
3. G0 (s) = G(s ⊕ G(s)1...n ), where G(s)1...n are the n most-significant bits
of G(s).
4. G0 (s) = G(π(s)) where π is a (fixed) permutation.
5. G0 (s) = G(s + 1).
6. (harder!) G0 (s) = G(s ⊕ sR ).
A. Solution to G0 (r ++ s) = r ++ G(s):
B. Solution to G0 (s) = G(s⊕G(s)1...n ): may not be a PRG. For example, let
g be a PRG from any number m bits to m+1 bits, i.e., output is pseudorandom
string just one bit longer than the input. Assume even n; for every x ∈ {0, 1}n/2
and y ∈ {0, 1}n/2 ∪ {0, 1}1+n/2 , let G(x ++ y) = x +
+ g(y). If g is a PRG, then
G is also a PRG (why?). However, when used in the above construction:
G0 (x +
+ y) + y) ⊕ G(x +
= G [(x + + y)]
+ y) ⊕ (x +
= G [(x + + g(y))]
= G [(x ⊕ x) +
+ (y ⊕ g(y))]
h i
n/2
= G 0 + y) ⊕ (x +
+ + g(y))
= 0n/2 +
+ y ⊕ g(y)
87
As this output begins with n/2 zero bits, it can be trivially distinguished from
random. Hence G0 is clearly not a PRG.
Exercise 2.33. Let G1 , G2 : {0, 1}n → {0, 1}2n be two different candidate
PRGs (over the same domain and range). Consider the function G defined in
each of the following sections. Is it a secure PRG - assuming both G1 and G2
are secure PRGs, or assuming only that one of them is secure PRG? Prove.
Exercise 2.35 (Ad-Hoc PRF competition project). In this exercise, you will
experiment in trying to build directly a cryptographic scheme - in this case, a
PRF - as well as in trying to ‘break’ (cryptanalyze) it. Do this exercise with
others, in multiple groups (each containing one or multiple persons).
1. In the first phase, each group will design a PRF, whose input, key and
output are all 64 bits long. The PRF should be written in Python (or some
other agreed programming language), and only use the basic mathematical
operations: module addition/subtraction/multiplication/division/remain-
der, XOR, max and min. You may also use comparisons and conditional
code. The length of your program should not exceed 400 characters, and
it must be readable. You will also provide (separate) documentation.
2. All groups will be given the documentation and code of the PRFs of all
other groups, and try to design programs to distinguish these PRFs from a
random function (over same input and output domains). A distinguisher
is considered successful if it is able to distinguish in more than 1% of the
runs.
3. Each group, say G, gets one point for every PRF that G succeeded to
distinguish, and one point for every group that failed to distinguish G’s
PRF from random function. The group with the maximal number of
points wins.
88
Exercise 2.36. Let f be a secure Pseudo-Random Function (PRF) with n bit
keys, domain and range, and let k be a secret, random n bit key. Derive from
k, using f , two pseudorandom keys k1 , k2 , e.g., one for encryption and one
for authentication. Each of the derived keys k1 , k2 should be 2n-bits long, i.e.,
twice the length of k. Note: the two keys should be independent, i.e., each
of them (e.g., k1 ) should be pseudorandom, even if the adversary is given the
other (e.g., k2 ).
1. k1 =
2. k2 =
Exercise 2.37 (PRF constructions). Let F n,b,l : {0, 1}n × {0, 1}b → {0, 1}l
be a secure PRF; for brevity, we write simply Fk (x) for Fkn,b,l (x). Is F 0 , as
defined in each of the following sections, a secure PRF? Prove.
7. F̂k (m) = LSb(Fk (m)), where LSb returns the least-significant bit of the
input.
8. (harder!) F̂k (mL + +FFk (0b ) (mR ⊕Fk (mL )). Assume
+mR ) = FFk (1b ) (mL )+
l = n = b.
Solution of F̂k (m) = Fk (m⊕1): yes, if Fk (m) is a secure PRF, then F̂k (m) =
Fk (m ⊕ 1) is also a secure PRF. Assume, to the contrary, that there is a PPT
algorithm  that ‘breaks’ F̂ , i.e., there is some (strictly-positive) polynomial
p(n) s.t. for sufficiently large n holds:
ˆ
Pr ÂF̂k (·) (1n ) = 1 − Pr Âf (·) (1n ) = 1 > p(n) (2.43)
89
ĝ(m) = g(m ⊕ 1);
m
1)
⊕
g (m
) =
Âĝ (1n )
n
1 ĝ (m
0
Ag (1n ) : 1/
{
Return Âĝ (1n ),
where ĝ(m) ≡ g(m ⊕ 1);
}
Figure 2.32: Design of adversary A for the solution of item 1 of Exercise 2.37.
By applying this equation together with the fact that, by design, F̂k (m) =
Fk (m ⊕ 1), we have:
ÂF̂k (m) (1n ) = AFk (m⊕1⊕1) (1n ) = AFk (m) (1n ) (2.46)
However, Eq. (2.48) implies that F is not a secure PRF, which contradicts the
assumption was F is a secure PRF, proving that assumption was wrong, i.e.,
F̂ is a secure PRF.
Exercise 2.38 (Key dependent message security). Several works design cryp-
tographic schemes such as encryption schemes, which are secure against a ‘key
dependent message attack’, where the attacker specifies a function f and re-
ceives encryption Ek (f (k)), i.e., encryption of the message f (k) where k is the
secret key. See [30].
90
1. Extend the definition of secure pseudo-random function for security against
key-dependent message attacks.
2. Suppose that F is secure pseudo-random function. Show a (’weird’) func-
tion F 0 which is also a secure pseudo-random function, but not secure
against key-dependent message attacks.
Exercise 2.39 (ANSI X9.31 PRG and the DUHK attack). The ANSI X9.31
is a well-known PRG design, illustrated in Fig. 2.33. In this question we inves-
tigate a weakness in it, presented in [103]; it was recently shown to be still rel-
evant for some devices using this standard, in the so-called DUHK attack [45].
Our presentation is a slight simplification of the X9.31 design but retains the
important aspects of the attack. The design uses a PRF (or block cipher)
F : {0, 1}n × {0, 1}n → {0, 1}n , with a randomly-chosen and then fixed key k;
the attacks we discuss assume that the key is then known to the attacker. Let
f (x) = Fk (x).
1. Let g(x) = f (x) +
+ f (f (x)) +
+ . . .. Is g a secure PRG?
2. Let g(x) = g1 (x) + + g2 (x) + + . . ., where g1 (x) = f (x ⊕ f (t)), g2 (x) =
f (f (t) ⊕ f (g1 (x) ⊕ f (t))), and t is a known value (representing the time).
Is g a secure PRG?
Hint: Solution to first part is almost trivial; indeed this part is mostly there to
aid you in solving the second part (which may not be much harder, after solving
the first part).
Ti AESK ⊕ AESK Vi
Vi−1 ⊕ AESK Ri
Figure 2.33: A single round of the ANSI X9.31 generator, instantiated Fk (x)
by AESk (x) (i.e., using AES as the block cipher or PRF).
91
2. For each of the modes, specify which bits is predictable as a function of
the bits of m and the known fact that the 200th bit flipped.
1. ECB
2. CBC
3. OFB
4. CFB
Solution: The first block contains f, r (10 bits each), and top 24 bits of the
time t, the second block contains 8 more bits of the time, x (24 bits) and 32
bits of the comment; block three contains 64 bits of comments, and block four
contains 32 bits of comment and 32 bits of parity. Denote these four plaintext
blocks by m1 + + m2 ++ m3 + + m4 .
Denote the ciphertext blocks captured by Mal as c0 + + c1 +
+ c2 ++ c3 ++ c4 ,
where c0 is the IV.
92
1. ECB: attacker select the third block (completely comment) to be identical
to the second block, except for containing the maximal value in the 24
bits from bit 8 to bit 31. The attacker then switches between the third
and fourth block before giving to the bank. Parity bits do not change.
2. CBC: Attacker chooses y s.t. m3 = m2 . Now attacker sends to the bank
the manipulated message z0 + +c3 ++c3 + +c4 , where z0 = m1 ⊕m3 ⊕c2 .
+c3 +
As a result, decryption of the first block retrieves m1 correctly (as m1 =
z0 ⊕ m3 ⊕ c2 ), and decryption of the last block similarly retrieves m4
correctly (no change in c3 , c4 ). However, both the second and the third
block, decrypt to the value (c3 ⊕ c2 ⊕ m3 ). Hence, the 32 bit XOR of
the message does not change. The decryption of the second block (to
c3 ⊕ c2 ⊕ m3 ) is likely to leave the time value valid - and to increase the
amount considerably.
3. OFB: the solution is trivial since Mal can flip arbitrary bits in the de-
crypted plaintext (by flipping corresponding bits in the ciphertext).
4. CFB: as in CBC, attacker chooses y s.t. m3 = m2 . Attacker sends
to the bank the manipulated message c0 ++ c1 +
+ c1 +
+ c1 +
+ z4 where
z4 = p4 ⊕ c2 ⊕ p2 .
Exercise 2.44 (Affine block cipher). Hackme Inc. proposes the following
highly-efficient block cipher, using two 64-bit keys k1 , k2 , for 64-bit blocks:
Ek1 ,k2 (m) = (m ⊕ k1 ) + k2 (mod 264 ).
1. Show that Ek1 ,k2 is an invertible permutation (for any k1 , k2 ), and the
inverse permutation Dk1 ,k2 .
2. Show that (E, D) is not a secure block cipher (invertible PRP).
3. Show that encryption using (E, D) is not CPA-IND, when used in the
following modes: (1) ECB, (2) CBC, (3) OFB, (4) CFB.
Exercise 2.45 (How not to build PRP from PRF). Suppose F is a secure PRF
with input, output and keyspace all of length n bits. For xL , xR ∈ {0, 1}n , let
Fk0 (xL + + Fk (xR ) and Fk00 (xL +
+ xR ) = Fk (xL ) + + xR ) = Fk (xL ⊕ xR ) +
+ Fk (xL ⊕
Fk (xL ⊕ xR )). Prove that neither Fk0 nor Fk00 are a PRP.
Exercise 2.46 (Building PRP from a PRF). Suppose you are given a secure
PRF F , with input, output and keyspace all of length n bits. Show how to use
F to construct:
1. A PRP, with input and output length 2n bit and key length n bits,
2. A PRP, with input, output and key all of length n bits.
Exercise 2.47. Show that the simple padding function pad(m) = m + + 0l , fails
to prevent CCA attacks against most of the modes-of-operation (Fig. 2.6), when
l ≤ n. The attacker may perform CPA and CCA queries, and the plaintext
contains multiple blocks.
93
Exercise 2.48 (Indistinguishability definition). Let (E, D) be a stateless shared-
key encryption scheme, and let p1 , p2 be two plaintexts. Let x be 1 if the most
significant bits of p1 , p2 are identical and 0 otherwise, i.e., x = {1 if M Sb(p1 ) =
M Sb(p2 ), else 0}. Assume that there exists an efficient algorithm X that com-
putes x given the ciphertexts, i.e., x = X(Ek (p1 ), Ek (p2 )). Show that this
implies that (E, D) is not IND-CPA secure, i.e., there is an efficient algo-
rithm ADV which achieves significant advantage in the IND-CPA experiment.
Present the implementation of ADV by filling in the missing code below:
ADV Ek (‘Choose’, 1n ) : {
}
ADV Ek (‘Guess’, s, c∗ ) : {
}
1. Assume the attacker sees ciphertext (c0 , c1 ) resulting from CBC encryp-
tion with c0 being the IV, of a single-block message m, which can have
only two known values: m ∈ {m0 , m1 }. To find if m was m0 or m1 , the
adversary uses fact that it knows the next IV to be used, which we denote
c00 , and asks for CBC encryption of a specially-crafted single-block mes-
sage m0 ; denote the returned ciphertext by the pair (c00 , c01 ), where c00 is
the (previously known) IV, as indicated earlier. The adversary can now
compute m0 from c01 :
a) What is the value of m0 that the adversary will ask to encrypt?
b) Fill the
missing parts in the solution of the adversary:
m0 if
m=
m1 if
2. Show pseudo-code for the attacker algorithm used in the previous item.
3. Show pseudo-code for an attack that finds the last byte of message m.
Hint: use the previous solution as a routine in your code.
4. Assume now that the attacker tries to find a long secret plaintext string
x of length l bytes. Assume attacker can ask for encryption of messages
m = p+ + x, where p is a plaintext string chosen by the attacker. Show
pseudo-code for an attack that finds x. Hint: use previous solution as
routine; it may help to begin considering fixed-lenght x, e.g., four bytes.
94
Sketch of solution to second part (to be updated): Attacker makes
query for encryption of some one-block message y, receives α0 , α1 where α1 =
Ek (α0 ⊕ y). Suppose now attacker knows next message will be encrypted with
IV I. Attacker picks m0 = I ⊕ y ⊕ α0 , and m1 some random message. If
game pick bit b = 0 then attacker receives encryption of m0 which is I and
Ek (I ⊕ m0 ) = Ek (I ⊕ I ⊕ y ⊕ α0 ) = Ek (y ⊕ α0 ) = α1 ; otherwise, it receives
some other string.
Exercise 2.50 (Robust combiner for PRG). 1. Given two candidate PRGs,
say G1 and G2 , design a robust combiner, i.e., a ‘combined’ function G
which is a secure PRG is either G1 or G2 is a secure PRG.
2. In the design of the SSL protocol, there were two candidate PRGs, one
(say G1 ) based on the MD5 hash function and the other (say G2 ) based
on the SHA-1 hash function. The group decided to combine the two; a
simplified version of the combined PRG is G(s) = G2 (s ++ G1 (s)). Is this
a robust-combiner, i.e., a secure PRG provided that either G1 or G2 is a
secure PRG?
Hint: Compare to Lemma 2.3. You may read on hash functions in chapter 4,
but the exercise does not require any knowledge of that; you should simply
consider the construction G(s) = G2 (s+
+G1 (s)) for arbitrary functions G1 , G2 .
Exercise 2.51 (Using PRG for independent keys). In Example 2.2, we saw
how to use a PRF to derive multiple pseudo-random keys from a single pseudo-
random key, using a PRF.
1. Show how to derive two pseudo-random keys, using a PRG, say from n
bits to 2n bits.
2. Show how to extend your design to derive four keys from the same PRG,
or any fixed number of pseudo-random keys.
Exercise 2.52. Let (E, D) be a block cipher which operates on 20 byte blocks;
suppose that each computation of E or D takes 10−6 seconds (one microsecond),
on given chips. Using (E, D) you are asked to implement a secure high-speed
encrypting/decrypting gateway. The gateway receives packets at line speed of
108 bytes/second, but with maximum of 104 bytes received at any given second.
The goal is to have minimal latency, using minimal number of chips. Present
an appropriate design, argue why it achieves the minimal latency and why it is
secure.
95
Exercise 2.53. Consider the AES block cipher, with 256 bit key and 128 bit
blocks, and two random one-block (128 bit ) messages, m1 and m2 , and two
random (256-bit) keys, k1 and k2 . Calculate (or approximate/bound) the prob-
ability that Ek1 (m1 ) = Ek2 (m2 ).
Exercise 2.54 (PRF→PRG). Present a simple and secure construction of a
PRG, given a secure PRF.
Exercise 2.55 (Independent PRGs). Often, a designer has one random or
pseudo-random ‘seed/key’ binary string k ∈ {0, 1}∗ , from which it needs to
generate two or more independently pseudorandom strings k0 , k1 ∈ {0, 1}∗ ;
i.e., each of these is pseudorandom, even if the other is given to the (PPT)
adversary. Let P RG be a pseudo-random generator, which on input of arbitrary
length l bits, produces 4l output pseudorandom bits. For each of the following
designs, prove its security (if secure) or its insecurity (is insecure).
1. For b ∈ {0, 1}, let kb = P RG(b +
+ k).
2. For b ∈ {0, 1}, let kb = P RG(k) [(b · 2 · |k|) . . . ((2 + b) · |k| − 1)].
Solution:
1. Insecure, since it is possible for a secure PRG to ignore the first bit,
i.e., P RG(b ++ s) = P RG(b + + s), resulting in k0 = P RG(0 ++ k) =
P RG(1 + + k) = k1 . We skip the (simple) proof that such a PRG may be
secure.
2. Secure, since each of these is a (non-overlapping) subset of the output of
the PRG.
96
Figure 2.34: Figure for Exercise 2.56 (to be done).
1. Alice uses some secure shared key encryption scheme (E, D), with l bit
keys, to encrypt the plaintext records into the ciphertext records. The goal
of this part is to allow Alice to encrypt and decrypt each record i using
a unique key ki , but maintain only a single ‘master’ key k, from which
it can easily compute ki for any desired record i. One motivation for
this is to allow Alice to give keys to specific record(s) ki to some other
users (Bob, Charlie,...), allowing decryption of only the corresponding
ciphertext ci , i.e., pi = Dki (ci ). Design how Alice can compute the key ki
for each record (i), using only the key k and a secure block cipher (PRP)
(F, F −1 ), with key and block sizes both l bits. Your design should be as
efficient and simple as possible. Note: do not design how Alice gives ki
to relevant users - e.g., she may do this manually; and do not design
(E, D).
97
Figure 2.35: Figure for solution of Exercise 2.56 (to be done).
Solution: ki =
2. Design now the encryption scheme to be used by Alice (and possibly by
other users to whom Alice gave keys ki ). You may use the block cipher
(F, F −1 ), but not other cryptographic functions. You may use different
encryption scheme (E i , Di ) for each record i. Ensure confidentiality of
the plaintext records from the cloud, from users (not given the key for
that record), and from eavesdroppers on the communication. Your design
should be as efficient as possible, in terms of the length of the ciphertext
(in bits), and in terms of number of applications of the secure block cipher
(PRP) (F, F −1 ) for each encryption and decryption operation. In this
part, assume that Alice stores P only once, i.e., never modifies records
pi . Your solution may include a new choice of ki , or simply use the same
as in the previous part.
Solution: ki = ,
Eki i (pi ) = ,
Dki i (ci ) = .
3. Repeat, when Alice may modify each record pi few times (say, up to 15
times); let ni denote number of modifications of pi . The solution should
allow Alice to give (only) her key k, and then Bob can decrypt all records,
using only the key k and the corresponding ciphertexts from the server.
Note: if your solution is the same as before, this may imply that your
solution to the previous part is not optimal.
Solution: ki = ,
Eki i (pi ) = ,
Dki i (ci ) = .
4. Design an efficient way for Alice to validate the integrity of records re-
trieved from the cloud server S. This may include storing additional
98
information Ai to help validate record i, and/or changes to the encryp-
tion/decryption scheme or keys as designed in previous parts. As in pre-
vious parts, your design should only use the block cipher (F, F −1 ).
Solution: ki = ,
Eki i (pi ) = ,
Dki i (ci ) = ,
Ai = .
5. Extend the keying scheme from the first part, to allow Alice to also
compute keys ki,j , for integers i, j ≥ 0 s.t. 1 ≤ i · 2j + 1, (i + 1) ·
2j ≤ n, where ki,j would allow (efficient) decryption of ciphertext records
ci·2j +1 , . . . , c(i+1)·2j . For example, k0,3 allows decryption of records c1 , . . . , c8 ,
and k3,2 allows decryption of records c13 , . . . , c16 . If necessary, you may
also change the encryption scheme (E i , Di ) for each record i.
Solution: ki,j = ,
Eki i (pi ) = ,
Dki i (pi ) = .
Exercise 2.58 (Modes vs. attack models.). For every mode of encryption we
learned (see Table 2.6):
1. Is this mode always secure against any of the attack models we discussed
(CTO, KPA, CPA, CCA)?
2. Assume this mode is secure against KPA. Is it then also secure against
CTO? CPA? CCA?
3. Assume this mode is secure against CPA. Is it then also secure against
CTO? KPA? CCA?
Justify your answers.
Exercise 2.59. Recall that WEP encryption is defined as: W EPk (m; IV ) =
[IV, RC4IV,k ⊕(m+ +CRC(m))], where IV is a random 24-bit initialization win-
dow, and that CRC is a error-detection code which is linear, i.e., CRC(m ⊕
m0 ) = CRC(m)⊕CRC(m0 ). Also recall that WEP supports shared-key authen-
tication mode, where the access point sends random challenge r, and the mobile
response with W EPk (r; IV ). Finally, recall that many WEP implementations
use 40-bit key.
1. Explain how an attacker may efficiently find the 40-bit WEP key, by
eavesdropping on the shared-key authentication messages between the mo-
bile and the access point.
2. Present a hypothetical scenario where WEP would have used a fixed value
of IV to respond to all shared-key authentication requests, say IV=0.
Show another attack, that also finds the key using the shared-key authenti-
cation mechanism, but requires less time per attack. Hint: the attack may
use (reasonable) precomputation process, as well as storage resources; and
99
the attacker may send a ‘spoofed’ challenge which the client believes was
sent by the access point.
3. Identify the attack models exploited in the two previous items: CTO,
KPA, CPA or CCA?
4. Suppose now that WEP is deployed with a long key (typically 104 bits).
Show another attack which will allow the attacker to decipher (at least
part) of the encrypted traffic.
100
Chapter 3
Authentication: Message
Authentication Code (MAC) and
Signature Schemes
101
In fact, many ciphers are malleable; often, an attacker can easily modify a
known ciphertext c, to c0 6= c s.t. m0 = Dk (c0 ) 6= m (and also m0 6= ERROR).
Furthermore, often the attacker can ensure useful relations between m0 and m.
An obvious example is when using the (unconditionally-secure) one-time-pad
(OTP), as well as using Output-Feedback (OFB) mode.
Sender identification Consider two - or more - parties that use the same
MAC key to send authenticated messages among them. By validating the tag
102
Figure 3.1: Message Authentication Code (MAC).
received, recipients know that the tag was computed by one of the key holders
- but not which key holder computed the MAC. Adding the identity of the
sender to the input to the MAC, in addition to the message itself, ensures
correct identification of the sender, if all the parties are trusted to add their
identity.
103
positive polynomial for sufficiently large n (as n → ∞), where:
h i 1
εM AC
F,A (n) ≡ Pr (m, Fk (m)) ← AFk (·|except m)
(1n ) − l (3.1)
$
k←{0,1}n
2
$
Where the probability is taken over the random choice of an n bit key, k ←
{0, 1}n , as well as over the coin tosses of A.
Oracle. The expression AFk (·|except m) refers to the output of the adversary
A, where during its run, the adversary can give arbitrary inputs x 6= m and
receive the corresponding values of the function, Fk (x). We say that the ad-
versary A has an oracle to the MAC function FK (·) (excluding the message
m). See Definition 2.7.
Output length - fixed (l) or as key length (n). In some other definitions
of MAC schemes, the output length is also n, i.e., same as the key. In this case,
the 21l element becomes 21n , which is negligible in n, and hence can be ignored.
(Readers are encouraged to prove this last statement, as an exercise.)
Input domain. Notice that the definition allows an arbitrary input do-
main D to the MAC function. The two most commonly used domains are
D = {0, 1}∗ , i.e., the set of all binary string (of unbounded length), and
D = {0, 1}lin , i.e., the set of all binary strings of some fixed length lin . Of
course, lin may also be the same as l. A MAC function whose input is the set
of binary strings of fixed length, is called FIL-MAC, i.e., Fixed Input Length
MAC. In contrast, a MAC function whose input is the set of all binary strings
is called VIL-MAC, i.e., Variable Input Length MAC.
104
messages (which we can sign by applying S). The three algorithms and their
basic operations are illustrated in Figure 3.2.
105
Digital signatures provide message authentication, like a Message Authen-
tication Code (MAC) schemes. There is, however, a critical difference:
MAC use the same secret key k for authenticating a message m, by com-
puting the authenticator M ACk (m), and for verifying the match between
a given pair of message m and authenticator a.
Signatures use (private, public) key pair (s, v), where the private sign-
ing key s is required for signing, and the public verification key v suffices
for verification. Knowledge of the public verification key v should not
help in signing.
This separation between the signing functionality and the verification func-
tionality is very useful, and is the reason that we use the name signature
schemes; they correspond to the property associated with handwritten sig-
natures. Bob may use Alice’s public verification key A.v to recognize that
σ = SA.s (m) is Alice’s signature on m, but that would not allow Bob to forget
Alice’s signature on other messages. Following the conservative design prin-
ciple (Principle 7), Bob should not be able to forge Alice’s signature on any
message not signed by Alice; this is referred to as existential unforgeability.
The definition is quite similar to that of MAC functions, except for providing
the adversary with the public verification key v.
Where the probability is taken over the random coin tosses of A and KG, and
the message m ∈ D is not one of the messages for which A used the oracle
Ss (·|except m) to sign.
106
and range {0, 1}n (i.e., h : {0, 1}∗ → {0, 1}n ), we define the HtS scheme SHtS
h
as follows:
h
SHtS .KG(1n ) ≡ [Link](1n ) (3.4)
h
SHtS .Ss (m) ≡ S.S(h(m)) (3.5)
h
SHtS .Vv (m, σ) ≡ [Link] (h(m)) (3.6)
h
The HtS scheme SHtS may be applied to any binary string, i.e., its domain
∗
is {0, 1} . The reader may confirm that it is a correct signature scheme over
{0, 1}∗ (Exercise 3.17). Theorem 4.1 shows that if h : {0, 1}∗ → {0, 1}n is a
collision-resistant hash function (CRHF) h(·), as in Definition 4.1, and S is
existentially unforgeable signature scheme over {0, 1}n , then the HtS scheme
h
SHtS is existentially unforgeable signature scheme over {0, 1}∗ , i.e., applicable
to arbitrary-length binary strings. Of course, the HtS method may fail if using
an insecure hash function h; see Exercise 3.18.
Example 3.2 (MAC does not ensure confidentiality.). To show that MAC may
not ensure confidentiality, we construct such a Non-confidential MAC function
F N M (where N M stands for ‘Non-confidential MAC’). Our construction uses
107
an arbitrary secure MAC scheme F (which may or may not ensure confiden-
tiality). Specifically:
We show, later on, that every PRF is a MAC. The following exercise shows
that the reverse is not true: a MAC is not necessarily a PRF. This exercise is
similar to the example above.
Exercise 3.1 (Non-PRF MAC). Show that a MAC function is not necessarily
a Pseudo-Random Function (PRF).
Key separation Another problem with the SSH ‘Encrypt and Authenticate’
design, Ek (m) ++ M ACk (m), is the fact that the same key is used for both
encryption and MAC. This can cause further vulnerability; an example is shown
in the following simple exercise.
108
Exercise 3.2. Show that the use of the same key for encryption and MAC in
Ek (m) ++ M ACk (m) can allow an attacker to succeed in forgery of messages -
in addition to the potential loss of confidentiality shown above - even when E
and M AC are secure (encryption and MAC, respectively).
Principle 10 (Key Separation). Keys used for different purposes and crypto-
graphic schemes should be independent from each other - ideally, each chosen
randomly; if necessary, pseudo-random derivation is also Ok.
109
Signatures facilitate non-repudiation and evidences (‘digital signa-
tures’). The use of the private signing key is required to digitally sign a
message, but validation of a signature only requires the corresponding public
verification key. This allows a recipient of a signed message to know that once
she validated a signature, using the verification key v, she would be able to
‘convince’ other parties that the message was, in fact, signed by the use of the
private key corresponding to v; and these parties also only need to know v. We
refer to this property as non-repudiation, since the owner of the private key
cannot claim that the ability to verify messages allowed another party to forge
a signature, i.e., compute a seemingly-valid signature of a message, without
access to the private signing key.
Note that non-repudiation does not hold for (shared-key) MAC schemes,
where one computes the MAC, using the key k, both to verify a given MAC
authenticator, and to compute the MAC authenticator in the first place.
The non-repudiation property allows a digitally-signed document to provide
an evidence for the agreement of the signer, much like the classical use of hand-
written signatures. Indeed, the use of digital signatures to prove agreement,
has significant advantages compared to the use of hand-written signatures:
Security. Handwritten signatures are prone to forging of the signature it-
self, as well as to modification of the signed document. If the signature
scheme is secure (i.e., existentially unforgeable, see Definition 3.2), then
production of a valid signature over a document m practically requires
the application of the private signing key to sign exactly m.
Convenience. Digital signatures can be sent over a network easily, and their
verification only requires running of an algorithm. Admittedly, signature
verification does involve some non-negligible overhead, but is much easier
than the manual process and expertise required to confirm handwritten
signatures. Later on, digital signatures may be easily archived, backed-up
and so on.
Non-repudiation is essential for many important applications, such as sign-
ing an agreement or a payment order, or for validation of recommendations
and reviews; they are also applied extensively in different cryptographic sys-
tems and protocols. One especially important application is their use to im-
plement a public key certificate, linking between an entity and its public key,
which is central to the public key infrastructure (PKI). We discuss PKI mainly
in chapter 8.
110
Other systems and organizations, consider as a ‘digital signature’ the scanned
or scribbled version of a person’s signature, which we refer to as digitized hand-
written signatures.
These interpretations are related to handwritten signatures rather than to
cryptographic signatures. In particular, since digitized handwritten signatures
are merely digitally-represented images, they definitely cannot prevent an at-
tacker from modifying the ‘signed’ document in arbitrary way, or even reusing
the signature to ‘sign’ a completely unrelated document. From the security
point of view, these digitized handwritten signatures are quite insecure - not
only compared to cryptographic signatures, but even compared to ‘real’ hand-
written signatures, since ‘real’ handwritten signatures may be verified with
some precision by careful inspection (often by experts).
111
in advance ; if that’s the case, the parties could use this shared key to establish
secure communication directly.
Signature schemes provide a solution to this dilemma. Namely, a party
receiving signed information from a remote peer, can validate that informa-
tion, using only the public signature-validation key of the signer. Furthermore,
signatures also allow the party performing the signature-validation, to first
validate the public signature-validation key, even when it is delivered by an in-
secure channel which is subject to a MitM attack, such as email. This solution
is called public key certificates.
112
We note that, based on the PRP/PRF switching lemma (Lemma 2.4), we
could use a block-cipher instead of the PRF in these constructions, since a
block-cipher is indistinguishable from a PRF. Since a PRF is often not in-
cluded in cryptographic libraries, it may be tempting to use instead, in these
construction, a block cipher, which is part of most cryptographic libraries. How-
ever, recall this is not advisable, since the use of block cipher instead of PRF
involves loss in security. Instead, use one of the efficient, simple constructions
of PRF from a block cipher, which avoid the loss of security, e.g., [18, 87].
The section contains three subsections, In the first, we observe that given
a PRF, we can actually use it directly as a MAC, i.e., every PRF is also a
MAC. There is a caveat: the input domain of the MAC is the same as that of
the PRF, which, in turn, is the same as of the underlying block cipher (if the
PRF is implemented from a block cipher as explained above). Namely, if we
use n-bit blocks, i.e. the domain of the block-cipher (and PRF) is {0, 1}n , then
the MAC function also applies to n-bit messages. However, typical messages
are longer.
The second subsection presents the CBC-MAC construction, which con-
structs a l · n-bit PRF from an n-bit PRF, for a given constant number of
blocks l. This allows efficient and secure use of n-bit-input PRF (or block
cipher), to encrypt longer, l · n-bits messages.
Finally, in the third subsection we discuss extensions that allow a MAC for
messages of arbitrary length.
Proof: Assume that F is not a MAC (for same domain D and range {0, 1}l ).
Namely, assume that there exists some adversary AM AC s.t. εM AC
AM AC ,F (n) is
non-negligible in n (as defined in Equation 3.1). We use AM AC to construct
another adversary, AP RF , s.t. εP RF
AP RF ,F (n) is non-negligible in n (as defined in
Equation 2.25); this shows that F is (also) not a PRF, which proves the claim.
Let us now define AP RF . First, recall that in Equation 2.25, adversary
$
AP RF is given an oracle either to a random function f ← {D → {0, 1}l , or
to the pseudo-random function Fk : D → {0, 1}l for some random n-bit key
$
k ← {0, 1}n . Adversary AP RF runs AM AC , letting it use the same oracle.
Namely, whenever AM AC asks its oracle with input x ∈ D, adversary AP RF
calls its oracle with the same input x; and when it receives a result ξ, it returns
that result to AM AC .
113
When AM AC terminates, it should return some pair, which we denote by
(m, σ). Upon receiving (m, σ), adversary AP RF provides m as input to its
oracle; denote the output by σ 0 . If σ 6= σ 0 , then AP RF returns ‘Rand’; other-
wise, i.e., if σ = σ 0 , then AP RF returns ‘Pseudo’. Essentially, AP RF outputs
‘Rand’ (i.e., guess it was given a random function), when AM AC fails was able
to predict correctly the output of the oracle for the input m.
Let us consider what happens if AP RF is given an oracle to a random
$
function f ← {D → R}. In this case, when running AM AC , the values returned
from the oracle were for that random function f ; clearly, AM AC cannot be
expected to perform as well as when given an oracle to the function Fk (·). In
fact, AM AC has to return a pair (m, σ), without giving input m to the oracle.
But if the oracle is to a random function f , then f (m), is chosen independently
of f (x) for any other input x 6= m; learning other outputs cannot help you guess
the output when the input is m! Hence, the probability of a match is (only)
2−l - the probability of a random match between two random l bit strings.
Namely, Pr $ Af (1n ) = ‘Rand’ = 2−l .
f ←{D→R}
Now consider what happens if AP RF is given an oracle to a pseudo-random
function Fk (·). The claim is that F is also a MAC, but we assumed, to the
contrary, that it is not; so AM AC is able to return a pair (m, Fk (m)) - with
probability significantly larger
F than 2−l . In these cases, AP RF will return
‘PR’. Namely, Pr $ n
A k (1 ) = ‘Rand’ = 2−l + p(n), where p(n) is a
n
k←{0,1}
significant (not negligible) function.
It follows that εP RF
A,F (n) is not negligible, and hence, F is not a PRF.
114
Exercise 3.3 (CTR-MAC is insecure). Let E be a secure (n + 1)−bit block
cipher, and define the following 2n−bit domain function: Fk (m0 +
+ m1 ) =
Ek (0 +
+ m0 ) +
+ Ek (1 ++ m1 ) (CTR-MAC). Present a counterexample showing
that F is not a secure 2n−bit MAC.
m1 m2 m3
0n
Ek Ek Ek
Figure 3.4: CBC-MAC: construction of l · n−bit PRF (and MAC), from n−bit
PRF.
There are other constructions of secure MAC from PRFs (and block ci-
phers), including more efficient constructions, e.g., supporting parallel compu-
tation. However, CBC-MAC is the most widely used MAC based on block
ciphers, as also possibly the simplest, hence we focus on it.
We next present Lemma 3.2 which shows that CBC-MAC constructs a
secure PRF (and hence also MAC), provided that the underlying function E
is a PRF.
Lemma 3.2. If E is an n-bit PRF, then CBC − M ACkE (·) is a secure n · l-bit
PRF and MAC, for any constant integer l > 0.
115
arbitrary length, i.e., a variable input length (VIL) PFR (and MAC) - defined
for input domain domain {0, 1}∗ ?
One obvious problem is that an arbitrary binary string, may not even consist
of an integral number of blocks, while CBC-MAC is defined only for inputs
which are of length n · l, i.e., integral number of blocks. However, let us ignore
that problem for now, and focus on inputs whose length is an integral number
of blocks, i.e., the inputs in the domain VIBC domain, defined as:
116
Lemma 3.3 (Length-prepending CBC-MAC is a VIL PRF.). Let fk (m) =
CBC − M ACkE (L(m) + + m), where L(m) is the block-encoded length of m (as
defined above). Then fk (·) is a PRF over the set of all binary strings(and
MAC).
117
EDC schemes are designed to ensure integrity - albeit, their design model as-
sumes random errors, rather than intentional modifications. However, can we
extend them, using a secret key, to provide also authentication?
Notice that in § 2.10 we showed that encryption of CRC may not suffice to
ensure authentication. Still, this does not rule out their use for authentication
by using a secret key in a different way, in particular, unrelated to encryption.
In the following exercise, we show that two specific, natural constructions,
M ACk (m) = EDC(k + +m) and M ACk0 (m) = EDC(m+ +k), are both insecure.
Exercise 3.5 (Insecure EDC-based MACs). Show that both M ACk (m) =
EDC(k + + m) and M ACk0 (m) = EDC(m +
+ k) are insecure, even when us-
ing a ‘strong’ EDC such as CRC.
Solution: We first note that the insecurity is obvious for simple EDCs such
as bit-wise XOR of all bits of the message, and appending the result as an
EDC. This weak EDC detects single bit errors, but fails to detect any error
involving an even number of bits. This holds equally well with and without a
secret key, concatenated before or after the message.
Let us now show that these designs are insecure, also when using a ‘strong
EDC’ such as CRC. Specifically, consider CRC-MACk (m) = CRC(k + + m); we
next show this is not a secure MAC.
Recall that the CRC function is linear, namely CRC(m⊕m0 ) = CRC(m)⊕
CRC(m0 ). Hence, for any message m,
Namely, to forge the MAC for any message m, the attacker makes a query
for q = 0|m| , and receives CRC-MACk (0|m| ). Adversary now computes:
CRC-MAC0|k| (m) = CRC(0|k| + + m), and finally computes CRC-MACk (m) =
CRC-MAC0|k| (m) ⊕ CRC-MACk (0|m| ).
We conclude that these ECD-based MACs are - as expected - insecure.
Note that in Exercise 3.5 above, the attack assumes that the attacker can
obtain the MAC for the specific message (query) q = 0|m| . Obtaining MAC for
this specific (‘chosen’) message may be infeasible in many scenarios, i.e., the
attack may appear impractical. However, as the following exercise shows, it is
quite easy to modify the attack so that it works for any (‘known’) message for
which the attacker can receive the MAC value.
118
Guidance: The attack is a slight modification of the one in Exercise 3.5,
exploiting the linearity, very much like in Eq. 3.9, except for choosing a dif-
ferent message (query) q, not q = O|m| as before. The main challenge is to
select the message (query) q so that CRC-MACk (m) = CRC-MAC0|k| (q) ⊕
CRC-MACk (m0 ); you can find the required value of q by essentially solving
this equation, which, using the linearity of CRC, is actually a simple linear
equation.
Solution (from [92]): Let F 0 , F 00 be two candidate MAC schemes, and define
Fk0 ,k00 (m) = Fk0 0 (m) +
+ Fk0000 (m). We should show that it suffices that either F 0
00
or F is a secure MAC, for F to be a secure MAC scheme as well. Without loss
of generality, assume F 0 is secure; and assume, to the contrary, that F is not
a secure MAC. Namely, assume an attacker AFk0 ,k00 (µ)|µ6=m that can output a
pair m, Fk0 ,k00 (m), given access to an oracle that computes Fk0 ,k00 on any value
except m. We use A to construct an adversary A0 which succeeds against F 0 .
Adversary A0 operates by running A, as well as selecting a key k 00 and
running Fk0000 (·); this is needed to allow A0 to provide the oracle service to
AFk0 ,k00 (µ)|µ6=m , computing Fk0 ,k00 (µ) for any given input µ. Whenever A makes
a query q, then A0 makes the same query to the Fk0 0 (·) oracle, to receive Fk0 0 (q).
Then, A0 computes by itself Fk0000 (q), and combines it with Fk0 0 (q) to produce
the required response (Fk0 0 (q), Fk0000 (q)).
When A finally returns the pair (m, Fk0 ,k00 (m)) = (m, Fk0 0 (m) + + Fk0000 (m)),
0 0
then A simply returns the pair (m, Fk0 (m)), i.e., omitting the second part of
the MAC that A returned.
However, concatenation is a rather inefficient construction for robust com-
biner of MAC schemes, since it results in duplication of the length of the out-
put. The following exercise shows that exclusive-or is also a robust combiner
for MAC - and since the output length is the same as of the component MAC
schemes, it is efficient.
Exercise 3.8. Show that exclusive-or is a robust combiner for MAC functions.
Namely, that M AC(k0 ,k00 ) (x) = M ACk0 0 (x) ⊕ M ACk0000 (x) is a secure MAC, if
one or both of {M AC 0 , M AC 00 } is a secure MAC.
Guidance: Similar to the solution of Ex. 3.7; see in chapter 10.
119
3.6.3 MAC constructions from other cryptographic
mechanisms
Finally, we consider constructions of MAC functions from other cryptographic
mechanisms, following the cryptographic building blocks principle (§ 2.7); these
type of constructions of one cryptographic scheme from another, are also the
most widely studied in cryptographic literature.
The most well-known and widely used constructions of MAC functions from
other cryptographic schemes, are from two ‘standard’ cryptographic building-
blocks: block ciphers and cryptographic hash functions.
Constructions of MAC functions from block ciphers, need to address the ob-
vious challenge of input length: we defined MAC functions for arbitrary input
length, usually abbreviated as VIL (for Variable Input Length, while block ci-
phers have Fixed Input Length (FIL). This makes these constructions somewhat
more complex, and we discuss them in the following section (subsection 3.5.2).
Cryptographic hash functions, in contrast, usually allow for variable input
length (VIL), and therefore, constructions based on them are mostly simpler.
We discuss cryptographic hash functions in chapter 4, and their use to construct
MAC functions in subsection 4.6.1.
120
if the ciphertext is found not-authentic; similar verification property can be
implemented by a MAC scheme, by comparing the ‘tag’ received with a message
to the result of computing the MAC on the message. AE schemes may also
have a key-generation function; in particular, this is necessary when the keys
are not uniformly random.
The use of such combined scheme allows simpler, less error-prone implemen-
tations, with calls to only one function (encrypt-and-authenticate or decrypt-
and-verify) instead of requiring the correct use of both encryption/decryption
and MAC functions. Many constructions are generic, i.e., built by combin-
ing arbitrary implementation of cryptographic schemes, following the ‘crypto-
graphic building blocks’ principle. The combinations of encryption scheme and
MAC scheme that we study later in this subsection are good examples for such
generic constructions.
Other constructions are ‘ad-hoc’, i.e., they are designed using specific func-
tions. Such ad-hoc constructions may have better performance than generic
constructions, however, that may come at the cost of requiring more complex or
less well-tested security assumptions, contrary to the Cryptographic Building
Blocks principle.
In many applications, some of the data to be authenticated should not
be encrypted, since it is used also by agents which do not have the secret
(decryption) key; for example, the identity of the destination. Such data is often
referred to as associated data, and authenticated encryption schemes supporting
it are referred to as AEAD (Authenticated Encryption with Associated Data)
schemes [146]. AEAD schemes have the same three functions (key-generation,
encrypt-and-authenticate, decrypt-and-verify); the change is merely in adding
an optional ‘associated-data’ field as input to the encrypt-and-authenticate
function and as output of the decrypt-and-verify function.
Exercise 3.9. Present precise definitions for IND-CPA and security against
forgery for AE and AEAD schemes.
121
3.7.2 EDC-then-Encrypt Schemes
Several practical secure communication systems first apply an Error-Detecting-
Code (EDC) to the message, and then encrypt it, i.e.: c = Ek (m + + EDC(m)).
We believe that the motivation for this design is the hope to ensure authenti-
cation as well as confidentiality, i.e., the designers were (intuitively) trying to
develop an authenticated-encryption scheme. Unfortunately, such designs are
often insecure; in fact, often, the application of EDC/ECC before encryption
allows attacks on the confidentiality of the design. We saw one example, for
WEP, in § 2.10. Another example of such vulnerability is in the design of GSM,
which employs not just an Error Detecting Code but even an Error Correcting
Code, with very high redundancy. In both WEP and GSM, the encryption
was performed by XORing the plaintext (after EDC/ECC) with the keystream
(output of PRG).
However, EDC-then-Encrypt schemes are often vulnerable, also when using
other encryption schemes. For example, the following exercise shows such vul-
nerability, albeit against the authentication property, when using CBC-mode
encryption.
Exercise 3.10 (EDC-then-CBC does not ensure authentication). Let E be
a secure block cipher and let CBCkE (m; IV ) be the CBC-mode encryption of
plaintext message m, using underlying block cipher E, key k and initializa-
tion vector IV , as in Eq. (2.38). Furthermore, let EDCtCBCkE (m; IV ) =
CBCkE (m + + h(m); IV ) where h is a function outputting one block (error de-
tecting code). Show that EDCtCBC E is not a secure authenticated encryption;
specifically, that authentication fails.
Hint: attacker asks for EDCtCBC E encryption of the message m0 = m +
+
h(m); the output gives also the encryption of m.
Authenticate and Encrypt (A&E) , e.g., used in early versions of the SSH
protocol: C = Enck0 (m), A = M ACk00 (m); send (C, A).
Authenticate then Encrypt (AtE) , e.g., used in the SSL and TLS stan-
dards: A = M ACk00 (m), C = Enck0 (m, A); send C.
122
Encrypt then Authenticate (EtA) , e.g., used by the IPsec standard: C =
Enck0 (m), A = M ACk00 (C); send (C, A).
Exercise 3.11 (Generic AE and AEAD schemes). Above we described only the
‘encrypt-and-authenticate’ function of the authenticated-encryption schemes for
the three generic constructions, and even that, we described informally, with-
out the explicit implementation. Complete the description by writing explicitly,
for each of the three generic constructions above, the implementation for the
encrypt-and-authenticate (EnA) and the decrypt-and-verify (DnV) functions.
Present also the AEAD (Authenticated Encryption with Associated Data) ver-
sion.
Partial solution: we present only the solution for the A&E construction.
The AE implementations are:
The AEAD implementations are very similar, except also with Associated
Data (wAD); we present only the EnA function:
123
Exercise 3.13 shows that AtE is also insecure. The argument is more elabo-
rate than the A&E argument from Exercise 3.12, and it may not be completely
necessary to understand it for a first reading; however, it is a nice example
of a cryptographic counterexample, so it may be worth investing the effort.
Readers may also consult [110] for more details.
Exercise 3.13 (Authenticate then Encrypt (AtE) is insecure). Show that a
pair of secure encryption scheme Enc and secure MAC scheme M AC may be
both secure, yet their combination using the AtE construction would be insecure.
Solution: Consider the following simplified version of the Per-Block Random
(PBR) mode presented in subsection 2.9.2, defined for single block messages:
Enck (m; r) = m ⊕ Ek (r) + + r, where E is a block cipher; notice that this is also
essentially OFB and CFB mode encryption, applied to single block messages.
When the random bits are not relevant, i.e., simply selected uniformly, then
we do not explicitly write them and use the simplified notation Enck (m).
As shown in Theorem 2.1, if E is a secure block cipher (or even merely a
PRF or PRP), then Enc is an IND-CPA secure encryption scheme. Denote
the block length by 4n, i.e., assume it is a multiple of 4. Hence, the output of
Enc is 8n-bits long.
We next define a randomized transform Split : {0, 1} → {0, 1}2 , i.e.,
from one bit to a pair of bits. The transform always maps 0 to 00, and
randomly transforms 1 to {01, 10, 11} with the corresponding probabilities
{49.9%, 50%, 0.1%}. We extend the definition of Split to 2b-bit long strings, by
applying Split to each input block, i.e., given 2n-bit input message m = m1 + +
. . .+
+m2n , where each mi is a bit, let Split(m) = Split(m1 )+ +. . .+
+Split(m2n ).
We use Split to define a ‘weird’ variant of Enc, which we denote Enc0 ,
defined as: Enc0k (m) = Enck (Split(m)). The reader should confirm that,
assuming E is a secure block cipher, then Enc0 is IND-CPA secure encryption
scheme (for 2n-bit-long plaintexts).
Consider now AtEk,k0 (m) = Enc0k (m + + M ACk0 (m)) = Enck (Split(m + +
M ACk0 (m))), where m is an n-bits long string, and where M AC has input
and outputs of n-bits long strings. Hence, the input to Enc0 is 2n-bits long,
and hence, the input to Enc is 4n-bits long - as we defined above.
However, AtE is not a secure authenticated-encryption scheme. In fact,
given c = AtEk,k0 (m), we can decipher m, using merely feedback-only CCA
queries.
Let us demonstrate how we find the first bit m1 of m. Denote the 8n bits of c
as c = c1 + +c8n . Perform the query c0 = c¯1 +
+. . .+ +c¯2 +
+c3 +
+c4 +
+c5 ++. . .+
+c8n , i.e.,
inverting the first two bits of c. Recall that c = AtEk,k0 (m) = Enck (Split(m+ +
M ACk0 (m))) and that Enck (m; r) = m⊕Ek (r)+ +r. Hence, by inverting c1 , c2 ,
we invert the two bits of Split(m1 ) upon decryption.
The impact depends on the value of m1 . If m1 = 0, then Split(m1 ) = 00;
by inverting them, we get 11, whose ‘unsplit’ transform returns 1 instead of 0,
causing the MAC validation to fail, providing the attacker with an ‘ERROR’
feedback. However, if m1 = 1, then Split(m1 ) is either 01 or 10 (with proba-
bility 99.9%), and inverting both bits does not impact the ‘unsplit’ result, so
124
that the MAC validation does not fail. This allows the attacker to determine
the first bit m1 , with very small (0.1%) probability of error (in the rare case
where Split(m1 ) returned 11).
Note that the AtE construction is secure - for specific encryption and MAC
schemes. However, it is not secure for arbitrary secure encryption and MAC
schemes, i.e., as a generic construction. Namely, Encrypt-then-Authenticate
(EtA) is the only remaining candidate generic construction. Fortunately, EtA
is secure, for any secure encryption and MAC scheme, as the following lemma
states.
Lemma 3.4 (EtA is secure [110]). Given a CPA-IND encryption scheme Enc
and a secure MAC scheme M AC, their EtA construction ensures both CPA-
IND and secure MAC.
Proof sketch: We first show that the IND-CPA property holds. Suppose, to
the contrary, that there is an efficient (PPT) adversary A that ‘wins’ against
EtA in the IND-CPA game, with significant probability. We construct adver-
sary A0 that ‘wins’ in the IND-CPA game against the encryption scheme Enc,
employed as part of the EtA scheme. Specifically, A0 generates a key k 00 for the
MAC function, and runs A. Whenever A chooses the two challenge messages
m0 , m1 , and should be provided with the authenticated-encryption of mb , then
A0 chooses the same two messages and receives c∗ = Enck0 (mb ). Then A0
uses the key k 00 it generated to compute a∗ = M ACk00 (c∗) and return the pair
(c∗, a∗) which would be the authenticated-encryption of mb , as required.
Similarly, whenever A asks for encryption of a message m, then A0 uses its
oracle to compute c = Enck0 (m), and k 00 to compute a = M ACk00 (c). A0 then
returns the pair (c, a) to A, which is exactly the required EtA.EnAk0 ,k00 (m).
Finally, when A guesses a bit b, then A0 guesses the same bit. If A ‘wins’,
i.e., correctly guesses, then A0 also ‘wins’. It follows that there is no efficient
(PPT) adversary A that ‘wins’ against EtA in the IND-CPA game.
We next show that EtA also ensures security against forgery, as in Def. 3.1,
adjusted for AE / AEAD schemes, as in Ex. 3.9. Suppose there is an effi-
cient (PPT) adversary A that succeeds in forgery of the EtA scheme, with
significant probability. Namely, A produces a message c and tag a s.t. m =
EtA.DnVk0 ,k00 (c, a), for some message m, without making a query to EtA.EnAk0 ,k00 (m).
By construction, this implies that a = M ACk00 (c).
However, from the definition of encryption (Def. 2.1), specifically the cor-
rectness property, there is no other message m0 6= m whose encryption would
result in same ciphertext c. Hence, A did not make a query to EtA.EnAk0 ,k00
that returned M ACk00 (c) as the tag - yet A obtained M ACk00 (c) somehow - in
contradiction to the assumed security of MAC.
125
Efficiency: Any corruption of the ciphertext, intentional or benign, is detected
immediately by the verification process (comparing the received tag to
the MAC of the ciphertext). This is much more efficient then encryption.
Foil DoS: This improved efficiency implies that it is much harder, and rarely
feasible, to exhaust the resources of the recipient by sending corrupted
messages (ciphertext).
Foil CCA: By validating the ciphertext before decrypting it, EtA schemes
prevent CCA attacks against the underlying encryption scheme, where
the attacker provides specially-crafted ciphertext messages, receives the
corresponding plaintext (or failure indication if the ciphertext was not
valid encryption), and uses the resulting plaintext and/or failure indi-
cation to attack the underlying encryption scheme. If the attacker is
creating such crafted ciphertext and sending the the EtA scheme, then
it should fail the MAC validation, and would not even be input to the
decryption process. Therefore, as long as the attacker cannot forge legit-
imate MAC, they can only attack the MAC component of the EtA, and
the encryption scheme is protected from this threat.
Partial solution:
A&E: Let Ek0 ,k00 (m) = Ek0 0 (m) +
+ k 00 and M ACk0 ,k00 (m) = k 0 +
+ M ACk00 (m).
Obviously, when combined using the A&E construction, the result is com-
pletely insecure - both authentication and confidentiality are completely
lost.
AtE: To demonstrate loss of authenticity, let Ek0 ,k00 (m) = Ek0 0 (m) +
+ k 00 as
above.
126
EtA: To demonstrate loss of confidentiality, let M ACk0 ,k00 (m) = k 0 +
+M ACk00 (m)
as above. To demonstrate loss of authentication, with a hint to one el-
egant solution: combine Ek0 ,k00 (m) = Ek0 0 (m) + + k 00 as above, with a
(simple) extension of Example 3.2.
Exercise 3.15 (Generating two keys from one key). Given a secure n-bit-
key shared-key encryption scheme (E, D) and a secure n-bit-key MAC scheme
M AC, and a single random, secret n-bit key k, show how we can derive two
keys (k 0 , k 00 ) from k, s.t. the EtA construction is secure, when using k 0 for
encryption and k 00 for MAC, given:
127
3.8 Message Authentication: Additional exercises
Exercise 3.16. Mal intercepts a message sent from Alice to her bank, and
instructing the bank to transfer 10$ to Bob. Assume that the communication
is protected by OTP encryption, using a random key shared between Alice and
her bank, and by including Alice’s password as part of the plaintext, validated
by the bank. Assume Mal knows that the message is an ASCII encoding of the
exact string Transfer 10$ to Bob. From: Alice, PW: xxxxx, except that xxx is
replaced by Alice’s password (unknown to Mal). Show how Mal can change the
message so that upon receiving it, the bank will, instead, transfer 99$ to Mal.
Exercise 3.17. Let S be a correct signature scheme over domain {0, 1}n , and
let h : {0, 1}∗ → {0, 1}n be a hash function whose output is n bits long. Prove
h
that the HtS construction SHtS , defined as in Equation 3.5, is correct.
Exercise 3.20. Let F : {0, 1}n → {0, 1}l be a secure PRF, from n bit strings
to l < n bit strings. Define F 0 : {0, 1}n → {0, 1}l as: Fk0 (m) = Fk (m)+
+Fk (m),
i.e., concatenate the results of Fk applied to m and to the inverse of m. Present
0
an efficient algorithm ADV Fk which demonstrates that F 0 is not a secure MAC,
0
i.e., outputs tuple (x, t) s.t. x ∈ {0, 1}n and t = Fk0 (x). Algorithm ADV Fk
may provide input m ∈ {0, 1}n and receive Fk0 (m), as long as x 6= m. You
0
can present ADV Fk by ‘filling in the blanks’ in the ‘template’ below, modifying
and/or extending the template if desired, or simply write your own code if you
like.
0
ADV Fk : {t0 = Fk0 ( );
Return ( ); }
128
1. Show an attack demonstrating that CF B − M ACkE is not a secure l · η-
bit MAC, even when E is a secure l-bit block cipher (PRP). Your attack
should consist of:
a) Up to three ‘queries’, i.e., messages m = , m0 =
00
and m = , each of one or more blocks, to which
the attacker receives CF B − M ACkE (m), CF B − M ACkE (m0 ) and
CF B − M ACkE (m00 ). Note: actually, one query suffices.
b) A forgery, i.e., a pair of a message mF and its
authenticator a = such that mF 6∈ {m, m0 , m00 }
and a = CF B − M ACkE (mF ).
2. Would your attack also work against the ‘improved’ variant ICF B −
M ACkE (m) = EK (CF B −M ACkE (m))? If not, present an attack against
ICF B −M ACkE (m): m = , m0 = ,
00 F
m = ,m and a = .
Exercise 3.22. 1. Alice sends to Bob the 16-byte message ‘I love you Bobby’,
where each character is encoded using one-byte (8 bits) ASCII encoding.
Assume that the message is encrypted using the (64-bit) DES block ci-
pher, using OFB mode. Show how an attacker can modify the ciphertext
message to result with the encryption of ‘I hate you Bobby’.
2. Can you repeat for CFB mode? Show or explain why not.
3. Can you repeat for CBC mode? Show or explain why not.
4. Repeat previous items, if we append to the message its CRC, and verify
it upon decryption.
Exercise 3.23. 1. Our definition of FIL CBC-MAC assumed that the input
is a complete number of blocks. Extend the construction to allow input of
arbitrary length, and prove its security.
2. Repeat, for VIL CBC-MAC.
Exercise 3.24. Consider a variant of CBC-MAC, where the value of the IV
is not a constant, but instead the value of the last plaintext block, i.e.:
CBC−M ACkE (m1 + +m2 + +mη ) = {c0 ← mη ; (i = 1 . . . η)ci = Ek (mi ⊕ ci−1 ); outputcη }
+. . .+
(3.14)
Is this a secure MAC? Prove or present convincing argument.
Exercise 3.25. Let E be a secure PRF. Show that the following are not secure
MAC schemes.
129
Exercise 3.26 (MAC from a PRF). In Exercise 2.35 you were supposed to
construct a PRF, with input, output and keyspace all of 64 bits. Show how to
use such (candidate) PRF to construct a VIL MAC scheme.
Note: you may combine the solutions to the two last items; but separating
the two is recommended, to avoid errors and minimize the impact of errors.
Exercise 3.28 (Single-block authenticated encryption?). Let E be a block ci-
pher (or PRP or PRF), for input domain {0, 1}l , and let l0 < l. For input
0 0
domain m ∈ {0, 1}l−l , let fk (m) = Ek (m +
+ 0l ).
Exercise 3.29. Let F : {0, 1}κ × {0, 1}l+1 → {0, 1}l+1 be a secure PRF,
where κ is the key length, and both inputs and outputs are l + 1 bits long. Let
F 0 : {0, 1}κ × {0, 1}2l → {0, 1}2l+2 be defined as: Fk0 (m0 +
+ m1 ) = Fk (0 ++
m0 ) + + m1 ), where |m0 | = |m1 | = l.
+ Fk (1 +
130
1. Explain why it is possible that F 0 would not be a secure 2l-bit MAC.
2. Present an adversary and/or counter-example, showing F 0 is not a secure
2l-bit MAC.
3. Assume that, indeed, it is possible for F 0 not to be a secure MAC. Could
F 0 then be a secure PRF? Present a clear argument.
Exercise 3.30. Given a keyed function fk (x), show that if there is an efficient
operation ADD such that fk (x + y) = ADD(fk (x), fk (y)), then f is not a
secure MAC scheme. Note: a special case is when ADD(a, b) = a + b.
Exercise 3.31 (MAC from other block cipher modes). In subsection 3.5.2 we
have seen given an n-bit block cipher (E, D), the CBC-MAC, as defined in Eq.
(3.7), is a secure n · η-bit PRF and MAC, for any integer η > 0; and in Ex.
3.3 we have seen this does not hold for CTR-mode MAC. Does this property
hold for...
131
Chapter 4
132
m m
h(·) k hk (·)
h(m) hk (m)
133
Figure 4.2: Typical load-balancing application of non-cryptographic hash func-
tion h
Fig. 4.2, this refers to an adversary who can manipulate some of the input
names, and whose goal is to cause imbalanced allocation of names to bins, i.e.,
many collisions - which can cause bad performance.
Consider an attacker whose goal is to degrade the performance for a particu-
lar name, say Bob. This attacker may provide to the system a list of deviously-
crafted names x1 , x2 , . . ., especially selected such that all of them ‘collide’ - i.e.,
are mapped to the same bin as Bob, i.e., h(‘Bob’) = h(x1 ) = h(x2 ) = . . .. The
attack is illustrated in Fig. 4.3. This method is sufficient to significantly impair
the performance of many algorithms and systems, in a so-called Algorithmic
Complexity Denial-of-Service Attack. One way in which attackers may exploit
such an attack is to cause excessive overhead for network security devices, such
as malware/virus scanners, Intrusion-Detection Systems (IDS) and Intrusion-
134
Figure 4.4: With a secure cryptographic hash function and N bins, the at-
tacker’s needs to compute hash for about N1 inputs till finding one that has the
same hash as Bob. Typically the digest is n bits long, and then N = 2n .
Prevention Systems (IPS), causing these systems to ‘give up’ and allowing at-
tacks to penetrate undetected. We will discuss this and other Denial-of-Service
(DoS) attacks in volume II, which focuses on network security.
Such vulnerability of ‘classical’ hash functions, which were not designed
for security, is not surprising. Instead, it is indicative of the need for well-
defined security requirements for (cryptographic) hash functions, following the
attack model and security requirements principle (Principle 1). In particular,
using a secure cryptographic hash function, with the correct security property,
should foil the Algorithmic Complexity Denial-of-Service Attack of Fig. 4.3.
Specifically, each name that the adversary chooses is mapped to a ‘random’
bin; only one in roughly 2n names will match the ‘target’, i.e. h(xi ) = h(‘Bob’).
Note that some hash functions may seem to provide sufficiently-randomized
mapping when the inputs are ‘natural’ but may still allow an attacker to easily
select inputs that will hash to a specific bin (e.g., the one Bob is mapped to).
See the following exercise.
135
(collision) m s.t. h(m) = h(‘Bob’). This property is called second preimage
resistance (SPR). See Fig. 4.4.
Note that if the number of bins is not sufficiently high, the adversary may
still be able to find collisions - on average, N1 of the inputs will match the
desired by. One may try to address this by using a secret mapping, e.g., a
pseudo-random function (PRF), instead of relying on hash functions. Note
that we consider only keyed hash where the key is not secret, hence, such hash
cannot be used for this role (as a replacement for the PRF).
Table 4.1: Goals and Requirements for cryptographic hash functions. The
abridged descriptions are presented for keyless crypto-hash h : {0, 1}∗ →
{0, 1}n . For keyed hash h : {0, 1}n × {0, 1}∗ → {0, 1}n , use hk instead of
h, with a random key k. In SPR and OWF, the message m is random.
136
the security of a system using crypto-hash functions as if we were using a
randomly-chosen function instead; the ROM is often adopted to allow analysis
of designs using cryptographic hash functions, without identifying a feasible
security requirement which ensures security of the design.
Here is an exercise which will strengthen your (still intuitive) understanding
of the different security requirements in Table 4.1. A solution is provided for
part (a); if you have difficulties solving part (b), try again after reading the
following sections, which discuss each of these requirements in details.
Exercise 4.2 (Insecure hash example). Show that the following hash functions
fail to provide the security properties defined above: (a) h(x) = x mod 2n - all
properties, (b) h0 (x) = x2 mod 2n - all except OWF.
Solution for item (a): We first show that h is not SPR (and hence surely
not collision resistant). Namely, assume we are given a random input x; let
x0 = x + 2n . Clearly x0 6= x, and yet h(x0 ) = (x + 2n ) mod 2n = x mod 2n =
h(x), namely, x0 is a collision (second preimage) with x.
We next show that h is not a one-way function (OWF). Specifically, given
h(x) for any preimage x, let x0 = h(x); clearly:
Integrity, digests and blockchain : the (short) digest h(m) allows valida-
tion of the integrity of the (long) message (or file) m. Digest schemes
and blockchains allow efficient validation of sequences of multiple mes-
sages (or files), optionally collected into blocks, with efficient validation
of only specific message(s)/file(s).
Hash-then-Sign : possibly the most well-known use of hash functions: facil-
itate signatures over long (VIL) documents. This uses the hash-then-sign
137
Application Sufficient requirements
Integrity, Merkle-tree, blockchain (§4.2) Collision resistance
Hash-then-sign (§4.2.6) Collision resistance
One-time-password (§4.4.1) OWF
Password hashing, OTP-chain (9.1) ROM
One-time signatures (§4.4.2) OWF (for VIL also CRHF)
Proof-of-Work (§4.6) ROM
Key/random generation Randomness extracting;
(§4.5) ≥ n random input bits
Random map (§4.1.1) SPR (for large n)
paradigm (subsection 4.2.6), i.e., applying the RSA or other FIL signing
function, to a digest h(m) of the message m being signed. See subsec-
tion 4.2.6.
Login when server file may be compromised : Hash functions are used
to improve the security of password-based login authentication, in several
ways. The most widely deployed method is using a hashed password file,
which makes exposure of the server’s password file less risky - since it
contains only the hashed passwords. Another approach is to use a hash-
based one-time password, which is a random number allowing the server
to authenticate the user, with drawbacks of single use and having to re-
member or have this random number. One-time passwords are improved
into OTP-chain (aka hash-chain), to allow multiple login sessions with
the same credential. See §9.1 and §4.4.1.
Proof-of-Work : cryptographic hash functions are often used to provide
Proof-of-Work (PoW), i.e., to prove that an entity performed a con-
siderable amount of computation. This is used by Bitcoin and other
cryptocurrencies, and for other applications. See subsection 4.9.3.
Key derivation and randomness generation : hash functions are used to
extract random, or pseudorandom, bits, given input with ‘sufficient ran-
domness’. In particular, this is used to derive secret shared keys. See
§4.5.
Random map : as discussed above (§4.1.1), hash functions are often used,
usually for efficiency, for ‘random’ mapping of inputs into ‘bins’, i.e., the
2n possible digests.
138
as discussed in the cryptographic building blocks principle (Principle 8). This
implies the importance of defining and adopting standard functions, which can
be widely evaluated for security - mainly by cryptanalysis - and the need for
definitions of security.
There have been many proposed cryptographic hash functions; however,
since security is based on failed efforts for cryptanalysis, designers usually avoid
less-well-known (and hence less tested) designs. The most well-known crypto-
graphic hash functions include the MD4 and MD5 functions proposed by RSA
Inc., the SHA-1, SHA-21 and SHA-3 functions standardized by NIST ( [67,
141]), the RIPEMD and RIPEMD-160 standards, and others, e.g., BLAKE2.
Several of these, however, were already ‘broken’, i.e., shown to fail some of
the requirements (discussed next). In particular, collisions - and specifically,
chosen-prefix collisions - were found for RIPEMD, MD4 and MD5 in [158], and
later also for SHA-1 [120]. As a result, these functions should be avoided and
replaced, at least in the (many) applications which depend on the collision-
resistance property.
Note that existing standards define only keyless cryptographic hash func-
tions. However, as we later explain, there are strong motivations to use keyed
cryptographic hash functions, which use a random, public key (without a pri-
vate key). In particular, one of the security requirements, collision-resistance,
cannot be achieved by any keyless function. We later discuss constructions of
keyed hash functions from (standard) keyless hash functions.
1 The SHA-2 specifications defines six variants for SHA-2, with digests lengths of 224,
256, 384 or 512 bits; these variants are names SHA-224, SHA-256, SHA-384, SHA-512, SHA-
512/224, and SHA-512/256.
139
Figure 4.5: Keyless collision resistance: for sufficient digest length n = |h(·)|,
it is infeasible to find efficiently a collision, i.e., a pair of inputs x, x0 ∈Domain,
which are mapped by hash function h to the same output, h(x) = h(x0 ), except
with negligible probability.
140
it does almost nothing else. Ah, and more: Ah does not just succeeds with a
‘significant’ probability; it always succeeds. Namely, h is very very far from the
requirements of Definition 4.1!
Ok, so now we hope you are already intrigued and want to see the trick - or
did you already detect it? Since yet, we have essentially already did the trick
- ‘hidden in plain sight’ exactly in the paragraph above. Can you find it? Try
to, before you read the proof, then compare. This exercise should be fun and
instructive. And we explain the ‘trick’ right following the proof.
As in Definition 4.1, the lemma refers to a keyless hash function as h(n) (·),
where n is the length of the range (output) of h(n) (·), i.e, n = h(n) (x) for
every string x ∈ {0, 1}∗ . The output length n must be an explicit parameter,
since the keyless CRHF definition requires the probability of a collision to be
negligible in n (for an attacker whose runtime is bounded by a polynomial in
n); see discussion of Definition 4.1.
Lemma 4.1 (Keyless CRHF do not exist.). Let h(n) : {0, 1}∗ → {0, 1}n be
a keyless hash function. Then h(n) (·) is not a keyless CRHF (as defined in
Definition 4.1).
Proof: Given h(n) (·), we prove that there exists an efficient adversary algo-
rithm Ah(n) that always finds a collision, i.e. εCRHF
h,A (n) = 1 - clearly showing
that h(n) (·) does not satisfy the definition of a keyless CRHF.
Before we prove that such Ah(n) exists, first note that, since the domain
of h(n) is unbounded while the range is the bounded set {0, 1}n , then h(n)
must have collisions, i.e., pairs of binary messages m 6= m̂ s.t. h(m) = h(m̂).
Let m(n) , m̂(n) denote one such collision; we have such a pair for each digest
length n. It doesn’t matter how we pick the particular collision, and we do
not assume an efficient algorithm for picking it; for example, given n, we can
pick the collision m(n) , m̂(n) which has the smallest value for m (among all
collisions of h(n) , and if m collides with multiple other strings, pick m)ˆ(n) to
be the smallest string that collides with m(n) . So these values m(n) , m̂(n) are
well defined (even if we didn’t show any efficient algorithm to find them).
Define the adversarial algorithm simply as: Ah(n) (1n ) = (m(n) , m̂(n) ). Namely,
this algorithm has ‘burned in’ a table of collisions (m(n) , m̂(n) ) for every value
of the security parameter n. Clearly, there is such an algorithm - we just de-
fined it, in fact, as we define the contents of this ‘table of collisions’ and the
trivial algorithm that looks up in this table and outputs a collision. Further-
more, this algorithm is polynomial-time (in PPT), since it only looks-up the
collision and outputs it; as readers familiar with the basics of the theory of
computation should be able to confirm (see [81]). Therefore, h(n) (·) is not a
keyless CRHF (as defined in Definition 4.1).
Ok, so the ‘trick’ was that we proved that such an attacker Ah exists - but
in a non-constructive way, i.e., we did not present such an adversary or showed
an efficient way to find it. We only showed that such an adversary exists.
This possibly-surprising lemma shows that there is no keyless CRHF, as de-
fined in Definition 4.1. Of course, there may be some other reasonable definition
141
for keyless CRHFs, for whom the lemma does not apply; indeed, we later define
Second-Preimage Resistant (SPR) hash, which is essentially a weaker collision-
resistance property, and there are other related definitions in the cryptographic
literature. However, all definitions we are aware of are significantly different
from CRHF.
Keyless CRHF remain an important and useful concept - although there
are no keyless CRHFs. In particular, all existing standard hash functions are
keyless. Cryptanalysts spend significant efforts to find collisions; where found,
e.g., for MD5 and SHA-1, we migrate to supposedly-stronger standards, e.g.,
SHA-2 and SHA-3. So, finding collisions to these functions appears to be ‘hard’
- but only in the intuitive, everyday sense of the word, and not as a well-defined
concept.
However, cryptographic hash functions are one of the few cryptographic
building blocks, and per Principle 8, we want to use such building blocks to
construct other cryptographic mechanisms, and prove the security of such con-
structions by reduction to the security of the building block. That cannot be
achieved when we do not have a precise definition of the building block, or, in
this case, when we know that there are no keyless CRHFs.
In this textbook, we deal with relatively simple applications of CRHF, and
in most of the follow-up chapters, our discussion is less formal. Therefore, for
simplicity, we will usually use keyless CRHF; in all of the constructions and
designs, it is easy to add the ‘missing’ keys, when desired (e.g., for provably
secure reductions). Namely, we consider the use of keyless CRHFs as a conve-
nient simplification. A justification may be that if the system using the hash
is insecure, then we may be able to use the attack to find the collision - which
is assumed hard; and anyway in ‘real’ implementations, the output length is
fixed. In fact, many cryptographic designs use an even stronger simplification
- the random oracle model (ROM), which we discuss in §4.6.
Another approach is to design the application without assuming CRHF at
all, and instead, rely on other properties, which may exist for keyless hash,
such as one-way function (OWF), second-preimage resistance (SPR), or other
properties (which we do not cover). SPR is especially relevant, as it is, essen-
tially, a weak form of collision resistance; in fact, it is sometimes even referred
to as weak collision resistance. Of course, care must be taken to ensure that
SPR is really sufficient for the application; there could be subtle vulnerabilities
due to use use of SPR in an application requiring ‘real’ collision-resistance. We
discuss SPR in § 4.3.
A final alternative is to use a keyed CRHF instead of keyless CRHF. Con-
sidering that existing standard define only keyless hash, a common approach
is to use construction of a keyed hash from a keyless hash. Often, this would
be the HMAC construction, originally designed as a construction of a MAC
function from hash. We discuss HMAC in subsection 4.6.1. We discuss this
next.
142
Figure 4.6: Keyed collision resistance hash function (CRHF): given random
key k, it is hard to find a collision for hk , i.e., a pair of inputs x, x0 ∈ {0, 1}∗
s.t. hk (x) = hk (x0 ).
εCRHF
h,A (n) ≡ Pr [(x, x0 ) ← A(k) s.t. (x 6= x0 ) ∧ (hk (x) = hk (x0 )] (4.2)
k←{0,1}n
Where the probability is taken over the random coin tosses of A and the random
choice of k.
143
Figure 4.7: Target collision resistant (TCR) hash: adversary cannot find target
x, to which it would be able to find a collision x0 , once it would be given the
random key k.
that they (and we) call2 Target Collision Resistant (TCR) hash. The term TCR
emphasizes that, to ‘win against’ the TCR definition, the attacker has to first
select the target x, i.e., one of the two colliding strings, before it receives the
(random) key k. Only then the attacker is given the random key k, and has to
output the colliding string x0 s.t. h(x) = h(x0 ). Intuitively, this makes sense:
it seems that on most applications, a collision between two ‘random’ strings
x, x0 may not help the attacker; the attacker often needs to match some specific
‘target’ string x. The TCR definition still allows the attacker to choose the
target - but at least not as a function of the key!
We next define target collision resistance, which we illustrate in Figure 4.7.
Definition 4.3 (Target collision resistant (TCR) hash). A keyed hash function
hk (·) : {0, 1}∗ × {0, 1}∗ → {0, 1}∗ is called a target collision-resistant (TCR)
hash, if for every efficient (PPT) algorithm A, the advantage εTh,A CR
(n) is neg-
ligible in n, i.e., smaller than any positive polynomial for sufficiently large n
(as n → ∞), where:
x ← A(1n );
0 0
εTh,A
CR
(n) ≡ Pr n s.t. (x 6
= x ) ∧ (h k (x) = hk (x )
k←{0,1} x0 ← A(x, k)
(4.3)
Where the probability is taken over the random coin tosses of A and the random
choice of k.
144
4.2.4 Birthday and exhaustive attacks on CRHFs
Find collisions in exponential time. Both definition 4.2 and definition 4.1,
may appear to be overly-permissive, in two ways: we restrict the adversary to
run in polynomial time (PPT) in the length n of the digest, and we allow
the adversary to have a negligible probability of finding a collision. However,
without these two ‘relaxations’, the definition would not be feasible. Namely,
we show that for every hash h, we can find collisions in exponential time; or, if
we prefer, we can find collisions in polynomial time - but with exponentially-
small probability. We will focus here on keyless hash, but it holds almost
unchanged for keyed hash.
Let us first argue that an adversary which can run in time exponential in n
would be able to find a collision. Consider a hash function h : {0, 1}∗ → {0, 1}n ,
and a set X containing 2n + 1 distinct input binary strings. The output of h
is the set of n-bits strings, which contains 2n elements; hence, there must be
at least two elements x 6= x0 in the set X, which collide, i.e., h(x) = h(x0 ).
An adversary that runs in time exponential in n can surely compute h(x) for
every element in X and find this collision. Hence, the definitions restrict the
adversary to run in time polynomial in n. This argument clearly hold for
keyed-hash (and TCR hash) as well.
145
should be hashed before finding a collision h(mi ) = h(mj ) is approximately:
r
n/2 π
q/2 · / 1.254 · 2n/2 (4.4)
2
Hence, to ensure collision-resistance against adversary who can do 2q com-
putations, e.g., q = 80 hash calculations, we need the digest length n to be
roughly twice that size, e.g., 160 bits. Namely, the effective key length of a
CRHF is only q = n/2. This motivates the fact that hash functions often
have digest length twice the key length of shared-key cryptosystems used in
the same system. Using longer digest length and/or longer key length does not
harm security, but may have performance implications.
Note that the birthday attack applies to both keyed CRHF and keyless
CRHF; however, it does not apply to Target Collision Resistant (TCR) hash.
Can you see why? Carefully compare Definition 4.2 vs. Definition 4.3, and
you’ll find out!
Collision resistance is a great tool for ensuring integrity. One common ap-
plication is to distribute a (large) object m, e.g., a file containing the executable
code of a program. Suppose the file m is distributed from its producer in LA,
to a user or repository in Washington DC (step 1 in Fig. 4.8). Next, a user in
NY is downloading the file from the repository (or peer user) in DC (step 3),
and, to validate the integrity, also the digest h(m) of the file, directly from the
146
producer in LA (step 2). By downloading the large file m from (nearby) DC,
the transmission costs are reduced; by checking integrity using the digest h(m),
we avoid the concern that the file was modified in DC or in transit between
LA, DC and NY.
A potential remaining concern is modification of the digest h(m) received
directly from producer in LA, by a Monster-in-the-Middle (MitM)3 attacker.
This may be addressed in different ways, including the use of a secure web
connection for retrieving h(m), as discussed in chapter 7, and/or receiving the
digest from multiple independent sources.
This method of download validation is deployed manually, by savvy users,
or in an automated way, by operating system, application or even a script
running within a browser, e.g., see [77].
Keyless HtS is secure. Let us first recall the keyless Hash-then-Sign con-
struction, which we discussed in subsection 3.3.2. This construction uses a
keyless CRHF h : {0, 1}∗ → {0, 1}n . Given signature scheme (KG, S, V ) whose
input domain is (or includes) n-bit strings, i.e., {0, 1}n , the keyless hash-then-
sign signature of any message m ∈ {0, 1}∗ is defined as Ssh (m) ≡ Ss (h(m)),
where we use s for the private signing key of S (and of Ssh ).
We next show that provided that h is a Collision-Resistant Hash Function
(CRHF), and that the signature scheme (S, V ) is secure (existentially unforge-
able, see Definition 3.2), then (S h , V h ) is also secure.
Proof: Assume that the claim does not hold, i.e., that there is an effi-
cient adversary A ∈ P P T s.t. εeu−Sign
h
SHtS ,A
(n) 6∈ N EGL(n), as defined in Equa-
tion 3.3. Namely, with significant probability, A outputs a pair (m, σ) s.t. A
3 Also called Man-in-the-Middle
147
h h
didn’t provide m as input to the SHtS .Ss (·) oracle, yet SHtS .Vv (m, σ). From
h
Equation 3.6, SHtS .Vv (m, σ) = [Link] (h(m)). Let φ ≡ h(m); now, either there
was another message m0 s.t. φ = h(m0 ) which Adid provide as input to the
h
SHtS .Ss (·) oracle, or not. Let us consider both cases; at least one of the two
must occur with significant probability.
If there is another message m0 s.t. φ = h(m0 ) which A provided as input to
SHtS .Ss (·), then the pair (m, m0 ), both of which produced by A, is a collision
h
148
Figure 4.9: Second-preimage resistance (SPR): given keyless hash function
h : {0, 1}∗ → {0, 1}n , for any input length m ≥ n, given a random first
preimage x ∈ {0, 1}l , for l ← A(1n ), it is hard to find a collision with x, i.e., a
second preimage x0 ∈ {0, 1}∗ s.t. x0 6= x yet h(x) = h(x0 ).
Why and how we fix the length of the first preimage (l)? We can only
select a value with uniform probability from a finite set; for example, given the
set {0, 1}l , i.e., binary strings of length l, we can select a random string by
149
flipping l fair coins - giving probability 21l to each of the 2l strings in {0, 1}l .
But we cannot select a value with uniform probability from an infinite set -
e.g., from {0, 1}∗ .
Therefore, in order to be able to select the a random first preimage x, with
uniform distribution, we take it from the finite set {0, 1}∗ . But what is this l?
Intuitively, we want the property to hold for ‘any’ l; but since the string is given
as input to the adversary A, we can’t allow it to be of exponential length. We
solve this by allowing the adversary to pick l. The definition follows; note that
we found it more convenient to let the adversary directly specify the length of
x, without explicitly setting this length into a variable l.
Definition 4.6 (Second-preimage resistance (SPR) Hash Function). A (key-
less) hash function h : {0, 1}∗ → {0, 1}n is second-preimage resistant (SPR)
if for every efficient algorithm A ∈ P P T , the advantage εSP R
h,A (n) is negligi-
ble in n, i.e., smaller than any positive polynomial for sufficiently large n (as
n → ∞), where:
εSP R
h,A (n) ≡ Pr [x0 ← A(x) s.t. x 6= x0 ∧ h(x) = h(x0 )] (4.11)
$
x←{0,1}A(1n )
Where the probability is taken over the choice of x and the random coin tosses
of A.
SPR is sometimes referred to as weak collision resistance, and indeed, al-
most trivially, every CRHF is also an SPR hash function. However, the reverse
is not true, and in particular, it is widely believed that (keyless) SPR hash
functions exist, while, as argued above, keyless CRHF cannot exist. In prac-
tice, collision attacks are known against some standard hash functions such as
SHA1 and MD5, but not second-preimage attacks. See the next exercise.
Exercise 4.3. Let h be an SPR hash function. Use h to construct another
hash function, h0 , which you will show to be (1) an SPR (like h), but (2) not
a CRHF.
Solution: See chapter 10.
We can use an SPR hash function for the ‘random mapping’ application,
discussed in subsection 4.1.1. In this application, the goal is to prevent the
attacker from selecting many inputs to collide with an incoming message or
name (e.g., with ‘Bob’). Of course, the attacker can try different values, and
for each guess, has probabilty 2−n of being a collision; but this attack fails if
we select sufficiently large digest size n. Hence, for this case, SPR is a sufficient
requirement.
There are other applications which require only the SPR property and not
the stronger collision-resistance property, e.g., see the following exercise. How-
ever, we usually prefer to use only keyless cryptographic hash functions for
whom no collisions have been found, i.e., where CRHF ‘seems’ to hold (recall
that we know that actually, no function can satisfy the CRHF goal). In par-
ticular, this protects against the common case, where a designer incorrectly
150
believes that an SPR hash suffices, while the system is actually vulnerable to
non-SPR collision attacks. Importantly, SPR is not sufficient for Hash-and-Sign
applications, as we discuss next.
Exercise 4.4. Identify an additional application, discussed earlier in this chap-
ter, for which an SPR hash function seem, intuitively, to suffice for security.
Explain this intuition (why the SPR property seems sufficient for security of
that application). Is there any simplification of reality required for this intuition
to hold?
(∀s) h(p +
+x+ + x0 +
+ s) = h(p + + s) (4.12)
151
x$ - a real bargain! Oh well, you already know what is really going to happen,
right?
Alice comes along and happily buys the item, by sending to Mal a signed
payment order to her bank, e.g.: (P O, SignA.s (h(P O))), where P O = Pay $x to Mal,
ready to be deposited at the bank. Mal indeed deposits a payment order signed
by Alice - but not P O, the payment order received... Instead, Mal deposits a
fake payment order P O0 for $ x0 , attaching the same signature that Alice sent
for P O. Specifically, Mal sends to the bank the pair (P O0 , SignA.s (h(P O))),
where P O0 = Pay $x0 to Mal. Now, due to chosen-prefix vulnerability, we
know that:
s ← ‘=’ +
+ x1 +
+ ‘then display’ +
+ t1 +
+ ‘, else display’ +
+ tM
152
Figure 4.10: One-Way Function, aka Preimage-Resistant hash function: given
(sufficiently long) random preimage x, it is hard to find x, or any other preimage
x0 of h(x), i.e., s.t.. h(x0 ) = h(x).
Mal is now ready to launch the attack on Alice, similarly to the simplified
attack above. Namely, Mal first sends D1 to Alice, who views it and sees the
rendering t1 . Let us assume that Alice agrees to pay 1$ to Amazon, and hence
signs D1 , i.e., computes σ = SA.s (h(D1 )) and sends (D1 , σ) it back to Mal.
Mal forwards to the bank the modified message (DM , σ). The bank vali-
dates the signature, which would be Ok since h(D1 ) = h(p + + x1 ++ s) = h(p +
+
xM ++s) = h(DM ). The bank then views DM , sees tM = ‘Pay one million dollars to Mal’,
and transfers one million dollars from Alice to Mal.
Pl
Exercise 4.5. Consider the hash function h(x1 + + x2 + + ... ++ xl ) = i=1 xi
mod p, where each xi is 64 bits and p is a 64-bit prime. (a) Is h an SPR
hash function? CRHF? (b) Present a collision-finding algorithm CF for h. (c)
Create two HTML files D1 , DM as above, i.e., s.t. h(D1 ) = h(DM ), yet when
they are viewed in a browser, they display texts t1 , tM as above.
Solution: See chapter 10.
εOW F
h,A (n) ≡ Pr [x0 ← A(h(x)) s.t. h(x) = h(x0 )] (4.13)
$
x←{0,1}n
Where the probability is taken over the the choice of x and over the random
coin tosses of A.
153
Note that the definition does not require one-way functions to be hash func-
tions, i.e., we do not require bounded output length, or even that the output
length be shorter than the input length. In fact, one particularly interesting
case is one-way permutation, which is a OWF which is also a permutation.
The correct way to use a OWF is by ensuring that the input domain is
random. We next present two related applications: one-time password and
one-time signature.
Show that if h is a OWF, then g is also a OWF; yet, show that f (x) = g(g(x)) is
not a OWF, and in particular, that a OTP-chain using g is completely insecure.
4 It is unfortunate that the acronym OTP is used for both One Time Pad and One
Time Password, but the use of this acronym for these two different purposes seems firmly
entrenched.
5 OTP-Chain is often referred to as hash-chain, but we prefer the term OTP-chain, to
avoid confusion with digest-chain and blockchain schemes, which have different goals, prop-
erties and designs; see § 4.7 and § 4.9.
154
Figure 4.11: A one-time signature scheme, limited to a single bit (as well as to
a single signature).
Figure 4.12: A one-time signature scheme, for l-bit string (denoted d).
155
Figure 4.13: A one-time signature scheme, for variable-length message m, using
‘hash-then-sign’.
will become digest of a longer message in the next extension.) This is simply
application of the one-bit signature scheme of Figure 4.11, over each bit di of
d, for i = 1, . . . , l. We use now multiple key pairs (sib , vbi ), where b ∈ {0, 1} is
the bit value (as before) and i is the index of the bit within d, and vbi = h(sib ).
Finally, we extend the scheme further, to efficiently sign arbitrary-length
inputs (VIL) string m. This extension, illustrated in Figure 4.13, simply applies
the hash-then-sign paradigm. Namely, we first use a CRHF, which we denote
by h0 (since it does not have to be the same as h), to compute the l-bit digest
d of the message: d = h0 (m). Then, we simply apply the scheme of Figure 4.12
to sign the digest d.
156
the input to have ‘sufficient randomness’ ? There are different possible formal
definitions for this intuitive requirement. Unfortunately, the definitions used
in the theoretical cryptography publications appear to be too complex for our
modest goals. Instead, we discuss two simple models for randomness extraction.
Exercise 4.8. [Von Neumann extractor] Show that, if the input satisfies the
assumption of the Von Neuman model, then the output is uniformly random,
i.e., each bit xi is 1 with probability exactly half - independently of all other
bits.
157
Figure 4.14: Bitwise-Randomness Extraction (simplified).
to the hash function, selected by the adversary - except for (at least) µ(n) of
the bits in x, which are ‘randomized’, i.e., replaced with random bits.
The string M is a bitmask; each of its bits corresponds to one bit of m.
When a bit in M is turned on (1), then the corresponding bit of P m would
be randomized. At least µ(n) bits in M contain 1, i.e., µ(n) ≤ i M [i]. If
M [i] = 1, i.e., the ith bit of M is turned on, then this bit of m is randomized.
Technically, we do this by selecting randomly a string m0 of the same length
as m, and then using m ⊕ (m0 ∧ M ) as the input to the hash function h.
Finally, we perform an ‘indistinguishability test’, much like the one used to
define (IND-CPA) encryption (Definition 2.10), or, even more, the (simpler)
definition of pseudorandom generator (PRG, Definition 2.6). Namely, we select
$
a random bit b, and let yb = h(m⊕(m0 ∧M )) and y1−b ← {0, 1}n ; the adversary
Adv ‘wins’ if it correctly guesses the value of b.
158
Algorithm 1 Bitwise-Randomness Extraction Indistinguishability experiment
IND-BREµA,h (b, n).
(m, M ) ← A(1n )
P|M |
If |m| =
6 |M | or i=1 M (i) < µ(n) return ⊥
$
m0 ← {0, 1}|m|
yb ← h(m ⊕ (m0 ∧ M ))
$
y1−b ← {0, 1}n
return A(y0 , y1 , m, M )
159
Can we define a property which implies such vulnerable designs, and then
prove that a candidate design is secure in the (limited) sense of being secure
for such ‘ideal’ hash function? Unfortunately, we don’t know how to define an
‘ideal-security’ hash function...
The Random Oracle Model (ROM)6 , proposed by Bellare and Rogaway [21],
is a common approach to this dilemma. Intuitively, Random Oracle Model
(ROM) constructions and protocols are secure in the (impractical) case that
the parties select h() as a truly random function (for the same domain and
range), instead of using a concrete, specific hash function as h(). The function
h() is still assumed to be public, i.e. known to the attacker. Namely, we model
an ‘ideal’ hash function as a random function (over the same domain and range,
i.e., {0, 1}∗ → {0, 1}n ).
Definition 4.10 (ROM-security). Let H be the set of all n-bit hash functions,
i.e., functions h : {0, 1}∗ → {0, 1}n (for some n). Consider a parameterized
scheme S h , where h is a given hash function h. Also, for any security definition
def , let εdef
S h ,Ah
→ [0, 1] be the def -advantage function, defined for a given
scheme S h and parameterized adversary Ah , where Ah is a PPT algorithm,
using standard computational model (e.g., Turing machine), with the additional
ability to provide an arbitrary input x to h and receive back h(x) (as a single
operation).
We say that the (parameterized) system Sh is def -ROM-secure, or def -
secure under the Random Oracle Model, if the advantage of any PPT adversary
$
Ah for scheme S h , for a random hash function h ← H, is negligible, i.e.:
Pr εdef
S h ,Ah
∈ N EGL(n) (4.15)
$
h←H
From the definition it follows that to ‘prove security under the ROM’, we
would analyze the construction/protocol as if the function h(·), used by the
protocol, was chosen randomly at the beginning of the execution and then
made available to all parties - legitimate parties running the protocols or using
the scheme/construction, as well as the adversary.
6 Often people use the term with ‘methodology’ or ‘method’ instead of ‘model’, but we
160
Security under the ROM vs. Security under the Standard Model.
Analysis of security under the ROM model is so widely used, that papers in
cryptography often use the term ‘secure in the standard model’ to emphasize
that their results are ‘really’ proven secure, rather than only proven under
the ROM (or under another idealized model). Of course, these proofs are still
based on reductions, i.e., on unproven assumptions; however, these assumptions
are ‘standard’ cryptographic assumptions. For many of these standard cryp-
tographic assumptions there are even theoretical results showing that there
exist schemes satisfying these assumptions under a ‘standard’ mathematical
assumption, most often, assuming P 6= N P .
We emphasize again, that ROM-security does not necessarily imply that
the design is ‘really’ secure, when implemented with any specific hash function;
once the hash function is fixed, there may very well be an adversary that breaks
the system. This is true even when the hash function meets the ‘standard’
security specifications, e.g., CRHF. However, ROM-security is definitely a good
indication of security, since a vulnerability has to use some property of the
specific hash function. Indeed, there are many designs which are only proven
to be ROM-secure. This motivates many works in cryptography, which provide
designs secure in the standard model, as alternatives to known designs which
are secure only under the ROM. The following subsection studies one of the
most widely used applications of hash functions - the construction of a Message
Authentication Code (MAC) scheme from a hash function; we show several
constructions which are secure under ROM but insecure under the standard
model.
About the terms: keyed hash vs. MAC. Constructions of MAC func-
tions from hash functions are often referred to as keyed hash, where they assume
that the hash function is ‘keyed’, in some way, using a secret key k. This dif-
fers from the ‘standard’ use of the term ‘keyed hash function’, which we adopt,
where the key k is not secret (i.e., we assume that k is known to the adver-
sary). Indeed, why use ‘keyed hash’ to mean exactly the same thing as MAC?
And surely we can’t only use ‘keyed hash’ to mean MAC, considering MAC
functions may be constructed in different ways, e.g., from a block cipher, e.g.,
the CBC-MAC (subsection 3.5.2)!
161
Security of constructions of MAC from hash. Let us return to the
‘real’ question: how to construct a MAC from a cryptographic hash? Many
heuristic proposals were made, mostly constructing the MAC from a keyless
hash function. Three of the most well known heuristics were presented and
compared by Tsudik [160]. Given keyless hash function h, key k and message
m, these are:
An obvious question is whether these schemes are secure - assuming that the
cryptographic hash function h satisfies some assumption. Let us first observe
that all three constructions are secure under the ROM.
Example 4.1. Show that M AC 2AK is insecure, (even) under the ROM.
solution: Adversary asks to receive M ACk2AK for the message m = 0l (for
+σR , where |σL | = |σR | = n.
any length l); let the value returned by denoted σL +
Then the adversary returns the ‘guess’ (1l , σR + + σL ). Verify that this is the
correct pair.
Unfortunately, it is easy to see that even if a hash function h satisfies any
of the properties we have defined in the previous sections, its use in all of these
constructions may still result in insecure MAC. This even holds for a hash
function h that satisfies all of these assumptions. See following exercise.
Exercise 4.12. Present a keyless hash function h such that:
162
1. h is a CRHF, yet (a) M AC P K , (b) M AC AK , (c) M AC M itM is not a
secure MAC.
2. h is a SPR, yet (a) M AC P K , (b) M AC AK , (c) M AC M itM is not a
secure MAC.
3. h is a OWF-hash, yet (a) M AC P K , (b) M AC AK , (c) M AC M itM is not
a secure MAC.
4. h is a BRE-hash, yet (a) M AC P K , (b) M AC AK , (c) M AC M itM is not
a secure MAC.
5. h is CRHF, OWF and BRE, yet (a) M AC P K , (b) M AC AK , (c) M AC M itM
is not a secure MAC.
The examples may assume a hash function h0 which has the corresponding
property (CRHF, SPR, OWF, BRE or their combination).
163
fact that such important standard has not be ‘broken’ by some cryptanalysis.
In fact, HMAC is also often used for additional goals, such as a candidate PRF,
and as a Key Derivation Function (KDF), which is essentially a keyed variant
of a randomness extraction hash function; see discussion in § 4.5, § 6.3 and [58].
164
Figure 4.16: The Merkle-Damgård Construction of a collision-resistance digest
function from a CRHF. The construction, with minor preprocessing of the
input, also be used to construct a CRHF from a compression function (which
is a CRHF restricted to fixed-length inputs), see details in the text.
sequences M 6= M 0 which have the same digest, i.e., ∆(M ) = ∆(M 0 ). Let us
define this a bit more precisely, although we still present the definition for fixes
digest length of n bits; recall that the more precise interpretation is that we
define a whole sequence of such functions ∆(n) for every integer n > 0, we just
omit the (n) for brevity and simplicity - and since in practice, we will use a
specific length anyway.
165
For l = 1: MDh .∆ ({m1 }) ≡ h(0n+1 + + m1 ) (4.18)
h
MD .∆(m1 , . . . , ml−1 )
MDh .∆ ({m1 , . . . , ml }) ≡ h (4.19)
++1 +
+ ml
and
and of course
Now, if the inputs to the hash are identical, than this means that MDh .∆(m01 , . . . , m0l0 −1 ) =
MDh .∆(m1 , . . . , mi ), contradicting the induction hypothesis. If the inputs to
the hash are different, then this is a collision. Hence, in both cases, Ah can
output a collision, as claimed.
It remains to consider the case where l0 = 1 (and we prove for l = i + 1
after we proved for l = i). Equation 4.20 still holds, but in this case we have
and
166
Figure 4.17: A compression function: fixed input length to fixed (and shorter)
output length. For simplicity, assume input length is 2n.
. Since the (n+1)th bit differs between these two inputs to h, but their outputs
are the same, it follows that also in this case, Ah outputs a collision and the
claim is complete.
Exercise 4.13. Show that collisions may be possible for a variant of the con-
struction where Equation 4.19 is replaced by:
MDh .∆ ({m1 , . . . , ml }) ≡ h(MDh .∆(m1 , . . . , ml−1 ) +
+0+
+ ml )
Note: this is not an easy exercise. Hint: Assume some CRHF h0 and use it
to design a very unlikely CRHF h for which such collision is possible. Reading
the proof carefully may help.
The Merkle-Damgård construction was proposed independently by Merkle
and Damgård, in [52, 129]; I personally find Damgård’s text easier to follow.
However, that in both works, and in most of the extensive work building on this
important construction, it is not presented at all as a construction of a digest
function from a hash function. Instead, it is presented as a construction of a
CRHF from a compression function, where a compression function7 is defined
just like a CRHF, except that its input domain is the set of binary strings of
some specific length m > n (where n is still used for the size of the output
string).
One motivation to build a cryptographic hash function from a compression
function, is the ‘cryptographic building blocks’ principle 8: The security of
cryptographic systems should only depend on the security of a few basic building
blocks. These blocks should be simple and with well-defined and easy-to-test
security properties.
Cryptographic hash functions are one of these few building blocks of applied
cryptography, due to their simplicity and wide range of applications. However,
compression functions are even simpler, since their input is restricted to fixed-
input length strings. Let us, therefore, explain how the construction can be
also be used for this application, i.e., constructing a CRHF from a compression
function
7 The term compression function may not be the best choice; it may have been clearer
167
We first consider the case of hashing binary strings of length n0 which splits
exactly into m−n bit ‘messages’, i.e., assume the input length n0 satisfies n0 = 0
mod (m − n). In this case, we don’t need the MD-strengthening preprocessing
step, and given a collision-resistant compression function h, can simply define
the following CRHF h0 :
0
m [1 : (m − n)], m0 [(m − n + 1) : 2 · (m − n)], . . .
0 0 h
h (m ) = MD .∆
. . . , m0 [|m0 | − (m − n) + 1 : |m0 |]
(4.21)
Where we use the notation m0 [i : j] for the sub-string of m0 , from the ith bit
to the j th bit.
It is easy to see, from Lemma 4.2, that if h is a collision-resistant compres-
sion function, then h0 would be collision-resistant.
0
+0(m−n)−[n
hM D (m0 ) = h0 (m0 + mod (m−n)]
+binm−n ((m − n) − [n0
+ mod (m − n)])
(4.22)
Where binl (x) is defined above and h0 is defined in Equation 4.21.
so that’s fine, but why ‘strengthening’ ? It seems that this term is used in relation to naive
and vulnerable methods of padding the input to the Merkle-Damgård construction. But I
am not sure.
168
Initialization Vector (IV). The string of 0n bits that we append to the first
message m1 in Equation 4.18, is often referred to as an Initialization Vector
(IV), similarly to the use of these term in some descriptions of the ‘modes of
operation’ of block cipher (§ 2.9). The choice of 0n is completely arbitrary; and
n-bit string could have been used, as long as it is a fixed string - if we allow the
IV to be chosen freely each time, then collisions are possible (see next exercise).
Note that it is possible to use a random IV as a way to key the hash function
- but, again, only if this IV is used for all messages.
Exercise 4.14. Assume that |m1 | = n, and consider a variant on the MD
construction where we change Equation 4.18 so that for l = 1, we have:
MDh .∆ ({m1 }) ≡ m1 . This variant ‘saves’ a hash operation; however, show
that it may allow collisions.
169
Extend is the extend function, whose inputs are a digest ∆l and a sequence
of ‘additional’ messages Ml+1,l0 , and whose output is a ‘new’ digest ∆l0 .
A digest-chain scheme is correct if for any given ∆l = ∆(Ml ) and sequence
of additional messages Ml+1,l0 , Equation 4.23 holds.
A digest-chain scheme is secure if it is correct and its digest function is
collision-resistant (see Definition 4.11).
In spite of this simple definition and requirements, there are three different
ways to use the Extend function, for different applications and scenarios:
Extend current digest: this is direct use of ∆ to extend the sequence of mes-
sages, Ml = {m1 , . . . , ml }, with additional messages Ml+1,l0 {ml+1 , . . . , ml0 .
The digest function will receive as input the current digest ∆l = ∆(Ml ),
and the sequence of additional messages Ml+1,l0 , and produce the new
digest ∆l0 . The basic correctness property is that this would be the digest
of the entire sequence, i.e., that ∆l0 = ∆(Ml + + Ml+1,l0 ).
Validate digest consistency: in this use-case, the current digest ∆l and the
new digest ∆l0 are computed by one entity, e.g., a bank, and received by
a different entity, Val, e.g., a customer. Val may want to validate that
∆l0 is consistent with ∆l , and with a given set of new messages, e.g.,
transactions, Ml+1,l0 {ml+1 , . . . , ml0 . Namely, Val needs to know that
∆l0 = ∆(Ml + + Ml+1,l0 , for some set of messages Ml , committed-to by
the old digest ∆l , i.e., ∆l = ∆(Ml ). Notice that in some applications,
Val may not even be interested in the specific additional transactions
in the set Ml+1,l0 , but they must be used for validation when using a
digest-chain scheme; this will be avoided in the Merkle-digest scheme
and Blockchain scheme, presented in the following sections.
Validate Inclusion: in this use-case, Val is an entity who has a digest ∆l0 ,
and receives a particular message ml+1 . Val wants to validate that ml+1
appeared in the sequence whose digest is the known ∆l0 , possibly also
with its sequence number. To this end, Val must be provided with the
∆l = ∆(Ml ) and with the entire sequence of additional messages Ml+1,l0 ,
and use these to reproduce ∆l0 .
170
Lemma 4.4. If h is a CRHF, then (MDh .∆, MDh .Extend) is a secure digest-
chain scheme.
171
usually based on a CRHF and on the graph-theory concept of a tree9 , and are
widely used in cryptography. We present below two of the simpler, classical
constructions, and mention few of their many applications.
However, while different constructions were proposed, they are usually all
referred to as Merkle tree or some variant of that name; the term is also used to
refer to this type of cryptographic scheme (rather than a specific construction).
However, the author believes that it is important to distinguish between an
abstract scheme (e.g., block cipher) and constructions of it (e.g., AES and
DES).
We think it is better to use different terms for the abstract scheme and for
each specific construction. Specifically, we use the term Merkle digest to refer
to the abstract scheme. We use the terms Merkle tree (MT ) and two-layered
hash tree construction (2lMT ) to refer to two specific constructions we present.
The MT construction is a minor variant of the one by Merkle (in [128]), and
the 2lMT construction is a simpler, ‘folklore’ construction. We also discuss
the extensible Merk digest scheme, which adds additional functionality to the
Merkle digest scheme, and constructions for it.
Note, also, that our definition of a Merkle digest scheme is not a widely-
adopted definition; the author is not aware of any existing widely-deployed
definition for such schemes, and believes that this definition is a bit simpler
than some of the few definitions that the author did find. Comments on these
points (and other aspects of this manuscript) would be highly appreciated.
this fascinating use useful topic, e.g. see [71, 172]. However, this is not be really critical for
understanding the constructions.
10 Sometimes each message is restricted in length, e.g., , m ∈ {0, 1}n .
i
172
produces a proof P oI(M, i) for the contents of the ith message in the set M
(i.e., mi ), and V erP oI(d, m, i, p) uses proof p to verify that m is the ith mes-
sage in some set M , whose digest is d (i.e., (∃M s.t. m = M [i])d = ∆(M )).
Merkle digest constructions are optimized not only for computation time, but
also to have succinct proofs, e.g., only n log |M | bits.
M.∆ is the Merkle tree digest function, whose input is a sequence of mes-
sages M = {mi ∈ {0, 1}∗ }i and whose output is an n-bit digest: M.∆ :
∗
({0, 1}∗ ) → {0, 1}n .
M.P oI is the Proof-of-Inclusion function, whose input is a sequence of mes-
sages M = {mi ∈ {0, 1}∗ }i , an integer i ∈ [1, |M |] (the index of one mes-
sage in M ), and whose output is a Proof-of-Inclusion (P oI): M.P oI :
∗
({0, 1}∗ ) × N → {0, 1}∗ .
M.V erP oI is the Verify-Proof-of-Inclusion predicate, whose inputs are digest
d ∈ {0, 1}n , message m ∈ {0, 1}∗ , index i ∈ N, proof p ∈ {0, 1}∗ , and
whose output is a bit (1 for ‘true’ or 0 for ‘false’): M.V erP oI : {0, 1}n ×
{0, 1}∗ × N × {0, 1}∗ → {0, 1}.
173
extended sequence - like the Extend function of the digest-chain scheme (sub-
section 4.7.2). For example, this may be desirable in order to allow a recipient
to validate new entries and the corresponding new digest, even if the recipient
did not maintain all the entries which were included in the sequence so far,
e.g., for maintaining a log or ledger of transactions.
The Merkle digest scheme, as defined in Definition 4.13, allows verification
of the integrity of the sequence (e.g., log) using just the digest, and verification
of a particular entry, using the P oI mechanism. However, to allow the sequence
of events to be extended over time, we need an additional mechanism: Proof
of Consistency (P oC). A P oC allows to verify that a given new digest dN ,
is consistent with the known, ‘current’ digest dC ; namely, if dC is the digest
of some sequence MC = {m1 , . . . , mlC } with lC entries, then dN is the digest
of a sequence MN with lN > lC entries which is an extension of MC , i.e.,
MN = {m1 , . . . , mlC , . . . , mlN .
We will use M to refer to the entire scheme, including also these two additional
functions.
We say that the M has correct P oC if for every two sequences of mes-
sages M = {mi ∈ {0, 1}∗ }i , M 0 = {m0i ∈ {0, 1}∗ }i , their Proof-of-Consistency
verifies correctly, i.e.:
+ M0 ), M.P oC(M, M0 ))
M.V erP oC (M.∆(M ), M.∆(M + (4.26)
We say that M has secure P oC, if for every efficient (PPT) algorithm A,
the P oC-advantage εP oC
M,A (n) is negligible in n, where:
εP oC
M,A (n) ≡ Pr
M.V erP oC(d, d0 , x) ∧
(6 ∃M, M 0 ∈ {0, 1}∗ )(x = M.P oC(M, M 0 ))
Merkle Digest PoC vs. Blockchain PoC Merkle Digest and digest-chains
are both used in many Blockchain systems. Blockchains systems allow parties
174
to agree on a sequence of blocks of events (entries). Blockchains, like Merkle di-
gests, provide P oC and V erP oC mechanisms to ensure consistency. However,
this does not necessarily mean that they use the Proof-of-Consistency of the
Merkle scheme; often, blockchains use only the PoC of the digest chain (using
the Extend function). We discuss the blockchain scheme and constructions in
§ 4.9.
175
Figure 4.18: The keyless Two-layered Merkle Tree (2lMT ) construction, ap-
plied to input set of four-messages M ≡ {m1 , m2 , m3 , m4 }. Let xi = h(mi )
denote the hash of a single message mi (for i ∈ {1, 2, 3, 4}). The digest
of the set M is the hash of the concatenation of the hashes of each mes-
sage, i.e., y = h [h(m1 ) +
+ h(m2 ) +
+ h(m3 ) +
+ h(m4 )]. We denote the digest
by 2lMT .∆(M ) = y.
Figure 4.19: The keyed Two-layered Mekle Tree (2lMT ) construction, ap-
plied to input set of four-messages M ≡ {m1 , m2 , m3 , m4 }. Let xi = hk (mi )
denote the hash of a single message mi (for i ∈ {1, 2, 3, 4}). The digest of
the set M is the hash of the concatenation of the hashes of each message,
i.e., y = hk [hk (m1 ) +
+ hk (m2 ) +
+ hk (m3 ) +
+ hk (m4 )]. We denote the digest by
2lMT .∆k (M ) = y.
176
sume now that some Proof-of-Inclusion verifies correctly, i.e., 2lMT .V erP oI(d, m, i, {xi }li=1 ) =
1, but d is not the digest of some sequence M of messages whose ith message
is m (i.e., M [i] = m). Show, from the construction, that this also implies a
collision for h.
The obvious disadvantage of the 2lMT construction is that the Proof-of-
Inclusions are of length l ·n bits, which is inefficient; this is the main motivation
for the use of the MT construction, which we show in the next subsection.
We next show the P oC for the 2lMT construction. Again, it is very simple
- which is our main motivation for showing it - but definitely inefficient, with
long Proof-of-Consistency.
Definition 4.16 (Proof-of-Consistency for the Two-layered Merkle Tree). Given
a keyless function h : {0, 1}∗ → {0, 1}n , We define the 2lMT .P oC and
2lMT .V erP oC functions as:
0
2lMT .P oC((m1 , . . . , ml ), (m01 , . . . , m0l0 )) ≡ {h(mi )}li=1 , {h(m0i )}li=1
0
2lMT .V erP oC d, d0 , {xi }li=1 , {x0i }li=1 ≡ d = h(x1 + + xl ) ∧ d0 = h(x01 +
+ ... + + x0l0 )
+ ... +
177
m1 m2 m3 m4
h1 h2 h3 h4
h1−2 h3−4
h1−4 = h(h1−2 +
+ h3−4 )
Figure 4.20: The Merkle Tree (MT ) construction, applied to input set of four
messages M ≡ {m1 , m2 , m3 , m4 }. Let hi = h(mi ) denote the hash of a single
message mi , and hi−j denote the MT digest for messages mi , . . . , mj ; the
complete digest is MT .∆(M ) = h1−4 = h(h1−2 + + h3−4 ). The figure does
not indicate the use of the key, as for keyless MT ; however the only change
required for keyed version would be that all hashing is done using a common,
random key, known to the attacker.
bits - or, that the input is one long string broken down to chunks of n bits.
In any case, let us focus on our variant; in the special case where inputs are
strings of n bits each, one can simply eliminate one layer of hashing (i.e., use
Merkle’s original construction). For simplicity, assume that the number l of
inputs is a power of two, say l = 2L . It is easy to extend the construction to
support any l, e.g., by padding.
This construction has L + 1 ‘layers’, which we number from i = 0 to i = L.
The first layer, i = 0, is unique: it applies the hash function to each of the 2L
inputs. The output are 2L strings of n bits each. The next layer hashes each
consecutive pair of output of the previous layer, i.e., 2n-bits, resulting in 2L−1
sting of n bits each. The process then repeats, with each layer i (from i = 1
to i = L) receiving 2L−(i−1) strings from previous layer (i − 1), and outputting
2L−i digests (n bits each). This continues, each time halving the total number
of bits, until we remain with only the final n-bits digest.
The definition for the keyless MT construction follows; we leave the defi-
nition of the keyed versions, using ACR and using TCR hash, to the reader.
The definition is a bit ‘hairy’; most readers may prefer to only understand the
construction from Figure 4.20 and Figure 4.21.
178
m1 m2 m3 m4
h1 h2 h3 h4
h1−2 h3−4
h1−4 = h(h1−2 +
+ h3−4 )
If L = 0 : h(m1 )
MT .∆(M ) ≡ Else h (MT .∆ (m1 , . . . , m2L−1 ) + +
+
+MT .∆ (m2L−1 +1 , . . . , m2L ))
If L = 0 : (empty string)
L−1
If j > 2 : MT .∆ (m1 , . . . , m2L−1 ) +
+
MT .P oI(M, j)1≤j≤l ≡ +MT .P oI (m2L−1 +1 , . . . , m2L ) , j − 2L−1
+
Else : MT .∆ (m2L−1 +1 , . . . , m2L ) +
+
+MT .P oI [(m1 , . . . , m2L−1 ) , j]
+
Figure 4.22: The Merkle Tree (MT ) construction for l = 2L input messages:
M = {m1 , . . . , m2L }.
Theorem 4.4. The (keyless) Merkle Tree (MT ) construction (Fig. 4.22) is
a correct and secure MT scheme.
179
MT extensions: arbitrary l and P oC. We simplified the MT construc-
tion by assuming that the number of messages in the input, l, is a power of two
(l = 2L ). Under this assumption, it is also easy to define P oC and V erP oC
functions; we leave this as an exercise.
It is a bit more challenging to extend the MT construction for arbitrary
number of messages l (not a power of two), and to define the appropriate P oC,
V erP oC functions, and we will not do it here. It is not very difficult, so readers
are encouraged to work out the details, and/or see published constructions, e.g.,
in [48, 61, 115].
180
Figure 4.23: A basic blockchain: sequence of digests ∆1 , ∆2 , . . . of a sequence
of blocks B1 = {m11 , m21 , . . .}, B2 = {m12 , . . .}, . . .
181
Blockchain digest schemes, like Merkle digest schemes, support two addi-
tional validation mechanisms: Proof-of-Inclusion (PoI) and Proof-of-Consistency
(PoC).
182
Figure 4.24: Permissioned Blockchain: blocks added only with permission -
signature which is validated with known authority key vAuthority . If there are
multiple authorities, use consensus to avoid conflicts.
183
plication of PoW that we will explore in this volume, there are many more
applications of PoW in Cybersecurity, and we will discuss some of them in the
next volume [93], mainly with respect to Denial-of-Service attacks.
Intuitively, a PoW allows one party, the worker, to solve a challenge, with an
approximately known amount of computational resources, resulting in a proof
of this success, which can be efficiently verified by anyone.
Proofs-of-Work schemes belong in this chapter of hash functions, both due
to their use in permissionless blockchains and in particular Bitcoin, but also
since their most well known implementation - and the one used in Bitcoin - is
based on a hash function.
Notice that we used the general term ‘computational resources’ and not a
more specific term such as computation-time; the reason is that some PoW pro-
posals focus on other resources, e.g., storage, or on a combination of resources,
e.g., time and storage. However, from this point, let us focus on the case where
provision of the PoW requires an approximately known amount of computation
time. This is the most widely used form of PoW - and in particular, the one
used in Bitcoin, which, as we mentioned (and will show), is based on the use
of a cryptographic hash function.
Like our definitions of hash functions and of the schemes in this chapter,
PoW schemes may be keyed or keyless ; and like for the other schemes, we
focus on the keyless variant.
We define a PoW scheme with respect to a specific computational model
M and ‘challenge domain’ CD . As mentioned above, our definition is limited
to keyless PoW based on computational time.
Definition 4.18 (Proof of Work (PoW)). A PoW scheme PoW consists of
two efficient algorithms: [Link], and [Link].
184
$
r ← {0, 1}n , is less than α · w, holds: εP oW
A,PoW (n) ∈ N EGL(n), where:
εP oW
A,PoW (n) ≡ Pr {(∃c ∈ CD )PoW.V alidate(c, r, w, A(c, r, w)) = true}
$
r ←{0,1}n
(4.28)
185
BitCoin mining uses the PoW B Proof-of-Work design, presented in subsec-
tion 4.9.3. As shown in Figure 4.25, if the previous (current) digest is ∆i−1 ,
then to add a block, the new digest ∆i must be signed by private key si ,
where the corresponding public key is included in a PoW solved by the entity
adding the new block. The PoW is computed over both the public key vi , and
the previous digest ∆i−1 . The inclusion of the previous digest, ensures that
the ‘competition’ for solving the PoW (and mining) may begin only once the
previous digest is known.
Of course, solving PoW requires considerable computational resources - in
fact, the wasting of these resources - including energy - is one of the criticisms
against Bitcoin (and in favor of permissioned blockchains). To motivate entities
to invest this effort and solve the PoW, Bitcoin offers an incentive: whenever a
key vi is included in the PoW, this key is ‘awarded’ a Bitcoin. This is also the
(only) process of adding new Bitcoins, which is the reason that this process is
referred to as mining, obviously with gold-mines more than, say, coal-mines in
mind. Another motivation is a transaction fee that may be charged from each
transaction in the block, and also given to the ‘block issuing public key’ vi .
The work-amount parameter w of the PoW (not shown in Figure 4.25), is
adjusted automatically by a clever feedback mechanism in Bitcoin, that ensures
that new blocks will be added at a reasonable, but not excessive, rate. The
idea is that as issuing of blocks becomes more valuable, the work-amount is
automatically increased, which reduces the economical incentive for mining,
and hence is expected to slow down mining.
186
2. Second-preimage resistance.
3. One-wayness (preimage resistance)
4. Randomness extraction.
5. Secure MAC, when h is used in the HMAC construction.
1. Collision-resistance.
2. Second-preimage resistance.
3. One-wayness (preimage resistance)
4. Randomness extraction.
Would any of your answers change, if h and h0 have a random public key as
an additional input?
187
Exercise 4.20. It is proposed to combine two hash functions by cascade, i.e.,
given hash functions h1 , h2 we define h12 (m) = h1 (h2 (m)) and h21 (m) =
h2 (h1 (m). Suppose collision are known for h1 ; what does this imply for colli-
sions in h12 and h21 ?
Exercise 4.22. Let h be the result of a Merkle hash tree, using a compression
function comp : {0, 1}2n → {0, 1}n , and let (KG, S, V ) be a secure (FIL)
signature scheme. Let Ssh (m) = Ss (h(m)) follow the ‘hash then sign’ paradigm,
to turn (KG, S, V ) into a VIL signature scheme, i.e., allow signatures over
messages of arbitrary number of blocks. Show that Ssh is not a secure signature
scheme, by presenting an efficient adversary (program) that outputs a forged
signature.
Exercise 4.23. Consider the following slight simplification of the popular
HMAC construction: h0k (m) = h(k + + h(k ++ m)), where h : {0, 1}∗ → {0, 1}n is
a hash function, k is a random, public n-bit key, and m ∈ {0, 1}∗ is a message.
1. Assume h is a CRHF. Is h0k also a CRHF?
Yes. Suppose h0k is not a CRHF, i.e., there is some adversary A0 that
finds a collision (m01 , m02 ) for h0 , i.e., h0k (m01 ) = h0k (m02 ). Then at least
one of the following pairs of messages (m1,1 , m2,1 ), (m1,2 , m2,2 ) is a colli-
sion for h, i.e., either h(m1,1 ) = h(m2,1 ) or h(m1,2 ) = h(m2,2 ) (or both).
The strings are: m1,1 = , m1,2 = ,
m2,1 = , m2,2 = .
No. Let ĥ be some CRHF, and define h(m) = .
Note that h is also a CRHF (you do not have to prove this, just to design h
so this would be true and easy to see). Yet, h0k is not a CRHF. Specifically,
the following two messages m01 = , m02 =
0 0 0
are a collision for hk , i.e., hk (m1 ) = hk (m2 ).
188
2. Assume h is an SPR hash function. Is h0k also SPR?
Yes. Suppose h0k is not SPR, i.e., for some l, there is some algorithm
A0 which, given a (random, sufficiently-long) message m0 , outputs a col-
lision, i.e., m01 6= m0 s.t. h0k (m0 ) = h0k (m01 ). Then we define algorithm A
which, given a (random, sufficiently long) message m, outputs a collision,
i.e., m1 6= m s.t. hk (m) = hk (m1 ). The algorithm A is:
Algorithm A(m):
{
Let m0 =
Let m01 = A0 (m0 )
Output
}
No. Let ĥ be some SPR, and define h(m) = . Note
that h is also an SPR (you do not have to prove this, just to design h so
this would be true and easy to see). Yet, h0k is not an SPR. Specifically,
given a random message m0 , then m01 = is a collision,
i.e., m0 6= m01 yet h0k (m01 ) = h0k (m02 ).
3. Assume h is a OWF. Is h0k also a OWF?
Yes. Suppose h0k is not OWF, i.e., for some l, there is some algorithm
A0 which, given h0k (m0 ) for a (random, sufficiently-long) message m0 ,
outputs a preimage, i.e., m01 6= m0 s.t. h0k (m0 ) = h0k (m01 ). Then we define
algorithm A which, given h(m) for a (random, sufficiently long) message
m, outputs a preimage, i.e., m1 s.t. hk (m) = hk (m1 ). The algorithm A
is:
Algorithm A(m):
{
Let m0 =
Let m01 = A0 (m0 )
Output
}
No. Let ĥ be some SPR, and define h(m) = . Note
that h is also an SPR (you do not have to prove this, just to design h so
this would be true and easy to see). Yet, h0k is not an SPR. Specifically,
given a random message m0 , then m01 = is a collision,
i.e., m0 6= m01 yet h0k (m01 ) = h0k (m02 ).
4. Repeat similarly for bitwise randomness extraction.
Exercise 4.24. Consider the following construction: h0k (m) = h(k + + m),
where h : {0, 1}∗ → {0, 1}n is a hash function, k is a secret n-bit key, and
m ∈ {0, 1}∗ is a message. Assume you are given some SPR hash function
ĥ : {0, 1}∗ → {0, 1}n̂ ; you can use n̂ which is smaller than n. Using ĥ, construct
hash function h, so that (1) it is ‘obvious’ that h is also SPR (no need to prove),
yet (2) h0k (m) = h(k + + m) is (trivially) not a secure MAC. Hint: design h s.t.
it becomes trivial to find k from h0k (m) (for any m).
189
1. h(x) = .
2. (Justification) h is an SPR since .
3. (Justification) h0k (m) = h(k+
+m) is not a secure MAC since .
Exercise 4.25 (HMAC is secure under ROM). Show that the HMAC con-
struction is secure under the Random Oracle Model (ROM), when used as a
PRF, MAC and KDF.
190
Chapter 5
Shared-Key Protocols
5.1 Introduction
In the previous two chapters, we discussed cryptographic schemes, which con-
sist of one or more functions, with security criteria. For example, MAC, PRF
and PRG schemes consist of a single function, with criteria such as security
against forgery (Def. 3.1). Similarly, encryption schemes consist of multiple
functions (encryption, decryption and possible key generation), with criteria
such as CPA-indistinguishability (CPA-IND, Def. ??).
Cryptographic schemes are very useful, but rarely as a single, stand-alone
function. Usually, cryptographic schemes are used as a part of different proto-
cols, which involve multiple exchanges of messages among a set P of parties,
often only two, e.g., P = {Alice, Bob}. There are many types of protocols,
including many related to cryptography, and, more generally, security.
191
Note 5.1: Alternatives to global, synchronous time
192
5.1.2 Focus: two-party shared-key handshake and session
protocols
In this chapter we discuss shared-key protocols, i.e., protocols between two
parties, P = {Alice, Bob}. Both parties are initialized with a shared symmetric
key κ. In the following chapters, we discuss protocols using public keys, in
addition to protocols using shared keys.
A session begins by executing a handshake protocol, which involves authen-
tication of one or both parties. The handshake protocol often also allows the
parties to agree on a shared session key. Handshake protocols are the main
topic of this chapter. A successful handshake is usually followed by exchange of
one or more messages between the parties, using a session protocol. We discuss
session protocols in subsection 5.1.4.
Handshake and session protocols are usually quite simple and easy to un-
derstand - but this simplicity can be deceptive, and many attacks have been
found on proposed, and even widely deployed, protocols. Most attacks are sur-
prisingly simple in hindsight. Furthermore, most attacks - esp. on handshake
protocols - do not involve exploiting vulnerabilities of the underlying crypto-
graphic schemes such as encryption and MAC. Instead, these attacks exploit
the fact that designers did not use the schemes correctly, e.g., used schemes
for goals they are not designed for - e.g., assuming that encryption provides
authentication. There have been many attacks on such insecure, vulnerable
handshake protocols, in spite of their use of secure cryptographic primitives.
Therefore, it is critical to clearly define the adversary model and conservative
security goals, and to have proof of security under reasonable assumptions - or,
at least, careful analysis.
Monster in the Middle. This allows us to use the pronoun ‘It’ to refer to the attacker, in
contrast to Alice and Bob.
193
input to the protocol (e.g., OP EN signals), and provide the adversary with
all the outputs of the protocol. For example, see Definition 5.2, which defines
mutual-authentication for handshake protocols.
In contrast, to define confidentiality properties, we slightly restrict the ad-
versary’s access to output events, and control over input events. For example,
we define IND-CPA security for session protocols by allowing the attacker to
choose arbitrary ‘plaintext’ messages m, as well as to select a pair of special
‘challenge’ messages m0 , m1 . We then select a random bit b ∈ {0, 1}. The
attacker then observes the encoding of the chosen messages m as well as of
the ‘challenge’ message mb . Finally, the attacker guesses the value of b. This
essentially extends the IND-CPA security definition for encryption schemes
(Definition ??).
Finally, in protocols involving multiple parties, we may also let the adver-
sary control some of the parties running the protocols; this is less relevant to
two-party protocols which are our focus in this chapter. We will, however,
discuss scenarios where the attacker may have access to some of the storage,
including keys, used by some of the parties.
194
(CPA-IND, Def. ??) test. The main difference is that we allow a stateful
protocol instead of stateless scheme.
Message authentication: universal forgery capabilities. To test a pro-
tocol for ensuring message authentication, we would allow the adversary
to ask parties to send arbitrary messages. The MitM attacker should not
be able to cause receipt of a message that it never asked a party to send
- similarly to the security against forgery (Def. 3.1) test.
Session mapping. There is a one-to-one mapping from every session where
one party sent or received a message, to a session at the corresponding
other party, s.t. the messages received in each of the two sessions session,
are identical, in content and order, to the corresponding messages sent
in the corresponding session.
Detecting truncation. If a session at Alice is mapped to a session at Bob,
but Bob sent some messages that Alice did not receive, then the session
at Alice did not yet terminate - or, terminated with failure indication.
The obvious and common way to ensure secure order is by authenticat-
ing a sequence number Seq, or some other mechanism to prevent re-ordering,
typically, as part of the authentication of the message. Often, the underlying
communication channel preserves order of messages, and hence the sender and
recipient can maintain Seq and it is not necessary to include Seq explicitly
in the messages; for example, this is done in SSL/TLS. In other cases, the
sequence number is sent in the clear, i.e., authenticated but not encrypted;
this allows ordering and identification of losses - even by intermediate agents
who cannot decrypt. Other fields that are often sent authenticated but ‘in the
clear’, i.e., not encrypted, include the sender and recipient addresses; usually,
these fields are grouped together, and referred to as the header.
Note that ensuring secure order, by authentication of messages and sequence
numbers, does not suffice to prevent truncation, i.e., loss of the very last mes-
sages from from one party to the other. To prevent truncation, the session
protocol usually terminates with a special ‘termination exchange’, allowing a
party to detect when an attacker dropped some message from its peer.
In addition to the security goals, session-transmission protocols have the
following reliability and efficiency goals:
Error detection and/or correction, typically using Error Detection Code
(EDC) such as Checksum, or Error Correction Code (ECC), such as
Reed–Solomon codes. These mechanisms are designed against random
errors, and are not secure against intentional, ‘malicious’ modifications.
Note that secure message authentication, such as using MAC, also ensures
error detection; however, as we explain below, it is often desirable to also
use the (insecure) error detection codes.
Compression, to improve efficiency by reducing message length, usually pro-
vided by applying a compression code. As we explain below, this require-
ment may conflict with the confidentiality requirement.
195
Message
Compress
Plaintext
Encrypt
MAC
Header Ciphertext tag
Code
Header Ciphertext tag ECC
Figure 5.1: Secure Session Sending Process: Security, Reliability and Compres-
sion.
Fig. 5.1 presents the recommended process for combining these functions,
justified as follows:
• Compression is only effective when applied to data with significant redun-
dancy; plaintext is often redundant, in which case, applying compression
to it could be effective. In contrast, ciphertext would normally not have
redundancy. Hence, if compression is used, it must be applied before en-
cryption. Note, however, that this may conflict with the confidentiality
requirement, as we explain below; for better confidentiality, avoid com-
pression.
• Encryption is applied next, before authentication (MAC), following the
‘Encrypt-then-Authenticate’ construction. Alternatively, we may use an
196
authenticated-encryption with associated data (AEAD) scheme, to com-
bine the encryption and authentication functions. Notice that by ap-
plying authentication after encryption or using an AEAD scheme, we
facilitate also authentication of a sequence-number or similar field used
to prevent re-play/re-order/omission, which is often known to recipient
(and not sent explicitly); we can also authenticate ‘header’ fields such as
destination address, which are not encrypted since they are used to pro-
cess (e.g., route) the encrypted message; see Fig. 5.1. The Encrypt-then-
Authenticate mode also allows prevention of chosen-ciphertext attacks
and more efficient handling of corrupted messages.
• Finally, we apply error correction / detection code. This allows efficient
handling of messages corrupted due to noise or other benign reasons.
An important side-benefit is that authentication failures of messages to
which errors were not detected imply an intentional forgery attack - an
attacker made sure that the error-detecting code will be correct.
197
Table 5.1: Signals of shared-key entity-authenticating handshake protocols, for
session σ. The first three signals are common to most protocols; the rest are
specific to handshake protocols.
which provide client-authentication and keying for confidentiality for the GSM
mobile network. We discuss two serious vulnerabilities of the GSM handshake:
replay attacks, facilitated by client-only authentication, and downgrade attacks,
facilitated by insecure ciphersuite negotiation.
In § 5.6, we discuss variants designed to provide (limited) resiliency to
exposures of secret information (keys).
198
If the messages are exchanged correctly, the responder pR will also output a
BIN D(pI , σ) signal, indicating the successful initiation of a handshake session
by initiator pI , where σ is the same session identifier as in the corresponding
BIN D(pR , σ) output signal previously output by the initiator pI to refer to
this session.
The session identifier σ is used in following input and output signals to refer
to this particular session, similarly to a socket/file handles in used in the socket
API. For simplicity, assume that session identifiers are unique, i.e., the protocol
never opens two sessions with the same identifier σ, not even consecutively.
Following the BIN D signal, the protocol at both parties continues to ex-
change messages, using OU T signals, to perform the authentication. When the
entity authentication is successful at a party ρ ∈ I, R, then the protocol invokes
the U Pρ (σ) output signal, indicating that the session is active. Messages are
sent, usually using a session protocol, only while the session is active.
The protocol outputs signal DOW Nρ (σ, ξ) to indicate termination of ses-
sion σ at party ρ ∈ I, R. The ξ ∈ {OK, F ail} signals successful (OK) or
unsuccessful (Fail) termination. Successful termination is always the result of
a previous CLOSE(σ) input signal, requesting the protocol to terminate ses-
sion σ; unsuccessful (Fail) termination is due to failure, and does not require a
previous CLOSE input signal.
The rest of this section deals with secure and vulnerable designs of mutual-
authentication handshake protocols. Achieving a secure design is not very
difficult, however, it has to be done carefully, since it is also easy to come up
with a vulnerable design.
199
Note 5.2: More rigorous treatment and sessions without explicit identifiers
200
Figure 5.2: SNA two-party mutual authentication handshake protocol
201
Finally, Bob similarly validates that it received the expected function Ek (NB )
of its randomly selected nonce NB , and concludes that this handshake was ini-
tiated by Alice.
Both parties, Alice and Bob, signal successful completion of the handshake,
using U P (σ), (only) upon receiving the expected response (Ek (NA ) for Alice
and Ek (NB ) for Bob).
Readers are encouraged to transform the description above and in Fig. 5.2
to pseudocode.
202
Figure 5.3: Example of SNA handshake failing to ensure concurrent initiator
authentication. Eve pretends to be Alice, who is not present at all during the
communication. To do this, Eve uses two connections.
203
Figure 5.4: 2PP: Three-Flows Authenticating Handshake Protocol.
204
Note 5.3: Proof that 2PP ensures mutual authentication
Lemma 5.1 (2PP ensures mutual authentication). The 2PP protocol, as in Fig-
ure 5.4, is mutually authenticating.
we study a minor extension, where the handshake protocol does not only au-
thenticate the entities, but also the session, including the messages exchanged
between the parties.
205
transmission of multiple messages.
A handshake protocol ensures session authentication if it ensures mutual
entity-authentication Definition 5.2, and furthermore, a message is received at
one party, say Bob, at session σ, only if it was sent by the peer party, say
Alice, in the same session σ, and after the session σ was OP EN ed at Bob.
Furthermore, if a session σ terminates successfully at one party, e.g., with
DOW NI (σ, OK), after a message was sent, i.e., SEN D(σ, m) input signal,
then that message was previously successfully received by the peer in this
session σ, i.e., RECEIV E(σ, m) output signal occurred earlier.
Note that this definition builds on the mapping that exists between sessions
at both ends, as required from mutual entity-authenticating protocol (Def. 5.2).
The session authentication property implies message authentication, i.e.,
messages received by one party were indeed sent by the other party. It also im-
plies freshness, which means that messages are received in FIFO order, without
any reordering or duplications; however, omissions may be permitted. Fresh-
ness also implies that when a message is received, say by Bob, in some ses-
sion, that message was sent by Alice during the same session, after the session
OPENed in Bob.
206
Figure 5.5: Three-flows session-authenticating 2PP handshake
action, where the initiator contacts the responder and sends to it some request,
and the responder sends back a response to the request.
In the next two subsections, we present two variants of the message-authenticating
handshake that support sending a request by the initiator and receiving a
response from the responder; we refer to such protocols as request-response
authenticating. Note that each of these two variants also has a drawback, com-
pared to the three-flows session-authenticating 2PP: either a fourth flow, or
relying on synchronized time and/or state.
207
Figure 5.6: Four-flows, request-response authenticating handshake protocol
208
replaying information from previous exchanges. For example, consider the
request-response authentication of Figure 5.6; if NB is removed (or fixed), then
an eavesdropper to the flows between Alice and Bob in one request-response
session can copy these flows and cause Bob to process the same request again.
For some requests, e.g., Transfer 100$ from my account to Eve, this can be a
concern.
To ensure freshness without requiring the extra flows, one may use Times-
tamps instead of exchanging nonces. Notice that even if clocks are synchro-
nized, there is some delay for messages, forcing recipients to allow messages
which contain timestamps earlier than the time at which they were received.
To deal with this, the recipient (e.g., Bob) typically remembers the last times-
tamp received, and processes only requests with increasing timestamps. This
memory can be erased after there has been no new request for enough time,
allowing the recipient to confirm that a new request is not a replay. Still, when
the delay is large, timestamps have the additional advantage that the recipient
does not need to remember all ‘pending nonces’ (sent and not yet received),
assuming synchronized clocks.
Timestamp-based authenticated handshake may operate as follows. The
initiator includes with each request, say of session σ, the timestamp value
TA (σ), which is guaranteed to exceed the value TA (σ 0 ) sent with any previously-
sent request sent from this initiator to this responder. One way to implement
TA is to set it, at time t, to TA = timeA (t), where timeA (t) gives the current
value of a clock maintained by Alice at time t, which monotonously increases
with time t. Another way for the initiator, e.g. Alice, to implement TA , is using
a counter maintained by Alice and incremented upon every OP EN or SEN D
event. However, often the requirement to maintain a persistent state is harder
than the requirement of keeping a clock.
The responder, e.g. Bob in Fig. 5.7, needs to maintain the last-received
value of TA and ignore or reject requests which arrive with TA values smaller
than the last value it received. Even this state may be reduced if the responder
also has a clock, synchronized - to some extent - with the initiator, as we show
in the following exercise.
Exercise 5.5. Assume that the initiator (Alice) and responder (Bob) have
synchronized clocks, timeA () and timeB (), whose values never differ by more
than ∆ seconds, i.e. for every time t holds |timeA (t) − timeB (t)| ≤ ∆, and
that the delay for a message sent between Alice and Bob is at most D. Explain
how to modify the protocol to reduce the persistent storage requirements, while
maintaining security (and in particular, ensuring freshness).
209
is used only to securely setup a following exchange of messages - a session.
Therefore, if we consider a MitM adversary, we normally have to consider not
just attacks on the handshake phase, but also following attacks on the session
itself.
Later, in subsection 5.1.4, we discuss the session protocols that protect the
communication over a session from a MitM attacker; these protocols rely on
a secret key shared between the participants in the session. In principle, the
parties could use a fixed shared secret key for all sessions between them - e.g.,
one could simply use the shared initialization (‘master’) key κ. However, there
are significant security advantages in limiting the use of each key, following
Principle 2. Specifically:
210
indistinguishable from a random string of same length, even if the adversary is
given all the other session keys.
We say that a two-party shared-key handshake protocol ensures secure key-
setup if it ensures both requirements, i.e., it ensures synchronized key-setup as
well as pseudo-random session keys.
k = P RFκ (NA +
+ NB ) (5.2)
In Eq. (5.2, κ denotes the long-term shared secret key (provided to both parties
in the IN IT (κ) input signal), and NA , NB are the values exchanged in the
protocol.
Since both parties compute the key in the same way from NA + + NB , it
follows that they will receive the same key, i.e., the key-setup 2PP extension
ensures synchronized key-setup. Furthermore, since NA and NB are chosen
randomly for each session, then each session identifier - the pair NA +
+ NB - is
used, with high probability, in no more than a single session. Since the session
keys are computed using a pseudo-random function, k = P RFκ (NA + + NB ),
it follows that the key of each session is pseudo-random (even given all other
session keys). Namely, the key-setup 2PP extension ensures secure key setup.
211
Explain the security of your solutions.
Hints for solution:
1. Assume you are given a secure encryption and MAC and ‘corrupt’ them
into the required counter-example.
2. Let kE = P RFk (‘E’), kA = P RFk (‘A’).
3. Instead of deriving k as in Eq. (5.2), derive kE , kA ‘directly’ using:
kE = P RFκ (‘E’ +
+ NA +
+ NB ) (5.3)
kA = P RFκ (‘A’ +
+ NA +
+ NB ) (5.4)
To further improve security of the session protocol, we may use two separate
A→B A→B
pairs of per-goal keys: one pair (kE , kA ) for (encryption, authentication)
B→A B→A
of messages from Alice to Bob, and another pair (kE , kA ) for (encryption,
authentication) of messages from Bob to Alice.
Hints for solution of parts 2 and 3: follow a similar approach as for Ex. 5.6,
but derive directly from the ‘master key’, saving a cryptographic operation.
212
Alice KDC Bob
h i
cB = EK E (KAB ), T = cB , M ACkM (time +
+ ‘Alice’ +
+ cB )
B B
cA = EK E (KAB ), M ACkM (time +
+ ‘Bob’ +
+ cA +
+ T)
A A
M
kAB ← P RFkAB (‘MAC’)
E
kAB ← P RFkAB (‘Enc’)
+A→B+
T, cReq = EkE (Request), M ACK M (1 + + time +
+ cReq )
AB AB
E M
Derive kAB from T and kAB , kAB
from kAB
+A←B+
cResp = EK E (Response), M ACK M (2 + + time +
+ cResp )
AB AB
Figure 5.8: Key Distribution Center Protocol. The protocol assumes that the
E
KDC shares two keys with each party; with Alice, it shares kA for encryption
M E
and kA for authentication (MAC), and with Bob, it shares kB for encryption
M
and kB for authentication (MAC). In this protocol, the KDC selects a shared-
key kAB to be used by Alice and Bob for the specific request-response. Alice
and Bob use kAB and a pseudo-random function P RF to derive two shared
E M
keys, kAB = P RFKAB (‘Enc’) (for encryption) and kAB = P RFKAB (‘MAC’)
(for authentication, i.e., MAC).
different key distribution protocol, which is used in the GSM cellular network
standard - and which is notoriously insecure.
The process essentially consists of two exchanges. The first exchange is
between Alice and the KDC. In this exchange, the KDC sends to Alice the key
kAB that will be shared between Alice and Bob. In addition, Alice receives a
ticket T , which is, essentially, the key kAB , encrypted and authenticated - for
Bob.
In the second phase, Alice sends her request to Bob, together with the ticket
T , allowing Bob to retrieve kAB . Alice and Bob both derive from kAB the
E M
shared encryption and authentication (MAC) keys, kAB and kAB , respectively.
Note that in the above protocol, the KDC never initiates communication,
but only responds to an incoming request; this communication pattern, where
a server machine (in this case, the KDC) only responds to incoming requests,
is referred to as client-server. It is often preferred, since it relieves the server
(e.g., KDC) from the need to maintain state for different clients, which makes
it easier to implement an efficient service, especially when clients may access
different servers.
213
In many applications, the TTP has an additional role: access control.
Namely, the TTP would control the ability of the client (Alice) to contact
the service (Bob). In this case, the ticket does not only transport the key but
also becomes a permit for the use of the server. One important example for
such a service is the Kerberos system [135], adopted in Windows and other
systems.
This protocol requires and assumes synchronized clocks (time) between all
parties. This allows Alice and Bob to validate that the key KAB they receive is
‘fresh’ and not a replay; when tickets also serve as permits, this also allows Bob
to validate that Alice was allowed access to the service (at the given time). If
there are no synchronized clocks, then we must use a different flow than shown
in Figure 5.8; in particular, Bob should be able to provide a nonce NB to the
KDC, and then to validate that nonce NB exists in the ticket that he receives.
Such protocols were also studied and deployed, e.g., see [27].
Exercise 5.8. Extend the KDC protocol of Figure 5.8 to provide also access-
control functionality by the KDC. Specifically, Alice should send her request also
to the KDC, in an authenticated and private manner; and the KDC should in-
clude a secure signal for Bob within the ticket T , letting Bob know that the
KDC approves that request. Your solution should only use the flows in Fig-
ure 5.8, adding and/or modifying the information sent as necessary. The so-
lution should avoid exposure of the request to the attacker (eavesdropper); the
KDC, of course, should be aware of the request (to approve it).
Exercise 5.9. Present an alternative design for a KDC protocol, which avoids
the assumption of synchronized clocks. Your solution should maintain client-
server communication, i.e., the KDC (as a server) should only send responses
to incoming requests, and never initiate communication with a client.
Hint: you may solve this by defining the contents of the flows in Fig. 5.9;
and you may use ideas from the 2PP protocol. Or, a simpler solution may use
additional state in the KDC, essentially, for counters.
The rest of this section focuses on a very specific, important case-study of
a three-party key distribution protocol, namely, that of the GSM network, and
some of its (very serious) vulnerabilities.
214
Alice KDC Bob
mobile itself and to the Home, which is the cellular network provider to whom
the mobile is subscribed. The home retrieves ki from its clients keys table CK,
but does not send it to the base. Instead, the home uses ki to derive and send
to the base per-session credentials, allowing the base to authenticate the client
and to set up a shared-key with it, to be used to encrypt the communication for
confidentiality. We now provide some more details on this process, and later
discuss some significant vulnerabilities.
Fig. 5.10 shows a simplification of the flows of the GSM handshake pro-
tocol. The handshake begins with the mobile sending its identifier IMSI (In-
ternational Mobile Subscriber Identity). The base forwards the IMSI to the
home, which retrieves the key of the user owning this IMSI, which we denote
ki . The home then selects a random value r, and computes the pair of values
(K, s) as (K, s) ← A38(ki , r). Here, K is a symmetric session key, and s stands
for secret result, a value used to authenticate the mobile. The function2 A38
should be a Pseudo Random Function (PRF).
2 The spec actually computes K, s using two separate functions: s ← A3(k , r) and K ←
i
A8(ki , r), and does not specify the required properties from A3, A8. However, for security, the
functions should be ‘independently pseudorandom’ - for example, using A3 = A8 is clearly
insecure. Indeed, in practice, both are computed by a joint function - usually a a specific
function called COM P 128. We use the abstract notation A38 for this function; COM P 128
215
Figure 5.10: The GSM key distribution protocol (simplified). Time proceeds
from top to bottom.
The home sends the resulting GSM authentication triplet (r, K, s) to the
base. For efficiency, the home usually sends multiple triplets to the base (not
shown). Another way for the base to avoid requesting again an authentication
triplet from the home is for the base to reuse a triplet in multiple connections
with the same mobile. Note that the GSM spec uses the terms KC , rand and
sres for what we denote by K, r and s, respectively.
Fig. 5.10 also shows an example of a message m sent from mobile to base,
encrypted using the connection’s key K. Of course, in typical real use, the
mobile and the base exchange a session consisting of many messages encrypted
with EK .
Contrary to Kerckhoffs’ principle (principle Principle 3), all of GSM’s cryp-
tographic algorithms, including the stream ciphers as well as the A3 and A8
algorithms, were kept secret, apparently in the (false) hope that this will im-
prove security. We believe that the choice of keeping GSM algorithms secret
contributed to the fact that these algorithms proved to be vulnerable - and
furthermore, that serious, and pretty obvious, vulnerabilities exist also in the
GSM security protocols. We discuss two of these in the next two subsections.
is a possible instantiation.
216
Figure 5.11: Fake-Base Replay attack on GSM. Time proceeds from left to
right.
217
this is reasonable, since multiple effective attacks are known on the GSM
ciphers A5-1 and A5-2.
Impersonate: finally, once cryptanalysis has exposed the session key K, the
attacker sets up a fake base station and uses that key to communicate
correctly with the client. This allows the attacker to eavesdrop and mod-
ify the communication. The attacker may also relay the messages from
the client to the ‘real’ base; one reason to do this is so that the client is
unlikely to detect that she is actually connected via a rogue base.
218
Figure 5.12: Cipher-suite negotiation in GSM.
A5/1, making A5/3 the preferred algorithm (with some attacks against it too).
A5/i
We denote encryption with stream-cipher A5/i and key K as EK .
219
Figure 5.13: A simplified, unrealistic Downgrade Attack on GSM. This version
usually fails, since GSM specifies that all clients should support the A5-1 cipher,
so Base should refuse to use A5-2.
MitM would only begin the cryptanalysis of A5/2 after receiving the Start
message, the base would time-out and ‘break’ the connection.
However, this issue is easily circumvented, by exploiting the fact that GSM
bases allow the client much more time to compute the authenticator s - more
than 10 seconds, typically. The MitM attacker exploits this fact by delaying
the transmission of the authenticator s, until it finishes cryptanalysis of the
message encrypted with A5/2 and finds the key K. Only at that point, the
MitM forwards s to the base; when receiving the Start command, the MitM
attacker can easily forward the messages from the client after re-encrypting
them with A5/1. See Figure 5.14.
Several additional variants of this attack are possible; see, for example, the
following exercise.
Hint: the attacker will resend the value of r from the eavesdropped-upon
communication (encrypted using a ‘strong’ cipher) to cause the mobile to re-
use the same key - but with a weak cipher, allowing the attacker to expose the
key.
220
Figure 5.14: GSM Downgrade Attack - the ‘real’ version. This version works,
since GSM clients are willing to use the weak A5/2 cipher.
Exercise 5.11 (Fix GSM key reuse.). Show a fix to the vulnerability caused
221
by reuse of the same key for different ciphers in GSM, as exploited in Exer-
cise 5.10. The fix should not require any change in the messages exchanged
by the protocol, and should simply appear as a new cipher, say A5/9, using
only information available to the client and base. You may assume that the
client has an additional secret key, k9,i and that the home sends to the base an
additional key K9 .
Hint: Note that your fix is not required to prevent the attack of Figure 5.14,
although this is also easy - if the Base may assume that all clients support
A5/9.
Note that the GSM response to these vulnerabilities was simply to abolish
the use of the insecure A5/2 in mobiles. This prevents downgrade attacks to
A5/2, but still allows downgrading from A5/3 to A5/1.
222
Figure 5.15: (Weak-)Forward-secrecy Handshake, implemented as in Eq. 5.5,
i.e., M Ki = P RG(M Ki−1 ). Exposure of all the information of an entity at
time t does not compromise the confidentiality of past sessions. Information
sent by the entity or sent to the entity, in any session which ended before time
t, remains secure even after the keys kept at time t are exposed. Session keys
may be derived from the current master key M Ki as in Eq. 5.6, similarly to
the derivation of session keys from the (fixed) master key in Eq. 5.2.
master key (e.g., M Ki−1 ). Definition follows. Note that some authors refer
to this notion as weak forward secrecy, and we often adopt this, to emphasize
the distinction from the stronger notion of perfect forward secrecy (which we
present later).
ki = P RFM Ki (NA +
+ NB ) (5.6)
223
Figure 5.16: Forward-secrecy key setup: derivation of per-session master keys
and session keys
The protocols of Figure 5.16 and Figure 5.18 ensure forward secrecy - but
not recover secrecy. This is since the attacker can use one exposed master key,
say M Ki0 −1 , to derive all the following master keys, including M Ki , using
Eq. 5.5; in particular, M Ki0 = P RG(M Ki0 −1 ).
However, a simple extension suffices to ensure recover secrecy, as well as
forward secrecy. The extension is simply to use the random values exchanged
in each session, i.e., NA , NB , in the derivation of the next master key, i.e.:
3 We may sometimes use the term ‘recover secrecy’ instead of ‘recover security’, due to
the similarity with ‘forward secrecy’. However, ‘recover security’ is a more appropriate term,
since this concept allows recovery not only of secrecy/confidentiality, but also of authenticity
and integrity.
224
Figure 5.17: RS-Ratchet key setup protocol, ensuring both (weak) Forward
Secrecy and Recover Secrecy
225
advantages and why they require more than the protocols we have seen in this
chapter; we discuss these notions further, with implementations, in § 6.4.
Exercise 5.12 (Forward Secrecy vs. Perfect Forward Secrecy (PFS)). Present
a sequence diagram, showing that the forward-secrecy key-setup handshake pro-
tocol presented in subsection 5.6.1, does not ensure Perfect Forward Secrecy
(PFS).
Perfect Recover Secrecy (PRS). We use the term perfect recover secrecy
to refer to key setup protocols where a single session without MitM attacks
suffices to recover secrecy from previous key exposures. Definition follows.
Definition 5.6 (Perfect Recover Secrecy (PRS) handshake). A handshake pro-
tocol π ensures perfect recover secrecy (PRS), if secrecy is ensured for messages
exchanged during session i, provided that there exists some previous session
i0 < i such that:
226
Figure 5.18: Forward-secrecy key setup: derivation of per-session master keys
and per-goal session keys
Note the similarity to PFS, in allowing only eavesdropping during the ‘tar-
get’ session (i for PFS, i0 for PRS). Also similarly to PFS, we discuss some
PRS handshake protocols in the next chapter, which deals with asymmet-
ric cryptography. Indeed, all known PRS protocols are based on asymmetric
cryptography.
227
Figure 5.19: Relations between notions of resiliency to key exposures. An
arrow from notion A to notion B implies that notion A implies notion B. For
example, a protocol that ensures Perfect Forward Secrecy (PFS) also ensures
Forward Secrecy.
228
Table 5.2: Notions of resiliency to key exposures of key-setup handshake pro-
tocols. See implementations of forward and recover secrecy in subsection 5.6.1
and subsection 5.6.2 respectively, and for the corresponding ‘perfect’ notions
(PFS and PRS) in subsection 6.4.1 and subsection 6.4.2, respectively.
consider most basic and important. Even for these notions, there are some
different interpretations and definitions, and sometimes inconsistent usage of
terms. In particular, some experts use the term forward secrecy as a synonym
to perfect forward secrecy (PFS). Furthermore, while break-in recovery is often
mentioned as a goal for the ratchet protocols, we introduced the terms recover
secrecy in subsection 5.6.2 and perfect recover secrecy (PRS) in subsection 6.4.2.
229
5.7 Shared-Key Session Protocols: Additional Exercises
Exercise 5.13 (Vulnerability of Compress-then-Encrypt). One of the impor-
tant goals for encryption of web communication, is to hide the value of ‘cookies’,
which are (often short) strings sent automatically by the browser to a website,
and often used to authenticate the user. Attackers often cause the browser to
send requests to a specific website, to try to find out the value of the cookie
attached by the browser. Assume, for simplicity, that the attacker controls the
entire contents of the request, before and after the cookie, except for the cookie
itself (which the attacker tries to find out). Furthermore, assume that the length
of the cookie is known. Further assume that the browser uses compression be-
fore encrypting requests sent to the server.
Finally, assume a very simple compression scheme, that only replaces: (1)
sequences of three or more identical characters with two characters, and (2)
repeating strings (of two or more characters, e.g., xyxy), with a single string
plus one character (e.g., ⊥xy; assume that the ⊥ does not appear in the request
except to signal compression).
1. Present an efficient attack which exposes the first character of the cookie.
2. Extend your attack to expose the entire cookie.
Exercise 5.14. Some applications require only one party (e.g., a door) to au-
thenticate the other party (e.g., Alice); this allows a somewhat simpler protocol.
We describe in the two items below two proposed protocols for this task (one
in each item), both using a key k shared between the door and Alice, and a
secure symmetric-key encryption scheme (E, D). Analyze the security of the
two protocols.
1. The door selects a random string (nonce) n and sends Ek (n) to Alice;
Alice decrypts it and sends back n.
2. The door selects and sends n; Alice computes and sends back Ek (n).
Show an attack against this protocol, and identify the design principles which
were violated by the protocol, and which, if followed, should have prevented such
attacks.
230
Exercise 5.16 (GSM). In this exercise we study some of the weaknesses of
the GSM handshake protocol, as described in subsection 5.5.1. In this exer-
cise we ignore the existence of multiple types of encryption and their choice
(‘ciphersuite’).
1. In this exercise, and in usual, we ignore the fact that the functions A8, A3
and the ciphers Ei were kept secret; explain why.
2. Present functions A3, A8 such that the protocol is insecure when using
them, against an eavesdropping-only adversary.
3. Present functions A3, A8 that ensure security against MitM adversary,
assuming E is a secure encryption. Prove (or at least argue) for security.
(Here and later, you may assume a given secure PRF function, f .)
4. To refer to the triplet of a specific connection, say the j th connection,
we use the notation: (r(j), sres(j), k(j)). Assume that during connection
j 0 attacker received key k(ĵ) of previous connection ĵ < j 0 . Show how
a MitM attacker can use this to expose, not only messages sent during
connection ĵ, but also messages sent in future connections (after j 0 ) of
this mobile.
5. Present a possible fix to the protocol, as simple and efficient as possible, to
prevent exposure of messages sent in future connections (after j 0 ). The
fix should only involve changes to the mobile and the base, not to the
home.
231
Figure 5.20: Simplified SSL
e.g., Πj∈{1,2,3} aj = a1 · a2 · a3 .
232
Present an attack allowing a malicious client, e.g., Mal, to learn the key
kG for a group it does not belong to, i.e., M al 6∈ G; e.g., assume G = {a, b, c}.
Mal may eavesdrop to all messages, and request and receive kG0 for any group
G0 s.t. M al ∈ G0 .
Exercise 5.19. In the GSM protocol, the home sends to the base one or more
authentication triplets (r, K, s). The base and the mobile are to use each triplet
only for a single handshake; this is somewhat wasteful, as often the mobile has
multiple connections (and handshakes) while visiting the same base.
233
value of j together with r from base to mobile, and may change the stored
value of s at the end of every handshake; let sj denote the value of s
at the j th handshake, where the initial value is s received from the home
(i.e., s1 = s). Your solution consists of defining the value of sj given
sj−1 , namely: sj = .
Exercise 5.20. The GSM protocol is very vulnerable to downgrade attacks;
let’s design a method to prevent downgrade attacks on new ciphers, when both
client (mobile) and base support (the same) new cipher.
1. An attacker impersonating as a base, may try to behave as if it is a base
supporting only an older cipher (without protection against downgrade
attack).
Exercise 5.21. Consider the following key establishment protocol between any
two users with an assistance of a server S, where each user U shares a secret
key KU S with a central server S.
A → B : (A, NA )
B → S : (A, NA , B, NB , EKBS (A +
+ NA ))
S → A : (A, NA , B, NB , EKAS (NA +
+ sk), EKBS (A +
+ sk), NB )
A → B : (A, NA , B, NB , EKBS (A +
+ sk))
Assume that E is an authenticated encryption. Show an attack which allows
an attacker to impersonate one of the parties to the other, while exposing the
secret key sk.
Exercise 5.22 (Hashing vs. Forward Secrecy). We discussed in §5.6.1 the
use of PRG or PRF to derive future keys, ensuring Forward Secrecy. Could
a cryptographic hash function be securely used for the same purpose, as in
κi = h(κi−1 )? Evaluate if such design is guaranteed to be secure, when h is a
(1) CRHF, (2) OWF, (3) bitwise-randomness extracting.
Exercise 5.23 (PFS definitions). Below are informal definitions for PFS from
the literature. Compare them to our definitions for PFS: are they equivalent?
Are they ‘weaker’ - a protocol may satisfy them yet not be PFS as we define, or
the other way around? Or are they incomparable (neither is always weaker)?
Can you give an absurd example of a protocol meeting the definition, which is
‘clearly’ not sensible to be claimed to be PFS? Any other issue?
From Wikipedia, [171] An encryption system has the property of forward
secrecy if plain-text (decrypted) inspection of the data exchange that oc-
curs during key agreement phase of session initiation does not reveal the
key that was used to encrypt the remainder of the session.
From [127, 138] A protocol has Perfect Forward Secrecy (PFS) if the compro-
mise of long-term keys does not allow an attacker to obtain past session
keys.
234
Chapter 6
235
key cryptology: public key cryptosystem (PKC), digital signature schemes, and
key exchange protocols.
We illustrate digital signature schemes in Figure 3.2, and discuss them in § 6.7.
236
generation function KG receives as input a security parameter 1l , and outputs
a pair of keys: a public key and a private key. The key-combining function F
receives as input a public value (from one party) and a private value (from the
other party), and produces a (shared) key. Each party, e.g., Alice, uses KG to
generate a pair (a, PA ) of private value a, kept by Alice, and a public value PA ,
Public Key Cryptology
which Alice sends to its peer, Bob. Each party also receives public information
from the peer: Alice receives PB from Bob, and Bob receives PA from Alice.
Each party now uses F to derive a key; Alice derives kA = F (a, PB ) and Bob
deriveskBKey exchange.
= F (b, PA ). See Figure 6.1.
Alice Bob
PA
PA PB
KG KG
𝑎 Shared key: 𝐹 𝑎, 𝑃𝐵 = 𝐹(𝑏, 𝑃𝐴 ) 𝑏
Figure 6.1: Key Exchange protocol. Each party, Alice and Bob, runs the Key-
Generation algorithm KG, which outputs a (private, public) key-pair: a, PA for
Alice and b, PB for Bob. The parties exchange their public keys (PA and PB ).
Then, each party applies a key-combining function F to its own private key (a
for Alice and b for Bob), and to the public key received from the peer (PA from
Alice and PB from Bob). A key-exchange protocol should ensure correctness
8/18/2018 © Amir Herzberg 4
(kA = F (a, PB ) = F (b, PA ) = kB ) and key-indistinguishability (kA = kB is
pseudorandom), allowing use of kA = kB as a shared key.
237
sufficiently-large security parameter 1l , holds:
A (PA , PB , r) = 1
A (PA , PB , F (a, PA )) = 1 where
where $
Pr
$
(a, P ) ←
− Pr A KG(1l ), ∈ N EGL(1l )
(a, PA ) ← KG(1l ), $
KG(1l ),
(b, PB ) ←
$
(b, PB ) ← KG(1l ) $
r ← {0, 1}|F (a,PA )|
(6.4)
238
Public key cryptology (PKC) also makes it easier to design and deploy
secure systems. Specifically, public keys are easier to distribute, since they
can be given in a public forum (such as directory) or in an incoming message;
note that the public keys still need to be authenticated, to be sure we are
receiving the correct public keys, but there is no need to protect their secrecy.
Distribution is also easier since each party only needs to distribute one (public)
key to all its peers, rather than setting up different secret keys, one per each
peer.
Furthermore, public keys are easier to maintain and use, since they may
be kept in non-secure storage, as long as they are validated before use - e.g.,
using MAC with a special secret key. Finally, only one public key is required
for each party, compared to O(n2 ) shared keys required for n peers; namely,
we need to maintain - and refresh - less keys.
239
However, it is certainly conceivable that an efficient algorithm exists - and
would someday be found. In fact, such discovery may even occur suddenly
and soon - such unpredictability is the nature of algorithmic and mathematical
breakthroughs. Furthermore, since all of the widely-used PKC algorithms are
so closely related, it is even possible that such cryptanalysis would apply to all
of them - leaving us without any practical PKC algorithm. PKC algorithms
are the basis for the security of many systems and protocols; if suddenly there
will not be a viable, practical and ‘unbroken’ PKC, that would be a major
problem.
Furthermore, efficient algorithms to solve these problems are known - if an
appropriate quantum computer can be realized. There has been many efforts
to develop quantum computers, with significant progress - but results are still
very far from the ability to cryptanalyze these PKC schemes. But here, too,
future developments are hard to predict.
All this motivates extensive work by cryptographers, to identify additional
candidate PKC systems, which will rely on other, ‘independent’ or - ideally -
more general assumptions, as well as schemes which are secure even if large-
scale quantum computing becomes feasible (post-quantum cryptology). In par-
ticular, this includes important results of PKC schemes based on lattice prob-
lems. Lattice problems are very different from number-theoretic problems, and
seem resilient to quantum-computing; furthermore, some of the results in this
area have proofs of security based on the general and well-founded complexity
assumption of NP-completeness. Details are beyond our scope; see, e.g., [3].
240
in which the ciphertexts are to remain confidential. Experts estimate the ex-
pected improvements in the cryptanalysis capabilities of attackers over years,
due to improved hardware speeds, reduced hardware costs, reduced energy
costs (due to improved hardware), and, often more significantly by hardest to
estimate, improvements in methods of cryptanalysis. Such predictions cannot
be done precisely, and hence, recommendations differ, sometimes considerably.
Accordingly, Table 6.1 compares the recommended key lengths for three years:
2020, 2030 and 2040.
Table 6.1 presents the recommendations for four typical, important cryp-
tosystems, in three columns: two to four. Column two presents the recommen-
dations for symmetric cryptosystems such as AES. The same recommendations
hold for any other symmetric (shared-key) cryptosystem, for which there is not
‘shortcut’ cryptanalytical attack (which provides significantly better efficiency
compared to exhaustive search).
Column three presents the recommendations for RSA and El-Gamal, the
two oldest and most well-known public-key cryptosystems; we discuss both
cryptosystems, in sections 6.6 and 6.5.2. This column also applies to the Diffie-
Hellman (DH) key-exchange protocol; in fact, the El-Gamal cryptosystem is
essentially a variant of the DH protocol, as we explain in subsection 6.5.2. RSA
and El-Gamal/DH are based on two different number-theoretic problems: the
factoring problem (for RSA) and the discrete-logarithm problem (for DH/El-
Gamal); but the best-known attacks against both are related, with running time
which is exponential in half the key-length. We briefly discuss these problems
in subsection 6.1.7.
The fourth column of table 6.1 presents the recommendations for elliptic-
curve based public-key cryptosystems such as ECIES. As the table shows, the
recommended key-lengths for elliptic-curve based public-key cryptosystems are,
quite consistently, much lower than the recommendations for the ‘older’ RSA
and El-Gamal/DH systems; this makes them attractive in applications where
longer keys are problematic, due to storage and/or communication overhead.
We do not cover elliptic-curve cryptosystems in this course; these are covered
in other courses and books, e.g., [3, 89, 159].
Table 6.1 shows that the required key-length is considerably higher for
public-key schemes - about twice than symmetric schemes for Elliptic-curve
cryptosystem, and over twenty times (!) for RSA and DH schemes. The
lower key-length recommendations for Elliptic-curve cryptography, makes these
schemes attractive in the (many) applications where key-length is critical, such
as when communication bandwidth and/or storage are limited.
The bottom row of Table 6.1 compares the running time of implementations
of AES with 128 bit key in counter (CTR) mode, RSA with 1024 and 2048 bit
key, and 256 bit ECIES elliptic curve cryptosystem. We see that the symmetric
cryptosystem (AES) is many orders of magnitude faster. It supports more 4·109
bytes/second, compared with less than 106 bytes/second for the comparably-
secure 2048-bit RSA, and less than 32·103 bytes/second for ECEIS. We used the
values reported for one of the popular Cryptographic libraries, Crypto++ [50].
Energy costs would usually be even worse than this factor of 4000 to 4,000,000
241
Table 6.1: Comparison of key-length and computational overheads: symmetric
cryptosystems, vs. main types of asymmetric cryptosystems
Principle 11 (Minimize use of PKC). Designers should avoid, or, where ab-
solutely necessary, minimize the use of public-key cryptography.
In particular, consider that typical messages are much longer than the size
of inputs to the public-key algorithms. In theory, we could use designs as
presented for encryption and MAC, for applying the public-key algorithms to
multiple blocks. However, the resulting computation costs would have been
absurd. Even more absurd would be an attempt to modify the public-key
operation to support longer inputs. Luckily, there are simple and efficient solu-
tions, to both encryption and signatures, which are used essentially universally,
to apply these schemes to long (or VIL) messages:
Signatures: use the hash-then-sign (HtS) paradigm, see subsection 4.2.6.
Encryption: use the hybrid encryption paradigm, see the following subsection
(subsection 6.1.6).
242
setup such shared key - using either key-exchange protocol between them, or
by having one party use the public key of its peer to encrypt the shared key
and send it, encrypted, to the peer. The later, widely-used, technique is called
hybrid encryption; details follow.
Hybrid encryption combines a public key cryptosystem (P KG, P KE, P KD)
with a shared key cryptosystem (SKG, SKE, SKD), to allow efficient public
key encryption of long messages. Our description assumes that the sender
knows the recipient’s public key e.
243
Intuitively, public key schemes use hard problems, by having the secret key
provide the solution to the problem, and the public key provide the parameters
to verify the solution. To make this more concrete, we briefly discuss factoring
and discrete logarithm, the two hard problems which are the basis for many
public key schemes, including the oldest and most well known: RSA, DH, El-
Gamal. For more in-depth discussion of these and other schemes, see courses
and books on cryptography, e.g., [159]. Note that while so far, known attacks
are equally effective against both systems (see Table 6.1), there is not yet a
proof that an efficient algorithm for one problem implies an efficient algorithm
against the second.
Factoring
The factoring problem is one of the oldest problems in algorithmic number
theory, and is the basis for RSA and other cryptographic schemes. Basically,
the factoring problem involves finding the prime divisors (factors) of a large
integer. However, most numbers have small divisors - half of the numbers
divide by two, third divide by four and so on... This allows efficient number
sieve algorithms to factor most numbers. Therefore, the factoring hard problem
refers specifically to factoring of numbers which have only large prime factors.
For the RSA cryptosystem, in particular, we consider factoring of a number
n computed as the product of two large random primes: n = pq. The factoring
hard problem assumption is that given such n, there is no efficient algorithm
to factor it back into p and q.
Verification consists simply of multiplying p and q, or, if given only one of
the two, say p, of dividing n by p and confirming that the result is an integer
q with no residue.
Discrete logarithm
The discrete logarithm problem is another important, well-known problem from
algorithmic number theory - and the basis for the DH (Diffie-Hellman) key-
exchange protocol, the El-Gamal cryptosystem, elliptic-curve cryptology, and
additional cryptographic schemes.
Note: readers are expected to be familiar with the basic notions of number
theory. Our discussion of the public key cryptosystems (RSA, DH, El-Gamal)
and the relevant mathematical background is terse; if desired/necessary, please
consult textbooks on cryptology and/or number theory, e.g., [159].
Discrete logarithms are defined for a given cyclic group G and a generator g
of G. A cyclic group G is a group whose elements can be generated by a single
element g ∈ G, called a generator of the group, by repeated application of the
group operation. The usual notation for the group operation is the same as
the notation of multiplication in standard calculus, i.e., the operation applied
to elements x, y ∈ G is denoted x · y or simply xy, and the group operation
applied a times to element x ∈ G, where a is an integer (i.e., a ∈ N), is denoted
244
xa ; in particular, g a = Πai=1 g. Applying these notations, a cyclic group is a
group where (∀x ∈ G)(∃a ∈ N)(x = g a ).
Given generator g of cyclic group G and an element x ∈ G, the discrete
logarithm of x over G, w.r.t. g, is the integer a ∈ N s.t. x = g a . This is
similar to the ‘regular’ logarithm function logb (a) over the real numbers R,
which returns the number logb (a) ≡ x ∈ R s.t. bx = a, except, of course, that
discrete logarithms are restricted to integers, and defined for given cyclic group
G.
There are efficient algorithms to compute logarithms over the reals; these
algorithms work, of course, also when the result is an integer. However, for
some finite cyclic groups, computing discrete logarithms is considered hard.
Note that the verification of discrete logarithms only requires exponentiation,
which can be computed efficiently.
Definition 6.2 (Discrete logarithm problem). Let G be a cyclic group, g be
a generator for G and x ∈ G be an element of G. A discrete logarithm of x,
for group G and generator g, is an integer a ∈ N s.t. x = g a . The discrete
logarithm problem for G is to compute integer a ∈ N s.t. x = g a , given x ∈ G
and generator g for G.
Definition 6.3 (The discrete logarithm assumption for safe prime groups).
The discrete logarithm assumption (DLA) for safe prime groups holds, if for
every PPT algorithm A holds:.
for every safe prime p of at least n bits, and every generator g of Z∗p =
{1, 2, . . . , p − 1}.
245
On the secrecy implied by the discrete logarithm assumption. Sup-
pose that the discrete logarithm assumption for safe-prime groups holds, i.e., it
is computationally-hard to find the discrete-log a, given g a mod p, where g is
a generator of the safe-prime group. Does this mean that the attacker cannot
learn any information on a?
The answer is no; the attacker can learn some information about a - e.g.,
its least-significant bit (LSb). As we will see later, this has important impli-
cations on the design of some discrete logarithm-based cryptographic schemes,
most notably, on the ‘secure’ way to use the Diffie-Hellman protocol; e.g.,
see Claim 6.3.
Let us explain how the attacker can learn the least-significant bit (LSb) of
the exponent a. Namely, we explain an efficient method using which an attacker
can learn LSb(a), given g a mod p. The method is based on two claims from
basic number theory, which we present below. We present these claims without
proof, since their proofs, although not complex, would still require us to get
into more number theory than we believe desirable in this introductory course;
interested readers can find these proofs, e.g., in [98], a great textbook on the
mathematics of cryptography. To present the two claims, we first introduce the
notion of quadratic residue modulo p, which has many uses in the mathematics
of cryptography.
Definition 6.4. Let p be a prime number, and let y be a positive integer. We
say that y is a quadratic residue modulo p, if there is some integer z s.t. y = z 2
mod p.
The first claim simply states that quadratic residuosity can be efficiently
computable.
Claim 6.1. There is an efficient algorithm that can determine if a given pos-
itive integer y is a quadratic residue modulo a given prime p.
The second claim says that y is a quadratic residue mod p if and only if the
least significant bit of x is zero. Combined with Claim 6.1, this shows that we
can efficiently find the least-significant bit of the exponent x.
Claim 6.2. Let y = g x mod p, where p is a prime, g is a generator for Fp∗ ,
and x is a positive integer. Then y is a quadratic residue if and only if the
least significant bit of x is zero.
Let us prove just the easy direction: if the LSb of x is zero, then y is a
quadratic residue. The LSb of an integer x is zero when x is even, i.e., x = 2x0
for some integer x0 . Namely, if the LSb of x is zero, then
0 0
y = g x = g 2x = (g x )2 mod p (6.6)
0
Let z = g x ; we see that y = z 2 mod p, hence y is a quadratic residue modulo
p. For the (harder) proof for the other direction, i.e., that if y is a quadratic
residue, then x must be even (i.e., its LSb must be zero), as well as for proof
of Claim 6.1, see, e.g., [98].
246
Note, however, that there are also several ‘positive’ results. For example,
[90] shows that except for some least-significant bits, the other bits of the
discrete log are secure.
247
Figure 6.3: Physical Key Exchange Protocol
padlock and vice verse; the protocol nevertheless, allows them to securely share
a key.
Alice initiates the protocol by placing the key to be shared in the box, and
locking the box with her padlock. When Bob receives the locked box, he cannot
remove Alice’s padlock and open the box. Instead, Bob locks the box with his
own padlock, in addition to Alice’s padlock. Bob now sends the box, locked by
both padlocks, to Alice.
Upon receiving the box, locked by both padlocks, Alice removes her own
padlock and sends back the box, now locked only by Bob’s padlock, back to
Bob. Finally, Bob removes his own padlock, and is now able to open the box
and find the key send by Alice. We assume that the adversary - Monster
in the Middle - cannot remove Alice’s or Bob’s padlocks, and hence, cannot
learn the secret in this way. The Diffie-Hellman protocol replaces this physical
assumption, by appropriate cryptographic assumptions.
However, notice that there is a further limitation on the adversary, which
is crucial for the security of this physical key exchange protocol: the adversary
should be unable to send a fake padlock. Note that in Figure 6.3, both padlocks
are stamped by the initial of their owner - Alice or Bob. The protocol is not
secure, if the adversary is able to put her own padlock on the box, but stamping
it with A or B, and thereby making it appear as Alice’s or Bob’s padlock,
respectively. This corresponds to the fact that the Diffie-Hellman protocol is
only secure against an eavesdropping adversary, but insecure against a MitM
adversary.
The critical property that facilitated the physical key exchange protocol, is
that Alice can remove her padlock, even after Bob has added his own padlock.
248
Figure 6.4: XOR Key Exchange Protocol
249
Exercise 6.1 (XOR key exchange protocol is insecure). Show how an eaves-
dropping adversary may find the secret key exchanged by the XOR Key Ex-
change protocol, by (only) using the values sent between the two parties.
250
Figure 6.5: Exponentiation Key Exchange Protocol
251
Figure 6.6: Modular-Exponentiation Key Exchange Protocol, for safe prime p
groups. The values k, a and b are integers smaller than p − 1.
252
Figure 6.7: Diffie-Hellman Key Exchange Protocol, for safe prime p groups;
a, b are integers smaller than p − 1.
253
n ∈ N, holds:
A(g a mod p, g b mod p) = g ab mod p < nc
Pr (6.7)
$
a,b←Zp∗
for every safe prime p of at least n bits and every generator g of Zp∗ =
{1, 2, . . . , p − 1}.
However, note that even if the CDH assumption for safe prime groups holds,
an eavesdropper may still be able to learn some partial information about g ab
mod p. The following claim shows that this allows immediate deduction of
whether g ab mod p is a quadratic residue modulo p, i.e., exposes ‘one bit of
information’ about g ab mod p: whether it is a quadratic residue or not.
Claim 6.3. Let PA = g a mod p and PB = g b mod p, where p is a prime, g
is a generator for Fp∗ , and a, b are positive integers. Given PA , PB , we can
efficiently deduce if g ab mod p is a quadratic residue modulo p.
Proof: from Claim 6.1, the attacker can efficiently find if g a mod p and
b
g mod p are quadratic residues modulo p. From Claim 6.2, this gives us the
least significant bit (LSb) of a and b, since, e.g., LSb(a) = 0 if and only if g a
mod p is a quadratic residue modulo p. Clearly, ab is even, i.e., LSb(ab) = 0,
if either a or b is even. Hence, given PA = g a mod p and PB = g b mod p, we
can efficiently know LSB(ab). From Claim 6.2, this also allows us to efficiently
deduce if g ab mod p is a quadratic residue modulo p.
Therefore, using g ab mod p directly as a key may allow an attacker to
learn some partial information about the key - even assuming that the CDH
assumption is true. Notice that while we show only exposure of this one bit of
information - the quadratic residuosity of g ab mod p - there could be ways to
expose more information, without violating the CDH assumption. So, how can
we use the DH protocol to securely exchange a key ? Some implementations
simply ignore this concern; however, let us discuss two ‘more secure’ options.
First option: use DDH groups. The first option is not to use a safe prime
group; instead, use a group which is believed to satisfy a stronger assumption
- the Decisional DH (DDH) Assumption. Some of the groups where DDH is
assumed to hold, and are used in cryptographic schemes, include Schnorr’s
group and some elliptic-curve groups; we will not get into such details (see,
e.g., in [159]).
Definition 6.6 (The Decisional DH (DDH) Assumption). The Decisional
DH (DDH) Assumption is that there is no PPT algorithm A that a can dis-
b ab
tinguish,
with significant advantage compared to guessing, between g , g , g
and g a , g b , g c , for random a, b and c. A group for which the DDH assumption
is believed to hold is called a DDH group.
Note, however, that this technique requires use of a group where DDH is
assumed to hold, and in particular, a safe-prime group cannot be used; this is
a significant hurdle.
254
Exercise 6.4 (Safe prime groups do not satisfy DDH). Show that safe prime
groups are not DDH groups, i.e., they do not satisfy the DDH assumption.
Another challenge with the use of this method is that the resulting shared-
value g ab is ‘only’ indistinguishable from a random group element, but not
from a random string. This implies that we cannot use g ab directly as a key.
However, this challenge was essentially resolved by Fouque et al. in 2006 [73],
who showed that the least-significant bits of g ab are indistinguishable from
random - enough bits to use as a shared key, for typical key-length and prime
size.
Second option: use CDH group, with key derivation. The second
option is to use a safe prime group - or another group where ‘only’ CDH is
assumed to hold - but not use the bits of g ab mod p directly as a key. Instead,
we derive a shared key k from g ab mod p, using a Key Derivation Function
(KDF). We discuss key derivation in the following subsection.
255
PRF fk (x) KDF fk (x) Rand.-extracting hash h(x)
Key k Secret, random Public, random No key
Data x Arbitrary ‘Sufficiently’ secret and random ‘Sufficiently’ secret and random
Output Pseudorandom Pseudorandom Pseudorandom
Where the probabilities are taken over random coin tosses of ADV , and over
$
s, x, r ← {0, 1}n .
For more details on key derivation, including provably-secure constructions,
see [111].
Note that a KDF seems quite similar, in its ‘signature’ (inputs and out-
puts), to a Pseudo-Random Function (PRF). Let’s compare PRF to KDF,
adding to the comparison another related primitive - randomness-extracting
hash function. See also Table 6.2.
We first note that the goal of all three mechanisms is to output uniformly
pseudorandom strings (unpredictable by attacker). Furthermore:
• Both KDF and PRF use, for this purpose, a uniformly-random key; how-
ever, PRF require this key to be secret, while KDF allows a public key.
Of course, randomness-extracting hash does not require any key (so, in
a sense, it’s more ‘extreme’ than KDF).
• A PRF ensures that the output is pseudorandom, even for arbitrary in-
put, possibly known or even determined by the attacker. In contrast,
both KDF and randomness-extracting hash assume that the input is
‘sufficiently’ secret and random. For one definition of ‘sufficiently ran-
dom input’, see the hashing lecture (where I presented such definition for
randomness-extracting hash). But for this course purposes, an intuitive
understanding should suffice.
256
The following exercise shows that the KDF and PRF definitions are ‘in-
comparable’ : a function can be a PRF but not a KDF and vice versa. An
interesting example is the popular HMAC construction, which is used in many
applications. Some of these applications rely on HMAC to satisfy the PRF
properties, e.g., for message authentication; other applications rely on HMAC
to satisfy the KDF properties, e.g., to derive a key from g ab mod p as in the
DH key exchange; and yet other applications rely on HMAC to satisfy both the
KDF properties and the PRF properties, e.g., strong resiliency to key exposure
of the Double-ratchet key-exchange protocols, see subsection 6.4.4.
Exercise 6.5 (PRF vs. KDF). Assume that f is a (secure) PRF and g is a
(secure) KDF. Derive from these a (secure) PRF f 0 and a (secure) KDF g 0 ,
such that f 0 is not a secure KDF and g 0 is not a secure PRF.
Sketch of proof: The PFS property follows immediately from the fact that
ki , the session key exchanged during session i, depends only on the result of
the DH protocol, i.e., is secure against an eavesdropping-only adversary. The
257
Figure 6.8: The Authenticated DH Protocol, ensuring PFS (but not recover
security)
protocol also ensures secure key setup, since a MitM adversary cannot learn
M K and hence cannot forge the DH messages (or find ki ).
Exercise 6.6. Alice and Bob share master key M K and perform the authen-
ticated DH protocol daily, at the beginning of every day i, to set up a ‘daily
key’ ki for day i. Assume that Mal can eavesdrop on communication between
Alice and Bob every day, but perform MitM attacks only every even day (i s.t.
i ≡ 0 ( mod 2)). Assume further that Mal is given the master key M K, on the
fifth day. Could Mal decipher messages sent during day i, for i = 1, . . . , 10?
Write your responses in a table.
Note that the results of Ex. 6.6 imply that the authenticated DH proto-
col does not ensure recover security. We next show extensions that improve
resiliency to key exposures, and specifically recover security after exposure,
provided that the attacker does not deploy MitM ability for one handshake.
258
Figure 6.9: The Synchronous-DH-Ratchet protocol: PFS and PRS
259
set of keys, it must first receive the message from its peer (say Bob), since
the computation of the new key ki requires to receive the public-value from
the peer (g bi mod p). What if such a message never arrives, maybe because a
Man-in-the-Middle (MitM) attacker prevents it from arriving?
The Asynchronous-DH-Ratchet protocol, presented in Fig. 6.10, addresses
this challenge, i.e., allows Alice to change her key even before she receives a
message from Bob - and similarly for Bob, of course. However, this results
in a slightly more complex protocol, as we explain. For simplicity, we present
the protocol focusing only on protecting the authenticity of messages, leaving
for the reader the exercise of extending to support message confidentiality, too
(Exercise 6.7).
The key difference is that this protocol maintains separate key counters for
Alice and Bob; namely, each shared key is now denoted kiA ,iB , i.e., each key
has two indices: iA for Alice and iB for Bob. We derive kiA ,iB , as follows,
using a pseudo-random function f , much like in the synchronous-DH-ratchet
protocol, namely:
kiA ,iB = fkiA −1,iB (g aiA biB ) ⊕ fkiA ,iB −1 (g aiA biB ) (6.9)
Actually, Alice and Bob cannot apply Eq. (6.9) directly, since Alice does
not know biB - or even the current value of iB - and, similarly, Bob does not
know aiA - or even the current iA . Instead, Alice computes the current key
value kiA ,îB using aiB , its private, randomly-chosen exponent, and the latest
public value PB,îB which Alice received from Bob, i.e.:
ai ai
kiA ,îB = fki (PB,Aî ) ⊕ fki (PB,Aî ) (6.10)
A −1,îB B A ,îB −1 B
Notice that Alice ‘maintains’ iA , and Bob ‘maintains’ iB ; i.e., Alice can
increment iA at any time, and Bob cannot immediately be aware of this, and
vice versa. However, this does not cause a problem: Alice maintains its own
counter for Bob, which we denote îB , and similarly Bob maintains îA . Alice
authenticates messages it sends using key kiA ,îB , and includes îB so that Bob
will know which key it should use to authenticate them; and increments îB when
it receives a new, validly-authenticated key-share from Bob. See Fig. 6.10.
This design allows the Asynchronous-DH-Ratchet protocol to ensure perfect
forward secrecy (PFS) and perfect recover secrecy (PRS), and furthermore, to
be ‘robust’ to a MitM adversary, i.e., a MitM adversary cannot prevent the
parties from changing their keys. Indeed, a party can move to a new key
even when the peer is non-responsive. This can be a significant advantage,
especially in asynchronous scenarios, where one party may be disconnected for
long periods, e.g., in securing communication between mobile users.
260
Alice Bob
Init: iA , îB ← 0 , PB,0 = g Init: îA , iB ← 0 , PA,0 = g
Send mA,1
ψ
Increment iA z }| {
mA,1 , g aiA mod p, îB , fki (mA,1 , g aiA mod p)
A ,îB
Receive mA,1
Increment îA
PA,îA ← ψ
ψ
Send mB,1
z }| { Increment iB
mB,1 , g biB mod p, îA , fkî (mB,1 , g biB mod p)
A ,iB
Receive mB,1
Increment îB Send mB,2
ψ
PB,îB ← ψ z }| { Increment iB
mB,2 , g biB mod p, îA , fkî (mB,2 , g biB mod p)
A ,iB
Receive mB,2
Increment îB
PB,îB ← ψ
Hint: Notice that you should not use the same key for both authentication
and encryption. Also, notice that in order to ensure perfect forward and recover
security, the protocol must make sure to erase old decryption keys.
261
As a result, practical deployments of ratchet key-exchange protocols would
usually use rather ‘long’ periods, i.e., use large values of T . To provide addi-
tional security against key-exposure, even between runs of the ratchet exchange
(involving modular exponentiations), the Double Ratchet Key-Exchange proto-
col combines the strong PFS+PRS security of the ratchet key-exchange pro-
tocols, with the weaker security guarantees of the Recover-Security Handshake
protocol of subsection 5.6.2. Let us explain how this is done, with some sim-
plifications. The double-ratchet protocol runs, essentially, the asynchronous-
ratchet protocol presented in the previous subsection, to derive the asynchronous-
ratchet keys kiA ,iB [0], essentially as in Eqs. (6.9-6.11). Note that in the double-
ratchet protocol, these keys would have an index whose value is zero, rather
than simply kiA ,iB as in the asynchronous-ratchet protocol - but otherwise this
would be the same.
After deriving the asynchronous-ratchet keys kiA ,iB [0], the double-ratchet
protocol then applies the PRF-based ratchet of the Recover-Security Handshake
protocol, described in subsection 5.6.2, to extract additional keys, kiA ,iB [i] for
i > 0. This derivation only requires (one) computation of a PRF, and is
therefore much more efficient than the multiple exponentiations required for
each round of the ratchet protocol. Hence, it is reasonable to perform this PRF-
based more frequently, than the frequency of performing the asynchronous-
ratchet protocol, with its much higher overhead.
The PRF-ratchet provides additional security for the duration between two
invocations of the asynchronous-ratchet protocol. Namely, the PRF-ratchet
suffices to make it impossible to ‘go back’, i.e., exposure of kiA ,iB [i] does not
expose kiA ,iB [j] for j < i.
From each of these keys kiA ,iB [i], we need to further derive specific keys for
different message-security purposes: encryption from Alice to Bob (ekiA→B A ,iB
[i]),
encryption from Bob to Alice (ekiB→A A ,iB
[i]), authentication of message from
Alice to Bob (akiA→B A ,iB
[i]) and authentication of message from Bob to Alice
(akiB→A
A ,iB
[i]). We leave it to the reader to define the derivation of these different
keys.
The resulting Double-Ratchet Key-Exchange protocol is illustrated in Fig-
ure 6.11, however, this figure should be improved; we leave it here in the hope
that it may provide some help in understanding.
The double-ratchet protocol is the essence of the TextSecure protocol, de-
ployed in popular instant messaging applications, e.g., WhatsApp and Signal.
[TBC]
262
Figure 6.11: The Double-Ratchet Key-Exchange protocol. Figure should be
updated, it does not conform exactly with the notation currently in text (and
other improvements are needed too).
Figure 6.12: The DH-h Public Key Cryptosystem. The private decryption key
dA and random b are random integers less than p − 1. The text in blue is the
same as the two flows of the DH protocol.
they did present the DH key exchange protocol (Figure 6.7). We next show
that a minor tweak allows us to turn the DH key exchange protocol into a
PKC; we accordingly refer to this PKC as the DH PKC, and a variant of it
that also uses a hash function h as the DH-h PKC.
Fig. 6.12 presents the DH-h public key cryptosystem, by slightly changing
the presentation of the DH key exchange protocol (Figure 6.7). Essentially,
instead of Alice selecting random secret a and sending g a mod p to Bob in
the first flow of the DH protocol, we now view g dA mod p as Alice’s public
key eA , and dA is Alice’s private key. To encrypt a message m for Alice, using
her public key eA = g dA mod p, Bob essentially performs his role in the DH
protocol, i.e., selects random random value b ∈ [2, p − 2], and computes the
ciphertext.
263
Figure 6.13: The El-Gamal Public-Key Encryption
This has the disadvantage, that secrecy relies on the (stronger) the Decisional
DH assumption (DDH), rather than on the (weaker) Computational DH as-
sumption (CDH). In fact, if an attacker is able to distinguish between g dA ·b and
a random string, then indistinguishability may not hold for DH PKC. To ad-
dress this, in DH-h we apply a cryptographic, randomness-extracting hash func-
tion h before XORing, i.e., the ciphertext is the pair g b mod p, m ⊕ h(g dA ·b mod p) .
Exercise 6.8. Write formulas for the three functions comprising the DH PKC:
(KGDH (n), E DH , DDH ), and similarly for the DH-h PKC.
264
The correctness property holds since:
y mod p
DdA (x, y) =
xdA mod p
b
m · g dA mod p mod p
= dA
(g b mod p) mod p
m · g b·dA mod p
=
g b·dA mod p
= m
EeEG
A
(m1 · m2 mod p) = (x1 · x2 , y1 · y2 ) mod p (6.14)
265
Tally Decrypt
Alice Bob Cora
server server
eDS eDS eDS
eDS dDS
EeDS (piA )
EeDS (piB )
EeDS (piC )
votes; the server decrypts and then tallies the votes. This system requires
complete trust in the server; in particular, the server can trivially know the
vote of each voter.
To ensure voter anonymity, we separate the two functions of the server and
use two servers: a tally server and a decryption server. We also switch the
order of operations: the encrypted votes are sent first to the tally server, who
aggregates all of them into a single (encrypted) value, and then sent to the
decryption server, who decrypts to produce the final outcome.
The voting process is shown in Fig. 6.14. As shown, each candidate i
is assigned a unique small prime number: pi > 1. Each voter, e.g. Alice,
selects one candidate, say piA , and sends to the tally server EeDS (piA ). The
tally server combines the encrypted votes by computing EeDS (piA · piB · piC ) =
EeDS (piA ) · EeDS (piB ) · EeDS (piC ) and sending it to the decrypt server. The
decrypt server outputs the combined vote piA · piB · piC . By factoring this, we
find how many votes were given to each candidate i.
Let us point out another simple mechanism using multiplicative homomor-
phic encryption, e.g., El-Gamal: re-encryption. Namely, given a ciphertext
c, we can compute another ciphertext c0 such that c and c0 decrypt to the
same value, without knowing the plaintext or the decryption key. To do this,
we first encrypting the message 1, i.e., obtaining (x1 , y1 ) = EeA (1) (suppose
eA is the public key). We then use the homomorphic property to combine
(x1 , y1 ) = EeA (1) with c = (x, y) = EeA (m), thereby computing the new
266
ciphertext c0 = (x0 , y 0 ), which decrypts to the same value as c. Namely,
x0 = x · x1 , y 0 = y · y1 . From the homomorphic property, m = DdA (x0 , y 0 ), since
m = m · 1. Re-encryption is used in different protocols to preserve anonymity.
Notice that the above method of re-encryption of El-Gamal encryption re-
quires use of the public key eA with which the message was encrypted. In
some applications, it is desirable to allow re-encryption without specifying the
public key, e.g., for recipient anonymity. In such case, one can use an elegant
extension called universal re-encryption, which allows re-encryption without
knowledge of the encryption key eA . This is done by appending the encryption
EeA (1) to each ciphertext; see details in [84].
Note also that we only discussed re-encryptions which preserved the same
decryption key. El-Gamal also allows proxy re-encryption, where a proxy is
given a special key, denoted eA→B and computed by Alice, that allows the
proxy to transform ciphertext encrypted to Alice, c = EeA (m), into encryption
of the same message with Bob’s key, c0 = EeB (m). For more details on this
cool mechanism and its applications, see [33].
267
n 1 2 3 4 5 6 7 8 9 10
φ(n) 1 1 2 2 4 2 6 4 6 4
factors? none none none 2·2 none 2·3 none 23 3·3 2·5
Table 6.3: The Euler function φ(n), computed for small integers; see eq. (6.17).
The public key of RSA is < e, n > and the private key is < d, n >, since
the modulus n is required for both encryption and decryption. However, we -
and others - often abuse notation and refer to the keys simply as e and d.
Notice that exactly the same process is used for key generation for RSA
signature schemes (discussed below), except that we denote the public verifica-
tion key by v (instead of public encryption key e) and the private signing key
by s (instead of private deryption key d).
268
1)(q −1); you can see it in the table, but it is not hard to confirm that this holds
in general. This is the reason for us using φn = φ(n) = φ(p · q) = (p − 1)(q − 1)
in the RSA key generation process.
We now present Euler’s theorem:
Theorem 6.1 (Euler’s theorem). For any co-prime integers m, n holds mφ(n) =
1 mod n.
We will not prove the theorem; interested readers can find proofs in many
texts. However, let us use the theorem, to explain RSA’s correctness, i.e., why
Dd (Ee (m)) = m.
Our explanation, below, uses Euler’s theorem, with m being the message
and n being the RSA modulus. However, the theorem requires m and n to be
co-primes. Does this hold?
Recall that the message m may be any positive integer s.t. 1 < m < n − 1.
How many of these possible messages - i.e., integers smaller than n - are co-
prime to n? Why, this is exactly the definition of φ(n), which we know to be:
φ(n) = φ(p · q) = (p − 1) · (q − 1) = n − q − p + 1.
So most possible messages m are indeed co-prime to to n - but p + q − 2
messages are not co-prime to n. Our explanation would not hold for these val-
ues. We assure the reader, however, that correctness holds also for these values;
it simply requires a slightly more elaborate argument. The argument usually
uses the Chinese Remainder Theorem, and can be found in many textbooks
on cryptography (and number theory). We present only the argument for the
case that m and n are co-prime (gcd(m, n) = 1).
Recall that ed = 1 mod φ(n), i.e., for some integer i holds ed = 1 + i · φ(n).
Hence:
med mod n = m1+i·φ(n) mod n
i
= m · mφ(n) mod n
b
Recall Eq. (2.7) : ab mod n = (a mod n) mod n. Hence, by substitut-
ing mφ(n) = 1 mod n (Euler’s theorem), we have:
i
med mod n = m · mφ(n) mod n mod n = m · 1i = m (6.18)
269
with such extremely-small e; in particular, if m is also small, in particular, if
c = me < n (without reducing mod n), then we can efficiently decrypt by
1/e
taking the e-th root: c1/e = (me ) = m. This particular concern is rela-
tively easily addressed by padding, as discussed below; but there are several
additional attacks on RSA with very-low exponent e, in particular in the case
where sending the same message, or ‘highly related’ messages, to multiple re-
cipients. These attacks motivate (1) the use of padding to break any possible
relationships between messages (see §6.6.4), as well as (2) the choice of slightly
larger e, such as 17 or even 216 +1 = 65537. The reason to choose these specific
primes is that exponentiation requires only 5 or 17 multiplications, respectively;
see next exercise.
Exercise 6.10. Given integer m, show how to compute m17 in only five mul-
16
tiplications, and m2 +1 in only 17 multiplications.
Hint: use the following idea: compute m8 with three multiplications by
2 2
m8 = m2 .
270
RSA Security.
Another question is the relationship between the RSA assumption and the
security of RSA as used as a public key cryptosystem (PKC). Trivially, if the
RSA assumption is false, then RSA is not a secure cryptosystem - definitely
not the ‘textbook RSA’ defined above.
However, what we really care about is the reverse direction, i.e., having a
cryptosystem which is secure assuming that the RSA assumption holds. This
does not hold for textbook RSA. There are a few problems we should address,
to build a secure PKC from RSA:
271
Figure 6.15: RSA with OAEP (Optimal Asymmetric Encryption Padding).
Figure ?? illustrates the process of signing a message (by Alice) and valida-
tion of the signature (by Bob). We denote Alice’s keys by A.s (for the private
signing key) and A.v (for the public validation key); note that this figure as-
sumes that Bob knows A.v - we later explain how signatures also facilitate
distribution of public keys such as A.v.
272
Signature schemes have two critical properties, which make them a critical
enabler to modern cryptographic systems. First, they facilitate secure remote
exchange in the MitM adversary model; second, they facilitate non-repudiation.
We begin by briefly discussing these two properties.
273
validate Alice’s signature over a message m, as shown in Fig. 3.3. Note that
this requires Bob to trust this CA and to have its validation key, CA.v.
This discussion of certificates is very basic; more details will be provided in
chapter 8, which discusses public-key infrastructure and the TLS/SSL protocol.
274
Above, s is the private signature key, and v is the public validation key. The
keys are generated using the RSA key generation process; see subsection 6.6.1
In practice, as discussed in §4.2.6, input messages are of variable length -
and rarely shorter than modulus. Hence, real signatures apply the Hash-then-
Sign (HtS) paradigm (??), using some cryptographic hash function h, whose
range is contained in (1, n − 1), i.e., allowable input to the RSA function.
Applied to the RSA FIL signature as defined above, we have the signature
scheme (S RSA,h , V RSA,h ), defined as follows:
s
SsRSA,h (m) = ([h(m)] mod n, m)
VvRSA,h (σ, m) = {m if h(m) = σ v mod n, error otherwise}
275
For validation to be meaningful, there should be only a tiny subset of the
integers x s.t. xv mod n would be in the range of R, i.e., the result of the
mapping of some message m. Since there are at most n values of xv mod n to
begin with, this means that the range of R, i.e., the set of legitimate messages,
must be tiny in comparison with n - which means that the message space should
be really tiny.
In reality, messages being signed are almost always much longer than the
tiny message space available for signatures with message recovery. Hence, the
use of this method is almost non-existent. In fact, our description of signature
schemes (Figure 3.2) assumed that the message is sent along with its signature,
i.e., our definition did not even take into consideration schemes like this, which
avoid sending the original message entirely.
Note that RSA signatures with message recovery are often a cause of con-
fusion, due to their syntactic similarity to RSA encryption. Namely, you may
come across people referring to the use of ‘RSA encryption with the private
key’ as a method to authenticate or sign messages. What these people really
mean is to the use of RSA signatures with message recovery. We caution to
avoid such confusing use of terminology; RSA signatures are usually used with
appendix, but even in the rare cases of using RSA signatures with message
recovery, RSA signing is not the same as encryption with the private key!
276
6.8 Additional Exercises
Exercise 6.11. The Diffie-Hellman protocol is a special case of a key ex-
change protocol, defined by the pair of functions (KG, F ), as introduced in
subsection 6.1.3.
1. Present the Diffie-Hellman protocol as a key exchange protocol, i.e., define
the corresponding (KG, F ) functions.
2. We presented two assumptions regarding the security of the DH protocol:
the computational-DH (CDH) assumption and the decisional-DH (DDH)
assumption. Show that one of these assumption does not suffice to ensure
key-indistinguishability? What about the other one?
Exercise 6.12. It is proposed that to protect the DH protocol against an im-
poster, we add an additional ‘confirmation’ exchange after the protocol termi-
nated with a shared key k = h(g ab mod p). In this confirmation, Alice will send
to Bob M ACk (g b ) and Bob will respond with M ACk (g a ). Show the message-
flow of an attack, showing how an attacker (Monster) can impersonate as Alice
(or Bob). The attacker has ‘MitM capabilities’, i.e., it can intercept messages
(sent by either Alice or Bob) and inject fake messages (incorrectly identifying
itself as Alice or Bob).
Exercise 6.13. Suppose that an efficient algorithm to find discrete log is found,
so that the DH protocol becomes insecure; however, some public-key cryptosys-
tem (G, E, D) is still considered secure, consisting of algorithms for, respectively,
key-generation, encryption and decryption.
1. Design a key-agreement protocol which is secure against an eavesdropping
adversary, assuming that (G, E, D) is secure (as a replacement to DH).
2. Explain which benefits the use of your protocol may provide, compared
with simple use of the cryptosystem (G, E, D), to protect the confiden-
tiality of messages sent between Alice and Bob against a powerful MitM
adversary. Assume Alice and Bob do have known public keys.
Exercise 6.14. Assume that there is an efficient (PPT) attacker A that can
find a specific bit in g ab mod p, given only g a mod p and g b mod p. Show
that the DDH assumption does not hold for this group, i.e., that there is an
efficient (PPT) attacker A that can distinguish, with significant advantage over
random guess, between g ab mod p and between g x for x taken randomly from
[1, . . . , p − 1].
Exercise 6.15. It is frequently proposed to use a PRF as a Key Derivation
Function (KDF), e.g., to extract a pseudo-random key k 0 = P RFk (g ab mod p)
from the DH exchanged value g ab mod p, where k is a uniform random key
(known to attacker). Show a counterexample: a function f which is a secure
PRF, yet insecure if used as a KDF. For your construction, you may use a
secure PRF f 0 .
277
Figure 6.16: How not to ensure resiliency - illustration for Ex. 6.16
Exercise 6.16 (How not to ensure resilient key exchange). Fig. 6.16 illustrates
a slightly different protocol for using authenticated DH to ensure resilient key
exchange. Present a sequence diagram showing that this protocol is not secure.
Hint: show how an attacker is able to impersonate as Alice, without know-
ing any of Alice’s previous keys; at the end of the handshake, Bob will believe
it has exchanged key k with Alice, but the key was actually exchanged with
the attacker.
Exercise 6.17 (Insecure variant of authenticated DH). The protocol in Fig. 6.17
is a simplified version of the authenticated DH protocol of Fig. 6.8.
1. Show a sequence diagram for an attack showing that this variant is inse-
cure. Hint: your attack may take advantage of the fact that there is no
validation of the incoming flows, except for validation of the MAC values.
2. Explain why this attack does not apply to the ratchet protocol (Fig. ??).
278
Figure 6.18: Insecure ‘robust-combiner’ authenticated DH protocol, studied in
Exercise 6.18
2. Show a simple fix that achieves the goal (robust combiner authenticated
DH protocol).
Exercise 6.20. Assume it takes 10 seconds for any message to pass between
Alice and Bob.
1. Assume that both Alice and Bob initiate the ratchet protocol (Fig. ??)
every 30 seconds. Draw a sequence diagram showing the exchange of
messages between time 0 and time 60seconds; mark the keys used by each
of the two parties to authenticate messages sent and to verify messages
received.
2. Repeat, if Bob’s clock is 5 seconds late.
3. Repeat, when using the ‘double-ratchet’ variant, where both parties per-
form the PRF derivation whenever 10 seconds passed since last changing
the key.
Exercise 6.21. In the ratchet protocol, as described (Fig. ??), the parties
derive symmetric keys ki,j and use them to authenticate data (application)
messages they exchange between them, as well as the first message of the next
handshake.
1. Assume a chosen-message attacker model, i.e., the attacker may define
arbitrary data (application) messages to be sent from Alice to Bob and
279
Figure 6.19: Authenticated DH with changing Master Keys (Ex. 6.24)
vice verse at any given time, and ‘wins’ if a party accepts a message never
sent by its peer (i.e., that message passes validation successfully). Show
that, as described, the protocol is insecure in this model.
2. Propose a simple, efficient and secure way to avoid this vulnerability, by
only changing how the protocol is used - without changing the protocol
itself.
Exercise 6.22. The DH protocol, as well as the ratchet protocol (as described
in Fig. ??), are designed for communication between only two parties.
1. Extend DH to support key agreement among three parties.
2. Similarly extend the ratchet protocol.
Exercise 6.23. In the double-ratchet protocol, as described in class, at the
t
beginning of ‘turn’ t in a party, the party uses the ‘current key’ ki,j to derive
t+1 t+1
two keys: k , to be used at the next ‘turn’, and k , used to authenticate
i,j
d
i,j
and encrypt messages sent and received between the peers.
t+1
1. Explain why kd
i,j is used to authenticate and encrypt, rather than using
t+1
ki,j .
t+1
2. Explain how to use kd
i,j (to authenticate and encrypt messages sent be-
tween the peers).
280
Figure 6.20: Insecure variant of Ratchet DH Protocol (Ex. 6.25)
• What are the days that the attacker can decrypt (know) their messages,
upon day ten?
• Show a sequence diagram of the attack, and list every calculation done by
the attacker. For every value used by the attacker, explain why/how that
value known to the attacker.
Exercise 6.25 (Insecure variant of Ratchet DH). Figure 6.20 shows a vulnera-
ble variant of the Ratchet DH protocol, using a (secure) pseudorandom function
f to derive the session key. Assume that this protocol is run daily, from day
i = 1, and where k0 is a randomly-chosen secret initial key, shared between
Alice and Bob; messages on day i are encrypted using key ki . An attacker
can eavesdrops on the communication between the parties on all days, and on
days 3, 6, 9, . . . it can also spoof messages (send messages impersonating as ei-
ther Alice or Bob), and act as Monster-in-the-Middle (MitM). On the fifth day
(i = 5), the attacker is also given the initial key k0 .
Exercise 6.26 (Improving security of Sync-Ratchet). Alice and Bob use low-
energy devices to communicate. To ensure secrecy, they run, daily, the Sync-
Ratchet protocol (Fig. 5.12), but want to further improve security, by changing
keys every hour, but avoiding additional exponentiations. Let kij denote the key
they share after the j th hour of the ith day, where ki0 = ki (the key exchanged
in the ‘daily exchange’ of Fig. 5.12).
1. Show how Alice and Bob should set their hourly shared secret key kij = .
2. Define the exact security benefit achieved by your solution.
Hint: Compute kij = P RFkj−1 (‘next’).
i
281
Exercise 6.27. We saw that El-Gamal encryption (Eq. (6.12) may be re-
randomized, using the recipient’s public key, and mentioned that this may be
extended into an encryption scheme which is univerally re-randomizable, i.e.
where re-randomization does not require the recipient’s public key. Design such
encryption scheme. Hint: begin with El-Gamal encryption, and use as part of
the ciphertext, the result of encrypting the number 1.
Exercise 6.28. Design a simple and efficient protocol allowing a set of users
{1, . . . , n} to exchange messages securely among them, i.e., ensuring confiden-
tiality, authenticity and integrity of the messages. Your design may assume
that users know the public keys of each other; furthermore, you may assume
that each user i has two pairs of public-private keys: an encryption-decryption
key-pair (e(i), d(i)) and a signing-verifying key-pair (s(i), v(i)). Assume that
the public keys e(i), v(i) of every user i, are known to all users. Your descrip-
tion should be very clear, well-defined and concise, but can be high-level, e.g.,
use (a, b, c) ← α to denote ‘splitting’ a tuple α = (a, b, c) into its components.
Please read all three parts below before answering; the third part is an addi-
tional requirement, that you may meet already in answer of parts 1 and 2, and
this may save your time when answering part 3.
1. A send function (process) that receives message m, receiver identifier i, a
sender identifier j and the sender’s private keys d(j), s(j), and produces
a ‘ciphertext’ c to be sent to i, i.e., c = sendj,d(j),s(j) (m, i).
2. A receive function (process) that receives ‘ciphertext’ c, receiver identifier
i, and the receiver’s private keys d(i), s(i), and produces message m and
sender identifier j, if c was output of send executed by j on message m
with receiver i, and an error indicator ⊥ otherwise.
3. Another goal is to prevent recipients from proving to somebody else that
the sender sent the message (as when showing signed message). Is this
provided by your solutions? Why? If not, present processes for sending
and receiving to support this goal.
Exercise 6.29. The RSA algorithm calls for selecting e and then computing
d to be its inverse ( mod φ(n)). Explain how the key owner can efficiently
compute d, and why an attacker cannot do the same.
Exercise 6.30. The RSA key generation algorithm requires the selection of
two large primes p, q. Would it be secure to save time by using p = q? Or first
choose p, then let q be the next-largest prime?
Exercise 6.31 (Tiny-message attack on textbook RSA). We discussed that
RSA should always be used with appropriate padding, and that ‘textbook RSA’
(no padding) is insecure, in particular, is not probabilistic so definitely does not
ensure indistinguishability.
1. Show that textbook RSA may be completely decipherable, if the message
length is less than |n|/e. (This is mostly relevant for e = 3.)
282
2. Show that textbook RSA may be completely decipherable, if there is only
a limited set of possible messages.
3. Show that textbook RSA may be completely decipherable, if the message
length is less than |n|/e, except for a limited set of additional (longer)
possible messages.
Exercise 6.32. Consider the use of textbook RSA for encryption (no padding).
Show that it is insecure against a chosen-ciphertext attack.
Exercise 6.33. Consider a variation of RSA which uses the same modulus N
for multiple users, where each user, say Alice, is given its key-pair (A.e, A.d)
by a trusted authority (which knows the factoring of N and hence φ(N ). Show
that one user, say Mal, given his keys (M.e, M.d) and the public key of other
users say A.e, can compute A.d. Note: recall that each users’s private key is
the inverse of the public key ( mod φ(n), e.g., M.e = M.d−1 mod φ(n).
Exercise 6.34. Public-key algorithms often use term ‘public key’ to refer to
only one component of the public key. For example, with RSA, people often
refer to e as the public key, although the actual RSA public key consists of the
pair (e, n), i.e., also includes the modulus n.
Consider an application which receives an RSA signature (eA , n), where eA
is the same as in the public key (eA , nA ) of user Alice, but n 6= nA ; however,
the application still concludes that this is a valid signature by Alice. Show how
this allows an attacker to trick the recipient into believing - incorrectly - that
an incoming message (sent by the attacker) was signed by Alice.
Note :similar situation exists with other public key algorithms, e.g., elliptic
curves, where the public key consists of a specification of a curve and of a
particular ‘public point’ on the curve, but often people refer only to the point
as if it is the (entire) public key. In particular, this led to the ‘Curveball’
vulnerability in the Windows certificate-validation mechanism [154], which was
due to validation of only the ‘public point’ and use of the curve selected by the
attacker.
Exercise 6.35. You are given textbook-RSA ciphertext c = 281, with public
key e = 3 and modulus n = 3111. Compute the private key d and the message
m = cd mod n.
Exercise 6.36. Consider the use of textbook RSA for encryption as well as for
signing (using hash-then-sign), with the same public key e used for encryption
and for signature-verification, and the same private key d used for decryption
and for signing. Show this is insecure against chosen-ciphertext attacks, i.e.,
allows either forged signatures or decryption.
Exercise 6.37. The following design is proposed to send email while preserv-
ing sender-authentication and confidentiality, using known public encryption
283
and verification keys for all users. Namely, assume all users know the pub-
lic encryption and verification keys of all other users. Assume also that all
users agree on public key encryption and signature algorithms, denoted E and
S respectively.
When one user, say Alice, wants to send message m to another user, say
Bob, it computes and sends: c = EB.e (m + + ‘A’ ++ SA.s (m)), where B.e is Bob’s
public encryption key, A.s is Alice’s private signature key, and ‘A’ is Alice’s
(unique, well-known) nickname, allowing Bob to identify her public keys. When
Bob receives this ciphertext c, it first decrypts it, which implies it was sent to
him. He then identifies by the ‘A’ that it was purported to be sent by Alice.
To validate this, he looks up Alice’s public verification key A.v, and verifies the
signature.
1. Explain how a malicious user Mal can cause Bob to display a message
m as received from Alice, although Alice never sent to Bob that mes-
sage. (Alice may have sent a different message, or sent that message to
somebody else.)
2. Propose a simple, efficient and secure fix.
1. It is proposed that Alice will select a random key k and send to Bob the
triplet: (cK , cM , σ) = (EB.e (k), k⊕m, SignA.s (‘Bob0 +
+k⊕m)). Show this
design is insecure, i.e., a MitM attacker may either learn the message m
or cause Bob to receive a message ‘from Alice’ - that Alice never sent.
2. Propose a simple, efficient and secure fix. Define the sending and receiv-
ing process precisely.
3. Extend your solution to allow prevention of replay (receiving multiple
times a message sent only once).
284
Chapter 7
285
Figure 7.1: Overview of the use of TLS/SSL, with server public key certificate,
to secure the connection between browser and website.
ing SSL/TLS. On the one hand, being such an important, widely-used and
widely-studied protocol, implies that this is probably the most important and
most interesting protocol to study. On the other hand, this also means that
there is an excessive wealth of important and interesting information - indeed,
entire books were dedicated to cover SSL/TLS, e.g., [137, 143], and even they
do not cover all aspects. We have tried to maintain a reasonable balance; how-
ever, there were many hard choices and surely there is much to improve; as in
other aspects, your feedback would be appreciated.
1. The user (Alice) enters the desired Universal Resource Locator (URL);
in the given example, the URL is [Link] The URL consists
of the protocol (https) and the domain name of the desired web-server
([Link]); in addition, the path may contain identification of a specific
object in the server. In this example, Alice does not specify any specific
object; and the browser considers this a request for the default object
[Link]. The choice of the https protocol, instructs the browser to
286
open a secure connection, i.e., send the HTTP requests over an SSL/TLS
session, rather than directly over an unprotected TCP connection. Note
that the request may be specified in one of three ways: (1) by the user
‘typing’ the URL into the address-bar of the browser, i.e., ‘manually’, (2)
‘semi-automatically’, by the user clicking on an hyperlink which specified
this URL, or (3) ‘fully automatically’, by a script running in the browser;
scripts can instruct the browser to request different objects.
2. This step is used, if necessary, to resolve the Internet-Protocol (IP) ad-
dress of the domain name of the server ([Link]). The step is not
necessary, and hence skipped, if this IP address is already known (e.g.,
cached from previous connection). To find the IP address, the browser
sends a resolve request to a Domain Name System (DNS) server, spec-
ifying the domain ([Link]). The server responds with the IP address
of the [Link] domain, e.g., [Link].
3. The browser sends the TCP SYN message to the web-server’s IP address
([Link]), and the server responds with the TCP SYN+ACK message,
thereby opening the TCP connection between the browser and the web-
server.
4. The browser sends the TLS Hello message, and the [Link] responds
with its public key (pk) and its certificate, linking the public key pk to
the domain name [Link], and signed, much in advance, by a trusted
certificate authority (CA). The client validates pk based on the certificate,
and then uses the public key pk to encrypt a random, secret shared key.
These steps are referred to as the TLS handshake.
5. Next, the client and server communicate in a TLS session, sending mes-
sage back and forth. This includes sending GET, POST and other re-
quests, from the browser to the web-server, and receiving the responses.
The figure shows some typical flows.
6. Finally, the browser displays the page to the user (Alice), together with
a few security indicators such as the URL and the padlock.
287
Goal SSLv2 SSLv3 TLS1.0-1.2 TLS1.3
Key exchange
Server authentication
Client authentication
Connection integrity
Confidentiality
Cipher agility #
G
PFS #
Table 7.1: TLS/SSL: security goals vs. versions: : achieved , #G: achieved
partially, #: not achieved. Note that known attacks and vulnerabilities, may
cause failure to achieve a goal (even where marked here as ‘achieved’) - we
present several of these.
288
Robust cryptography. Cipher agility helps us to recover after a possible
cryptographic vulnerability is identified; until then, the system could be vul-
nerable. In contrast, cryptographic robustness requires the protocol to ensure
its security properties, even while some of its cryptographic modules or as-
sumptions are weak. In particular, the protocol should maintain security even
if its sources of randomness are imperfect, and when one of its cryptographic
algorithms (‘building blocks’) is vulnerable, i.e., deploy robust combiner design.
Cryptographic robustness was not defined as an explicit goal in SSL/TLS, how-
ever, there have been several elements of robust cryptographic designs since
SSLv3.
289
TLS Handshake HTTPS ...
HTTP ...
TLS record
TCP sockets API
TCP
IP
Figure 7.2: Placement of TLS/SSL in the TCP/IP protocol stack. The TL-
S/SSL record protocol (in green) The TLS handshake protocol is marked in
green; it establishes keys for, and also uses, the TLS record layer protocol (also
in green). We mark in yellow, the HTTPS protocol, and other application pro-
tocols that use the TLS/SSL record protocol. Application protocols that do not
use TLS/SSL for security, including the HyperText Transfer Protocol (HTTP),
are marked in pink. These protocols, as well as TLS/SSL itself, all use the TCP
protocol, via the sockets library layer. TCP ensures reliable communication,
on top of the (unreliable) Internet Protocol (IP).
Ease of deployment and use. Finally, the success and wide-use of the
SSL/TLS protocols are largely due to their ease of deployment and usage. As
shown in Figure 7.2, the TLS/SSL protocol is typically implemented ‘on top’
of the popular TCP sockets API, and then used by applications, directly or via
the HTTPS or other protocols. This architecture makes it easy to install and
use SSL/TLS, without requiring changes to the operating-system and kernel.
This is in contrast to some of the other communication-security mechanisms, in
particular the IPsec protocol [60,74], which, like TLS, is also an IETF standard.
290
Figure 7.3: Phases of TLS/SSL connection. The black flows (Syn+Ack and
later Fin+Ack) are the TCP connection setup and tear-down exchanges, re-
quired to ensure reliability. The fuchsia flows represent the TLS/SSL hand-
shake; notice there are often more than the three shown. The blue flows rep-
resent the data transfer, protected using TLS/SSL record layer; and the red
flows represent the TLS/SSL connection tear-down exchange.
291
Figure 7.4: The SSL/TLS record layer protocol.
292
Client C Server S ([Link])
Client hello: client version (vC ), client random (rC )
Server hello: server random (rS ) and certificate: SCA.s (S.e, [Link], . . .)
Figure 7.5: ‘Basic’ SSLv2 handshake. The client selects randomly a shared
master key kM , encrypts it using RSA encryption with the server’s public
key S.e, and sends to the server. The client key kC and server key kS are
derived from the master key kM and the randoms rC , rS using the M D5 crypto-
hash, see Eqs. (7.1,7.2). This ‘basic’ handshake does not include ciphersuite
negotiation, session resumption and client authentication, which we illustrate
in the following figures.
293
The public key encryption of kM is the most computationally-intensive
operation by the client; therefore, it is desirable for the protocol to be secure
even if the client reuses the same master key kM and its encryption ES.e (kM ) in
multiple connections, assuming that the master key was not exposed. To ensure
this, the client and server each selects and exchange a random ‘nonce’, rC and
rS , respectively, and derive the cryptographic keys to protect communication in
the connection from the master key together with both these random numbers.
The use of both random numbers rC and rS is required, to ensure that a
different key is used in different connections. This is essential, to prevent replay
of messages - from either client or server; see exercise 7.1.
Exercise 7.1. For costs and energy savings, IoT devices often have limited
computation power, and often do not have a source of random bits, and no
non-volatile memory. Consider such an IoT-lock, used to lock/unlock a car or
a door. The IoT-lock is implemented as a simple web server, and uses SSLv2
to authenticate the client requests. Specifically, to unlock (or lock), the client
sends to the IoT-lock the corresponding command (‘unlock’ or ‘lock’), together
with a ‘secret password/code’, say consisting of 20 alphanumeric characters.
Assume that the IoT-lock uses the same server-random string rS in all con-
nections, selected randomly upon initialization of the IoT-lock. Show how a
message sequence diagram demonstrating how a MitM may trick the IoT-lock
into unlocking, by replaying messages from a legitimate connection between the
client and the IoT-lock. Note: this attack works for any version of SSL/TLS,
for implementations which reuse rS .
In fact, in SSLv2, the parties derive and use two keys from kM and the
random nonces rC , rS : the client key kC , used by the client to protect messages
it sends, and the server key kS , used by the server to protect messages it sends.
These are derived as follows:
kC = M D5(kM +
+ “1” +
+ rC +
+ rS ) (7.1)
kS = M D5(kM +
+ “0” +
+ rC +
+ rS ) (7.2)
294
Client Server
Client hello: client random (rC ), ID
Figure 7.6: SSLv2 handshake, with ID-based session resumption. The client-
hello includes session-ID, received from server in a previous connection. If
the server does not have the (ID, kM ) pair, then it simply ignores the ID
and sends server-hello, as in the ‘basic’ handshake (Fig.7.5). However, if the
server still has (ID, kM ), from a previous connection, then it reuses kM , i.e.,
‘resumes the session’, and derives new shared keys from it (using Eqs. (7.1,7.2).
This avoids the public key operations, encryption by client and decryption by
server of master key kM , as well as the overhead of transmitting the certificate
SCA.s (S.e, [Link]).
295
Client Server
Client hello: version (vC ), client random (rC ), cipher-suites
Figure 7.7: SSLv2 handshake, with ciphersuite negotiation. Both client and
server indicate the cipher-suites they support in their respective hello messages;
then, the client specifies its preferred cipher-suite in the key exchange message
(this aspect was modified in later versions).
servers, or to ensure that a client will contact the same machine each time - a
difficult requirement that sometimes is infeasible. These drawbacks motivate
the adoption of alternative methods for session resumption, most notably, the
session-token mechanism that we discuss later (and which requires the use of
TLS).
Note that the session resumption protocol is one reason for requiring the
use of client and server random numbers; see the following exercise.
Exercise 7.2. Consider implementations of the SSLv2 protocol, where the (1)
client random or (2) server random fields are omitted (or always sent as a fixed
string). Show a message sequence diagram for two corresponding attacks, one
allowing replay of messages to the client, and one allowing replay of messages
to the server.
296
Client Server
Client hello: client random (rC ),
cipher-suites=RC4 128 MD5, RC4 40 MD5, DES 64 MD5
Figure 7.9: The SSLv2 downgrade attack. Server and client end up using master
key kM with only 40 secret bits, which the attacker can find by exhaustive
search. Attacker does not need to find key during handshake; parties use
the 40-bit key for entire connection, attacker may even just record ciphertexts
and decrypt later. Note that while SSLv2 is not used anymore, we later discuss
version-downgrade-attacks that trick the server and/or client into using SSLv2,
exposing them to this (and other) attacks on SSLv2.
algorithm, but with three different ciphers (128-bit RC4, 40-bit RC4 and 64-bit
DES), and the server supports two ciphers (128-bit RC4 and 40-bit RC4).
In SSLv2, the finish messages only confirm that the parties share the same
server and client keys (KS and KC , respectively), but not the integrity of the
rest of the hello messages - in particular, there is no authentication of the
ciphersuites sent by server and client. This allows simple downgrade attacks,
removing ‘strong’ ciphers from the list of ciphers supported by client and/or
server. Figure 7.9 illustrates how a Monster-in-the-Middle (MitM) attacker
may perform this downgrade attack on SSLv2; in the example illustrated, the
attacker removes the ‘regular-version’ 128-bit RC4 encryption from the list of
ciphers supported by the client, leaving only the weaker ‘export-version’ 40-bit
RC4 encryption. Note that the SSLv2 downgrade attack is even simpler than
the downgrade attack on GSM (§5.5.3).
297
Client Server
Client hello: version (vC ), random (rC ), cipher-suites, [extensions,]
Figure 7.10: The ‘basic’ RSA-based handshake, for SSLv3 and TLS 1.0, 1.1
and 1.2. The master key kM is computed, as in Eq. (7.3), from the pre-master
key kP M , which is sent in the client key exchange message (third flow). Notice
that the client key exchange message simply contains encryption of kP M , i.e.:
ES.e (kP M )).
Improved key derivation and kP M (§7.3.1): the key derivation process was
significantly overhauled between SSLv2 and the later versions, beginning
298
with SSLv3. In particular, the client-key-exchange message of the basic
exchange includes the premaster key kP M , from which the protocol de-
rives the master key kM . As before, the master key kM is used to derive
the keys for the record-protocol, used to encrypt and authenticate data
on the connection.
Improved negotiation and handshake integrity (§7.3.2): from SSLv3, the
finish message authenticates all the data of all previous flows of the hand-
shake; this prevents the SSLv2 downgrade attack (Figure 7.9). TLS, and
to lesser degree SSLv3 too, also improve other aspects of the negotiation,
in particular, support for extensions, negotiation of the protocol version,
and negotiation of additional mechanisms, including key-distribution and
compression.
DH key exchange and PFS (§7.3.4): From SSLv3, the SSL/TLS proto-
cols supports DH key exchange, as an alternative or complementary mech-
anism to the use of RSA-based key exchange (the only method in SSLv2).
The main advantage is support for Perfect forward secrecy (PFS).
Session-Ticket Resumption (§7.3.5): an important TLS extension allows
Session-Ticket Resumption, a new mechanism for session resumption.
Session-ticket resumption allows the server to avoid keeping state for
each session, which is often an important improvement over the ID-based
session resumption mechanism supported already in SSLv2 (but which
requires servers to maintain state for each session).
The main motivation for this additional step is that the value exchanged
between the parties, may not be a perfectly-uniform, secret binary string, as
required for a cryptographic key. When exchanging the shared key using the
‘basic’, RSA-based handshake, this may happen when the client does not have
a sufficiently good source of randomization, or if the client simply resends the
same encrypted premaster key as computed and used in a previous connection
299
to the same server - not a recommended way to use the protocol, of course, but
possibly attractive for some very weak clients.
When exchanging the shared key using the DH protocol, there is a different
motivation for using this additional derivation step, from premaster key to
master key. Namely, the standard DH groups are all based on the use of a safe
prime; as we explain in §6.2.3, this implies that we rely on the Computational
DH assumption (CDH), and that the attacker may be able to learn at least
one bit of information about the exchanged key. By deriving the master key
from the premaster key, we hope to ensure that the entire master key would
be pseudorandom.
300
Table 7.2: Derivation of connection keys and IVs, in SSLv3 to TLS1.2
shake. Many of these changes were required to deal with vulnerabilities and
attacks exploiting weaknesses of the negotiation mechanisms, beginning with
the simple downgrade attack on SSLv2 (Figure 7.9); others were required to
add additional flexibility and options, often required for critical security or
functionality features; some examples follow.
We begin by discussing a change which is rather insignificant, yet, it is
visible already by comparing the ‘basic’ handshake flows of the two versions:
Figure 7.10 (for SSLv3 to TLS 1.2) vs. Figure 7.5 (the corresponding ‘basic’
handshake of SSLv2). Namely, in both versions, the client-hello message in-
cludes the list of cipher-suites supported by the client. However, in SSLv2,
the server responds with the subset of this list which the server also supports
(server’s cipher-suites), and the client chooses its preferred cipher-suite from
this list. In contrast, from SSLv3, the server responds, in server-hello, with its
choice of the cipher-suite, rather than sending its own cipher-suite list to let the
client decide, as in SSLv2. The goal of this change appears merely to simplify
the handshake a bit, since, in practice, SSLv2 servers almost always sent only
one cipher-suite back, the one they most preferred among these offered by the
client, making it redundant for the client to send back the same value.
With this out of the way, let us consider the other changes, which, in
contrast, have significant security impact.
301
vS = P RFkM (‘server finished’ +
+ h(handshake-messages)) (7.6)
The equations use a cryptographic hash function h, whose definition differs
between the different versions. Specifically, in TLS 1.2, the hash function is
implemented simply as SHA-256, i.e., h(m) = SHA 256(m). The TLS 1.0 and
1.1 design is more elaborate, and follows the ‘robust combiner for MAC’ design
of §3.6.2; specifically, the hash is computed by concatenating the results of
two cryptographic hash functions, M D5 and SHA1, as: h(m) = M D5(m) + +
SHA1(m). SSLv3 also similarly combines MD5 and SHA1, however, there the
combination is in the computation of P RF itself; details omitted.
rigid.
302
risk, while still allowing clients running new versions of TLS to interact with
servers running older versions?
The standard solution is the Signaling Cipher Suite Value (SCSV) cipher-
suite, specified in RFC 7507 [131]. Clients that support SCSV, first try to
connect to the server using their current TLS version - no change from clients
not supporting SCSV. The difference is only when this initial connection fails,
and the client decides to try the ‘downgrade dance’, to support connections
with servers supporting (only) older versions of TLS/SSL.
In these ‘downgrade dance’ handshakes, the client adds a special ‘cipher
suite’ to its list of supported cipher suites, sent as part of the ClientHello
message. The special ‘cipher suite’ is called TLS FALLBACK SCSV, and is
encoded by a specific string. Unlike the original (and main) goal of the cipher
suites field, the SCSV is not an indication of cryptographic algorithms sup-
ported by the client. Instead, the existence of SCSV indicates to the server,
that this handshake message is sent as part of a downgrade dance by the client,
i.e., that the client supports a higher version than the one specified in the cur-
rent handshake. If the server receives such handshake, and supports a higher
version of the protocol itself, this would indicate an error or attack, as this
client and server should use the higher version. Therefore, in this case, the
server responds with an appropriate indication to the client.
This use of the cipher-suites fields for signaling the downgrade dance is a
‘hack’ - it is not the intended, typical use of this field. A ‘cleaner’ alternative
would be to achieve similar signaling using a dedicated extension mechanism;
later in this section, we describe the TLS extension mechanism, which could
have been used for this purpose. We believe that the reason that SCSV was
defined using this ‘hack’ (encoding of a non-existent cipher suite) rather than
using an appropriate TLS extension, was the desire to support downgrade
dance to older versions of the TLS/SSL protocol, that do not support TLS
extensions.
303
HTTPS to HTTP). This attack is referred to as SSL-Stripping, and was first
presented by Marlinspike [125].
The best defense against this kind of attack, is for the browsers to detect or
prevent HTTP hyperlinks to a website which always uses (or offers) HTTPS
connections. The standard mechanism to ensure that is the HSTS (HTTP
Strict Transport Security) policy, defined in RFC 6797 [97]. The HSTS policy
indicates that a particular domain name (of a web server), should be used only
via HTTPS (secure) connections, and not via unprotected (HTTP) connec-
tions. HSTS is sent as an HTTP header field (Strict-Transport-Security), in
an HTTP response sent by the web server to the client.
The HSTS policy specifies that the specific domain name, and optionally
also subdomains, should always be connected using HTTPS, i.e., a secure con-
nection. Specifically,
1. The browser should only use secure connections to the server; in partic-
ular, if the browser receives a request to connect to the server using the
(unprotected) HTTP protocol, the browser would, instead, connect to
the server using the HTTPS (protected) protocol, i.e., using HTTP over
SSL/TLS.
2. The browser should terminate any secure transport connection attempts
upon any secure transport errors or warnings, e.g., for use of invalid
certificate.
Caching - max-age: The HSTS header field has a parameter called max-
age, which defines a period of time during which the browser should
‘remember’ the HSTS directive, i.e., keep it in cache. Any connection
within this time, would be protected by HSTS. This works if the browser
previously had a secure connection with the site, and received the HSTS
header, before the amount of time specified in max-age. This motivates
the use of a large value for max-age; however, notice that if a domain
must move back to HTTP for some reason, or there are failures in the
secure connection attempts for some reason, e.g., expired certificate, then
the site may be unreachable for max-age time units.
Pre-loaded HSTS policy: The browser maintains a list of HSTS domains
which are preloaded, i.e., do not require a previous visit to the site by
this browser. This avoids the risk of a browser accessing an HSTS-using
website but without a cached HSTS policy. However, this requires the
browser to be preloaded with the HSTS policy - a burden on the site and
on the browser, and some overhead for this communication. An optional
304
parameter of the HSTS header, instructs search engines to add the site
to the HSTS preload list of related browsers. This is used by Google to
maintain the pre-loaded HSTS list of the Chrome browser.
305
by design, which requires pre-designed, built-in secure mechanisms for exten-
sions and backward compatibility. This is an important design principle for
cryptographic systems and protocols.
Principle 12 (Secure extensibility by design). When designing security sys-
tems or protocols, one goal must be to build-in secure mechanisms for exten-
sions, downward compatible versions, and negotiation of options and crypto-
graphic algorithms (cipher-agility).
Note that the extensibility-by-design principle implies that extension mech-
anisms must be designed, not only that they be secure. By designing protocols
to be extensible and flexible, we allow the use of the same protocol in many
diverse scenarios, environments and applications. This allows more efforts to
be dedicated to analyzing the security of the protocol and its implementations.
We next discuss the TLS extensions mechanism, which is a great example -
in fact, some of the supported extensions have become very popular and had
great impact on the adoption of TLS (and migration of web servers from SSL).
306
in [31, 32]. Support for extensions became mandatory from TLS1.1. Some
standard extensions facilitate important functionality, and some are needed for
security; and users may define additional extensions.
Server Name Indication (SNI) is an example of an important, popular ex-
tension; in fact, SNI became mandatory from TLS 1.1, and was one of the
main factors motivating websites and clients to adopt TLS. SNI is designed to
support the common scenario, where the same web server is used to provide
web-pages belonging to multiple different domain names, e.g., [Link] and [Link].
Each domain name may require a different certificate; the SNI extension allows
the client to indicate the desired server domain name early on in the protocol,
before the server has to send a certificate to the client - allowing the server
to send the desired certificate based on the web-page that is being requested.
Before TLS, using SSL, the common way to a web-server to support multiple
web-sites, with different domain names, was by having each site use a dedicated
port - an inconvenient and inefficient solution.
307
Client Server
Client hello: version (vC ), random (rC ),
cipher-suites (. . . DH. . . ),
by the browser, and the certificate contains the domain name (e.g., [Link]) and
other parameters such as expiration date: SCA.s ((g, p, g S.x mod p), [Link], . . .).
See Figure 7.11.
In practice, the use of a certificate implies that the server’s DH public key,
g S.x , is fixed for long periods, similarly to the typical use of RSA or other
public key methods. Hence, the static (certified) DH key exchange is similar
in its properties to the RSA key exchange; the difference is simply that instead
of using RSA encryption to exchange the key, and relying on the RSA (and
factoring) assumptions, the static (certified) DH key exchange relies on the DH
(and discrete-logarithm) assumptions.
308
Client Server
Client hello: version (vC ), random (rC ), cipher-suites (incl. DHE-RSA) [, ID] [,extensions]
however, that in the typical case where the certificate uses RSA signatures, the
security of the handshake still relies also on the RSA (and factoring) assump-
tions. Namely, the DH key exchanges require both the computational-DH (and
discrete logarithm) assumption, and the RSA (and factoring) assumption. In
this sense, DH key exchanges are ‘less secure’ (or, rely on more assumptions)
compared to the RSA key exchange; in the case of ephemeral DH, this is off-
set by the security advantage of ephemeral DH handshake, namely, ensuring
perfect forward secrecy.
309
Client Server
Client hello: client random (rC ), cipher-suites, ID
kM is the session’s master key, and γ contains ‘related information’ such as the
ciphersuite used in the session.
When the server has the (ID, kM , γ) entry, it reuses kM and γ, i.e., ‘re-
sumes the session’, and derives new shared keys from it (using Eqs. (7.1,7.2).
This avoids the public key encryption (by client) and decryption (by server) of
master key kM , as well as the transmission of the relevant information, most
significantly, the public key certificate.
Note that when either the client or the server, or both, do not have a
valid (ID, kM ) pair, then the handshake is essentially the same as for a ‘basic’
handshake (without resumption), as in Fig. 7.5. The only changes are the
inclusion of the ID from client (if it has it), and the inclusion of an ID in
the ‘server-finish’ message, to be (optionally) used for future resumption of
additional connections (in the same session).
The session resumption mechanism can have a significant impact on perfor-
mance; in particular, websites often involve opening of a very large number of
TCP connections to the same server, to download different objects. The reduc-
tion in CPU time can easily be a ratio of dozens or even hundreds. Therefore,
this is a very important mechanism; however, it also has some significant chal-
lenges and concerns, as we next discuss.
310
Ensuring PFS with ID-based session resumption Another challenge is
that the exposure of the master key kM , exposes the entire communication of
every connection to an eavesdropper; namely, the storage of the key may foil
the perfect-forward secrecy (PFS) mechanism. To ensure PFS, we must ensure
that all copies of the key kM are discarded, without any copies remaining - a
non-trivial challenge.
This challenge is often made even harder due to the way that web-servers im-
plement the (ID, kM ) cache. Specifically, in some popular servers, e.g. Apache,
the operator can only define the size of the (ID, kM ) cache. Suppose the goal
is to ensure PFS on daily basis, i.e., to change keys daily. Then the cache size
must be small enough to ensure that entries will be thrown out after at most a
day, yet, if it is too small, there will be many cache misses, i.e., the efficiency-
gain of the resumption mechanism will be reduced. Furthermore, even if we
use a small cache, a client which continues a session for very long time may
never get evicted from the cache, and hence we may not achieve the goal of
ensuring PFS on daily basis, if the cache uses the (usual) paradigm of throwing
out the least-recently-used element; to ensure entries are thrown after one day
at most, it should operate as a queue (first-in-first-out).
Exercise 7.5. Consider a web server which has, on average, one million daily
visitors, but the number in some days may be as low as one thousand. What
is the required size of the ID-session cache, in terms of number of (ID, kM )
entries, to ensure PFS on daily basis, when entries are removed from the cache
only when necessary to make room for new entries? Can you estimate or
bound, how many of the connections will be served from cache on a typical
day? Assume the ID-session cache operates using a FIFO eviction paradigm.
311
Client Server
Client hello: client random (rC ), cipher-suites, ticket-extension(τ )
Session tickets and PFS. To preserve PFS, e.g., on daily basis, we need to
make sure that each ticket key kST EK is kept for only the allowed duration -
e.g., up to 24 hours (‘daily’). In principle, this is easy; we can maintain this key
only in memory, and never write it to disk or other non-volatile storage, making
it easier to ensure it is not kept beyond the desired period (e.g., daily). This
rule may require us to maintain several ticket-keys concurrently, e.g., generate
a new key once an hour, allowing it to ‘live’ for up to 24 hours.
In the typical case of replicated servers, the ticket keys kST EK should be
distributed securely to all replicates. Changing the key becomes even more
important, with it being used in so many machines.
Unfortunately, like for ID-based resumption, many popular web-servers
implement ticket-based resumption in ways which are problematic for perfect
forward secrecy (PFS). These web-server implementations do not provide a
mechanism to limit the lifetime of the ticket key, except by restarting the server
(to force the server to choose a new ticket key). For some administrators and
scenarios, this lack of support for PFS may be a consideration for choosing a
server, or for using session-IDs and disabling session-tickets.
312
Figure 7.15: Client authentication in SSLv3 to TLS 1.2.
request field together with the server-hello message. The certificate-request field
identifies the certificate-autorities (issuers) which are accepted by this server;
namely, client authentication is possible only if the client has a certificate from
one of these entities.
Next, the client attaches, to its client key exchange message, two fields.
The first is the certificate itself; the second, called certificate verify, is a digital
signature over the handshake messages. The ability to produce this signature,
serves as proof of the identity of the client.
This client authentication mechanism is quite simple and efficient; however,
it is not widely deployed. In reality, TLS/SSL is typically deployed using only
the public key (and certificate) of the server, i.e., only allowing the client to
authenticate the server, but without client authentication. The reason for that
is that SSL/TLS client authentication requires clients to use a private key,
and to obtain a certificate on the corresponding public key; furthermore, that
certificate must be signed by an authority trusted by the server.
This raises two serious challenges. First, clients often use multiple devices,
and this requires them to have access to their private keys on these multiple
devices, which raises both usability and security concerns. Second, clients must
obtain a certificate - and from an authority trusted by the server. As a result,
most websites prefer to avoid the use of SSL/TLS client authentication; when
user authentication is required, they rely on sending secret credentials such as
passwords or cookies, over the SSL/TLS secure connection.
Note also that the client authentication mechanism requires the client to
313
Client Server
Client hello:
client random (rC ), cipher-suites,
key-exchange: g1a1 mod p1 , g2a2 mod p2 , . . . , extensions
b
Server hello: server random (rS ), key-exchange:i, gi i , SCA.s (S.v, . . .), SS.s (handshake)
send her certificate ‘in the clear’. This may be a privacy concern, since the
certificate may allow identification of the client.
314
Figure 7.17: TLS 1.3: ‘full handshake’.
315
authentication (EtA)? Can you identify advantages to AtE and/or to
EtA?
5. The SSL/TLS record protocols apply compression, then authentication.
Is it possible to reverse the order, i.e., apply authentication and then
compression? Can you identify advantages to either order?
Exercise 7.7 (SSL 2 key derivation). SSL uses MD5 for key derivation. In this
question, we explore the required properties from MD5 for the key derivation to
be secure.
1. Show that it is not sufficient to assume that MD5 is collision-resistant,
for the key derivation to be secure.
2. Repeat, for the one-way function property.
3. Repeat, for the randomness-extraction property.
4. Define a simple assumption regarding MD5, which ensures that key deriva-
tion is secure. The definition should be related to cryptographic functions
and properties we defined and discussed.
Exercise 7.8 (TLS handshake: resiliency to key exposure). Fig. 7.10 presents
the RSA-based SSL/TLS Handshake. This variant of the handshake protocol
was popular in early versions, but later ‘phased out’ and completely removed in
TLS 1.3. The main reason was the fact that this variant allows an attacker that
obtains the server’s public key, to decrypt all communication with the server
using this key - before and after the exposure.
1. Show, in a sequence diagram, how a MitM attacker who is given the
private key of the server at time T1 , can decrypt communication of the
server at past time T0 < T1 .
2. Show, in a sequence diagram, how TLS 1.3 avoids this impact of exposure
of the private key.
3. Show, in a sequence diagram, how a MitM attacker who is given the
private key of the server at time T1 , can decrypt communication of the
server at future time T2 > T1 .
4. Explain which feature of TLS 1.3 can reduce the exposure of future com-
munication, and how.
Exercise 7.9 (Protocol version downgrade attack). Implementations of SSL
specify the version of the protocol in the ClientHello and ServerHello messages.
If the server does not support the client’s version, then it replies with an error
message. When the client receives this error message (‘version not supported’),
it re-tries the handshake using the best-next version of TLS/SSL supported by
the client.
316
Present a sequence showing how a MitM attacker can exploit this mecha-
nism to cause the server and client to use an outdated version of the protocol,
allowing the attacker to exploit vulnerabilities of that version.
Exercise 7.10 (Client-chosen cipher-suite downgrade attack). In many vari-
ants of the SSL/TLS handshake, e.g., the RSA-based handshake in Fig. 7.10,
the authentication of the (previous) handshake messages in the Finish flows,
is relied upon to prevent a MitM attacker from performing a downgrade attack
and causing the client and server to use a less-preferred (and possibly less se-
cure) cipher-suite. However, in this process, the server can choose which of
the client’s cipher-suites would be used. To ensure the use of the cipher-suite
most preferred by the client, even if less preferred by the server, some client
implementations send only the most-preferred cipher-suites. If none of these
is acceptable to the server, then the server responds with an error message. In
this case, the client will try to perform the handshake again, specifying now
only the next-preferred cipher-suite(s), and so on - referred to as ‘downgrade
dance’.
1. Show how a MitM attacker can exploit this mechanism to cause the server
and client to use a cipher-suite that both consider inferior.
2. Suggest a fix to the implementation of the client which achieves the same
goal, yet is not vulnerable to this attack. Your fix should not require
changes in the handshake protocol itself, or in the server.
3. Suggest an alternative fix, which only involves change in the handshake,
and does not require change in the way it is used by the implementation.
Exercise 7.11 (TLS server without randomness). An IoT device provides http
interface to clients, i.e., acts as a tiny web server. For authentication, clients
send their commands together with a secret password, e.g., on, ¡password¿ and
off, ¡password¿. Communication is over TLS for security, with the RSA-based
SSL/TLS handshake, as in Figure 7.10.
The IoT device does not have a source of randomness, hence, it computes
the server-random rS from the client-random, using a fixed symmetric key kS
(kept only by the device), as: rS = AESkS (rC ).
1. Present a message scheduling diagram showing how an attacker, which
can eavesdrop on a connection in which the client turned the device ‘on’,
can later turn the device ‘on’ again, without the client being involved.
2. Would your answer change (and how), if the device supports ID-based
session resumption? Ticket-based session resumption?
3. Show a secure method for the server to compute the server-random method,
which will not require a source of randomness. The IoT device may use
and update a state variable s; you solution consists of the computation
of the server-random: rS = and of the update to the
state variable performed at the end of every handshake: s = .
317
Exercise 7.12. Consider a client and server that use TLSv1.2 with ephemeral
DH public keys, as in Fig. 7.12. Assume that the client and server run this
protocol daily, at the beginning of every day i. (Within each day, they may
use session resumption to avoid additional public key operations; but this is
not relevant to the question). Assume that Mal can (1) eavesdrop on com-
munication every day, (2) perform MitM attacks (only) every even day (i s.t.
i ≡ 0 ( mod 2)), (3) is given all the keys known to the server on the fourth
day. Note: the server erases any key once it is not longer in use (i.e., on fourth
day, attacker is not given the ‘session keys’ established n previous days).
Fill the ‘Exposed on’ column of day i in in Table ??, indicating the first day
j ≥ i in which the adversary should be able to decrypt (expose) the traffic sent
on day i between client and server. Write ‘never’ if the adversary should never
be able to decrypt the traffic of day i. Briefly justify.
Exercise 7.13 (TLS with PRS). Consider a client that has three consecu-
tive TLS connections to a server, using TLS 1.3. An attacker has different
capabilities in each of these connections, as follows:
• In the first connection, attacker obtains all the information kept by the
server (including all keys).
• In the second connection, attacker is disabled.
• In the third connection, attacker has MitM capabilities.
Is the communication between client and server exposed, during the third con-
nection?
318
4. How can your improvement be implemented using TLS 1.3, allowing ‘nor-
mal’ TLS 1.3 interaction if client/server do not support your improve-
ment?
1. Assume that the server selects to use this p3 , i.e., sends back g3b3 mod p3
(as part of the server-hello message, and signed). Explain how a MitM
attacker would be able to eavesdrop and modify messages sent between
Alice and Bob.
2. Assume that the server prefers p2 , which is a safe prime. Show that the
attacker is able to (adapt the attack and still) eavesdrop/modify messages
between Alice and Bob.
3. Would this attack be possible, if Alice authenticates to the website (1)
using userid-pw, or (2) using TLS client authentication ? Explain.
319
Chapter 8
320
Certificate Authority
(Aka CA or Issuer)
Certificate CB :
CB = SignCA.s ([Link], Bob.e, . . .) Subject
(e.g, website [Link]))
Nurse
Basic PKI concepts: certificate, issuer (CA) and subject. All main-
stream PKIs, including X.509, distribute a public key pk together with a set
ATTR of attributes and a digital signature σ, which is the result of a signa-
ture algorithm applied to input containing both pk and ATTR. The tuple
(pk, ATTR, σ) is called a public key certificate or simply a certificate. The cer-
tificate is issued by an entity referred to as a Certificate Authority (CA) or
simply as the issuer.
Most attributes refer to the subject of the certificate, i.e., the entity who
knows (‘owns’) the private key corresponding to the certified public key pk.
In addition, there are often few additional attributes related to the certificate
itself rather than to the subject, such as the certificate validity period and
serial number.
The CA provides the certificate to the subject, who (often) provides it to
the relying party - for example, during the TLS/SSL handshake.
321
scenario in this figure includes three parties: the Certificate Authority (also
called CA or issuer), the subject of the certificate, i.e., the entity whose public
key is certified, and the relying party, i.e., the party who receives the subject’s
certificate in order to validate the subject’s public key. In this typical example,
the subject is the website [Link], and the relying party is Alice’s browser.
The figure shows the simple case of a typical identity certificate, issued to
website [Link] directly by a CA trusted by the relying party, who, in this case,
Alice’s browser. Such directly-trusted CAs are called ‘trust anchors’ or ‘root
CAs’. In reality, most Web-PKI certificates are indirectly-issued, i.e., issued by
an intermediate-CA (Figure 8.6), or even by a path of multiple intermediate-
CAs (Figure 8.7).
The certificate CB is a signature using the private signing key of the CA,
CA.s (not shown), over the subject’s identity, in this case the domain name
[Link], and the subject’s public key, in this case the public encryption key
Bob.e, typically provided from subject to CA. This is an identity certificate
since it contains the identifier (domain name) [Link]. In Web-PKI, using
TLS/SSL server-authentication, the web-site (subject) [Link] sends the cer-
tificate CB to the relying party (Alice’s browser).
322
certificate set, e.g., certificates with a particular identifier (e.g., domain
name). In § 8.6, we discuss Certificate Transparency (CT), a proposed
standard for extending X.509 with mechanisms to ensure transparency.
Equivocation-prevention/detection: a PKI supports equivocation preven-
tion if there cannot exist two mutually-valid yet different identity cer-
tificates for the same identifier (e.g., domain name). A PKI supports
equivocation detection if such ‘equivocating’ certificates may exist, but
would be detected soon after the second one is issued.
Privacy: Some ‘post-X.509’ PKI designs attempt to ensure different privacy
properties, e.g., to allow certificate subjects to present only a subset of
the attributes from a certificate issued to them, e.g., present a certificate
but only ‘exposing’ a specific ‘property-attribute’ such as (age¿21), and
not exposing other attributes (such as name or location).
323
2001 VeriSign: attacker gets code-signing certs
2008 Thawte: email-validation (attackers’ mailbox)
2008,11 Comodo not performing domain validation
2011 DigiNotar compromised, over 500 rogue certs discovered
2011 TurkTrust issued intermediate-CA certs to users
2013 ANSSI, the French Network and Information Security Agency, issued
intermediate-CA certificate to MitM traffic management device
2014 India CCA / NIC compromised (and issued rogue certs)
2015 CNNIC (China) issued CA-cert to MCS (Egypt), who issued rogue certs
2015,17 Symantec issued unauthorized certs for over 176 domains
Subject key exposure: private keys should be well protected from exposure;
however, exposures do happen. Normally, exposures are quite rare; how-
ever, a discovery of a software vulnerability may cause exposure of many
private keys, as happened due to the Heartbleed Bug [40, 173].
CA failures: usually, certificate authorities have operated in a secure, trust-
worthy manner, and issued correct certificate to the rightful subjects - as
required and expected. However, there have also been several incidents
where CAs have failed in different ways, including vulnerable subject iden-
tification, e.g., insecure email validation, issuing intermediate-CA certifi-
cates to untrusted entities, e.g. to all customers, and even CA compromise
and issuing of rogue certificates or what appears to be intentional issuing
of rogue certificates. See Table 8.1.
Cryptanalytical certificate forgery: certificate-based PKIs all use and de-
pend on the hash-then-sign mechanism, and therefore become vulnerable
if the signature scheme is vulnerable - or if the hash-function used is
vulnerable. Specifically, certificate forgery was demonstrated when us-
ing hash functions vulnerable to chosen-prefix collision attacks, specifi-
cally, using RIPEMD, MD4 and MD5 [158], and later also using SHA-
A [120, 158]. See chapter 4.
324
8.2 Basic X.509 PKI Concepts
In this section, we discuss the basic notions of the X.509 PKI standard, which
was developed as part of the X.500 global directory standard. X.509 is the
most widely deployed PKI specification, and also includes some of the more
advanced PKI concepts which we cover in the following sections.
325
C Country
L Locality
O Organization name
OU Organization unit
CN Common name
326
Figure 8.2: Example of the X.509 Distinguished Name (DN) hierarchy.
1. The distinguished name (DN) for a police officer names John Doe in the
Soho precinct of the NYPD may be defined as: C=US/L=NY/O=NYPD/OU=soho/CN=John
Doe; see Figure 8.2.
2. The distinguished name (DN) for an IBM UK employee with the name
Julian Jones may be written as: CN=Julian Jones, O=IBM, C=GB.
Read below on the author’s experience with this (realistic) DN.
327
‘modifying’ the common name. For example, if there are multiple IBM UK
employees with the name Julian Jones, one of them may be assigned the DN:
328
Figure 8.3: The Identifiers Trilemma: the challenge of co-ensuring unique,
decentralized and meaningful identifiers.
Email addresses are unique and meaningful. However, they are not decen-
tralized, since each issuer can only assign identifiers (email addresses) in
its own domain.
This begs the question: is there a scheme which will ensure identifiers which
fully satisfy all three properties, i.e., would be unique, meaningful and managed
and issued in a decentralized way? It seems that this may be hard or impossible,
i.e., it may be possible to only fully ensure two of these three goals, but not all
three. We refer to this challenge as the Identifiers Trilemma1 , and illustrate it
in Figure 8.3.
referred to a different trilemma, albeit also related to identifiers. Specifically, Zooko consid-
ered the challenge of identifiers which will be distributed, meaningful for humans, and also
self-certifying, allowing recipients to locally confirm the mapping from name to value.
329
Secure web-browsing: users, as well as hyperlinks, specify the desired web-
site using an Internet domain name, and not a distinguished name. Hence,
the relevant identifier for the web site is that domain name - provided
by the user or in the hyperlink. This requires mapping from the domain
name to the distinguished name. A better solution is for the certificate
to directly include the domain name; this is supported by the PKIX
standard, explained below.
Secure email/messaging: users also do not use distinguished names to iden-
tify peers with whom they communicate using email and instant mes-
saging applications. Instead, they use email addresses - or application-
specific identification. This problem may not be as meaningful, since
most end users do not have a public key certificate at all; and, again,
PKIX allows certificates to directly specify email address.
330
Figure 8.4: X.509 version 1 certificate.
331
Note 8.1: Object identifiers (OIDs)
An object identifier (OID) is used as a unique identifier for arbitrary objects. OIDs
are standardized by the ITU and ISO/IEC, as part of the ANS.1 standard [41, 62].
Object identifiers are specified as a sequence of numbers, e.g., [Link].45.34. OID
numbers are assigned hierarchically to organizations and to ‘individual objects’;
when an organization is assigned a number, e.g., 1.16, it may assign OIDs whose
prefix is 1.16 to other organizations or directly to objects, e.g. [Link].45.34. The
top level numbers are either zero (0), allocated to ITU, 1, allocated to ISO, or 2,
allocated jointly to ISO and ITU. RFC 3279 [9] defines OIDs for many cryptographic
algorithms and processes used in Internet protocols, e.g., RSA, DSA and elliptic-
curve signature algorithms; when specifying a signature process, the OID normally
also specifies both the underlying public key signature algorithm and key length,
e.g., RSA-2048, and the hashing function, e.g. SHA-256, used to apply the ‘hash-
then-sign process. X.509 uses OIDs to identify signature algorithms and other types
of objects, e.g., extensions and issuer-policies. The use of OIDs allows identification
of the specific type of each object, which helps interoperability between different
implementations.
Exercise 8.1. Provide a security motivation for the fact that the signature
process is specified as one of the (signed) fields within the certificate. Do this
by constructing two ‘artificial’ CRHFs, hA and hB ; to construct hA and hB ,
you may use a given CRHF h. Your constructions should allow you to show
that it could be insecure to use certificates where the signature process (incl.
hashing) is not clearly identified as part of the signed fields. Specifically, design
hA , hB to show how an attacker may ask a CA to sign a certificate for one
name, say Attacker, and then use the resulting signature over the certificate to
forge a certificate for a different name, say Victim.
332
Figure 8.5: X.509 version 3 certificate. Version 2 is identical, except for not
having the extensions field.
333
which includes an extension marked as critical, if this type of extension
is unknown to this relying party. Relying parties should use certificates
with unknown extension types, if they are marked as ‘non-critical’. When
the relying party is familiar with the type of an extension, the value of
the criticality indicator is not applicable.
Example 8.3 (Always critical example). PKIX specifies that the ‘key usage’
extension must be marked ‘critical’, while X.509 allows the ‘key usage’ exten-
sion to be marked as either ‘critical’ or ‘not-critical’. Let us give a somewhat-
contrived example of a possible attack exploiting a certificate where key-usage
was not marked as ‘critical’, causing a relying party who does not understand
this extension, to make a critical security mistake. Assume that the parties
(key-owner, i.e., certificate subject, and relying party) use ‘textbook RSA’ en-
cryption, i.e., encrypts plaintext mE by computing c = meE mod n; and ‘text-
book RSA’ signing, i.e., sign message mS by outputting σ = h(mS )d mod n,
i.e., ‘decrypting’ the hash of the message. Furthermore, assume the key-owner
uses its decryption key to authenticate that it is active at a given time, by
334
decrypting an arbitrary challenge ciphertext sent to it; this requires only a rel-
atively weak form of ciphertext-attack resistance, where the attacker must ask
for the decryption before seeing the challenge ciphertext it must decrypt, often
referred to as IND-CCA1 secure and assumed for textbook RSA. A key-owner
using this mechanism must use its key only for decrypting these challenges;
assume it receives a certificate CE for its encryption key e, with the key-usage
extension correctly marking this as an encryption key, but not marked as crit-
ical.
An attacker may abuse this, together with the fact that ‘key usage’ is not
understood by some relying parties, to mislead these relying-parties into thinking
that the key-owner signed some attacker-chosen-message mA , as follows. The
attacker computes cA = h(mA ) and sends it to the key-owner, as if it is a
standard challenge ciphertext to be decrypted. The key-owner therefore decrypts
cA and outputs the decryption, cdA mod n = h(mA )d mod n, which we denote
by σA , i.e., σA ≡ h(mA )d mod n. Now the attacker sends the pair (mA , σA ),
along with the certificate CE , to the relying party, claiming mA was signed by
the key-owner with signature σA . Since the relying party is not familiar with
the key-usage extension, and it was not marked ‘critical’ in the key-owner’s
certificate CE , then the relying-party would validate (mA , σA ), which would
validate correctly, and thereby incorrectly consider mA as validly-signed by the
key-owner.
The flexibility offered by the ‘criticality indicator’ makes the X.509 (and
PKIX) extensions mechanism much more versatile and useful; it is a pity that
this idea has not been adopted by other extension mechanisms. For example,
TLS client and servers simply ignore unknown extensions, i.e., treat them as
‘non-critical’, as discussed in chapter 7. It would be nice to allow also definition
of critical extensions, i.e., instructing the TLS peer to refuse connection if it
does not know the extension. This can be achieved quite easily, and in different
ways, see next exercise.
Exercise 8.2. Design how TLS may be extended to support critical extensions.
Could you achieve this using the existing TLS extensions mechanism?
335
Most of our discussion applies to both the X.509 specifications as defined
by the ITU, and to their adaptation for use in Internet protocols, as defined by
the IETF in RFC 5280 [47], Public Key Infrastructure (PKIX) certificate and
CRL profile. We point out few points where PKIX and X.509 differ.
In the following subsections, we discuss the certificate validation processes
and the most important X.509 and PKIX standard extensions. In subsec-
tion 8.3.1, we discuss the validation process for certificates signed by a trust-
anchor. In subsection 8.3.2, we discuss the standard alternative name ex-
tensions, providing alternative identification for both issuer and subject. In
subsection 8.3.3 we discuss standard extensions dealing with the usage of the
certified key, and the certificate policies related to the issuing and usage of the
certificate. In subsection 8.3.5 we discuss standard extensions defining con-
straints on certificates issued by the subject, for the special case where the
subject of a certificate is also a CA. In subsection 8.3.4 we discuss the pro-
cess of certificate path validation, allowing validation of certificates which are
not trusted directly by a trust-anchor, but, instead, by establishing trust in
intermediate CAs, and the related standard extensions.
Issuer. The relying party verifies that the issuer I of the certificate, as iden-
tified by the issuer distinguished name field, is a trusted CA, i.e., a trust
anchor.
Validity period. The relying party checks the validity period specified in the
certificate. If the public key is used for encryption or to validate sig-
natures on responses to challenges sent by the relying party, then the
certificate should be valid at the relevant times, including at the current
time. If the public key is used to validate signature generated at the past,
then it should be valid at a time when these signatures already existed,
possibly attested by supporting validation by trusted time-stamping ser-
vices.
Subject. The relying party verifies that the subject, as identified, using dis-
tinguished name, in the ‘subject’ field, is an entity that the relying party
expected. For example, when the relying party is a browser and it re-
ceives a website certificate, then the relying party should confirm that
336
the website identity (e.g., domain name) is the same as indicated in the
‘subject distinguished name’ field of the certificate.
Signature algorithms. The relying party confirms that it can apply and
trust the validation algorithm of the signature scheme identified in the
signature algorithm OID field of the certificate. If the certificate is signed
using an unsupported algorithm, or an algorithm known or suspected to
be insecure, validation fails.
Issuer and subject unique identifiers. From version 2, X.509 certificates
also include fields for unique identifiers for the issuer and the subject,
which the relying party should use to further confirm their identities. In
PKIX, these identifiers are usually not used, and PKIX does not require
their validation. This is probably since in PKIX, the issuer and subject
identifiers are typically in corresponding extensions.
Extensions. First, the relying party should validate that it is familiar with
any extension marked as ‘critical’; the existence of any unrecognized ex-
tension, marked as critical, would invalidate the entire certificate. Then,
the relying party should validate the provided set of key and policy ex-
tensions, as discussed in the next subsection. Finally, the relying party
should validate the existence and validity of any non-standard extensions,
which is required or supported by the relying party.
Validate signature. The relying party next uses the trusted public validation
key of the CA, CA.v, and the signature-validation process as specified in
the certificate, to validate the signature over all the ‘to be signed’ fields
in the certificate, i.e., all fields except the signature itself.
337
In fact, the use of alternate names is so common, that in many PKIX certifi-
cates, the subject and issuer distinguished-name fields are left empty. Indeed,
PKIX (RFC 5280) specifies that this must be done, when the Certificate Au-
thority can only validate one (or more) of the alternative name forms, which
is often the case in practice. PKIX specifies that in such cases, where the Sub-
jectAltName extensions is the only identification and the subject distinguished
name is empty, then the extension should be marked as critical, and otherwise,
when there is a subject distinguished name, it should be marked as non-critical.
Note that PKIX (RFC 5280) specifies that the Issuer Alternative Name
extension should always be marked as non-critical. In contrast, the X.509
standard specifies that both alternative-name extensions, may be flagged as
either critical or non-critical.
Also, note that implementations of the Secure Socket Layer (SSL) and
Transport Layer Security (TLS) protocols, often allow certificates to include
wildcard certificates, which, instead of specifying a specific domain name, use
the wildcard notation to specify a set of domain name. For TLS, this support is
clearly defined in RFC 6125 [149]. Wildcard domain names are domain names
where some of the alphanumeric strings are replaced with the wildcard char-
acter ‘*’; there are often restrictions on the location of the wildcard character,
e.g., it may be allowed only in the complete left-most label of a DNS domain
name, as in *.[Link]. Wildcard domain names are not addressed in
PKIX (RFC5280) or X.509, and RFC 6125 mentions several security concerns
regarding their use.
The authority key identifier extension. Provides an identifier for the is-
suer’s public key, allowing the relying party to identify which public val-
idation key to use to validate the certificate, if the issuer has multiple
public keys. It is always non-critical.
The subject key identifier extension. Provides an identifier for the certi-
fied subject’s public key, allowing the relying party to identify that key
when necessary, e.g., when validating a signature signed by one of few
signature keys of the subject - including signatures on (other) certificates.
It is always non-critical.
The key usage extension. Defines the allowed usages of the certified public
key of the subject, including for signing, encryption and key exchange.
The specification allows the use of same key for multiple purposes, e.g.,
encryption and validating signatures, however, this should not be used,
338
as the use of the same key for such different purposes may be vulner-
able - security would not follow from the pure security definitions for
encryption and for signatures. An exception, of course, is when using
schemes designed specifically to allow both applications, such as sign-
cryption schemes. This extension may be marked as critical or not.
The extended key usage extension. Allows definition of specific key-usage
purposes as supported by relying parties. The specification also allows
the CA to indicate that other uses, as defined by the key-usage extension,
are also allowed; otherwise, only the specified purposes are allowed. This
extension may be marked as critical or not.
The private key usage period extension. This extension is relevant only
for certification of signature-validation public keys; it indicates the al-
lowed period of use of the private key (to generate signatures). Always
marked non-critical.
The certificate policies extension. This extension identifies one or more
certificate policies which apply to the certificate; for brief discussion of
certificate policies, see Note 8.2. The extension identifies certificate poli-
cies using object identifiers (OID). In particular, the policy OID in the
certificate policies extension, is the main mechanism to identify the type
of validation of the legitimacy of the certificate, performed by the CA
before it issued the certificate - Domain Validation (DV), Origin Valida-
tion (OV) or Extended Validation (EV). For more discussion on certificate
policies and on the three types of validation, see Note 8.2. The certificate
policies extension may be marked as critical or as non-critical.
The policy mappings extension. This extension is used only in certificates
issued to another CA, called CA certificates. It specifies that one of the
issuer’s certificate policies, can be considered equivalent to a given (differ-
ent) certificate policy used by the subject (certified) CA. This extension
may be marked as critical or as non-critical.
Exercise 8.3. Some of the extensions presented in this subsection should al-
ways be non-critical, while others may be marked either critical or non-critical.
Justify each of these designations, e.g., for each of these extensions, give an
example of a case where it should be non-critical.
339
Note 8.2: Certificate policy (CP) and Domain/Origin/Extended Validation
A certificate policy (CP) is a set of rules that indicate the applicability of the
certificate to a particular use, such indicating a particular community of relying
parties that may rely on the certificate, and/or a class of relying party applications
or security requirements, which may rely on the certificate. Certificate policies
inform relying parties of the level of confidence they may have in the correctness of
the bindings between the certified public key and the information in the certificates
regarding the subject, including the subject identifiers. Namely, the Certificate
Policy provides information which may assist the relying party to decide whether
or not to trust a certificate for a particular purpose. The certificate policy may also
be viewed as a legally-meaningful document, which may define, and often limit,
the liability and obligations of the issuer (CA) for potential inaccuracies in the
certificate, and define statutes to which the CA, subject and relying parties should
conform; however, these legal aspects are beyond our scope.
One application of the certificate policies extension, and specifically of the policy
OID field, is as a method to identify the type of validation performed by the CA
before issuing the certificate. The type of validation is an indicator of its trustwor-
thiness, and may be used by relying parties to determine their use of the certificate.
Three types of validation are defined: Domain Validation (DV) and Organization
Validation (OV) and Extended Validation (EV) (in order of increasing trust).
Domain Validation (DV) is a fully-automated - but not very secure - validation
process. It involves sending a request to an address associated with the domain,
and validating the response. The address may be an IP address or email address
(sometimes referred to as email validation). Domain Validation is vulnerable to
MitM attacks; it is also vulnerable to off-path attacks exploiting weakness of the
domain name system (DNS) or of the routing infrastructure; see [93].
Both (OV) and Extended Validation involve additional validation (beyond DV), such
as review of documents. Extended validation, as the name implies, require more
through validation - although the precise requirements are not well defined.
The policy OID field is defined as the standard method to identify Extended Vali-
dation (EV) certificates. The OID field is also often used to identify DV and OV
certificates.
Browsers make minimal use of the type of validation, if at all. Many browsers display
the type of validation of the certificate to the user - usually, only when the user
enters a menu focusing on details of the site’s certificate (which most users never
do). Some browsers make some user-interface distinction, usually only between EV
certificates vs. other (OV and DV) certificates, but these indications are mostly
considered ineffective and their use seem to be in decline.
340
is directly trusted by a relying party, is called a trust anchor of that relying
party.
Direct trust in one or more trust-anchor (directly trusted) CAs, might suf-
fice for small, simple PKI systems. However, many PKI systems are more
complex. For example, browsers deploy PKI to validate certificates provided
by a website, during the SSL/TLS handshake. Browsers typically directly
trust a large number - about 100 - of trust anchor CAs, referred to in browsers
as root CAs. Furthermore, in addition to the root CAs, browsers also indi-
rectly trust certificates signed by other CAs, referred to as intermediate CA;
an intermediate CA must be certified by root CA, or by a properly-certified,
indirectly-trusted intermediate CA.
Different relying parties may have different trust anchors, and different
requirements for trusting intermediate CAs. The same CA, say CAA , may be
a trust anchor for Alice, and an intermediate CA for Bob, who has a different
trust anchor, say CAB .
Relying parties and PKIs may apply different conditions for determining
which certificates (and CAs) to trust. For example, in the PGP web-of-trust
PKI, every party can certify other parties. One party, say Bob, may decide
to indirectly trust another party, say Alice, if Alice is properly certified by
a ‘sufficient’ number of Bob’s trust anchors, or by a ‘sufficient’ number of
parties which Bob trusts indirectly. The trust decision may also be based on
ratings specified in certificates, indicating the amount of trust in a peer. Some
designs may also allow ‘negative ratings’, i.e., one party recommending not to
trust another party. The determination of whether to trust an entity based
on a set of certificates - and/or other credentials and inputs - is referred to as
the trust establishment or trust management problem, and studied extensively;
see [34, 35, 94, 95, 122] and citations of and within these publications.
We focus on the simpler case, where a single valid certification path suffices
to establish trust in a certificate. This is the mechanism deployed in most PKI
systems and by most relying parties, and specified in X.509 and PKIX. In both
of these, the validation of the certificate path is based on several certificate path
constraints extensions, which we discuss in the following subsections.
341
In the simple case, illustrated in Figure 8.6, the relying party (Alice) receives
two certificates: a certificate for the subject, e.g., the website [Link],
signed by some Intermediate CA, which we denote ICA; and a certificate for
ICA, signed by the trust anchor CA, TACA. In this case, we will say that the
subject, [Link], has a single-hop certification path from TACA, since ICA
is certified by the trust anchor TACA. In this case, therefore, the certification
path consists of two certificates: CICA , the certificate issued by the trust anchor
TACA to the intermediate CA ICA, and CB , the certificate issued by the
intermediate CA ICA to the subject ([Link]).
In more complex scenarios there are additional Intermediate CAs in the cer-
tification path from the trust anchor to the subject, i.e, the certification path
is indirect, or in other words, contains multiple hops. For example, Figure 8.7
illustrates a scenario where the subject, [Link], is certified via an indi-
rect certification path with three hops, i.e., including three intermediate CAs:
ICA1, ICA2 and ICA3. The subject [Link] is certified by ICA3, which
is certified by ICA2, which is certified by ICA1, and only ICA1 is certified by
a trust anchor CA, TACA. Hence, in this example, the certification path con-
sists of four certificates: (1) CICA1 , the certificate issued by the trust anchor
TACA to the intermediate CA ICA1, (2) and (3), the two certificates CICA2
and CICA3 , issued by the intermediate CAs ICA1 and ICA2, respectively, to
the intermediate CAs ICA2 an ICA3, respectively, and finally (4) CB , the
certificate issued by the intermediate CA ICA3 to the subject ([Link]).
We use the terms subsequent certificates to refer to the certificates in a
certification path which were issued by intermediate CAs, and the terms root
certificate or trust-anchor certificate to refer to the ‘first’ certificate on the path,
i.e., the one issued by the trust-anchor CA. The second certificate along the
path is certified by the intermediate CA certified by the trust anchor (in the
trust-anchor certificate); and any following certificate along the path, say the
ith certificate along the path (for i > 1), is certified by the intermediate CA
which was certified in the (i − 1)th certificate in the path. The length of a
certificate path is the number of intermediate CAs along it, which is one less
than the number of certificates along the path.
Note that, somewhat contrary to their name, the certification path con-
straints cannot prevent or prohibit Intermediate CAs from signing certificates
which do not comply with these constraints; the constraints only provide infor-
mation for the relying party, say Alice, instructing Alice to trust a certificate
signed by ICA, only if it conforms with the constraints specified in the certifi-
cates issued to the intermediate CAs.
342
non-standard capitalization), and an integer called pathLenConstraint (again,
with this capitalization).
The cA flag indicates if the subject ([Link]) is ‘allowed’ to issue
certificates, i.e., act as a CA; if cA = T RU E, then [Link] may issue
certificates, and if cA = F ALSE, then it is not ‘allowed’ to issue certificates.
Recall that this is really just a signal to the relying parties receiving certificates
signed by [Link]; also, this only restricts the use of the certificate that
I issued to [Link] for validation of certificates issued by [Link],
it does not prevent or prohibit [Link] from issuing certificates, which a
relying party may still trust, either since it directly trusts [Link] (i.e., it is
a trust anchor), or since it receives also an additional certificate for [Link]
signed by a different trusted CA, and that certificate allows [Link] to be
a CA, e.g., by having the value TRUE to the cA flag in the basic constraints
extension.
The value of the pathLenConstraint is relevant only when there is a ‘path’
of more than one intermediate CA, between the Trust Anchor CA and the
subject. For example, it is relevant only in Figure 8.7, and not in Figure 8.6.
Note also that root CA
For example, in both Figure 8.6 and Figure 8.7, the Trust Anchor CA
(TACA) signs certificate CICA1 , where is should specify the ICA1 is a trusted
(intermediate) CA. Namely, it must set the cA flag in the basic-constraints
extension of CICA1 to TRUE. However, in Figure 8.7, ICA1 further certifies
ICA2 which certifies ICA3 - and only ICA3 certifies the subject ([Link]).
Therefore, for the relying party to ‘trust’ certificate CB for the subject, signed
by ICA3, it is required that CICA1 will also contain the path-length (pathLen)
parameter in the basic constraint extension, and this is parameter must be at
least 2 - allowing two more CAs till certification of the subject. Similarly, the
certificate issued by ICA1 to ICA2 must contain the basic constraints extension,
indicating cA as TRUE, as well as value of 1 at least for the pathLen parameter.
Unfortunately, currently, essentially all browsers do not enforce path-length
constraints on the root CAs. Root CAs sometimes do enforce path-length
constraints on intermediate CAs, however, these are usually rather long, e.g.,
3, leaving wide room for an end-entity to receive, by mistake, a certificate
allowing it to issue certificates. Of course, in most cases, end-entity certificates
will not allow issuing certificates, typically since their basic-constraints will
indicate that they are not a CA.
Browsers usually enforce basic constraint, although, failures may happen,
esp. since this kind of flaw - lack of validation - is not likely to be detected by
normal user.
Exercise 8.4 (IE failure to validate basic constraint). Old versions of the IE
browser failed to validate the basic constraint field. Show a sequence diagram
for an attack exploiting this vulnerability, allowing a MitM attacker to collect
the user’s password to trusted sites which authenticate the user using user-id
and password, protected using SSL/TLS.
343
Exercise 8.5. Assume that TACA is concerned that subject-CAs may issue
certificates to end-entities (e.g., websites) and neglect to include a basic con-
straint extension, to prevent the end entity from issuing certificates. Explain
how TACA may achieve this, for the scenarios in Figure 8.6 and in Figure 8.7.
Identify any remaining potential for such failure by one of the intermediate
CAs in these figures.
bit cumbersome.
344
TACA Certificate CICA ICA
(Trust Anchor CA) (Intermediate CA)
Certificates
CICA , CB
Relying party
(e.g, Alice’s browser)
345
TACA ICA1 ICA2 ICA3
CICA1 CICA1 , CICA1 ,
CICA2 CICA2 ,
CICA3
Certificates
CICA1 , CICA2 ,
Relying party CICA3 , CB
(e.g, Alice’s browser)
Certificates CICA1 ,
CICA2 , CICA3 , CB Subject
(e.g, [Link])
Nurse
346
Figure 8.8: Example of the use of Name Constraint, where constraints are
over distinguished name keywords. NTT Japan issues a certificate to IBM
Japan, with the name constraint Permit O=IBM, i.e., allowing it to certify only
distinguished names with the value ‘IBM’ to the ‘O’ (organization) keyword,
since NTT Japan does not trust IBM Japan to certify other organizations. IBM
Japan certifies the global IBM, only for names in the IBM organization (Permit
O=IBM), and excluding names in Japan (Exclude C=Japan). Similarly, global
IBM certifies Symantec for all names, except names in the IBM organization.
347
Figure 8.9: Example of the use of Name Constraint, with similar constraints
to the ones in Figure 8.8, but here using DNS names (dNSName).
by the user.
inhibitPolicyMapping: if specified as a number n, and the certificate path is
longer than n, say C1 , . . . , Cn , Cn+1 , . . ., then Cn+1 and any subsequent
certificate, should not have a policy mapping extension.
However, this brings the question: how to revoke the certificates, i.e., how
to inform the relying parties that a certificate was revoked? This turns out to
be a significant challenge - definitely much larger than originally anticipated,
at the early X.509 design, who initially only offered one solution - Certificate
348
Revocations List (CRL) - which is widely implemented - but often not used due
to its excessive overhead, as we discuss below.
Indeed, there is still no consensus on the ‘best’ revocation mechanism. We
discuss several revocation mechanisms in the following subsections, focusing on
these that are already applied. Part of the difficulty in converging on the ‘best’
solution, is that the actual patterns of certificate revocation in practice, is not
sufficiently studied and understood, although there are definitely some good
studies, e.g., [173]. Another challenge is that there are multiple considerations
and trade-offs, including communication (bandwidth) overhead, delay (until
revocation information arrives), handling failure to receive revocation data,
and privacy (exposure of interest in specific certificate).
349
Figure 8.10: X.509 Certificate Revocation List (CRL) format.
Bytes!); and [157], who found average CRL of 173KB. The reason for that
is that the number of revocations may be surprisingly high; specifically, [173]
found that about 8% of the non-expired certificates were revoked. In truth,
most of these were caused by a large spike in revocation due to the Heartbleed
bug [40], however, even looking at their measurements before this, about 1% of
the non-expired certificates were revoked - which can still result in excessively
long CRLs.
Three standard X.509 extensions are designed to reduce the bandwidth
overhead of CRLs:
The CRL distribution point extension splits certificates issued by a CA
to several sets (‘distribution points’), each handled by a separate CRL.
To validate a specific certificate, you (only) need the CRL for that distri-
bution list. This reduces the length of each CRL, at the cost of requiring
the CA to sign and distribute multiple CRLs (periodically). Some CAs
adopt CRL distribution points to significantly reduce the size of their
CRLs, however notice that the result is that the relying party (client)
almost always has to download the relevant CRL upon receiving the cer-
tificate, which can cause significant delay - and the communication cost
is still significant, esp. since CAs do not adopt this mechanism or still
have many certificates in each CRL.
The Authorities Revocation List (ARL) extension lists only revocations
of CA certificates. This is essentially equivalent to placing CA certificates
in a dedicated distribution point.
The Delta CRL extension lists only new revocations, which occurred since
last base-CRL. To validate that a given certificate is not revoked, check if
350
it is contained either in the Delta-CRL or in a base-CRL, issued not ear-
lier than the time specified in the Delta-CRL. However, for this method
to be effective, relying parties should cache CRLs beyond their validity
period (in order to download deltas) - this would probably reduce much
from the savings obtained using this method, and make implementation
quite complex. Possibly due to such concerns, Delta-CRLs are not widely
deployed.
Even with such optimizations, CRLs may still introduce significant band-
width overhead.
351
OCSP Client OCSP Responder
(e.g., relying party) (CA or trusted OCSP server)
OCSP request:
version, {CertID1 , . . .} [, signature] [, extensions]
OCSP response:
ResponseStatus, producedAt, responses, signature
Figure 8.11: The Online Certificate Status Protocol (OCSP). The request in-
cludes one or more certificate identifiers {CertID1 , . . .}; requests are optionally
signed. The OCSP response is signed by the responder, and includes response
for each CertID in the request. Each of these ‘individual responses’ includes
the CertID, cert-status, time of this update, time of the next update, and
optional extensions. Cert-status is either revoked, good or unknown.
352
OCSP Responder TLS client TLS (web)
(often the CA) (browser) server
OCSP request
OCSP response
TLS finish
Figure 8.12: OCSP used by relying party (as OCSP client). There are several
concerns with this form of using OCSP, including privacy exposure, overhead
on CA, and handling of delayed/missing OCSP response by the client/browser.
This last concern, illustrated in Figure 8.13, motivated updated browsers to
support and prefer OCSP-stapling (see Figure 8.14), where the TLS/web server
makes the OCSP request, instead of the client/browser, and ‘staples’ the OCSP
response to the TLS server hello message.
OCSP vs. CRLs. The length of an OCSP response is linear in the number
of CertIDs in the corresponding OCSP request, rather than a function of
the total number of revoked certificates of this CA, as is the case for CRLs.
Furthermore, the computation required for sending an OCSP response is just
4 Certificate identifiers (CertIDs) may be specified using the hash of the issuer name and
353
Note 8.3: Multi-cert OCSP requests for Certificate-Path (CP)
354
by OCSP responder. Authentication information should be provided by
the client in an appropriate OCSP extension.
• Technical reasons, such as overload or internal error.
Recall now that in the ‘classical’ OCSP deployment, the OCSP client is the
relying party, typically, the browser, as in Figure 8.12. However, this creates a
dilemma for the browser (or other relying party): how should the relying party
respond to OCSP failures and ambiguous responses, e.g., when a response does
not arrive (within reasonable time) or indicates an OCSP failure? The following
are the main options - and why each of them seems unsatisfactory:
Wait: if the problem is timeout, then the relying party may simply continue
waiting for the OCSP response, possibly resending the request periodi-
cally, and never ‘giving up’. However, OCSP servers could fail or become
inaccessible forever, or for extremely long, leaving the relying party in
this state. We do not believe any relying party has taken or will take this
approach; also, it does not address the other types of OCSP ambiguities.
Hard-fail: abort the connection (and inform the user). That is clearly a ‘safe’
alternative, i.e., prevent use of a revoked certificate. However, the OCSP
interaction may often fail or return ambiguous response due to benign
reasons, such as network connectivity issues or overload of the OCSP
responder. In particular, usually, the OCSP responder is the CA, and
CAs often do not have sufficient resources to handle high load of OCSP
requests. Therefore, this approach is not widely adopted.
Ask user: the relying party may, after some timeout, invoke a user-interface
dialog and ask the user to decide if to continue with the connection or
abort it. For example, a browser may invoke a dialog, informing the user
that the certificate-validation process is taking longer than usually, and
ask the user what action it should take. While this option may seem
to empower the user, in reality, users are rarely able to understand the
situation and make an informed decision, and are very likely to continue
with the connection; see discussion of usability in chapter 9. Hence,
except for ‘shifting the responsibility’ to the user, this option is inferior
to direct soft-fail, discussed next.
Soft-fail: finally, the relying party may simply continue as if it received a
valid OCSP response. By far, this is the most widely-adopted option. In
the typical case of a benign failure to receive the OCSP response, there
is no harm in picking this option. However, this choice leaves the user
vulnerable to an impersonation attack using a revoked certificate, when
the attacker can block the OCSP response; see Figure 8.13. Since our
need for cryptography is mainly due to concerns about a Monster-in-the-
Middle attacker, who can surely block communication, this option results
in vulnerability.
355
TLS client MitM (fake server, OCSP Responder
(browser) with revoked cert) (CA)
OCSP request
time-out→
softfail TLS key exchange, finish
TLS finish
(data)
Figure 8.13: The MitM soft-fail Attack on TLS connection, using ‘classical’
OCSP deployment, where the TLS-client (browser) sends the OCSP request
(acts as OCSP client), and assuming the (vulnerable) ‘soft-fail’ handling of
timeouts and ambiguous OCSP responses. The attacker is impersonating as a
web site, to which the attacker has the private key; the corresponding certificate
is already revoked, but the attack allows the attacker to trick the browser into
accepting it anyway, allowing the impersonation attack to succeed. The browser
queries the CA (or other OCSP server) to receive a fresh certificate-status.
However, the attacker ‘kills’ the OCSP request, or the OCSP response (figure
illustrates dropping of the response). After waiting for some time, the browser
times-out, and accepts the revoked certificate sent by the impersonating web
site, although no OCSP response was received. This ‘soft-fail’ behavior is used
by most browsers, since the alternatives (very long timeout, asking the user,
or ‘hard-fail’) are not well received by users.
As Figure 8.13 shows, the soft-fail approach essentially nullifies the value
of OCSP validation - against an attacker that exposes the private key of the
(web) server, or is able to obtain a fake (and later revoked) certificate for
the server’s domain, and is also able to block the OCSP response. Exposing
the private key and obtaining a fake certificate are both challenging attacks;
however, they do occur, otherwise, there was no need in revocations. The other
condition, of being able to block the OCSP response, is often surprisingly easy
for an attacker, e.g., by sending an excessive number of OCSP requests to the
OCSP responder (e.g. the CA) at the same time as the OCSP request from the
relying party. In particular, an attacker is likely to be able to launch such attack
356
Note 8.4: The The UX > Security Precedence Rule
357
the beginning of a connection often results in considerable delay.
Privacy exposure: the stream of OCSP requests (and responses) may expose
the identities of web sites visited by the user to the OCSP responder, or
to other agents able to inspect the network traffic. By default, OCSP
requests and responses are not encrypted, exposing this information even
to an eavesdropper; but even if encryption is used, privacy is at risk.
First, the CA is still exposed to the identities of web-sites visited by
a particular user. Second, even with encryption of OCSP requests and
responses, the timing patterns create a side-channel that may allow an
eavesdropper to identify visited websites.
Computational and communication overhead: while OCSP often reduces
overhead significantly cf. to CRLs, it still requires each response to be
signed, which is computational burden on the OCSP responder. In ad-
dition to this computational overhead, there is the overhead due to the
need of the OCSP responder to interact with any client; this overhead
remains even if applying optimizations that reduce the OCSP computa-
tional overhead, e.g., as in Exercise 8.9.
358
typically the website, acting as the OCSP client. Namely, this design moves
the responsibility to obtain ‘fresh’ OCSP signed responses to the subject (e.g.,
web-server), rather than placing this responsibility (and burden) on every client
(e.g., browser). This addresses the privacy exposure and reduces the overhead
on the OCSP responder (typically, the CA), since it now needs only to send
a single signed OCSP response to each subject (website) - much less overhead
than sending to every relying party (browser). Furthermore, since now only
the subject is supposed to make OCSP requests, the CA may limit the service
to its customers, the subjects.
Therefore, of all the concerns discussed for the relying-party-based OCSP,
only one remains: handling of ambiguous OCSP responses, and in particular,
the MitM soft-fail attack (Figure 8.13). We discuss two variants of OCSP
stapling, which handle, in two different ways, such ambiguities and failures.
359
Web+TLS server [Link],
Browser, TLS client CA and
subject of CB and
and relying party OCSP Responder
OCSP client
OCSP response:
σ = SignCA.S (CB Ok:time(·))
TLS finish
Figure 8.14: (Optional) OCSP stapling in the TLS protocol, using the Cer-
tificate Status Request (CSR) TLS extension, for a typical TLS connection be-
tween browser and web-server [Link], the subject of certificate CB . [Link]
received CB from the CA (not shown); the CA is also the OCSP responder.
The web (and TLS) server [Link] periodically sends OCSP requests to the
CA (also OCSP responder), requesting the status of its own certificate CB . The
CA sends back the OCSP response, σ = SignCA.S (CB Ok:time(·)), signalling
that CB was not revoked up to time time(·). The browser sends the TLS CSR
extension to [Link] with TLS Client Hello, to request OCSP-stapling. The
server sends back σ, the OCSP response, also in the CSR extension. The TLS
handshake now completes as usual.
Once the browser receives the OCSP response (in the CSR TLS-extension),
it validates it, i.e., validates the signature of the CA (using the CA’s public
validation key CA.v), and then validating that the response indicates non-
revocation (which we marked by Ok) and that the time indicated is ‘recent
enough’. When all is Ok, the browser completes the TLS handshake with
[Link] and then continues with the TLS connection.
We described the OCSP-stapling process for a TLS connection between a
browser and a web-server, for the case where the certificate was issued by a root
360
CA (directly trusted by the browser). However, the process is exactly the same
for other TLS clients and servers, and the modifications for the (typical) case
of intermediate CA are simple, following the multi-cert OCSP request-response
as discussed earlier, including in Note 8.3.
Principle 15. Security defenses should not be bypassed due to failures: if de-
fenses are bypassed upon failure, attacker will cause failures to bypass defenses.
Namely, soft-fail security is insecurity.
361
TLS client MitM (fake server, OCSP Responder
(browser) with revoked cert) (CA)
TLS Client Hello
with CSR extension
OCSP request
time-out→
softfail TLS key exchange, finish
TLS finish
(data)
Figure 8.15: MitM soft-fail attack on OCSP-stapling TLS client (browser), us-
ing a revoked TLS server (website) certificate; assume that the attacker has the
certified (and revoked) private key. The browser sends the CSR TLS extension;
however, the website’s certificate does not have the X.509 Must-Staple exten-
sion, or the client does not respect this extension. The attacker impersonates
as the web-server, and send the TLS server-hello and certificate messages; the
attacker does not send the OCSP response (which would have indicated revoca-
tion). The client is misled into thinking that the server does not support OCSP
stapling. The client may now send an OCSP request to the appropriate OCSP
responder, e.g., the relevant CA, but the MitM attacker would ‘kill’ the OCSP
request or response (the figure shows killing of the response). After time-out,
the client ‘gives up’ on the OCSP response, and ‘soft-fails’, i.e., accepts the
certificate and establishes the connection with the impersonated website).
362
MitM (fake server,
TLS client (browser)
with revoked cert)
Figure 8.16: The use of the Must-Staple extension defends against the MitM
soft-fail attack on OCSP-stapling TLS client of Figure 8.15. As in Figure 8.15,
the attacker tries to impersonate a web site, to which the attacker has the
private key and the corresponding certificate, which was already revoked. As
in Figure 8.15, the client sends Client-Hello request, with the CSR extension,
i.e., asking the server to staple OCSP response. As in Figure 8.15, the attacker
responds without the CSR extension, i.e., trying to mislead the client into
falling back to sending an OCSP request (and then soft-failing). However,
the Must-Staple extension instruct the client to refuse to continue without the
OCSP response from the server.
Notice that the UX>Security rule (Principle 14) applies also to websites;
website developers would be reluctant to adopt the Must-Staple extension, if
they believe this may jeopardize the availability of their website. That may be
due to different reasons, such as clients processing the extension incorrectly,
web-servers not supporting the extension or the OCSP process correctly, or to
not receiving the OCSP response from the OCSP responder (usually, the CA).
Unfortunately, as of 2018, the results are not very encouraging [44]. How-
ever, we hope that this will gradually change, as there does not appear to
be any technical reason for either the incorrect processing or for failures of
the web-servers to receive OCSP responses (and then provide them to the
browsers).
Indeed, this is an example of the significant adoption challenge facing de-
signers of new Internet and web security mechanisms; we discuss adoption
challenges further in [93]. Adoption considerations should be an important
part of the design process. In the following exercise, we discuss some issues
which may help - or hinder - the adoption of the OCSP Must-Staple extension.
Exercise 8.7. For each of the following variants of the OCSP Must-Staple ex-
tension process, indicate whether they may help or hinder adoption, and explain
why:
1. Mark the OCSP extension as a critical X.509 extension.
2. Mark the OCSP extension as a non-critical X.509 extension.
363
3. Browsers would support the OCSP Must-Staple extension, however, if
they do not receive the stapled OCSP response from the website as ex-
pected, they would send the request to the CA, and abort the connection
only if this request also fails.
4. Same as previous item, however, the server will have the ability to indicate
if the client should try sending OCSP request to the CA (if it does not
receive it stapled from the web-server). Consider three ways to indicate
this: (a) an option of the OCSP Must-Staple extension, (b) a separate
extension, or (c) an option indicated in a TLS extension returned by the
web server.
Among the variants that you believe may help adoption, indicate their relative
merits (by ordering and justifying).
Notice that Must-Staple extension requires support by the CA, to include it
in the web-server’s certificate, and to provide sufficiently-reliable OCSP service.
An alternative solution which does not require such special certificate-extension
is discussed in Exercise 8.17.
364
σ1−8 = SignCA.s (h1−8 +
+ time)
h1−8
h1−4 h5−8
h1 h2 h3 h4 h5 h6 h7 h8
c1 , s1 c2 , s1 c3 , s3 c4 , s4 c5 , s5 c6 , s6 c7 , s7 c8 , s8
Figure 8.17: Signed certificates hash-tree. The leafs are the pair of certificate
ci and its status si ∈ {good, revoked, unknown}. The root is the signature over
the hash-tree and the time. Every internal node is the hash of its children; in
particular, for every i holds hi = h(ci , si ), and hi−(i+1) = h(hi + + hi+1 ). To
validate any certificate, say c3 , provide the signature of the certificate hash-tree,
i.e., σ1−8 , the time-of-signing and the values of internal hash nodes required to
validate the signed hash, namely h4 , h1−2 and h5−8 .
365
fication, preferably, with a reduction to prove security or with a counter-
example showing insecurity (for the use of SPR hash function in this
construction).
5. Present an alternative way to replace the keyless CRHF with a different
function which is about as efficient (as the original design using CRHF),
yet is secure under a more acceptable assumption.
366
‘daily validation token’ will change from (i, xi ) to (be-
fore any of the certificates in the group is revoked) and to
(after one or more of the certificates in the group is revoked).
Further improvements may be possible. In this paragraph and Exercise 8.10,
we consider the Revoked-certificates hash-tree OSCP-variant. This OSCP-
variant uses a hash-tree of all revoked certificate-identifiers, sorted by certifi-
cate identifier. Since the tree is sorted, it can provide efficient proof of non-
revocation of a certificate. For example, assume we use the certificate serial
numbers to identify certificates, both in OCSP requests, and as the key for
sorting the revoked identifiers hash-tree. Assume that an OSCP query con-
tains a single certificate serial number, say i. The OCSP response will include
the signed revoked-certificates hash tree, together with:
If i was revoked: proof of inclusion of i in the tree, similar to the one illus-
trated in Figure 8.17.
If i was not revoked: proof of inclusion of i0 and i00 in the tree, where i0 =
max{i0 < i ∧ i0 was revoked} and i00 = min{i00 > i ∧ i00 was revoked}.
Exercise 8.10 (Revoked-certificates hash-tree OSCP-variant). Following the
brief outline in the previous paragraph:
1. Design and analyze an improved OCSP-variant using hash-tree of revoked
certificates.
2. Extend your design to also incorporate the hash-chain technique (Exer-
cise 8.9).
367
found 1832 browser-trusted signing certificates, each representing a trusted
CA (mostly, intermediate CAs). Out of these, 40% were academic institutions,
and only 20% were commercial CAs. Only 7 of these CAs were restricted to a
particular name-space (name constraints), and most did not have any length
constraints either.
The following seem to be the main weaknesses of the classical Web-PKI
system:
Risk of rogue and negligent CAs: browsers, the most common type of re-
lying party, are distributed with a list of many - typically, around a
hundred or more - ‘root CAs’, i.e., trust-anchor CAs. The reason for this
excessively-long list may be that browser manufacturers do not want to
take the responsibility for judging the trustworthiness of different CAs,
a role that may imply liability and potential anti-trust concerns. Indeed,
the role of a browser is to provide functionality, not necessarily to rep-
resent the trust of individual users; ideally, each user should determine
which CAs are ‘trust anchors’. Browsers typically provide a user inter-
face allowing users to edit the list of trusted CAs; however, it is not
realistic to expect users to really use this and modify the default list of
trusted CAs, and while we are not aware of this being measured yet, we
are quite sure that essentially nobody is doing that. The bottom line
is that some root-CAs may not be sufficiently careful (negligent CAs),
or, worse, may be subject to coercion or otherwise under control of at-
tackers (rogue CAs). Note that such attacks may be done intentionally
by nation-states, which may mean that a CA may have to comply and
cooperate. Unfortunately, the legal and business challenges do not leave
significant hope for a change that will ensure trustworthy CAs, and/or
reduce the number of root CAs.
No restrictions on certified names/domains: not only are there (too) many
‘root’ (trust-anchor) CAs, but, furthermore, any root-CA may certify any
domain, without any restrictions. Furthermore, TLS/SSL certificates is-
sued by root-CAs to intermediate CAs rarely include ‘name constraint’,
hence, intermediate CAs are also may publish a certificates for any do-
main.
Insufficient validation, esp. of Domain-validated certificates: to ensure
security of certificates, it is crucial for the certificate authority to properly
authenticate requests for certificates. However, proper authentication re-
quires costly, time-consuming validation of the requesting entity and its
right to assert the requested identifier (typically, domain name). To re-
duce costs and provide quicker, easier service to customers (requesting
certificates), many certificate authorities use automated mechanisms for
authentication, often based on the weakly-secure domain validation; see
Note 8.2.
368
Equivocation: X.509 does not include any mechanisms to prevent or detect
certificate equivocation, i.e., existence of multiple different certificates for
the identifier. For theWeb PKI, a MitM attacker can impersonate a
TLS/SSL website [Link], if it is able to obtain an equivocating cer-
tificate for [Link]. For CAs that provide domain-validated certificates,
the defense against equivocating certificates is usually merely the weak
security of the domain-validation process (Note 8.2).
Scam and phishing: there are no standard requirements for validation of
domain names by CAs, to prevent certificates for scam and phishing web-
sites. In fact, obtaining such (domain-validated) certificate is usually
easy.
Ineffective Rogue-Cert Detection and Accountability. X.509 ensures ac-
countability - but only in the sense that once a rogue certificate is detected,
it is possible - even easy - to identify the ‘culprit’ CA. However, X.509
(and Web PKI) does not provide any mechanism to detect the rogue CA.
Of course, detection is possible; for example, the Google Chrome browser
has built-in mechanisms that detect receipt of a rogue certificate for the
Google domain, which were invoked in the DigiNotar incident (Table 8.1).
The last example is an exception that proves the rule; if we could rely
on browsers knowing the public keys, we wouldn’t need certificates at
all! This specific weakness is addressed by the Certificate Transparency
mechanism, which we discuss below (§ 8.6).
quirements from PKI schemes, similarly to the definitions presented in earlier chapters for
different cryptographic schemes such as encryption. Such definitions allow provably-secure
PKI schemes; for more details on this approach, see [117].
369
beyond the basic CA accountability, directly assured by the signed certificate.
The most significant in these proposals and efforts is probably certificate trans-
parency, which provides a public, auditable log of certificates; we discuss it in
the next section. Below, we discuss several other proposed defenses.
Use name and other constraints. One possible improvement to the secu-
rity of theWeb PKI system is simply to adopt and deploy the certificate path
constraints already defined in X.509 and PKIX, most notably, the name con-
straint, discussed in subsection 8.3.7. This would allow restriction of the name
space for certificates issued by a given CA, e.g., based on the DNS top-level
domain country codes (TLDcc), as defined in RFC 1591 [140]. For example, a
Canadian CA may be restricted to the TLDcc for Canada (.ca).
This idea may appear simple and easy to deploy, but we doubt it; deploy-
ment will probably face strong objections. Let us present two major concerns.
First, the use of name constraint requires a major change in the existingWeb
PKI system, which would be very hard to enforce. Second, there does not
appear to be a natural way to place name constraint on domain names which
are in one of the generic top level domains (gTLD) - and most domains belong
to a gTLD, mainly com, org, gov, edu and biz, not to mention that new top
level domains can be defined essentially by anyone. Restricing the certification
of gTLD certificates to only specific CAs may result in significant objections
by other parties (and countries).
370
nection would be with the legitimate website, and then used to protect following
connections; this approach is referred to as Trust-On-First-Use (TOFU).
However, there are drawbacks to the use of key/certificate pinning, includ-
ing:
1. If the private key is lost to the server, e.g., due to failure, then there is a
risk of losing the ability to serve the website, until the pinning times-out.
To address this (and the next) concern, a backup copy of the secret key
must be kept by the owner of the website in secure, reliable storage.
2. Suppose an attacker penetrates the server’s site, exposes the private key
and corrupts the copy of the key used by the server. This may allow the
attacker to serve the site to unsuspecting users - while preventing the
legitimate server from serving the site, or even changing its key. Note
that this problem may exist even for a site that did not use HPKP for
key/certificate pinning, since the attacker may perform the pinning.
3. Revoking a pinned key is difficult, since a replacement key is typically
not pinned. One option is to wait for the pinning to time-out, but that
implies period of unavailability of the site. An alternative is for the imple-
mentation to cancel key pinning once the certificate is revoked; however,
the current specification does not require this behavior.
4. Key-pinning may be applied only for long-lived public keys, and may
interfere with the use of rotating keys, and seems to completely prevent
the use of ephemeral master keys, e.g., for perfect-forward secrecy.
Due to these disadvantages, the use of key and certificate pinning may not
be widely adopted, and support for it may be dropped.
Note, however, that there may still be value in pinning of security policies,
e.g., pinning of the use of OCSP-stapling; see Exercise 8.17. Similarly, there
may be a value in CA pinning, i.e., pinning of the identity of specific certifi-
cate authorities which the website would use (say, in the coming year), foiling
attacks using certificates signed by rogue or negligent CAs.
371
variants. Where we had to choose, we focus on a variant of CT presented in
[118], which is work-in-progress by Hemi Leibowitz, Ewa Syta and the author.
372
(0.2) Certificate
CB = SignCA.s ([Link], Bob.e, . . .)
Logger CA
(0.3) PoI = (SignL.s (LogDigest, time), hint)
(0.1) (0.4)
Bob’s public key Certificate+PoI
Relying party Bob.e CB , PoI
(e.g, Alice’s browser)
Figure 8.18: Certificate Transparency (CT) issue process, using a (single) log-
ger who provides a Proof-of-Inclusion (PoI) and typical usage in TLS server
authentication. The Proof-of-Inclusion (PoI) includes a signature by the logger
over a recent digest of the log (LogDigest) and the time it was signed (time), as
well as a hint, which allows verification that the specific certificate CB appears
in the log. Note: some CT variants use SCT instead of PoI, see text.
added to the log at a given time, which we refer to as PoI (Proof of Inclusion).
Most of the CT literature focuses on the SCT case, but we will focus on the
case where the logger returns a PoI, since we believe that makes the design
clearer and stronger.
But who would be these loggers? Would they become a new trusted entities,
essentially replacing the CAs in this role? That seems undesirable, as it seems
likely to result is a similar set of incentives and legal constraints, that caused
the current situation of an excessively large and not sufficiently assessed and
trustworthy set of root CAs. So CT took a different high-level goal, which
could be summed up as reducing the trust requirements from loggers. In fact,
we present two possible more specific goals for CT, both addressing this high-
level goal of reducing trust in loggers; some variants and publications focus
on one goal, while others focus on the other. Note that the two goals are not
conflicting, and it is definitely possible to combine them.
CT Goal 2: avoid a single point of failure. One problem with the pre-CT
Web PKI design, is that a single rogue CA suffices to issue faulty certificates.
In principle, one solution could have been to require each website (or, more
generally, each subject), to present certificates from two different CAs; that
would avoided the risk due to an attack by a single CA; in fact, this even
protects against scenario containing multiple rogue CAs, as long as they do
373
not collude, i.e., they don’t both certify the same rogue certificate.
The ‘multiple CA’ solution has three drawbacks. First, it is simply infeasi-
ble; we can’t realistically suddenly require websites to receive two certificates
instead of one - no chance for successful adoption. Second, it still does not
ensure transparency, if both CAs end up using the same logger. Finally, it
completely relies on prevention rather than on accountability; and in particu-
lar, it completely fails if the attacker controls the multiple CAs. However, there
is an alternative solution, that avoids these drawbacks - or at least the first
two: continue using a single CA for each certificate, but require each certificate
to be logged by multiple loggers, ensuring transparency even when one of the
loggers is corrupt.
This is a very simple method to avoid a single point of failure - and, in
fact, this is how CT is currently deployed by CAs and by the popular Chrome
browser, which requires each certificate to be logged by two loggers. However,
while it does bring accountability to a CA who issues rogue certificates (since
they would be now easily detectable), it relies completely on prevention rather
than accountability with respect to the multiple loggers. In particular, the
transparency guarantee completely fails if multiple rogue loggers all ‘drop’ the
same certificate from their logs. The CT specifications and many of the pub-
lications describing it, include additional elements which are clearly designed
to achieve a different, and arguably more systematic and ambitious goal of
resiliency to rogue entities, which we describe next.
374
Website Issuer Logger L Monitor M
Date/time
Nurse
Day d + 1
Proof-of-Inclusion
(P oI), signed by logger
Monitor request
CB , P oI
Audit P oI
the cryptographic functions used by the design. We describe the ‘real’ - and
efficient - design of the cryptographic functions in ??.
Figure 8.19 is a high-level sequence diagram showing the different entities
and processes involved in the CT PKI, for a no-faults scenario. The figure
illustrate four CT processes:
375
includes the date, although this is not shown in the figure). The CA
sends the certificate CB and the P oI to the subject [Link].
CT process 2: Periodical monitoring (dashed lines). The monitor pe-
riodically, e.g. (here) daily, contacts the logger to inquire about the
current status of the log, i.e., were there any new certificates logged. The
logger should report all new certificates added to the log in the last day
(i.e., since the previous monitor query), including CB of course. Namely,
if the logger sent a PoI for a certificate, then this certificate should be
included in this periodical (e.g., daily) report returned to monitor re-
quests. The logger should also return a signed and time-stamped Proof-
of-Log (PoL), irrevocably defining the set of certificates in the current log
Log[d + 1] (including all certificates logged till day d + 1, inclusive); the
signature would also specify the date d itself (omitted from the figure).
The monitor validates that the PoL is correct, in particular, that it is
signed by the logger; this validation uses the logger’s validation key L.v.
CT process 3: Certificate usage. Figure 8.19 shows the typical certificate
use for server-authentication during TLS handshake, for secure connec-
tion between browser (relying party) and web-server (subject of certifi-
cate). Notice that the website sends its certificate as usual, but also
attaches the PoI (Proof-of-Inclusion), which the website received from
the logger via the CA. The relying party validates that the PoI is prop-
erly signed (using the logger’s public validation key L.v), and that it
‘proves’ that CB is in the log.
CT process 4: Audit (blue). Finally, the relying party, e.g., the browser,
may (randomly or otherwise) send an audit request, including the PoI.
The monitor validates that PoI is consistent with the signed PoL that
it received from the logger. In this figure, we show the case were it
is fine, and the monitor returns an ‘Audit-Ok’ message to the relying
party; to mitigate the risk of receiving a manipulated, incorrect ‘Audit-
Ok’ response, this response must be signed - this also allows dealing with
a faulty monitor, as we explain below. In the other case, where the PoI
and PoL are inconsistent, this indicates a rogue logger. In this case, the
pair of conflicting logger signatures - over the PoL and over the PoI -
serves as a Proof of Maliciousness (PoM) of the logger, and is sent to all
parties (broadcast), so nobody will trust the rogue logger any more.
376
We separate logger faults to two categories: peer-detected faults and auditing-
detected faults. Let us first explain this categorization of faults.
Let us first present a metaphor. The two fault categories resembles the
ways in which a tax-evading vendor may be detected: peer-detection, such
as when a the vendor refuse to provide a (properly-signed) receipt, detected
almost immediately by a customer who may complain and warn others; and
audit-detection, such as when the vendor provides a receipt - but on audit is
found to not have reported the transaction correctly.
Each type of detection has its pros and cons. Peer-detection is immediate
and almost certain7 : the customer may wait a bit for the receipt, but quite soon,
most customers will realize this is a fraud and raise alarm. Audit-detection,
on the other hand, is delayed and probabilistic: not all vendors are audited,
and auditing may happen years after the fraud. On the other hand, an audit-
detection produces a clear proof of misbehavior - the conflict between the signed
receipt and the signed tax report; while a peer-detection is likely to result in
conflicting accounts by the two parties - a he-said, she-said situation. Let us
consider the two categories - in our ‘real’ context, i.e., faulty loggers.
377
It remains to explain the cryptographic design of these two proofs (PoI and
PoL). Only for this subsection, we present a naive, inefficient design. This
design is very simple:
A PoI , in this naive design, is simply a signature by the logger on the cer-
tificate with a time-stamp, identifying the log in which it should appear
(e.g., day d in our example).
A PoL , in this naive design, is the period from the previous monitor query
till the current query, together with the list of certificates added to the
log during this period, all signed by the logger.
The combination of a signed PoI showing CB is supposed to be added to the
log at a given time (say day d), and a signed PoL with a list of certificate not
including CB and where the specified period includes the time of the PoI (day
d), can only exist if the logger is misbehaving, i.e., is a logger-PoM.
Handling monitor faults. Finally, let us point out that CT also allows
audit-detection of monitor faults. The role of monitors is only to detect a
faulty logger; therefore, detection of faulty monitors may appear unnecessary.
However, by slightly extending the relying-party auditing process, with negligi-
ble overhead, we can also protect against collusion of a logger with a monitor,
where a rogue monitor is ‘covering up’ for a rogue logger.
The way to deal with such collusion of a logger with a monitor, is by using
multiple monitors. One naive design is for the relying parties to always perform
audit with a set of monitors, including a non-faulty monitor (or several). In
this case, such cover-up would fail.
Notice, however, that this solution results in significant overhead - perform-
ing audit with a sufficiently-large set of monitors. In the next subsection, we
describe more efficient implementation of the CT mechanisms, which provides
very efficient audit-detection of such rogue monitors.
378
only a signed digest of the set of all logged certificates, and an extension from
the previous set (and digest); and PoI requires only a Proof-of-Inclusion of the
scheme. For details, see [118].
379
8.7 PKI: Additional Exercises
Exercise 8.11. Some X.509 extensions are quite elaborate, and may contain
many elements of different types; for example, the SubjectAltName (SAN)
extension. A relying party may receive a certificate with a known extension, but
containing an element of unknown type, or incorrectly formatted. X.509 default
behavior is to consider the entire extension as unrecognized; if the extension is
marked ‘critical’, this results in rejecting the entire certificate, i.e., considering
it invalid. However, X.509 allows a specific extension to define other behavior
for handling unrecognized elements.
Specify a format for an extension, which will allow defining critical and
non-critical element types. Critical elements must be recognized by the relying
party or the entire extension is deemed unrecognized, and non-critical elements
may be safely ignored by the relying party if not recognized, while still handling
the other elements in this extension.
Is this mechanism of potential use within an X.509v3 critical extension?
Within a non-critical extension?
Exercise 8.12. Locate the certificate information in your browser, and:
1. Count, or estimate, the number of root CAs.
2. Count, or estimate, the number of intermediate CAs.
3. Can you give two examples of root CAs that you believe belong to orga-
nizations or companies that you know and trust? Explain.
4. Can you give two examples of root CAs that you believe belong to orga-
nizations or companies that you do not know or do not trust? Explain.
5. Can you give two examples of intermediate CAs that you believe belong
to organizations or companies that you know and trust? Explain.
6. Can you give two examples of intermediate CAs that you believe belong
to organizations or companies that you do not know or do not trust?
Explain.
7. For one of the root CAs, view its details, and identify the extensions.
For extensions covered in this chapter, explain their fields. For other
extensions, identify what they are used for.
8. For one of the intermediate CAs, view its details, and identify the exten-
sions. For extensions covered in this chapter, explain their fields. For
other extensions, identify what they are used for.
Use screen-shots to document your results.
Exercise 8.13. A website [Link] receives a TLS certificate from a CA [Link].
What should prevent [Link] from using this certificate to impersonate as the
website for domain [Link]? Present at least one mistake that [Link] could
make in the certificate, which would allow this attack.
380
Exercise 8.14. It is sometimes desirable for certificates to provide evidence
of sensitive information, like gender, age or address. Such information may
be crucial to some services, e.g., to limit access to a certain chat room only to
individuals of specific gender. It is proposed to include such information in a
special extension, and to protect the privacy of the information by hashing it;
for example, the extension may contain h(DoB) where DoB stands for date
of birth. When the subject wishes to prove her age, she provides the certificate
together with the value DoB, allowing relying party to validate the age.
381
name) mappings for people she knows, acting as a CA. To establish secure
communication, two users exchange certificates they obtained for their keys,
and possibly also certificates of the signers. Each user u maintains a directed
graph (Vu , Eu ) whose nodes Vu are (publickey, name) pairs from the set of all
certificates known to u, and where there is an edge from one node, say (pkA ,
Alice) to another, say (pkB ,Bob), if u has a certificate over (pkB ,Bob) using
key pkA ; the graph has a special ‘trust anchor’ entry for u herself, denoted
(pku , u). Each user u decides on a maximal certificate path length L(u); we
say that u trusts (pkB ,Bob) if there is a path of length at most L(u) from
(pku , u) to (pkB ,Bob) in (Vu , Eu ).
Specify an efficient algorithm for determining for u to determine if she
should trust (pkB ,Bob). What is the complexity of this algorithm? Note: you
may use well-known algorithm(s), in which case, just specify their names and
reference, there is no need to copy them in your answer.
Exercise 8.17 (OCSP-stapling against powerful attacker). Consider the fol-
lowing powerful attacker model: the attacker has Man-in-the-Middle (MitM)
capabilities, and also is able to obtain a fraudulent certificate to a website, e.g.,
[Link]. Suppose, further, that the fraudulent certificate is promptly dis-
covered and revoked.
1. Show a sequence diagram showing that this attacker can continue to im-
personate as [Link], in spite of the revocation of the certificate
and of the use of OCSP-stapling by the website.
2. Explain how use of the must-staple certificate extension [88] would pre-
vent this attack.
3. Propose a simple extension to OCSP-stapling, OCSP-stapling-pinning,
that may also help against this threat, if the must-staple extension is
not supported. Explain how your extension would foil the attack you
presented. Hint: the required extension is related to the ‘key pinning’
mechanism discussed in subsection 8.5.2.
4. Discuss the applicability of the concerns of key pinning, discussed in sub-
section 8.5.2, to the extension.
5. Consider now an even more powerful attacker, who also has MitM capabil-
ities, but also controls a root certificate authority (trusted by the browser).
Show a sequence diagram showing that this attacker can continue to im-
personate as [Link], in spite of the use of the OCSP-stapling-
pinning extension as you presented above.
6. Propose an improvement to the OCSP-stapling-pinning extension, that
may help also against this threat.
Exercise 8.18 (Keyed hash and certificates). Many cryptographic protocols
and standard, e.g., X.509, PKIX and CT, rely on the use of the ‘hash-then-
sign’ paradigm, based on the assumption that the hash function in use, h(·), a
(keyless) collision-resistant hash function (CRHF).
382
1. Explain why this assumption is problematic, specifically, prove that there
cannot exist any collision-resistant hash function. (If you fail to prove,
at least present clear, convincing argument.)
2. One way to ‘fix’ such protocols, is by using, instead, a keyed CRHF.
Explain why your argument for non-existence of a keyless CRHF, does
not also imply non-existence of keyed-CRHF.
3. Present an extension to provide the keyed-hash key, for an X.509 cer-
tificate of a signature-verification public key. Explain, with example sce-
narios/applications, if the extension should be marked as ‘critical’, as
non-critical, or if for some applications it should be marked ‘critical’ and
for others marked ‘non-critical’.
Exercise 8.19 (Malicious CA). Let MAC be a malicious CA, trusted (e.g., as
a root CA) by browsers.
383
Chapter 9
1. Assume that a user is purchasing at the attacker’s site. Explain how that
site may be able to trick the user into providing their credentials to the
attacker. Assume typical user, and exploit typical human vulnerabilities.
Present the most effective attack you can.
2. Identify the human vulnerabilities exploited by your construction.
384
3. Propose up to three things that may help to reduce the chance of such
attack.
385
1. Only allow surfing to SSL/TLS protected (https) sites.
2. Do not open websites as results of clicking on URLs received in emails.
3. If user clicks on URL in email, browser displays warning and asks user
to confirm that the URL is correct before requesting that page.
4. On the first time, per day, that the user surfs to a protected site, popup a
window with the certificate details and ask the user to confirm the details,
before requesting and displaying the site.
Exercise 9.4. In the Windows operating system, whenever the user installs
new software, a pop-up screen displays details and asks the user to approve in-
stallation - or to abort. Many programs are signed by a vendor, with a certificate
for that vendor from a trusted CA; in this case the pop-up screen displays the
(certified) name of the vendor and the (signed) name of the program. Other
programs are not signed, or the vendor is not certified; in these cases the pop-up
screen displays the names given by the program for itself and for the vendor,
but with clear statement that this was not validated.
386
Chapter 10
1. Design an efficient and secure processes for generating the approval codes
(by the customs) and validating them, by the warehouse as well as by an
arbitrary auditor. Your design should consist of two functions: generate
code and validate approval slip.
2. Add two more functions: generate receipt (run by the warehouse) and
validate receipt (run by US customs or arbitrary auditor).
3. Extend your design to allow the auditor to validate also the integrity of
the log, i.e., to validate that the log contains all approval slips for which
the customs received (valid) receipts. In this part, do not (yet) optimize
your solution for efficiently auditing (validating) a very large number of
approvals.
387
4. Optimize your solution for efficiently auditing a very large number of
approvals.
Namely, the output is a string of zero bits, whose length is |G0 (s)|, i.e.,
2n.
2. This is again NOT a secure PRG. The argument is very similar to the
previous one. The only difference is that we set G2 (s) = G0 (s ⊕ 1|s| ).
3. The output of G2 will be fixed since its input is fixed. But the question
is if G is a secure PRG, so the fact that the output of G2 is fixed doesn’t
imply G isn’t a vsecure PRG - on the contrary! The adversary can
obviously compute the output of G2 (0|s| ) by herself, without knowing s
(just knowing its length); so if the adversary can distinguish btw G(s)
and a random string, then the adversary can also distinguish between
G1 (s) and a random string, i.e., G1 isn’t a PRG. So it follows that in this
case, G is a PRG if and only if G1 is a PRG.
388
1. Alice uses some secure shared key encryption scheme (E, D), with l bit
keys, to encrypt the plaintext records into the ciphertext records. The
goal of this part is to allow Alice to encrypt and decrypt each record i
using a unique key ki , but maintain only a single ‘master’ key k, from
which it can easily compute ki for any desired record i. One motivation
for this is to allow Alice to give keys to specific record(s) ki to some other
users (Bob, Charlie,...), allowing decryption of only the corresponding
ciphertext ci , i.e., pi = Dki (ci ). Design how Alice can compute the key ki
for each record (i), using only the key k and a secure block cipher (PRP)
(F, F −1 ), with key and block sizes both l bits. Your design should be
as efficient and simple as possible. Note: do not design how Alice gives
ki to relevant users - e.g., she may do this manually; and do not design
(E, D).
Solution: ki = Fk (i)
2. Design now the encryption scheme to be used by Alice (and possibly by
other users to whom Alice gave keys ki ). You may use the block cipher
(F, F −1 ), but not other cryptographic functions. You may use different
encryption scheme (E i , Di ) for each record i. Ensure confidentiality of
the plaintext records from the cloud, from users (not given the key for
that record), and from eavesdroppers on the communication. Your design
should be as efficient as possible, in terms of the length of the ciphertext
(in bits), and in terms of number of applications of the secure block cipher
(PRP) (F, F −1 ) for each encryption and decryption operation. In this
part, assume that Alice stores P only once, i.e., never modifies records
pi . Your solution may include a new choice of ki , or simply use the same
as in the previous part.
Solution: ki = Fk (i),
Eki i (pi ) = ki ⊕ pi ,
Dki i (ci ) = ki ⊕ ci .
3. Repeat, when Alice may modify each record pi few times (say, up to 15
times); let ni denote number of modifications of pi . The solution should
allow Alice to give (only) her key k, and then Bob can decrypt all records,
using only the key k and the corresponding ciphertexts from the server.
Note: if your solution is the same as before, this may imply that your
solution to the previous part is not optimal.
Solution: ki = Fk (i + + ni ),
Eki i (pi ) = (ni , ki ⊕ pi ),
Dki i (ci ) = Dki i ((ni , c0i )) = ki ⊕ c0i . Note: ni encoded as four bits (for
efficiency).
4. Design an efficient way for Alice to validate the integrity of records re-
trieved from the cloud server S. This may include storing additional
information Ai to help validate record i, and/or changes to the encryp-
tion scheme or keys as designed in previous parts. As in previous parts,
your design should only use the block cipher (F, F −1 ).
389
Solution: compute ki as before and append to any ciphertext ci a MAC
value mi = Fki (ci ). Use the stored MAC value mi to validate ci upon
retrieval.
5. Extend the keying scheme from the first part, to allow Alice to also com-
pute keys ki,j , for integers i, j ≥ 0 s.t. 1 ≤ i · 2j + 1, (i + 1) · 2j ≤
n, where ki,j would allow (efficient) decryption of ciphertext records
ci·2j +1 , . . . , c(i+1)·2j . For example, k0,3 allows decryption of records c1 , . . . , c8 ,
and k3,2 allows decryption of records c13 , . . . , c16 . If necessary, you may
also change the encryption scheme (E i , Di ) for each record i.
Solution: Assume for simplicity that n = 2m , or, to avoid this assump-
tion, let m = dlog2 (n)e, i.e., n ≤ 2m . Let ki = ki,m , where we compute
ki,m be the following iterative process. First, let k1,0 = k. Then, for
j = 1, . . . m, we compute ki,j , for i = {1, 2, . . . , 2j }, as follows:
ki,j = Fk (imod2)
2 c
b i+1 ,j−1
390
same query to the Fk0 0 (·) oracle, to receive Fk0 0 (q). Then, ADV 0 computes by
itself Fk0000 (q), combines it with Fk0 0 (q) by computing the XOR, and returns the
response Fk0 0 (q) ⊕ Fk0000 (q) to ADV .
When ADV finally returns a pair m, Fk0 ,k00 (m), then ADV 0 computes Fk0000 (m)
and returns (m, Fk0000 (m) ⊕ Fk0 ,k00 (m)), which is the same as (m, Fk0 0 (m)) - as
required.
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Message</title>
</>
<body>
<p id="dem"></p>
<script>
var x=0;
var msg;
if (1111111122222222==1111111122222222) {
391
msg = "Pay 1$ to Amazon.";
} else {
msg = "Pay one million dollars to Mel.";
}
[Link]("dem").innerHTML = msg;
</script>
</body>
<!-- comment -->
</html>
File DM :
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Message</title>
</>
<body>
<p id="dem"></p>
<script>
var x=0;
var msg;
if (2222222211111111==1111111122222222) {
msg = "Pay 1$ to Amazon.";
} else {
msg = "Pay one million dollars to Mel.";
}
[Link]("dem").innerHTML = msg;
</script>
</body>
<!-- comment -->
</html>
(solution by SW)
392
always equals 0). Therefore, it is always trivial to find x0 s.t. f (x0 ) = f (x)
(again, x0 = 0n works, for example), so f is not a OWF, and by the same
reasoning, OTP-chain using g is insecure.
(solution by SW)
Pr A ∩ C ∪ D Pr [ A ]
Pr A | C ∪ D = = =
Pr C ∪ D 1 − Pr[ C ∪ D ]
(p)(1 − p) (p)(1 − p) (p)(1 − p) 1
= = = =
1 − (p2 + (1 − p)2 ) 2p − 2p2 2p(1 − p) 2
393
Alice Eve Bob
A, NA = 1234
A, NA = 1111
Ek (1234), NB = 5678
Ek (1234), NB = 1111
Ek (1111)
Ek (1111), NB = 2222
Ek (2222)
chooses the messages so that the difference in the compressed lengths is such
that the encrypted lengths are also different - this must be true for some lengths
if Enc takes inputs of any length.) Thus, the adversary will be able to distin-
guish between Enc0k (m0 ) and Enc0k (m1 ).
(solution by SW)
394
compute (Ek (IV )⊕NA )⊕NA ⊕NB = Ek (IV )⊕NB and can send IV, Ek (IV )⊕
NB = EkCF B (NB ), all without knowing the key k.
(solution by SW)
395
signature key A.s and Bob’s public encryption key B.e; and to receive a mes-
sage from Alice, Bob uses his private decryption key B.d and Alice’s public
verification key A.v.
1. It is proposed that Alice will select a random key k and send to Bob the
triplet: (cK , cM , σ) = (EB.e (k), k ⊕ m, SignA.s (‘Bob0 +
+ k ⊕ m)). Show
this design is insecure, i.e., a MitM attacker may either learn the message
m or cause Bob to receive a message ‘from Alice’ - that Alice never sent.
Answer: MitM attacker Monster captures the specified triplet (x, c, t)
sent by Alice to Bob, where x = EB.e (k), c = k⊕m and t = SignA.s (‘Bob0 + +
k ⊕ m). Monster sends to Bob a modified triplet: (x0 , c, t), i.e., it mod-
ifies just the first element in the triplet; this allows Monster to ensure
that Bob will receive a message m’ chosen by Monster, instead of m (and
believe Bob will believe m’ was sent by Alice). To do so, Monster sets
x0 = EB.e (c ⊕ m0 ).
2. Propose a simple, efficient and secure fix. Define the sending and receiv-
ing process precisely.
Answer: Sign also the ciphertext, i.e., change the last component in the
triplet to t = SignA.s (‘Bob0 + + k ⊕ m).
+c+
3. Extend your solution to allow prevention of replay (receiving multiple
times a message sent only once).
Answer: Sign also a counter (or time-stamp - any monotonously-increasing
value), i.e., change the last component in the triplet to t = SignA.s (‘Bob0 +
+
i++c+ + k ⊕ m) where i is the number of messages sent by Alice so far;
each recipient has to keep the last message number received from any
recipient.
396
Index
397
chosen-prefix collisions, 139 CT, 320, 323, 371
Cipher-agility, 218 CTO, 20–22, 24, 57, 58, 62, 63, 78
cipher-agility, 296 cyclic group, 244
cipher-text only, 57
ciphersuite, 218 Data Encryption Standard, 8, 26
ciphersuite negotiation, 198, 218 DDH, 254, 255
ciphertext, 24 Decisional DH, 254
Ciphertext-Only, 78 Denial-of-Service, 135, 358
ciphertext-only, 24, 58 denial-of-service, 200
ciphertext-only attack, 21 DES, 8, 26
client authentication, 323 DGA, 372
client certificate, 323 DH, 111, 225, 241, 244
client-server, 213 DH key exchange, 235
collision, 139 DH protocol, 257
collision-resistance, 164 DH-h public key cryptosystem, 263
collision-resistant, 140, 143 differential cryptanalysis, 66
collision-resistant hash, 107 Diffie-Hellman, 111, 241, 244, 252
Collision-Resistant Hash Function, Diffie-Hellman Key Exchange, 8
147, 164 Diffie-Hellman Ratchet, 258
collision-resistant hash function, 168 Diffie-Hellmen, 225
collisions, 69 digest, 164, 167
Compress-then-Encrypt Vulnerabil- digest function, 171
ity, 197 Digest scheme, 137, 164
compression function, 167 Digest-Chain, 164
Computational DH, 253 digest-chain, 154, 164
concrete security, 36, 37, 56 digital signature, 236
conservative design, 61, 106, 111 digital signatures, 235
counter-mode, 44 digitized handwritten signatures, 111
CP, 340, 354 discrete logarithm, 244, 245
CPA, 24, 27, 57, 60 discrete logarithm assumption, 245
CRHF, 107, 147, 148, 164, 167, 168 Distinguished Name, 326, 327, 337
CRIME, 197 distinguished name, 327
critical, 363 Distinguished Names, 326
critical extensions, 334 DLA, 245
criticality indicator, 334 DN, 326, 327
CRL, 349 DNS, 337, 340
CRLsets, 351 dNSName, 337
CRV, 351 Domain Generation Algorithm, 372
cryptocurrency, 182, 185 domain name, 321
cryptographic building blocks, 120, Domain Name System, 337
142 domain name system, 340
cryptographic building blocks prin- Domain Validation, 339, 340
ciple, 296 domain validation, 368
cryptographic hash, 27 DoS, 135
cryptographic hash functions, 120 dot notation, 105
CSR, 359, 360
398
Double Ratchet Key-Exchange, 261, FHE, 265
262 FIL, 120
Double-Ratchet Key-Exchange, 262, FIL-MAC, 104
263 Fixed Input Length, 104, 120
Double-ratchet key-exchange, 257 Flash Crowd, 358
Downgrade Attack, 218 Forward Secrecy, 234
downgrade attack, 218, 296 forward secrecy, 222–224, 228, 238
DV, 339, 340 freshness, 209
FSR, 41
e-voting, 265 Fully Homomorphic Encryption, 265
eavesdropping adversary, 237, 248
ECC, 63, 195 generic attack, 25
ECIES, 241 gossip, 376, 378
EDC, 195 GSM, 22, 23, 41, 63, 78, 86, 212
effective key length, 25, 28, 146 GSM handshake protocol, 231
efficient, 12, 36 GSM security, 197, 214, 216
El-Gamal, 241, 244
El-Gamal PKC, 264 Hardware Security Module, 210, 222
email address, 340 hash-chain, 138, 154
email validation, 340 Hash-then-Sign, 106, 147, 148
Encrypt-then-Authenticate, 196 hash-then-sign, 137, 147, 242, 324,
entity authentication, 197 332
equivocation detection, 323 Heartbleed Bug, 324
equivocation prevention, 323 Heartbleed bug, 350
Error Correction Code, 195 HMAC, 142, 163, 257
Error Detection Code, 195 homograph attack, 372
error localization, 77 homomorphic, 265
Error-Correcting Code, 63 HPKP, 370
Euler’s function, 268 HSM, 210, 222
Euler’s Theorem, 268 HSTS, 304
EV, 339, 340 HtS, 106, 147, 148, 242
evidence, 238 HtS-TCR, 149
exhaustive search, 24, 25, 28, 241 HTTP Strict Transport Security, 304
existential unforgeability, 106 hybrid encryption, 242, 243, 268
existentially unforgeable, 110
existentially unforgeable signature, identity certificates, 321
106, 107, 128, 147 IDS, 134
extend, 170 IETF, 336
extend function, 169 IMSI, 215
Extended Merkle Digest, 378 IND-CCA, 75, 76, 82
Extended Validation, 339, 340 IND-CCA1 secure, 335
Extract-then-Expand, 255 IND-CPA, 60–63, 68, 75, 81
extract-then-expand, 159 independently pseudorandom, 53
indistinguishability test, 32
factoring, 244 indistinguishablility test, 32
Feedback Shift Register, 41 initialization vector, 92
399
intermediate CA, 341 letter-frequency attack, 21, 24
International Mobile Subscriber Iden- linear cryptanalysis, 66
tity, 215 logger, 372
International Telecommunication Union,
325 MAC, 104, 106, 161, 221, 236, 239,
Intrusion-Detection Systems, 134 257
Intrusion-Prevention Systems, 135 malware, 372
IP address, 340 malware/virus scanners, 134
IPS, 135 master key, 257
IPsec, 194 MD-strengthening, 168
issuer, 321, 322 Merkle digest, 172
Issuer Alternative Name, 338 Merkle digest scheme, 173, 174
IssuerAltName, 337 Merkle Tree, 178, 179
ITU, 325, 332, 336 Merkle tree, 172
Merkle-Damgård, 165
KDC, 212, 238 Message Authentication Code, 106,
KDF, 156, 164, 255–257 161, 236, 257
Kerberos, 214 message recovery, 275
Kerckhoffs’ principle, 7 mining, 183, 186
Kerckhoffs’ Principle, 15 MitM, 111, 193, 204, 209, 218, 219,
Key derivation, 255 238, 248, 250, 252, 273,
key derivation, 256 297, 340, 369
Key Derivation Function, 156, 164, MitM soft-fail, 359, 361–363
255, 256 mode of operation, 46
Key Distribution, 197 Monster in the Middle, 193
Key distribution Center, 212 monster-in-middle, 273
Key Distribution Protocol, 212 Monster-in-the-Middle, 111, 204, 218,
Key exchange, 236 250, 297, 355
key exchange, 235, 236, 247 Multi-cert OCSP requests for Certificate-
key generation, 236 Path, 354
key usage, 333 Must-Staple, 361–364
key-exchange, 111, 225 must-staple, 382
key-separation principle, 52, 211, 227
key-setup, 197 name constraint, 333, 344, 347
key-setup 2PP extension, 211, 223 name constraints, 341
keyed collision resistant, 143 negligible, 37
keyed CRHF, 142, 143, 146 non-critical, 363
keyed hash, 148, 149 non-critical extensions, 334
Keyed HtS, 148 non-repudiation, 109, 110, 273, 274
keyed-CRHF, 148 nonce, 201, 204
Keyed-HtS, 148 nonces, 209
keyless CRHF, 146, 147
keyless Hash-then-Sign, 147 Object Identifier, 330
known-plaintext, 24 object identifier, 332, 333
known-plaintext attack, 57 OCSP, 320, 353
KPA, 24, 57, 62 OCSP client, 352, 354
400
OCSP Must-Staple, 359 permissionless, 182
OCSP request, 352 permutation, 54
OCSP responder, 352 PFS, 222, 225, 226, 228, 238, 257–
OCSP response, 352 259, 261, 299
OCSP server, 354 PGP, 381
OCSP Stapling, 359 PHE, 265
OCSP stapling, 358, 359 phishing, 369, 372
OFB, 46 PKC, 8, 63, 111, 226, 236, 239,
OFB-mode, 44 240, 247, 320
off-path, 111, 340 PKI, 110–112, 320, 322
OID, 330, 332, 333, 339, 340 PKIX, 320, 336, 337
One Time Pad, 30, 32 plaintext, 24
one-time pad, 31 PoC, 182
one-time password, 154 Pohlig-Hellman algorithm, 245
one-time signatures, 147 PoI, 177, 182, 373, 376, 377
one-time-pad, 225 PoL, 376, 377, 379
One-Way Function, 153 policy constraints, 341, 347
one-way function, 39, 142, 147, 153 policy mapping, 348
OneCRL, 351 PoM, 374, 376–379
oracle, 47, 49, 60 PoW, 138, 182, 183
oracle access, 12, 60 PPT, 12, 36, 50, 243, 245, 253,
Organization Validation, 340 256
Origin Validation, 339, 340 prefetch, 349
OTP, 30, 32, 154, 225 Preimage resistance, 153
OTP-chain, 138, 154 preimage resistant, 153
Output Feedback, 46 preloaded, 304
OV, 339, 340 PRF, 32, 39, 42, 44, 45, 47–49,
OWF, 138, 142, 147, 153, 154 53, 65, 88, 136, 215, 227,
256, 257
partially-homomorphic encryption, PRG, 25, 32, 33, 35, 36, 38, 88,
265 225
PBR, 71 PRG indistinguishability test, 34
Per-Block Random, 71 privacy, 265
Per-goal keys, 53 private key, 236
per-goal keys, 211 Proactive security, 238
Perfect Forward Secrecy, 225, 226, proactive security, 227
228, 238, 257, 258 Probabilistic Polynomial Time, 12,
Perfect forward secrecy, 299 36, 243
perfect forward secrecy, 222, 228 Proof of Inclusion, 373
Perfect Recover Secrecy, 225, 226, Proof of Maliciousness, 376
257, 258 Proof of Misbehavior, 374
perfect recover secrecy, 222, 226, 228, Proof-of-Consistency, 171, 174, 182
229 Proof-of-Inclusion, 171, 173, 177,
perfect-forward secrecy, 261 182, 375–377
perfect-recover secrecy, 261 Proof-of-Log, 376, 377, 379
permissioned, 182 Proof-of-Misbehavior, 377–379
401
Proof-of-Stake, 183 quadratic residue, 246
Proof-of-Work, 138, 182, 183
protocols, 191 rainbow tables, 27
proxy re-encryption, 267 random functions, 43, 53
PRP, 32, 53, 55, 67 random functions., 42
PRP/PRF switching lemma, 66, 69, Random Oracle Model, 160
113 Random oracle model, 136
PRS, 222, 225–229, 257–259, 261 random oracle model, 142
Pseudo Random Function, 215 Random Oracle Model (ROM), 160
Pseudo-Random Function, 39, 42, random permutation, 53
44, 45, 47–49, 65, 227, 256 randomness extracting hash function,
pseudo-random function, 32, 136, 255
228 randomness extraction, 156, 164
Pseudo-Random Functions, 43 ransomware, 372
pseudo-random functions, 32 RC4, 41
Pseudo-Random Generator, 25, 32, record protocol, 194
33, 35, 36, 38 recover secrecy, 222, 224, 225, 228,
pseudo-random generator, 32, 225 229
pseudo-random generators, 32 recover security, 224
Pseudo-Random Permutation, 55, Recover-Security Handshake, 224, 262
67 relying parties, 325
pseudo-random permutation, 32, 53 relying party, 320, 322, 333, 342
pseudo-randomness, 32 resiliency to exposure, 238
pseudorandomness, 32 Resiliency to Exposures, 257
public key, 236 resiliency to exposures, 198
public key certificate, 110, 112, 238, Resiliency to key exposure, 222
273, 321, 328 resiliency to key exposure, 225
public key certificates, 151 robust combiner, 51, 289
public key cryptography, 320 ROM, 138, 142, 160
Public Key Cryptology, 8 root CA, 323, 341
Public key cryptology, 239 root certificate authorities, 323
public key cryptology, 225, 228, 235, routing, 340
247 RS-Ratchet, 225, 258
Public key cryptosystem, 236 RSA, 29, 111, 241, 244, 270
public key cryptosystem, 111, 147, RSA assumption, 270
236 RSA signatures, 275
public key cryptosystems, 63
Public Key Infrastructure, 109, 320, S/MIME, 323
336 safe prime, 245, 247, 251, 254, 255
public key infrastructure, 110, 111 salt, 255, 256
public key(s), 325 SAN, 337, 380
public-key cryptography, 194, 226 scam, 369, 372
public-key cryptosystem, 241, 247 Schnorr’s group, 254
public-key encryption, 65, 235 SCSV, 303
public-key infrastructure, 112 SCT, 372
second preimage resistance, 136
402
second-preimage resistance, 142, 149 table look-up attack, 27
Second-Preimage Resistant, 142 Target Collision Resistant, 144, 146
second-preimage resistant, 150 target collision-resistant, 144
secure in the standard model, 161 target-collision resistant, 148
Secure Session Protocols, 194 TCR, 144, 146, 148, 177
secure session transmission proto- textbook RSA, 268
col, 194 TextSecure, 262
Secure Socket Layer, 194 The UX > Security Precedence Rule,
security parameter, 49, 60, 204 357
security requirements, 11 Threshold security, 238
session key, 197 threshold security, 227
session protocol, 194 TIME, 197
Session Ticket Encryption Key (STEK), time-memory tradeoff, 25, 27
311 time/memory/data tradeoff, 27
session-authentication, 197 Timestamp, 208
shared-key authentication-handshake timestamp, 209
protocols, 197 Timestamps, 209
Shared-key Entity-Authenticating Hand- timing side channel, 82
shake Protocols, 198 TLDcc, 370
side channel, 82 TLS, 194, 195, 197, 285, 320–323,
side-channel, 358 360, 369
Signaling Cipher Suite Value, 303 TLS extension, 359
signature scheme, 65, 104, 236, 272 TLS feature, 334
signature schemes, 101, 274 TLS FALLBACK SCSV, 303
signature with appendix, 274 to-be-signed, 331
signature with message recovery, 274, TOFU, 111, 273, 371
275 top-level domain country codes, 370
smooth, 247 transparency, 322
SNA, 200–203 Transport-Layer Security, 194, 285
SNA handshake protocol, 200, 203 truncation, 195
soft-fail, 361 trust anchor, 335–337, 341, 343
SPR, 136, 142, 149, 150 trust on first use, 111, 273
SSL, 194, 195, 320–323, 369 Trust-On-First-Use, 371
SSL-Stripping, 304 trusted third party, 212
stapled-OCSP, 352 TTP, 212
stream cipher, 31 two-layered hash tree, 172
stream ciphers, 13 Two-layered Mekle Tree, 176
SubjectAltName, 337, 338, 380 Two-layered Merkle Tree, 175, 176
subsequent certificates, 342, 347 Two-layered Merkle Tree P oC is cor-
sufficient effective key length, 240 rect and secure., 177
symmetric cryptography, 212
symmetric cryptosystem, 241 unary, 50
Synchronous DH Ratchet, 259 universal one-way hash functions,
Systems Network Architecture, 201 144
universal re-encryption, 267
table look-up, 25 user experience, 357
403
user-experience, 357
UX, 357
UX>Security, 361
404
Bibliography
405
[10] T. Be’ery and A. Shulman. A Perfect CRIME? Only TIME Will Only
Tell. In Blackhat Europe, March 2013.
[11] M. Bellare, R. Canetti, and H. Krawczyk. Keying hash functions for
message authentication. In N. Koblitz, editor, Advances in Cryptology—
CRYPTO ’96, volume 1109 of Lecture Notes in Computer Science, pages
1–15. Springer-Verlag, 18–22 Aug. 1996.
[12] M. Bellare, R. Canetti, and H. Krawczyk. Pseudorandom functions revis-
ited: the cascade construction and its concrete security. In Proceedings
of 37th Conference on Foundations of Computer Science, pages 514–523,
1996.
[13] M. Bellare, R. Canetti, and H. Krawczyk. HMAC: Keyed-hashing for
message authentication. Internet Request for Comment RFC 2104, In-
ternet Engineering Task Force, Feb. 1997.
[14] M. Bellare, R. Canetti, and H. Krawczyk. A modular approach to the
design and analysis of authentication and key exchange protocols. In Pro-
ceedings of the thirtieth annual ACM symposium on Theory of computing,
pages 419–428. ACM, 1998.
[15] M. Bellare, A. Desai, E. Jokipii, and P. Rogaway. A concrete security
treatment of symmetric encryption. In Proceedings 38th Annual Sympo-
sium on Foundations of Computer Science, pages 394–403. IEEE, 1997.
[16] M. Bellare, R. Guérin, and P. Rogaway. Xor macs: New methods for
message authentication using finite pseudorandom functions. In Annual
International Cryptology Conference, pages 15–28. Springer, 1995.
[17] M. Bellare, J. Kilian, and P. Rogaway. The security of the cipher block
chaining message authentication code. J. Comput. Syst. Sci., 61(3):362–
399, 2000.
[18] M. Bellare, T. Krovetz, and P. Rogaway. Luby-rackoff backwards: In-
creasing security by making block ciphers non-invertible. In Advances in
Cryptology–Eurocrypt, 1998.
[19] M. Bellare and C. Namprempre. Authenticated encryption: Relations
among notions and analysis of the generic composition paradigm. Jour-
nal of Cryptology: the journal of the International Association for Cryp-
tologic Research, 21(4):469–491, Oct. 2008.
[20] M. Bellare and P. Rogaway. Entity authentication and key distribution.
In Crypto, volume 93, pages 232–249. Springer, 1993.
[21] M. Bellare and P. Rogaway. Random oracles are practical: A paradigm
for designing efficient protocols. In Proceedings of the 1st ACM conference
on Computer and communications security, pages 62–73, 1993.
406
[22] M. Bellare and P. Rogaway. Optimal asymmetric encryption. In Work-
shop on the Theory and Application of of Cryptographic Techniques,
pages 92–111. Springer, 1994.
[23] M. Bellare and P. Rogaway. Provably secure session key distribution:
the three party case. In Proceedings of the twenty-seventh annual ACM
symposium on Theory of computing, pages 57–66. ACM, 1995.
[24] M. Bellare and P. Rogaway. Collision-resistant hashing: Towards making
uowhfs practical. In Annual International Cryptology Conference, pages
470–484. Springer, 1997.
[25] S. M. Bellovin. Frank Miller: Inventor of the One-Time Pad. Cryptologia,
35(3):203–222, 2011.
[26] S. M. Bellovin. Vernam, Mauborgne, and Friedman: The One-Time Pad
and the index of coincidence. In P. Y. A. Ryan, D. Naccache, and J.-
J. Quisquater, editors, The New Codebreakers, volume 9100 of Lecture
Notes in Computer Science, pages 40–66. Springer, 2016.
[27] R. Bird, I. Gopal, A. Herzberg, P. Janson, S. Kutten, R. Molva, and
M. Yung. The kryptoknight family of light-weight protocols for authen-
tication and key distribution. IEEE/ACM Transactions on Networking
(TON), 3(1):31–41, 1995.
[28] R. Bird, I. Gopal, A. Herzberg, P. A. Janson, S. Kutten, R. Molva, and
M. Yung. Systematic design of a family of attack-resistant authenti-
cation protocols. IEEE Journal on Selected Areas in Communications,
11(5):679–693, 1993.
[29] A. Biryukov and A. Shamir. Cryptanalytic time/memory/data tradeoffs
for stream ciphers. In International Conference on the Theory and Ap-
plication of Cryptology and Information Security, pages 1–13. Springer,
2000.
[30] J. Black, P. Rogaway, and T. Shrimpton. Encryption-scheme security in
the presence of key-dependent messages. In K. Nyberg and H. M. Heys,
editors, Selected Areas in Cryptography, volume 2595 of Lecture Notes in
Computer Science, pages 62–75. Springer, 2002.
[31] S. Blake-Wilson, M. Nystrom, D. Hopwood, J. Mikkelsen, and T. Wright.
Transport Layer Security (TLS) Extensions. RFC 3546 (Proposed Stan-
dard), June 2003. Obsoleted by RFC 4366.
[32] S. Blake-Wilson, M. Nystrom, D. Hopwood, J. Mikkelsen, and T. Wright.
Transport Layer Security (TLS) Extensions. RFC 4366 (Proposed Stan-
dard), Apr. 2006. Obsoleted by RFCs 5246, 6066, updated by RFC 5746.
407
[33] M. Blaze, G. Bleumer, and M. S. 0001. Divertible protocols and atomic
proxy cryptography. In K. Nyberg, editor, Advances in Cryptology -
EUROCRYPT ’98, International Conference on the Theory and Appli-
cation of Cryptographic Techniques, Espoo, Finland, May 31 - June 4,
1998, Proceeding, volume 1403 of Lecture Notes in Computer Science,
pages 127–144. Springer, 1998.
[34] M. Blaze, J. Feigenbaum, and A. D. Keromytis. Keynote: Trust man-
agement for public-key infrastructures. In International Workshop on
Security Protocols, pages 59–63. Springer, 1998.
[35] M. Blaze, J. Feigenbaum, and J. Lacy. Decentralized trust management.
In Proceedings 1996 IEEE Symposium on Security and Privacy, pages
164–173. IEEE, 1996.
[36] D. Bleichenbacher. Chosen ciphertext attacks against protocols based on
the rsa encryption standard pkcs# 1. In Annual International Cryptology
Conference, pages 1–12. Springer, 1998.
[37] N. Borisov, I. Goldberg, and D. Wagner. Intercepting mobile com-
munications: The insecurity of 802.11. In Proceedings of the Seventh
Annual International Conference on Mobile Computing and Networking
(MOBICOM-01), pages 180–188, New York, July 16–21 2001. ACM
Press.
[38] BSI. Kryptographische verfahren: Empfehlungen und schlussell, Febru-
ary 2017.
[39] R. Canetti, R. Gennaro, A. Herzberg, and D. Naor. Proactive security:
Long-term protection against break-ins. RSA Laboratories’ CryptoBytes,
3(1):1–8, 1997.
[40] M. M. Carvalho, J. DeMott, R. Ford, and D. A. Wheeler. Heartbleed
101. IEEE Secur. Priv, 12(4):63–67, 2014.
[41] M. CCITT. Specification of abstract syntax notation one (asn.1). Open
Systems Interconnection-Basic Reference Model, 1988.
[42] D. Chadwick. Understanding X. 500: the directory. Chapman & Hall,
Ltd., 1994.
[43] S. Checkoway, M. Fredrikson, R. Niederhagen, A. Everspaugh, M. Green,
T. Lange, T. Ristenpart, D. J. Bernstein, J. Maskiewicz, and H. Shacham.
On the practical exploitability of dual ec in tls implementations. In Pro-
ceedings of the 23rd USENIX conference on Security Symposium, pages
319–335. USENIX Association, 2014.
[44] T. Chung, J. Lok, B. C. 0002, D. R. Choffnes, D. Levin, B. M. Maggs,
A. Mislove, J. P. Rula, N. Sullivan, and C. Wilson. Is the web ready for
ocsp must-staple? In Internet Measurement Conference, pages 105–118.
ACM, 2018.
408
[45] S. Cohney, M. D. Green, and N. Heninger. Practical state recovery at-
tacks against legacy RNG implementations, October 2017. online at
[Link]
[46] I. C. S. L. M. S. Committee. IEEE 802.11: Wireless LAN Medium Access
Control and Physical Layer Specifications, Aug. 1999.
[47] D. Cooper, S. Santesson, S. Farrell, S. Boeyen, R. Housley, and W. Polk.
Internet X.509 Public Key Infrastructure Certificate and Certificate Re-
vocation List (CRL) Profile. RFC 5280 (Proposed Standard), May 2008.
Updated by RFCs 6818, 8398, 8399.
[48] S. A. Crosby and D. S. Wallach. Efficient data structures for tamper-
evident logging. In USENIX Security Symposium, pages 317–334, 2009.
[49] J. Daemen and V. Rijmen. The design of Rijndael: AES-the advanced
encryption standard. Springer Science & Business Media, 2013.
[50] W. Dai. Crypto++ 6.0.0 benchmarks, 2018. version of 01-23-2018.
[51] I. B. Damgård. Collision free hash functions and public key signature
schemes. In Workshop on the Theory and Application of of Cryptographic
Techniques, pages 203–216. Springer, 1987.
[52] I. B. Damgård. A design principle for hash functions. In G. Brassard,
editor, Advances in Cryptology—CRYPTO ’89, volume 435 of Lecture
Notes in Computer Science, pages 416–427. Springer-Verlag, 1990, 1989.
[53] Y. Desmedt. Threshold cryptosystems. In International Workshop on
the Theory and Application of Cryptographic Techniques, pages 1–14.
Springer, 1992.
[54] T. Dierks and C. Allen. The TLS Protocol Version 1.0. RFC 2246
(Proposed Standard), Jan. 1999. Obsoleted by RFC 4346, updated by
RFCs 3546, 5746, 6176, 7465, 7507, 7919.
[55] T. Dierks and E. Rescorla. The Transport Layer Security (TLS) Protocol
Version 1.2. RFC 5246 (Proposed Standard), Aug. 2008. Obsoleted by
RFC 8446, updated by RFCs 5746, 5878, 6176, 7465, 7507, 7568, 7627,
7685, 7905, 7919, 8447.
[56] W. Diffie and M. Hellman. New directions in cryptography. IEEE Trans-
actions on Information Theory, 22(6):644–654, Nov. 1976.
[57] R. Dingledine, N. Mathewson, and P. F. Syverson. Tor: The second-
generation onion router. In M. Blaze, editor, Proceedings of the 13th
USENIX Security Symposium, August 9-13, 2004, San Diego, CA, USA,
pages 303–320. USENIX, 2004.
409
[58] Y. Dodis, R. Gennaro, J. Håstad, H. Krawczyk, and T. Rabin. Ran-
domness extraction and key derivation using the cbc, cascade and hmac
modes. In Annual International Cryptology Conference, pages 494–510.
Springer, 2004.
[59] D. Dolev, C. Dwork, and M. Naor. Nonmalleable cryptography. SIAM
review, 45(4):727–784, 2003.
[60] N. Doraswamy and D. Harkins. IPSec: the new security standard for the
Internet, intranets, and virtual private networks. Prentice Hall Profes-
sional, 2003.
[61] B. Dowling, F. Günther, U. Herath, and D. Stebila. Secure logging
schemes and certificate transparency. In European Symposium on Re-
search in Computer Security, pages 140–158. Springer, 2016.
[62] O. Dubuisson. ASN. 1 communication between heterogeneous systems.
Morgan Kaufmann, 2000.
[63] O. Dunkelman. Techniques for cryptanalysis of block ciphers. Thesis
(ph.d.), Faculty of Computer Science, Technion — Israel Institute of
Technology, Haifa, Israel, 2006.
[64] T. Duong and J. Rizzo. Here come the XOR ninjas. presented at
Ecoparty and available at [Link]
talks/bullrun/[Link], 2011.
[65] Z. Durumeric, J. Kasten, M. Bailey, and J. A. Halderman. Analysis of
the https certificate ecosystem. In K. Papagiannaki, P. K. Gummadi,
and C. Partridge, editors, Proceedings of the 2013 Internet Measurement
Conference, IMC 2013, Barcelona, Spain, October 23-25, 2013, pages
291–304. ACM, 2013.
[66] M. Dworkin. Recommendation for block cipher modes of operation. meth-
ods and techniques. Technical report, National Inst of Standards and
Technology Gaithersburg MD Computer security Div, 2001.
[67] M. J. Dworkin. Sha-3 standard: Permutation-based hash and extendable-
output functions. Technical report, NIST, 2015.
[68] M. J. Dworkin. Recommendation for block cipher modes of operation:
The cmac mode for authentication. Special Publication (NIST SP)-800-
38B, 2016.
[69] S. Dziembowski and K. Pietrzak. Leakage-resilient cryptography. In
Foundations of Computer Science, 2008. FOCS’08. IEEE 49th Annual
IEEE Symposium on, pages 293–302. IEEE, 2008.
[70] C. Evans, C. Palmer, and R. Sleevi. Public Key Pinning Extension for
HTTP. RFC 7469 (Proposed Standard), Apr. 2015.
410
[71] S. Even. Graph algorithms. Cambridge University Press, 2011.
[72] L. Ewing. Linux 2.0 penguins. Example of using The GIMP graphics
software, online; accessed 1-Sept-2017.
[73] P.-A. Fouque, D. Pointcheval, J. Stern, and S. Zimmer. Hardness of
distinguishing the msb or lsb of secret keys in diffie-hellman schemes. In
International Colloquium on Automata, Languages, and Programming,
pages 240–251. Springer, 2006.
[74] S. Frankel and S. Krishnan. IP Security (IPsec) and Internet Key Ex-
change (IKE) Document Roadmap. RFC 6071 (Informational), Feb.
2011.
[75] A. Freier, P. Karlton, and P. Kocher. The Secure Sockets Layer (SSL)
Protocol Version 3.0. RFC 6101 (Historic), Aug. 2011.
[76] S. Garfinkel and N. Makarevitch. PGP: Pretty Good Privacy. O’Reilly
International Thomson, Paris, France, 1995.
[77] Y. Gilad, A. Herzberg, M. Sudkovitch, and M. Goberman. Cdn-on-
demand: An affordable ddos defense via untrusted clouds. In Network
and Distributed System Security Symposium (NDSS). The Internet Soci-
ety, 2016.
[78] D. Giry. Cryptographic key length recommendation, 2018. version of
01-23-2018.
[79] O. Goldreich. Foundations of Cryptography, volume Basic Tools. Cam-
bridge University Press, 2001.
[80] O. Goldreich. Foundations of cryptography: volume 2, basic applications.
Cambridge university press, 2009.
[81] O. Goldreich. P, NP, and NP-Completeness: The Basics of Complexity
Theory. Cambridge University Press, 2010.
[82] O. Goldreich, S. Goldwasser, and S. Micali. How to construct random
functions. J. ACM, 33(4):792–807, 1986.
[83] S. Goldwasser and S. Micali. Probabilistic encryption. Journal of Com-
puter and System Sciences, 28(2):270–299, Apr. 1984.
[84] P. Golle, M. Jakobsson, A. Juels, and P. Syverson. Universal re-
encryption for mixnets. In Cryptographers’ Track at the RSA Conference,
pages 163–178. Springer, 2004.
[85] M. Goodwin. Revoking intermediate certifi-
cates: Introducing OneCRL. Mozilla Security Blog,
[Link]
revoking-intermediate-certificates-introducing-onecrl/,
Mar. 2015.
411
[86] C. G. Günther. An identity-based key-exchange protocol. In Workshop
on the Theory and Application of of Cryptographic Techniques, pages
29–37. Springer, 1989.
[87] C. Hall, D. Wagner, J. Kelsey, and B. Schneier. Building prfs from prps.
In Annual International Cryptology Conference, pages 370–389. Springer,
1998.
[88] P. Hallam-Baker. X.509v3 Transport Layer Security (TLS) Feature Ex-
tension. RFC 7633 (Proposed Standard), Oct. 2015.
[89] D. Hankerson, A. J. Menezes, and S. Vanstone. Guide to elliptic curve
cryptography. Springer Science & Business Media, 2006.
[90] J. Håstad and M. Nåslund. The security of all rsa and discrete log bits.
Journal of the ACM (JACM), 51(2):187–230, 2004.
[91] M. E. Hellman. A cryptanalytic time-memory trade-off. IEEE Trans.
Information Theory, 26(4):401–406, 1980.
[92] A. Herzberg. Folklore, practice and theory of robust combiners. Journal
of Computer Security, 17(2):159–189, 2009.
[93] A. Herzberg. Foundations of Cybersecurity, volume 2: An Internet-
focused Introduction to Network Security. Draft version available
online at [Link]
Foundations_of_Cybersecurity_early_draft_of_part_II_Network_
Security, 2020.
[94] A. Herzberg and Y. Mass. Relying party credentials framework. Elec-
tronic Commerce Research, 4(1-2):23–39, 2004.
[95] A. Herzberg, Y. Mass, J. Mihaeli, D. Naor, and Y. Ravid. Access control
meets public key infrastructure, or: Assigning roles to strangers. In
Proceeding 2000 IEEE Symposium on Security and Privacy. S&P 2000,
pages 2–14. IEEE, 2000.
[96] K. E. Hickman and T. Elgamal. The SSL protocol (version
2). Archived copy: =[Link]
vwfGws0GMow98DX3i7B/view?usp=sharing, June 1995. Published as
Internet Draft [Link].
[97] J. Hodges, C. Jackson, and A. Barth. HTTP Strict Transport Security
(HSTS). RFC 6797 (Proposed Standard), Nov. 2012.
[98] J. Hoffstein, J. Pipher, J. H. Silverman, and J. H. Silverman. An intro-
duction to mathematical cryptography. Springer, 2008.
[99] International Telecommunication Union. X.509 : Information technol-
ogy - Open Systems Interconnection - The Directory: Public-key and
attribute certificate frameworks, October 2019.
412
[100] J. Jean. TikZ for Cryptographers. [Link]
tikz/, 2016. CBC figures by Diana Maimut.
[101] A. Joux. Algorithmic cryptanalysis. CRC Press, 2009.
[102] D. Kahn. The Codebreakers: The comprehensive history of secret com-
munication from ancient times to the internet. Simon and Schuster, 1996.
[103] J. Kelsey, B. Schneier, D. Wagner, and C. Hall. Cryptanalytic attacks on
pseudorandom number generators. In S. Vaudenay, editor, Fast Software
Encryption: 5th International Workshop, volume 1372 of Lecture Notes
in Computer Science, pages 168–188, Paris, France, 23–25 Mar. 1998.
Springer-Verlag.
[104] A. Kerckhoffs. La cryptographie militaire. Journal des Sciences Mili-
taires, IX, 1883.
[105] S. Kille. A String Representation of Distinguished Names. RFC 1779
(Historic), Mar. 1995. Obsoleted by RFCs 2253, 3494.
[106] C. A. Kirtchev. A cyberpunk manifesto. Cyberpunk Review. Disponible
en [Link] 1997.
[107] A. Klein. Attacks on the RC4 stream cipher. Designs, Codes and Cryp-
tography, 48(3):269–286, 2008.
[108] L. R. Knudsen and M. Robshaw. The Block Cipher Companion. Infor-
mation Security and Cryptography. Springer, 2011.
[109] P. Koopman. 32-bit cyclic redundancy codes for internet applications. In
Proceedings 2002 International Conference on Dependable Systems and
Networks (DSN 2002), pages 459–472, (Bethesda, MD) Washington, DC,
USA, June 2002. IEEE Computer Society.
[110] H. Krawczyk. The order of encryption and authentication for protecting
communications (or: how secure is SSL?). In J. Kilian, editor, Advances
in Cryptology – CRYPTO ’ 2001, volume 2139 of Lecture Notes in Com-
puter Science, pages 310–331. International Association for Cryptologic
Research, Springer-Verlag, Berlin Germany, 2001.
[111] H. Krawczyk. Cryptographic extraction and key derivation: The hkdf
scheme. In T. Rabin, editor, Advances in Cryptology - CRYPTO 2010,
30th Annual Cryptology Conference, Santa Barbara, CA, USA, August
15-19, 2010. Proceedings, volume 6223 of Lecture Notes in Computer
Science, pages 631–648. Springer, 2010.
[112] J. F. Kurose and K. W. Ross. Computer networking: a top-down ap-
proach, volume 4. Addison Wesley Boston, 2009.
413
[113] J. Larisch, D. R. Choffnes, D. Levin, B. M. Maggs, A. Mislove, and
C. Wilson. Crlite: A scalable system for pushing all tls revocations to all
browsers. In IEEE Symposium on Security and Privacy, pages 539–556.
IEEE Computer Society, 2017.
[114] B. Laurie. Certificate transparency. Communications of the ACM,
57(10):40–46, 2014.
[115] B. Laurie, A. Langley, and E. Kasper. Certificate Transparency. RFC
6962 (Experimental), June 2013.
[116] B. Laurie, A. Langley, E. Kasper, E. Messeri, and R. Stradling. Cer-
tificate transparency version 2.0. IETF TRANS (Public Notary Trans-
parency) WG, Internet-Draft, November 2019.
[117] H. Leibowitz, A. Herzberg, and E. Syta. Provably model-secure pki
schemes. Cryptology ePrint Archive, Report 2019/807, 2019. https:
//[Link]/2019/807.
[118] H. Leibowitz, A. Herzberg, and E. Syta. PKIng: Practical, Provably-
Secure and Transparent PKI, or: In God we trust; Loggers we Monitor .
Work in progress, 2020.
[119] A. K. Lenstra and E. R. Verheul. Selecting cryptographic key sizes.
Journal of Cryptology, 14(4):255–293, 2001.
[120] G. Leurent and T. Peyrin. Sha-1 is a shambles: First chosen-prefix col-
lision on sha-1 and application to the {PGP} web of trust. In 29th
{USENIX} Security Symposium ({USENIX} Security 20), pages 1839–
1856, 2020.
[121] S. Levy. Crypto: how the code rebels beat the government, saving privacy
in the digital age. Viking, 2001.
[122] N. Li, J. C. Mitchell, and W. H. Winsborough. Design of a role-based
trust-management framework. In Proceedings 2002 IEEE Symposium on
Security and Privacy, pages 114–130. IEEE, 2002.
[123] M. Luby and C. Rackoff. How to construct pseudorandom permutations
from pseudorandom functions. SIAM Journal on Computing, 17(2):373–
386, Apr. 1988.
[124] I. Mantin and A. Shamir. A practical attack on broadcast RC4. In
International Workshop on Fast Software Encryption, pages 152–164.
Springer, 2001.
[125] M. Marlinspike. More tricks for defeating ssl in practice. Black Hat USA,
2009.
414
[126] J. Mason, K. Watkins, J. Eisner, and A. Stubblefield. A natural language
approach to automated cryptanalysis of two-time pads. In Proceedings
of the 13th ACM conference on Computer and communications security,
pages 235–244. ACM, 2006.
[127] A. J. Menezes, P. C. van Oorschot, and S. A. Vanston, editors. Handbook
of Applied Cryptography. CRC Press, 1996.
[128] R. C. Merkle. A certified digital signature. In G. Brassard, editor, Ad-
vances in Cryptology—CRYPTO ’89, volume 435 of Lecture Notes in
Computer Science, pages 218–238. Springer-Verlag, 1990, Aug. 1989.
[129] R. C. Merkle. One way hash functions and DES. pages 428–446, Berlin
- Heidelberg - New York, Aug. 1990. Springer.
[130] C. Meyer and J. Schwenk. Lessons learned from previous SSL/TLS at-
tacks - a brief chronology of attacks and weaknesses. IACR Cryptology
ePrint Archive, 2013:49, 2013.
[131] B. Moeller and A. Langley. TLS Fallback Signaling Cipher Suite Value
(SCSV) for Preventing Protocol Downgrade Attacks. RFC 7507 (Pro-
posed Standard), Apr. 2015.
[132] B. Möller, T. Duong, and K. Kotowicz. This POODLE bites: Exploiting
the SSL 3.0 fallback, September 2014. Online, accessed 01-Sept-2017.
[133] M. Naor and M. Yung. Universal one-way hash functions and their cryp-
tographic applications. In Proceedings of the twenty-first annual ACM
symposium on Theory of computing, pages 33–43, 1989.
[134] National Bureau of Standards. Data Encryption Standard. U. S. Depart-
ment of Commerce, Washington, DC, USA, Jan. 1977.
[135] B. C. Neuman and T. Ts’o. Kerberos: An authentication service for
computer networks. IEEE Communications magazine, 32(9):33–38, 1994.
[136] P. Oechslin. Making a faster cryptanalytic time-memory trade-off. In
Annual International Cryptology Conference, pages 617–630. Springer,
2003.
[137] R. Oppliger. SSL and TLS: Theory and Practice. Artech House, 2016.
[138] C. Paar and J. Pelzl. Understanding Cryptography - A Textbook for Stu-
dents and Practitioners. Springer, 2010.
[139] Y. Pettersen. The Transport Layer Security (TLS) Multiple Certificate
Status Request Extension. RFC 6961 (Proposed Standard), June 2013.
Obsoleted by RFC 8446.
[140] J. Postel. Domain Name System Structure and Delegation. RFC 1591
(Informational), Mar. 1994.
415
[141] S. Radack. Secure hash standard: Updated specifications approved and
issued as federal information processing standard (fips) 180-4. Technical
report, National Institute of Standards and Technology, 2012.
[142] B. Ramsdell and S. Turner. Secure/Multipurpose Internet Mail Exten-
sions (S/MIME) Version 3.2 Message Specification. RFC 5751 (Proposed
Standard), Jan. 2010.
[143] E. Rescorla. SSL and TLS: designing and building secure systems, vol-
ume 1. Addison-Wesley Reading, 2001.
[144] R. L. Rivest, A. Shamir, and L. Adleman. A method for obtaining digital
signatures and public-key cryptosystems. Communications of the ACM,
21(2):120–126, 1978.
[145] J. Rizzo and T. Duong. Crime: Compression ratio info-leak made easy.
In ekoparty Security Conference, 2012.
[146] P. Rogaway. Authenticated-encryption with associated-data. In
V. Atluri, editor, ACM Conference on Computer and Communications
Security, pages 98–107. ACM, November 2002.
[147] P. Rogaway. Evaluation of some blockcipher modes of operation. Cryptog-
raphy Research and Evaluation Committees (CRYPTREC) for the Gov-
ernment of Japan, 2011.
[148] P. Rogaway and T. Shrimpton. Cryptographic hash-function basics: Def-
initions, implications, and separations for preimage resistance, second-
preimage resistance, and collision resistance. In International workshop
on fast software encryption, pages 371–388. Springer, 2004.
[149] P. Saint-Andre and J. Hodges. Representation and Verification of
Domain-Based Application Service Identity within Internet Public Key
Infrastructure Using X.509 (PKIX) Certificates in the Context of Trans-
port Layer Security (TLS). RFC 6125 (Proposed Standard), Mar. 2011.
[150] J. Salowey, H. Zhou, P. Eronen, and H. Tschofenig. Transport Layer
Security (TLS) Session Resumption without Server-Side State. RFC 5077
(Proposed Standard), Jan. 2008. Obsoleted by RFC 8446, updated by
RFC 8447.
[151] S. Santesson, M. Myers, R. Ankney, A. Malpani, S. Galperin, and
C. Adams. X.509 Internet Public Key Infrastructure Online Certificate
Status Protocol - OCSP. RFC 6960 (Proposed Standard), June 2013.
[152] C. E. Shannon. Communication theory of secrecy systems. Bell Systen
Technicl Journal, 28:656–715, Oct. 1949.
[153] Y. Sheffer, R. Holz, and P. Saint-Andre. Summarizing Known Attacks
on Transport Layer Security (TLS) and Datagram TLS (DTLS). RFC
7457 (Informational), Feb. 2015.
416
[154] J. Simpson. An in-depth technical analysis of Curve-
Ball (CVE-2020-0601). Published in Trend Mi-
cro security intelligence blog, online at:[Link]
[Link]/trendlabs-security-intelligence/
an-in-depth-technical-analysis-of-curveball-cve-2020-0601/,
February 2020.
[155] S. Singh. The Science of Secrecy: The Secret History of Codes and Code-
breaking. Fourth Estate, London, UK, 2001.
[156] N. P. Smart. Cryptography Made Simple. Information Security and Cryp-
tography. Springer, 2016.
[157] T. Smith, L. Dickenson, and K. E. Seamons. Let’s revoke: Scalable global
certificate revocation. In NDSS. The Internet Society, 2020.
[158] M. Stevens, A. K. Lenstra, and B. de Weger. Chosen-prefix collisions for
md5 and colliding x.509 certificates for different identities. In M. Naor,
editor, Advances in Cryptology - EUROCRYPT 2007, 26th Annual In-
ternational Conference on the Theory and Applications of Cryptographic
Techniques, Barcelona, Spain, May 20-24, 2007, Proceedings, volume
4515 of Lecture Notes in Computer Science, pages 1–22. Springer, 2007.
[159] D. R. Stinson. Cryptography: theory and practice. CRC press, 2005.
[160] G. Tsudik. Message authentication with one-way hash functions. ACM
SIGCOMM Computer Communication Review, 22(5):29–38, 1992.
[161] A. M. Turing. On computable numbers, with an application to the
entscheidungsproblem. Procedings of the London Mathematical Society,
42(2):230–265, 1936.
[162] A. M. Turing. Computing machinery and intelligence. Mind,
59(236):433–460, Oct. 1950.
[163] L. Valenta, D. Adrian, A. Sanso, S. Cohney, J. Fried, M. Hastings, J. A.
Halderman, and N. Heninger. Measuring small subgroup attacks against
diffie-hellman. In Network and Distributed System Security Symposium
(NDSS), 2017.
[164] M. Vanhoef and F. Piessens. Key reinstallation attacks: Forcing nonce
reuse in wpa2. In B. M. Thuraisingham, D. Evans, T. Malkin, and D. Xu,
editors, Proceedings of the 2017 ACM SIGSAC Conference on Computer
and Communications Security, CCS 2017, Dallas, TX, USA, pages 1313–
1328. ACM, 2017.
[165] S. Venkata, S. Harwani, C. Pignataro, and D. McPherson. Dynamic Host-
name Exchange Mechanism for OSPF. RFC 5642 (Proposed Standard),
Aug. 2009.
417
[166] G. S. Vernam. Secret signaling system, July 22 1919. US Patent
1,310,719.
[167] J. Von Neumann. Various techniques used in connection with random
digits. Applied Math Series, 12(36-38):1, 1951.
[168] D. Wagner, B. Schneier, et al. Analysis of the ssl 3.0 protocol. In The
Second USENIX Workshop on Electronic Commerce Proceedings, pages
29–40, 1996.
[169] N. Wiener. Cybernetics, or control and communication in the animal and
the machine. John Wiley, New York, 1948.
[170] Wikipedia. Block cipher mode of operation, 2017. [Online; accessed
1-Sept-2017].
[171] Wikipedia contributors. Forward secrecy — Wikipedia, the free ency-
clopedia. [Link]
secrecy&oldid=973196673, 2020. [Online; accessed 16-August-2020].
[172] R. J. Wilson. Introduction to Graph Theory. Pearson, New York, NY, 5
edition, 2010.
[173] L. Zhang, D. R. Choffnes, T. Dumitras, D. Levin, A. Mislove, A. Schul-
man, and C. Wilson. Analysis of ssl certificate reissues and revocations
in the wake of heartbleed. Commun. ACM, 61(3):109–116, 2018.
[174] K. Zuse. Method for automatic execution of calculations with the aid of
computers (1936). In B. Randell, editor, The Origins of Digital Comput-
ers: Selected Papers, Texts and monographs in computer science, pages
163–170. Springer-Verlag, pub-SV:adr, third edition, 1982.
418