Problem
Show that appending the message length to the end of the message before applying basic CBC-MAC does not result in a secure MAC for arbitrary-length messages.
Solution
Query
m1​=B0​∣∣B1​, t1​=MACk​(m1​∣∣⟨∣m1​∣⟩)
m1∗​=B0∗​∣∣B1∗​, t1∗​=MACk​(m1∗​∣∣⟨∣m1∗​∣⟩)
∣m1∗​∣=∣m1​∣
m2​=m1​∣∣⟨∣m1​∣⟩∣∣B2​∣∣B3​, t2​=MAC(m2​∣∣⟨∣m2​∣⟩)
To be specific, the process of computing t2​ for message m2​ is listed below:
c0​=Fk​(B0​)
c1​=Fk​(c0​⊕B1​)
t1​=Fk​(c1​⊕⟨∣m1​∣⟩)
c3​=Fk​(t1​⊕B2​)
c4​=Fk​(c3​⊕B3​)
t=Fk​(c4​⊕⟨∣m2​∣⟩)
Hence, if we change m1​ to m1∗​,
c0∗​=Fk​(B0∗​)
c1∗​=Fk​(c0∗​⊕B1∗​)
t1∗​=Fk​(c1∗​⊕⟨∣m1∗​∣⟩)
In order to keep the result of MAC, it must hold that t1​⊕B2​=t1∗​⊕B2∗​. Thus
B2∗​=t1​⊕B2​⊕t1∗​ Therefore
c3∗​=Fk​(t1∗​⊕B2∗​)=Fk​(t1∗​⊕t1​⊕B2​⊕t1∗​)=Fk​(t1​⊕B2​)=c3​
c4∗​=Fk​(c3∗​⊕B3​)=Fk​(c3​⊕B3​)=c4​
t∗=Fk​(c4∗​⊕⟨∣m2∗​∣⟩)=Fk​(c4​⊕⟨∣m2​∣⟩)=t
∣m2∗​∣=∣m2​∣ can be easily get since ∣m1∗​∣=∣m1​∣
Hence we get a message and its valid tag ⟨m∗,t∗⟩ where
m∗:=m1∗​∣∣⟨∣m1∗​∣⟩∣∣t1​⊕B2​⊕t1∗​∣∣B3​t∗=t