In cryptography, a cipher block chaining message authentication code ( CBC-MAC) is a technique for constructing a message authentication code (MAC) from a block cipher. The message is encrypted with some block cipher algorithm in cipher block chaining (CBC) mode to create a chain of blocks such that each block depends on the proper encryption of the previous block. This interdependence ensures that a change to any of the plaintext bits will cause the final encrypted block to change in a way that cannot be predicted or counteracted without knowing the key to the block cipher. To calculate the CBC-MAC of message , one encrypts in CBC mode with zero initialization vector and keeps the last block. The following figure sketches the computation of the CBC-MAC of a message comprising blocks using a secret key and a block cipher : CBC-MAC on its own is not secure for variable-length messages (see the discussion below) and is currently used to construct a pseudorandom function family and as a component of the CCM mode.
CBC-MAC is also used as a "conditioning component" (a.k.a. randomness extractor, a method to generate bitstrings with full entropy) in NIST SP 800-90B.
The CBC-MAC algorithm is also included into ANSI X9.9, ANSI X9.19, ISO 8731-1, and ISO/IEC 9797-1 MAC (Algorithm 1).
This problem cannot be solved by adding a message-size block to the end. There are three main ways of modifying CBC-MAC so that it is secure for variable length messages: 1) Input-length key separation; 2) Length-prepending; 3) Encrypt last block. In such a case, it may also be recommended to use a different mode of operation, for example, CMAC or HMAC to protect the integrity of variable-length messages.
Suppose Alice has sent to Bob the cipher text blocks . During the transmission process, Eve can tamper with any of the cipher-text blocks and adjust any of the bits therein as she chooses, provided that the final block, , remains the same. We assume, for the purposes of this example and without loss of generality, that the initialization vector used for the encryption process is a vector of zeroes.
When Bob receives the message, he will first decrypt the message by reversing the encryption process which Alice applied, using the cipher text blocks . The tampered message, delivered to Bob in replacement of Alice's original, is .
Bob first decrypts the message received using the shared secret key to obtain corresponding plain text. Note that all plain text produced will be different from that which Alice originally sent, because Eve has modified all but the last cipher text block. In particular, the final plain text, , differs from the original, , which Alice sent; although is the same, , so a different plain text is produced when chaining the previous cipher text block into the exclusive-OR after decryption of : .
It follows that Bob will now compute the authentication tag using CBC-MAC over all the values of plain text which he decoded. The tag for the new message, , is given by:
Notice that this expression is equal to
which is exactly :
and it follows that .
Therefore, Eve was able to modify the cipher text in transit (without necessarily knowing what plain text it corresponds to) such that an entirely different message, , was produced, but the tag for this message matched the tag of the original, and Bob was unaware that the contents had been modified in transit. By definition, a Message Authentication Code is broken if we can find a different message (a sequence of plain-text pairs ) which produces the same tag as the previous message, , with . It follows that the message authentication protocol, in this usage scenario, has been broken, and Bob has been deceived into believing Alice sent him a message which she did not produce.
If, instead, we use different keys for the encryption and authentication stages, say and , respectively, this attack is foiled. The decryption of the modified cipher-text blocks obtains some plain text string . However, due to the MAC's usage of a different key , we cannot "undo" the decryption process in the forward step of the computation of the message authentication code so as to produce the same tag; each modified will now be encrypted by in the CBC-MAC process to some value .
This example also shows that a CBC-MAC cannot be used as a collision-resistant one-way function: given a key it is trivial to create a different message which "hashes" to the same tag.
When computing a message authentication code, such as by CBC-MAC, the use of an initialization vector is a possible attack vector.
In the operation of a ciphertext block chaining cipher, the first block of plain text is mixed with the initialization vector using an exclusive OR (). The result of this operation is the input to the block cipher for encryption.
However, when performing encryption and decryption, we are required to send the initialization vector in plain text - typically as the block immediately preceding the first block of cipher text - such that the first block of plain text can be decrypted and recovered successfully. If computing a MAC, we will also need to transmit the initialization vector to the other party in plain text so that they can verify the tag on the message matches the value they have computed.
If we allow the initialization vector to be selected arbitrarily, it follows that the first block of plain text can potentially be modified (transmitting a different message) while producing the same message tag.
Consider a message . In particular, when computing the message tag for CBC-MAC, suppose we choose an initialization vector such that computation of the MAC begins with . This produces a (message, tag) pair .
Now produce the message . For each bit modified in , flip the corresponding bit in the initialization vector to produce the initialization vector . It follows that to compute the MAC for this message, we begin the computation by . As bits in both the plain text and initialization vector have been flipped in the same places, the modification is cancelled in this first stage, meaning the input to the block cipher is identical to that for . If no further changes are made to the plain text, the same tag will be derived despite a different message being transmitted.
If the freedom to select an initialization vector is removed and all implementations of CBC-MAC fix themselves on a particular initialization vector (often the vector of zeroes, but in theory, it could be anything provided all implementations agree), this attack cannot proceed.
To sum up, if the attacker is able to set the IV that will be used for MAC verification, he can perform arbitrary modification of the first data block without invalidating the MAC.
The simplest countermeasure is to encrypt the IV before using it (i.e., prepending IV to the data). Alternatively MAC in CFB mode can be used, because in CFB mode the IV is encrypted before it is XORed with the data.
Another solution (in case protection against message replay attacks is not required) is to always use a zero vector IV.Introduction to Modern Cryptography, Second Edition by Jonathan Katz and Yehuda Lindell Note that the above formula for becomes . So since and are the same message, by definition they will have the same tag. This is not a forgery, rather the intended use of CBC-MAC.
|
|