Link to this headingCBC-MAC
- Encrypt with [CBC](/Crypto/Symmetric Encryption/Block Ciphers/CBC) and the last block is the MAC.
- Uses an all zero IV
- Ensure that the MAC key is different than the encryption key
Link to this headingImplementation
#First Block is the IV
=
= b *
=
=
=
#Do regular CBC Encryption but the MAC is the last block
return
=
=
=
Link to this headingIV Control Attack
The first block is controllable if the IV is user controllable
### IV Test
= b
= b
=
=
=
#Manipulate the IV so the input is the same
= + b *
=
#real_message: b'Administrator', real_mac: 958b151e5d001a449859077a20c9632d
#manipulated_iv: 20000000000000000000000000000000
#forged_message: b'administrator', forged_mac: 958b151e5d001a449859077a20c9632d
Link to this headingMessage Spoofing Attack
### Block Forging
=
= b
= b
=
=
=
#Lets get each block
=
=
#XOR the CBC output of forged_message1 with the Second block (forged_message2)
=
=
#real_message: b'User=Administrator\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e', real_mac: 5bd3e29e4485c3c93ad2c54d19c70392
#forged_message1: b'User=Administrat', forged_mac: 80fdcee9dd73a3cdb4642acbb3a6d27b
#forged_message2: b'or\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e\x0e', forged_mac: c56302835470a32beeaf0a48adf979de
#forged_input: b'\xef\x8f\xc0\xe7\xd3}\xad\xc3\xbaj$\xc5\xbd\xa8\xdcu', forged_mac: 5bd3e29e4485c3c93ad2c54d19c70392