ArticleslgStudy

science

CBC-MAC

CBC-MAC is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand CBC-MAC rather than just read about it. In short: 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.

CBC-MAC — main illustration
CBC-MAC — illustration

Key takeaways

  • CBC-MAC belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect CBC-MAC to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of CBC-MAC from memory before moving on to harder problems.

Reference excerpt

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 m, one encrypts m 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 m1‖m2‖⋯‖mx using a secret key k and a block cipher E: 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.

Use in standards The CBC-MAC construct is used as part of the CCM mode utilized in IEEE 802.11i and NIST SP 800-97 (as CCMP, the CCM encryption protocol for WPA2), IPsec, and TLS 1.2, as well as Bluetooth Low Energy (as of Bluetooth 4.0, see NIST SP 800-121 Rev2). It is available for TLS 1.3, but not enabled by default in OpenSSL. 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.

Standards that define the algorithm FIPS PUB 113 Computer Data Authentication is a (now obsolete) U.S. government standard that specified the CBC-MAC algorithm using DES as the block cipher. 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).

Security with fixed and variable-length messages If the block cipher used is secure (meaning that it is a pseudorandom permutation), then CBC-MAC is secure for fixed-length messages. However, by itself, it is not secure for variable-length messages. Thus, any single key must only be used for messages of a fixed and known length. This is because an attacker who knows the correct authentication tag (i.e. CBC-MAC) pairs for two messages (m,t) and (m′,t′) can generate a third message m″ whose CBC-MAC will also be t′. This is simply done by XORing the first block of m′ with t and then concatenating m with this modified m′; i.e., by making m″=m‖[(m1′⊕t)‖m2′‖…‖mx′]. When computing the MAC for the message m″, it follows that we compute the MAC for m in the usual manner as t, but when this value is chained forwards to the stage computing EKMAC(m1′⊕t) we will perform an exclusive OR operation with the value derived for the MAC of the first message. The presence of that tag in the new message means it will cancel, leaving no contribution to the MAC from the blocks of plain text in the first message m: EKMAC(m1′⊕t⊕t)=EKMAC(m1′) and thus the tag for m″ is t′. 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.

Length prepending One solution is to include the length of the message in the first block; in fact CBC-MAC has been proven secure as long as no two messages that are prefixes of each other are ever used and prepending the length is a special case of this. This can be problematic if the message length may not be known when processing begins.

Encrypt-last-block

Encrypt-last-block CBC-MAC (ECBC-MAC) is defined as CBC-MAC-ELB(m, (k1, k2)) = E(k2, CBC-MAC(k1, m)). Compared to the other discussed methods of extending CBC-MAC to variable-length messages, encrypt-last-block has the advantage of not needing to know the length of the message until the end of the computation.

Attack methods against incorrect use As with many cryptographic schemes, naïve use of ciphers and other protocols may lead to attacks being possible, reducing the effectiveness of the cryptographic protection (or even rendering it useless). We present attacks which are possible due to using the CBC-MAC incorrectly.

Using the same key for encryption and authentication

One common mistake is to reuse the same key k for CBC encryption and CBC-MAC. Although a reuse of a key for different purposes is a bad practice in general, in this particular case the mistake leads to a spectacular attack: Suppose Alice has sent to Bob the cipher text blocks C=C1‖C2‖…‖Cn. During the transmission process, Eve can tamper with any of the C1,…,Cn−1 cipher-text blocks and adjust any of the bits therein as she chooses, provided that the final block, Cn, 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 C=C1‖C2‖⋯‖Cn. The tampered message, delivered to Bob in replacement of Alice's original, is C′=C1′‖…‖Cn−1′‖Cn. Bob first decrypts the message received using the shared secret key K 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, Pn′, differs from the original, Pn, which Alice sent; although Cn is the same, Cn′−1′≠Cn−1, so a different plain text Pn′ is produced when chaining the previous cipher text block into the exclusive-OR after decryption of Cn: Pn′=Cn−1′⊕EK−1(Cn). 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, t′, is given by:

t′=EK(Pn′⊕EK(Pn′−1′⊕EK(⋯⊕EK(P1′)))) Notice that this expression is equal to

t′=EK(Pn′⊕Cn′−1′) which is exactly Cn:

… excerpt ends here. Continue reading the full article.

Illustrations

CBC-MAC: CBC-MAC construction
CBC-MAC construction
CBC-MAC: Computation of CBC-MAC Encrypt-last-block.
Computation of CBC-MAC Encrypt-last-block.

Worked examples

Example 1 — a first encounter with CBC-MAC

Start with the simplest possible case. Write down what CBC-MAC claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to CBC-MAC before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about CBC-MAC ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of CBC-MAC

In research
CBC-MAC appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses CBC-MAC in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
CBC-MAC is common in secondary-school and first-year university syllabi. It links to neighbouring topics Block cipher modes of operation, Message authentication codes, so understanding it makes those chapters shorter.
In everyday life
Look for CBC-MAC outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “CBC-MAC” →

How to study CBC-MAC in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what CBC-MAC means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain CBC-MAC out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is CBC-MAC in simple terms?

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…

Why does CBC-MAC matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study CBC-MAC?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on CBC-MAC.

Tags

  • Block cipher modes of operation
  • Message authentication codes

Keep exploring