Message authentication codes provide message integrity by appending a checksum to the message which receiver on decryption calculates again and verify whether message was tampered or not. Provides 2 properties:
- Authentication: Message was really created by sender
- Integrity: Message was not tempered during transmission.
But any middle man can create a new message with a new MAC, how does receiver know whether it's sent by original sender or adversary?
Nope, as you study further, you discover that MAC is actually realised using a tag whose only requirement is that it can only be generated with a secret key.
how is MAC different from signatures?
- consists of following algorithms:
- Canonical Verification: when receiver computes and verifies that .
- MAC’s, security definition: adversary should be able to verify MAC of message that it doesn’t have, i.e. forgery of MAC happens when adversary can produce valid MAC tag.
- : PPT adversary has access to oracle , and can request tag t for any message of its choice.
- maintains a set of messages containing all previously queries messages.
- succeeds if it can produce forgery of MAC, i.e. produces valid , where tag for wasn’t requested previously, and when is given to a third party, succeeds.
- Mac which has no efficient adversary is said to be ==existentially unforgeable under an adaptive chosen-message attack==.
- Strength of definition: for most scenarios, this definition of MAC seems too strong, because even though adversary can request tag for messages of its choice any number of times, it still can’t forge a new tag for unauthenticated message.
Examples
Browser Cookies: stored user side in browser to authenticate a user in a session. TCP handshake: calculated server side during second TCP syn+ack to authenticate the user.
- 2FA & TOTP: timed one-time passwords are an excellent example of real-world usage of MACs. user calculate mac , sends to server, and server verifies with key, .
- Replay attacks: Mac doesn’t provide replay attack prevention guarantees, i.e. adversary can send same (message, tag) and receiver won’t be able to detect whether this message has been sent previously or not.
- This is done to ensure usability of MACs in different scenarios and should be handled by higher-level application.
- Strong security: forges for MAC where .
- Denote . Now, maintains tuple of in set .
- Prove: secure MAC with canonical verification is strongly secure.
- Timing attacks: side channel attacks which can determine value of mac using timing attacks on verification oracle.
Secure-MAC using PRF
- Construct a MAC using PRF where , where is a PRF, and canonical verification happens using .
- Prove:
- To prove above construction is secure, create a Polynomial-time distinguisher that is given oracle access to , and needs to determine whether is PRF or not.
- simulates message authentication experiment for adversary by answering queries and returning to .
- After all queries, outputs . queries , and obtain .
- If and , outputs 1.
sequenceDiagram
loop Oracle queries
A->>+D: message: m_i
D->>+O: message: m_i
Note right of O: calculates $t=O(m)$
O->>-D: tag: t
D->>-A: tag: t
end
A->>D: (m,t)
D->>O: m
Note right of O: calculates $t'=O(m)$
O->>D: t'
Note over D: checks $t'=t$ and m was not sent before, output 1
- Now, when is a PRF, then adversary’s view is equal to in experiment, thus, .
- Similarly, when is uniform random function:
- Next prove that:
MAC for arbitrary length messages
- Construct a simple mac for arbitrary length message by dividing and computing .
- Construction: let be fixed length MAC of length , then
- : On input of key message , parse of length and choose a uniform . Compute . Output .
- : On input key , a message and tag , output .C
- Prove this is secure MAC.
- Basic idea is to prove by proving two events:
- : is used for some other message during oracle queries
- : tries to forge a block which was authenticated by before during answering queries to oracle.
- So, .
- Basic idea is to prove by proving two events:
CBC-MAC
- constructing a MAC using pseudorandom function for and length function , and message length .
- : parse m as and , then .
- : output 1 if .
- Prove this is a secure Mac.
Mac from difference-universal function
Let be a keyed function where and message and output , where is a group. For to be difference universal function, take and any such that , where .
Let’s construct a MAC from DUF, take to be DUF and to be a PRF, then following is a strongly secure MAC for messages in :
- : output key and .
- : for key, , choose uniform , output
- : for key, , parse , output 1 if
Prove that above construction is strongly secure MAC,
- take two events required to model the security:
- : is not repeated by in any of the oracle queries by .
- : outputs where was not used in any of the previous oracle query.
- study for uniform function first, i.e. .
- probability of repeat is
- Probability of new-r is because is a uniform function is ‘s view.
- prob of neither repeat, nor r-new is by taking two distinct , where was ith oracle query and their match (because new-r doesn’t occur) and equating their
- a common DUF is taking a finite field , to be a point in , and is a polynomial of degree < l (constant) in . Now, , i.e. evaluation of on . This is -DUF.
GMAC
TODO
Poly1305
TODO
Information-Theoretic MACs
- until now all MAC constructions are computational secure, i.e. efficient adversary that runs in polynomial time, and thus, we need a security parameter that is used to model the asymptotic behaviour of both the construction and the adversary.
- Now, we look at conditions that are required to create MAC that are secure for unbounded adversary, i.e. Information Theoretic MAC
- Max probability that we can reach for an unbounded adversary to correctly output a tag that works is , and only restriction on adversary is number of times it can access the oracle.
- Construct a one-time MAC:
- A gives and gets
- A outputs , output 1 if and .
- Strongly universal functions (SUF): or also called pairwise independent functions. Function , where and , such that .
- Construct MAC using SUF: simply output , and output 1 if .
- Prove above construction is secure MAC.
- A simple example of SUF is
- One-time MAC from DUF: can be constructed as simply taking and and .
Mac using hash functions
Let be a arbitrary length hash function
Hash-and-MAC: , and verify using .
- This can be proven as secure MAC by modelling two adversaries, i.e. . Now, prove that both terms are negligible.
- first can be proven secure by formulating a reduction proof on collision resistance property of with adversary that attacks and attacking .
- second is secure using secure MAC
HMAC: , and verified using .
- can be seen as Hash-and-MAC approach where inner pad is used to hash mac to length string
- and again hashed with outer pad to create a tag .
- and are generated using a pseudorandom generator
one question that arises is why ipad and opad is needed at all? why can't you just use to generate a pseudorandom string of ?
This is because is typically less than , and IV is concatenated with to increase key length. Moreover, need to be uniform, thus, a PRG is used to decrease key length to and derive two pseudorandom keys from that.
Questions
- 4.1: adversary’s success remains same, and canonical verification MAC will always satisfy this.
- 4.2: can i use a MAC that doesn’t use canonical verification? so just use vrfy oracle to determine a pair (m,t) and then output that pair.
- 4.3: if secure MAC uses canonical verification that it’s easy to see that its also strongly secure because adversary won’t be able to forge a tag with substantial probability.
- 4.4: