1
$\begingroup$

I want to use CBC MAC. First I hope to find some implementation of block cipher which I will use in CBC mode, which I understand is CBC MAC. But I have two questions:

1) If the length of the message to be authenticated is not multiple of block cipher block length, what shall I do?

2) Do I need to use session keys with CBC MAC? e.e. use different key for each message. Or I can use one key for long time period?

2) To strengthen CBC MAC one recommended way as mentioned on Wiki is to put the length of the message in the first block. But how should I encode the length, as string? Or in binary? If block length of cipher is say 64 bits, do I encode the number as 64 bit number? e.g. if message length is 230, I should use following value as first block:

00000000 00000000 00000000 00000000 00000000 00000000 00000000 ‭11100110‬

?

$\endgroup$
  • 1
    $\begingroup$ I would recommend using something other than CBC-MAC. $\endgroup$ – mikeazo Dec 2 '15 at 12:41
  • $\begingroup$ @mikeazo Assume I want to use it. With prefixing with length of msg CBC MAC should be fine $\endgroup$ – user29112 Dec 2 '15 at 13:50
1
$\begingroup$

1) Fill remaining of last block with nulls.

2) No, you can use same key for more messages, but not the same as encryption key.

3) Usually this is done binary, like you did. If you are going to use CBC MAC with variable length messages, you must do this.

I recommend you to use XCBC or CMAC instead (CBC MAC variants for variable length messages).

$\endgroup$
  • $\begingroup$ Fixed length messages is a sufficient but not a necessary condition for CBC-MAC's security. It's enough if no message is the prefix of another message. A length prefix is one way of achieving that. $\endgroup$ – CodesInChaos Dec 2 '15 at 12:03
  • $\begingroup$ @CodesInChaos I have corrected answer. $\endgroup$ – LightBit Dec 2 '15 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy