Docsity

Pseudorandom Function Generators and One Time Passwords, Lecture notes of Mathematics

Toggle sidebar
bg1
1We will often identify the strings of length ๐‘›with
the numbers between 0and 2๐‘›โˆ’1, and switch freely
between the two representations, and hence can think
of ๐‘–also as a string in {0,1}๐‘›. We will also switch
between indexing strings starting from 0and starting
from 1based on convenience.
4
Pseudorandom functions
Reading: Rosulek Chapter 6 has a good description of pseudorandom
functions. Katz-Lindell cover pseudorandom functions in a different
order than us. The topics of this lecture and the next ones are covered
in KL sections 3.4-3.5 (PRFs and CPA security), 4.1-4.3 (MACs), and
8.5 (construction of PRFs from PRG).
In the last lecture we saw the notion of pseudorandom generators, and
introduced the PRG conjecture, which stated that there exists a pseu-
dorandom generator mapping ๐‘›bits to ๐‘›+1bits. We have seen the
length extension theorem, which states that given such a pseudoran-
dom generator, there exists a generator mapping ๐‘›bits to ๐‘šbits for an
arbitrarily large polynomial ๐‘š(๐‘›). But can we extend it even further?
Say, to 2๐‘›bits? Does this question even make sense? And why would
we want to do that? This is the topic of this lecture.
At a first look, the notion of extending the output length of a pseu-
dorandom generator to 2๐‘›bits seems nonsensical. After all, we want
our generator to be efficient and just writing down the output will take
exponential time. However, there is a way around this conundrum.
While we canโ€™t efficiently write down the full output, we can require
that it would be possible, given an index ๐‘–โˆˆ{0,โ€ฆ,2๐‘›โˆ’1}, to compute
the ๐‘–๐‘กโ„Žbit of the output in polynomial time.1That is, we require that
the function ๐‘–โ†ฆ ๐บ(๐‘ )๐‘–is efficiently computable and (by security of
the pseudorandom generator) indistinguishable from a function that
maps each index ๐‘–to an independent random bit in {0,1}. This is the
notion of a pseudorandom function generator which is a bit subtle to de-
fine and construct, but turns out to have a great many applications in
cryptography.
Definition 4.1 โ€” Pseudorandom Function Generator. An efficiently com-
putable function ๐นtaking two inputs ๐‘ โˆˆ{0,1}โˆ—and ๐‘–โˆˆ{0,โ€ฆ,2|๐‘ |โˆ’
1}and outputting a single bit ๐น(๐‘ ,๐‘–)is a pseudorandom function
Compiled on 11.17.2021 22:35
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Pseudorandom Function Generators and One Time Passwords and more Lecture notes Mathematics in PDF only on Docsity!

(^1) We will often identify the strings of length ๐‘› with the numbers between 0 and 2 ๐‘›โˆ’1, and switch freely between the two representations, and hence can think of ๐‘– also as a string in {0, 1}๐‘›. We will also switch between indexing strings starting from 0 and starting from 1 based on convenience.

Pseudorandom functions

Reading: Rosulek Chapter 6 has a good description of pseudorandom functions. Katz-Lindell cover pseudorandom functions in a different order than us. The topics of this lecture and the next ones are covered in KL sections 3.4-3.5 (PRFs and CPA security), 4.1-4.3 (MACs), and 8.5 (construction of PRFs from PRG). In the last lecture we saw the notion of pseudorandom generators , and introduced the PRG conjecture , which stated that there exists a pseu- dorandom generator mapping ๐‘› bits to ๐‘› + 1 bits. We have seen the length extension theorem, which states that given such a pseudoran- dom generator, there exists a generator mapping ๐‘› bits to ๐‘š bits for an arbitrarily large polynomial ๐‘š(๐‘›). But can we extend it even further? Say, to 2 ๐‘›^ bits? Does this question even make sense? And why would we want to do that? This is the topic of this lecture. At a first look, the notion of extending the output length of a pseu- dorandom generator to 2 ๐‘›^ bits seems nonsensical. After all, we want our generator to be efficient and just writing down the output will take exponential time. However, there is a way around this conundrum. While we canโ€™t efficiently write down the full output, we can require that it would be possible, given an index ๐‘– โˆˆ {0, โ€ฆ , 2๐‘›^ โˆ’ 1}, to compute the ๐‘–๐‘กโ„Ž^ bit of the output in polynomial time.^1 That is, we require that the function ๐‘– โ†ฆ ๐บ(๐‘ )๐‘– is efficiently computable and (by security of the pseudorandom generator) indistinguishable from a function that maps each index ๐‘– to an independent random bit in {0, 1}. This is the notion of a pseudorandom function generator which is a bit subtle to de- fine and construct, but turns out to have a great many applications in cryptography.

Definition 4.1 โ€” Pseudorandom Function Generator. An efficiently com- putable function ๐น taking two inputs ๐‘  โˆˆ {0, 1}โˆ—^ and ๐‘– โˆˆ {0, โ€ฆ , 2|๐‘ |โˆ’ 1} and outputting a single bit ๐น (๐‘ , ๐‘–) is a pseudorandom function

Compiled on 11.17.2021 22:

112 an intensive introduction to cryptography

(^2) This also allows us to be consistent with the notion of โ€œpolynomial in the size of the input.โ€

(PRF) generator if for every polynomial time adversary ๐ด out- putting a single bit and polynomial ๐‘(๐‘›), if ๐‘› is large enough then:

๐‘ โˆˆ{0,1}๐‘›

[๐ด๐น (๐‘ ,โ‹…)(1๐‘›)] โˆ’ ๐”ผ

๐ปโ†๐‘…[2๐‘›]โ†’{0,1}

[๐ด๐ป^ (1๐‘›)]โˆฃ < 1/๐‘(๐‘›).

Some notes on notation are in order. The input 1 ๐‘›^ is simply a string of ๐‘› ones, and it is a typical cryptography convention to assume that such an input is always given to the adversary. This is simply be- cause by โ€œpolynomial time adversaryโ€ we really mean polynomial in ๐‘› (which is our key size or security parameter)^2. The notation ๐ด๐น (๐‘ ,โ‹…) means that ๐ด has black box (also known as oracle ) access to the func- tion that maps ๐‘– to ๐น (๐‘ , ๐‘–). That is, ๐ด can choose an index ๐‘–, query the box and get ๐น (๐‘ , ๐‘–), then choose a new index ๐‘–โ€ฒ, query the box to get ๐น (๐‘ , ๐‘–โ€ฒ), and so on for a polynomial number of queries. The notation ๐ป โ†๐‘… [2๐‘›] โ†’ {0, 1} means that ๐ป is a completely random function that maps every index ๐‘– to an independent and random different bit.

R Remark 4.2 โ€” Completely Random Functions. This no- tion of a randomly chosen function can be difficult to wrap your mind around. Try to imagine a table of all of the strings in {0, 1}๐‘›. We now go to each possible input, randomly generate a bit to be its output, and write down the result in the table. When weโ€™re done, we have a length 2 ๐‘›^ lookup table that maps each input to an output that was generated uniformly at random and independently of all other outputs. This lookup table is now our random function ๐ป. In practice itโ€™s too cumbersome to actually generate all 2 ๐‘›^ bits, and sometimes in theory itโ€™s convenient to think of each output as generated only after a query is made. This leads to adopting the lazy evaluation model. In the lazy evaluation model, we imagine that a lazy person is sitting in a room with the same lookup table as before, but with all entries blank. If someone makes some query ๐ป(๐‘ ), the lazy person checks if the entry for ๐‘  in the lookup table is blank. If so, the lazy evalu- ator generates a random bit, writes down the result for ๐‘ , and returns it. Otherwise, if an output has already been generated for ๐‘  previously (because ๐‘  has been queried before), the lazy evaluator simply returns this value. Can you see why this model is more convenient in some ways? One last way to think about how a completely random function is determined is to first observe that there exist a total of 22 ๐‘› functions from {0, 1}๐‘›^ to {0, 1} (can you see why? It may be easier to think of them as functions from [2๐‘›] to {0, 1}). We choose one of them

114 an intensive introduction to cryptography

that on input ๐‘  โˆˆ {0, 1}โˆ—^ and ๐‘– โˆˆ {0, โ€ฆ , 2|๐‘ |^ โˆ’ 1} outputs ๐‘“๐‘ (๐‘–) is a PRF generator.

Note that the condition of Definition 4.3 corresponds to requiring that for every polynomial ๐‘ and ๐‘(๐‘›)-time adversary ๐ด, if ๐‘› is large enough then

โˆฃ ๐‘ โˆˆ{0,1}๐”ผ ๐‘›[๐ด๐‘“๐‘ (โ‹…)(1๐‘›)] โˆ’ โ„Žโ†๐”ผ

๐‘…โ„ฑ๐‘›,

[๐ดโ„Ž(1๐‘›)]โˆฃ < 1/๐‘(๐‘›)

where โ„ฑ๐‘›,1 is the set of all functions mapping {0, 1}๐‘›^ to {0, 1} (i.e., the set {0, 1}๐‘›^ โ†’ {0, 1}).

P It is worth while to pause and make sure you un- derstand why Definition 4.3 and Definition 4.1 give different ways to talk about the same object.

Figure 4.1 : In a pseudorandom function, an adversary cannot tell whether they are given a black box that computes the function ๐‘– โ†ฆ ๐น (๐‘ , ๐‘–) for some secret ๐‘  that was chosen at random and fixed, or whether the black box computes a completely random function that tosses a fresh random coin whenever itโ€™s given a new input ๐‘–.

In the next lecture we will see the proof of following theorem (due to Goldreich, Goldwasser, and Micali)

Theorem 4.4 โ€” PRFs from PRGs. Assuming the PRG conjecture, there exists a secure pseudorandom function generator.

But before we see the proof of Theorem 4.4, let us see why pseudo- random functions could be useful.

pseudorandom functions 115

4.1 ONE TIME PASSWORDS (E.G. GOOGLE AUTHENTICATOR, RSA ID, ETC.)

Until now we have talked about the task of encryption , or protecting the secrecy of messages. But the task of authentication , or protecting the integrity of messages is no less important. For example, consider the case that you receive a software update for your PC, phone, car, pacemaker, etc. over an open channel such as an unencrypted Wi- Fi connection. The contents of that update are not secret, but it is of crucial importance that it was unchanged from the message sent out by the company and that no malicious attacker had modified the code. Similarly, when you log into your bank, you might be much more concerned about the possibility of someone impersonating you and cleaning out your account than you are about the secrecy of your information. Letโ€™s start with a very simple scenario which weโ€™ll call the login problem. Alice and Bob share a key as before, but now Alice wants to simply prove her identity to Bob. What makes this challenging is that this time they need to contend with not the passive eavesdropping Eve but the active adversary Mallory , who completely controls the communication channel between them and can modify (or mall ) any message that they send. Specifically for the identity proving case, we think of the following scenario. Each instance of such an identifica- tion protocol consists of some interaction between Alice and Bob that ends with Bob deciding whether to accept it as authentic or reject as an impersonation attempt. Malloryโ€™s goal is to fool Bob into accepting her as Alice. The most basic way to try to solve the login problem is by simply using a password. That is, if we assume that Alice and Bob can share a key, we can treat this key as some secret password ๐‘ that was se- lected at random from {0, 1}๐‘›^ (and hence can only be guessed with probability 2 โˆ’๐‘›). Why doesnโ€™t Alice simply send ๐‘ to Bob to prove to him her identity? A momentโ€™s thought shows that this would be a very bad idea. Since Mallory is controlling the communication line, she would learn ๐‘ after the first identification attempt and could then easily impersonate Alice in future interactions. However, we seem to have just the tool to protect the secrecy of ๐‘โ€” encryption. Suppose that Alice and Bob share a secret key ๐‘˜ and an additional secret password ๐‘. Wouldnโ€™t a simple way to solve the login problem be for Alice to send Bob an encryption of the password ๐‘? After all, the security of the encryption should guarantee that Mallory canโ€™t learn ๐‘, right?

P

pseudorandom functions 117

an actual random function instead of a pseudo random function. In a truly random function, every one of the values ๐‘“๐‘ (0), โ€ฆ , ๐‘“๐‘ (2๐‘›^ โˆ’ 1) is chosen independently and uniformly at random from {0, 1}. One useful way to imagine this is using the concept of โ€œlazy evaluationโ€. We can think of ๐‘“๐‘† as determined by tossing 2 ๐‘›^ different coins for the values ๐‘“(0), โ€ฆ , ๐‘“(2๐‘›^ โˆ’ 1). Now consider the case where we donโ€™t actually toss the ๐‘–๐‘กโ„Ž^ coin until we need it. The crucial point is that if we have queried the function in ๐‘‡ โ‰ช 2๐‘›^ places, then when Bob chooses a random ๐‘– โˆˆ [2๐‘›] it is extremely unlikely that any one of the set {๐‘–, ๐‘– + 1, โ€ฆ , ๐‘– + โ„“ โˆ’ 1} will be one of those locations that we pre- viously queried. Thus, if the function was truly random, Mallory has no information on the value of the function in these coordinates, and would be able to predict (or rather, guess) it in all these locations with probability at most 2 โˆ’โ„“.

P Please make sure you understand the informal rea- soning above, since we will now translate this into a formal theorem and proof.

Theorem 4.5 โ€” Login protocol via PRF. Suppose that {๐‘“๐‘ } is a secure pseudorandom function generator and Alice and Bob interact us- ing Protocol PRF-Login for some polynomial number ๐‘‡ of sessions (over a channel controlled by Mallory). After observing these in- teractions, Mallory then interacts with Bob, where Bob follows the protocolโ€™s instructions but Mallory has access to arbitrary efficient computation. Then, the probability that Bob accepts the interaction is at most 2 โˆ’โ„“^ + ๐œ‡(๐‘›) where ๐œ‡(โ‹…) is some negligible function.

Proof. This proof, as so many others in this course, uses an argument via contradiction. We assume, towards the sake of contradiction, that there exists an adversary ๐‘€ (for Mallory) that can break the identifi- cation scheme PRF-Login with probability 2 โˆ’โ„“^ + ๐œ– after ๐‘‡ interactions. We then construct an attacker ๐ด that can distinguish access to {๐‘“๐‘ } from access to a random function in ๐‘๐‘œ๐‘™๐‘ฆ(๐‘‡ ) time and with bias at least ๐œ–/2. How do we construct this adversary ๐ด? The idea is as follows. First, we prove that if we ran the protocol PRF-Login using an actual random function, then ๐‘€ would not be able to succeed in impersonating with probability better than 2 โˆ’โ„“^ + ๐‘›๐‘’๐‘”๐‘™๐‘–๐‘”๐‘–๐‘๐‘™๐‘’. Therefore, if ๐‘€ does do better, then we can use that to distinguish ๐‘“๐‘  from a random function. The adversary ๐ด gets some black box ๐‘‚(โ‹…) (for oracle ) and will use it while internally simulating all the partiesโ€” Alice, Bob and Mallory (using ๐‘€ ) in the ๐‘‡ + 1 interactions of the PRF-Login protocol. Whenever any

118 an intensive introduction to cryptography

of the parties needs to evaluate ๐‘“๐‘ (๐‘–), ๐ด will forward ๐‘– to its black box ๐‘‚(โ‹…) and return the value ๐‘‚(๐‘–). It will then output 1 if and only if ๐‘€ succeeds in impersonation in this internal simulation. The argument above showed that if ๐‘‚(โ‹…) is a truly random function, then the proba- bility that ๐ด outputs 1 is at most 2 โˆ’โ„“^ + ๐‘›๐‘’๐‘”๐‘™๐‘–๐‘”๐‘–๐‘๐‘™๐‘’ (and so in particular less than 2 โˆ’โ„“^ + ๐œ–/2). On the other hand, if ๐‘‚(โ‹…) is the function ๐‘– โ†ฆ ๐‘“๐‘ (๐‘–) for some fixed and random ๐‘ , then this probability is at least 2 โˆ’โ„“^ + ๐œ–. Thus ๐ด will distinguish between the two cases with bias at least ๐œ–/2. We now turn to the formal proof: Claim 1: Let PRF-Login* be the hypothetical variant of the protocol PRF-Login where Alice and Bob share a completely random function ๐ป โˆถ [2๐‘›] โ†’ {0, 1}. Then, no matter what Mallory does, the probability she can impersonate Alice after observing ๐‘‡ interactions is at most 2 โˆ’โ„“^ + (8โ„“๐‘‡ )/2๐‘›. (If PRF-Login* is easier to prove secure than PRF-Login, you might wonder why we bother with PRF-Login in the first place and not sim- ply use PRF-Login. The reason is that specifying a random function ๐ป requires specifying 2 ๐‘›^ bits, and so that would be a huge shared key. So PRF-Login is not a protocol we can actually run but rather a hy- pothetical โ€œmental experimentโ€ that helps us in arguing about the security of PRF-Login.) Proof of Claim 1: Let ๐‘– 1 , โ€ฆ , ๐‘–2๐‘‡ be the nonces chosen by Bob and recieved by Alice in the first ๐‘‡ iterations. That is, ๐‘– 1 is the nonce cho- sen by Bob in the first iteration while ๐‘– 2 is the nonce that Alice re- ceived in the first iteration (if Mallory doesnโ€™t modify it then ๐‘– 1 = ๐‘– 2 ). Similarly, ๐‘– 3 is the nonce chosen by Bob in the second iteration while ๐‘– 4 is the nonce received by Alice and so on and so forth. Let ๐‘– be the nonce chosen in the ๐‘‡ + 1๐‘ ๐‘ก^ iteration in which Mallory tries to im- personate Alice. We claim that the probability that there exists some ๐‘— โˆˆ {1, โ€ฆ , 2๐‘‡ } such that |๐‘– โˆ’ ๐‘–๐‘—| < 2โ„“ is at most 8โ„“๐‘‡ /2๐‘›. Indeed, let ๐‘† be the union of all the intervals of the form {๐‘–๐‘— โˆ’ 2โ„“ + 1, โ€ฆ , ๐‘–๐‘— + 2โ„“ โˆ’ 1} for 1 โ‰ค ๐‘— โ‰ค 2๐‘‡. Since itโ€™s a union of 2๐‘‡ intervals each of length less than 4โ„“, ๐‘† contains at most 8๐‘‡ โ„“ elements, so the probability that ๐‘– โˆˆ ๐‘† is |๐‘†|/2๐‘›^ โ‰ค (8๐‘‡ โ„“)/2๐‘›. Now, if there does not exists a ๐‘— such that |๐‘–โˆ’๐‘–๐‘—| < 2โ„“ then it means in particular that all the queries to ๐ป(โ‹…) made by either Alice or Bob during the first ๐‘‡ iterations are disjoint from the interval {๐‘–, ๐‘– + 1, โ€ฆ , ๐‘– + โ„“ โˆ’ 1}. Since ๐ป(โ‹…) is a completely random function, the values ๐ป(๐‘–), โ€ฆ , ๐ป(๐‘– + โ„“ โˆ’ 1) are chosen uniformly and independently from all the rest of the values of this function. Since Malloryโ€™s message ๐‘ฆ to Bob in the ๐‘‡ + 1๐‘ ๐‘ก^ iteration depends only on what she observed in the past, the values ๐ป(๐‘–), โ€ฆ , ๐ป(๐‘– + โ„“ โˆ’ 1) are inde- pendent from ๐‘ฆ, and hence under the condition that there is no overlap between this interval and prior queries, the probability that they equal ๐‘ฆ is 2 โˆ’โ„“. QED (Claim 1).

120 an intensive introduction to cryptography

Theorem 4.7 โ€” PRF length extension. Suppose that PRFs exist. Then for every constant ๐‘ and polynomial-time computable functions โ„“in, โ„“out โˆถ โ„• โ†’ โ„• with โ„“in(๐‘›), โ„“out(๐‘›) โ‰ค ๐‘›๐‘, there exist a PRF ensem- ble with input length โ„“in and output length โ„“out.

Thus from now on whenever we are given a PRF, we will allow ourselves to assume that it has any polynomial output size that is convenient for us.

4.2 MESSAGE AUTHENTICATION CODES

One time passwords are a tool allowing you to prove your identity to, say, your email server. But even after you did so, how can the server trust that future communication comes from you and not from some attacker that can interfere with the communication channel between you and the server (so called โ€œman in the middleโ€ attack)? Similarly, one time passwords may allow a software company to prove their identity before they send you a software update, but how do you know that an attacker does not change some bits of this software update on route between their servers and your device? This is where Message Authentication Codes (MACs) come into play- their role is to authenticate not only the identity of the parties but also their communication. Once again we have Alice and Bob , and the adversary Mallory who can actively modify messages (in contrast to the passive eavesdropper Eve). Similar to the case to encryption, Alice has a message ๐‘š she wants to send to Bob, but now we are not concerned with Mallory learning the contents of the message. Rather, we want to make sure that Bob gets precisely the message ๐‘š sent by Alice. Actually this is too much to ask for, since Mallory can always decide to block all communication, but we can ask that either Bob gets precisely ๐‘š or he detects failure and accepts no message at all. Since we are in the private key setting, we assume that Alice and Bob share a key ๐‘˜ that is unknown to Mallory. What kind of security would we want? We clearly want Mallory not to be able to cause Bob to accept a message ๐‘šโ€ฒ^ โ‰  ๐‘š. But, like in the encryption setting, we want more than that. We would like Alice and Bob to be able to use the same key for many messages. So, Mallory might observe the interactions of Alice and Bob on messages ๐‘š 1 , โ€ฆ , ๐‘š๐‘‡ before trying to cause Bob to accept a message ๐‘šโ€ฒ๐‘‡ +1 โ‰  ๐‘š๐‘‡ +1. In fact, to make our notion of security more robust, we will even allow Mallory to choose the messages ๐‘š 1 , โ€ฆ , ๐‘š๐‘‡ (this is known as a chosen message or chosen plaintext attack). The resulting formal definition is below:

pseudorandom functions 121

(^3) Clearly if the adversary outputs a pair (๐‘š, ๐œ) that it did query from its oracle then that pair will pass verification. This suggests the possibility of a replay attack whereby Mallory resends to Bob a message that Alice sent him in the past. As above, one can thwart this by insisting the every message ๐‘š begins with a fresh nonce or a value derived from the current time.

(^4) A priori you might ask if we should not also give Mallory an oracle to ๐‘‰๐‘˜(โ‹…) as well. After all, in the course of those many interactions, Mallory could also send Bob many messages (๐‘šโ€ฒ, ๐œโ€ฒ) of her choice, and observe from his behavior whether or not these passed verification. It is a good exercise to show that adding such an oracle does not change the power of the definition, though we note that this is decidedly not the case in the analogous question for encryption.

Definition 4.8 โ€” Message Authentication Codes (MAC). Let (๐‘†, ๐‘‰ ) (for sign and verify ) be a pair of efficiently computable algorithms where ๐‘† takes as input a key ๐‘˜ and a message ๐‘š, and produces a tag ๐œ โˆˆ {0, 1}โˆ—, while ๐‘‰ takes as input a key ๐‘˜, a message ๐‘š, and a tag ๐œ , and produces a bit ๐‘ โˆˆ {0, 1}. We say that (๐‘†, ๐‘‰ ) is a Message Authentication Code (MAC) if:

  • For every key ๐‘˜ and message ๐‘š, ๐‘‰๐‘˜(๐‘š, ๐‘†๐‘˜(๐‘š)) = 1.
  • For every polynomial-time adversary ๐ด and polynomial ๐‘(๐‘›), it is with less than 1/๐‘(๐‘›) probability over the choice of ๐‘˜ โ†๐‘… {0, 1}๐‘›^ that ๐ด๐‘†๐‘˜(โ‹…)(1๐‘›) = (๐‘šโ€ฒ, ๐œ โ€ฒ) such that ๐‘šโ€ฒ^ is not one of the messages ๐ด queries and ๐‘‰๐‘˜(๐‘šโ€ฒ, ๐œ โ€ฒ) = 1. 3

If Alice and Bob share the key ๐‘˜, then to send a message ๐‘š to Bob, Alice will simply send over the pair (๐‘š, ๐œ) where ๐œ = ๐‘†๐‘˜(๐‘š). If Bob receives a message (๐‘šโ€ฒ, ๐œ โ€ฒ), then he will accept ๐‘šโ€ฒ^ if and only if ๐‘‰๐‘˜(๐‘šโ€ฒ, ๐œ โ€ฒ) = 1. Mallory now observes ๐‘ก rounds of communication of the form (๐‘š๐‘–, ๐‘†๐‘˜(๐‘š๐‘–)) for messages ๐‘š 1 , โ€ฆ , ๐‘š๐‘ก of her choice, and her goal is to try to create a new message ๐‘šโ€ฒ^ that was not sent by Alice, but for which she can forge a valid tag ๐œ โ€ฒ^ that will pass verification. Our notion of security guarantees that sheโ€™ll only be able to do so with negligible probability, in which case the MAC is CMA-secure.^4

R Remark 4.9 โ€” Why can Mallory choose the messages?. The notion of a โ€œchosen message attackโ€ might seem a little โ€œover the topโ€. After all, Alice is going to send to Bob the messages of her choice, rather than those chosen by her adversary Mallory. However, as cryp- tographers have learned time and again the hard way, it is better to be conservative in our security defini- tions and think of an attacker that has as much power as possible. First of all, we want a message authentica- tion code that will work for any sequence of messages, and so itโ€™s better to consider this โ€œworst caseโ€ setting of allowing Mallory to choose them. Second, in many realistic settings an adversary could have some effect on the messages that are being sent by the parties. This has occurred time and again in cases ranging from web servers to German submarines in World War II, and weโ€™ll return to this point when we talk about chosen plaintext and chosen ciphertext attacks on encryption schemes.

pseudorandom functions 123

(^5) This discussion has more to do with computational complexity than cryptography, and so can be safely skipped without harming understanding of future material in this course.

output 1 with probability 1/๐‘(๐‘›). That means that such an adversary ๐ดโ€ฒ^ can distinguish between an oracle to ๐น (๐‘˜, โ‹…) and an oracle to a random function ๐ป, which gives us a contradiction. โ– 

4.4 ARBITRARY INPUT LENGTH EXTENSION FOR MACS AND PRFS

So far we required the message to be signed ๐‘š to be no longer than the key ๐‘˜ (i.e., both ๐‘› bits long). However, it is not hard to see that this requirement is not really needed. If our message is longer, we can divide it into blocks ๐‘š 1 , โ€ฆ , ๐‘š๐‘ก and sign each message (๐‘–, ๐‘š๐‘–) individually. The disadvantage here is that the size of the tag (i.e., MAC output) will grow with the size of the message. However, even this is not really needed. Because the tag has length ๐‘›/2 for length ๐‘› messages, we can sign the tags ๐œ 1 , โ€ฆ , ๐œ๐‘ก and only output those. The verifier can repeat this computation to verify this. We can continue this way and so get tags of ๐‘‚(๐‘›) length for arbitrarily long messages. Hence in the future, whenever we need to, we can assume that our PRFs and MACs can get inputs in {0, 1}โˆ—^ โ€” i.e., arbitrarily length strings. We note that this issue of length extension is actually quite a thorny and important one in practice. The above approach is not the most efficient way to achieve this, and there are several more practical vari- ants in the literature (see Boneh-Shoup Sections 6.4-6.8). Also, one needs to be very careful on the exact way one chops the message into blocks and pads it to an integer multiple of the block size. Several at- tacks have been mounted on schemes that performed this incorrectly.

4.5 ASIDE: NATURAL PROOFS

Pseudorandom functions play an important role in computational complexity, where they have been used as a way to give โ€œbarrier re- sultsโ€ for proving results such as P โ‰  NP.^5 Specifically, the Natural Proofs barrier for proving circuit lower bounds says that if strong enough pseudorandom functions exist, then certain types of argu- ments are bound to fail. These are arguments which come up with a property EASY of a Boolean function ๐‘“ โˆถ {0, 1}๐‘›^ โ†’ {0, 1} such that:

  • If ๐‘“ can be computed by a polynomial sized circuit, then it has the property EASY.
  • The property EASY fails to hold for a random function with high probability.
  • Checking whether EASY holds can be done in time polynomial in the truth table size of ๐‘“. That is, in 2 ๐‘‚(๐‘›)^ time.

124 an intensive introduction to cryptography

A priori these technical conditions might not seem very โ€œnatu- ralโ€ but it turns out that many approaches for proving circuit lower bounds (for restricted families of circuits) have this form. The idea is that such approaches find a โ€œnon genericโ€ property of easily com- putable function, such as finding some interesting correlations be- tween the some input bits and the output. These are correlations that are unlikely to occur in random functions. The lower bound typically follows by exhibiting a function ๐‘“ 0 that does not have this property, and then using that to derive that ๐‘“ 0 cannot be efficiently computed by this particular restricted family of circuits. The existence of strong enough pseudorandom functions can be shown to contradict the existence of such a property EASY , since a pseudorandom function can be computed by a polynomial sized cir- cuit, but it cannot be distinguished from a random function. While a priori a pseudorandom function is only secure for polynomial time distinguishers, under certain assumptions it might be possible to cre- ate a pseudorandom function with a seed of size, say, ๐‘›^5 , that would be secure with respect to adversaries running in time 2 ๐‘‚(๐‘›^2 ).