2
$\begingroup$

I apologize for the newbie question. If I were to use a 256-bit key and AES256 (assuming I had the function instead of AES128, the length of the for loops in the functions xor_128, leftshift_bit, generate_subkey, etc would remain as 16 correct? Since AES256 also returns a 128-bit result

example xor_128 function

void xor_128(unsigned char *a, unsigned char *b, unsigned char *out)
 {
      int i;
      for (i=0;i<16; i++)
      {
          out[i] = a[i] ^ b[i];
      }
  }

The AES-CMAC Algorithm in rfc4493

$\endgroup$
  • $\begingroup$ I guess the question is if the example code from rfc 4493 is compatible if I were to use a 256 bit key if I there was a AES_256(key,Y,X); function instead of AES_128(key,Y,X); from the example code $\endgroup$ – PolarBear May 26 at 20:07
  • 1
    $\begingroup$ Ah, wait, these are indeed the CMAC subkeys. Sorry, I was confusing CBC-MAC and CMAC. No, you're right, only the block size counts. I was wondering why a MAC definition included the cipher itself. Long day :) Have an upvote. $\endgroup$ – Maarten Bodewes May 26 at 21:00
1
$\begingroup$

AES has 128, 192, and 256 bits key sizes and always 128-bit block size. They are usually written as AES128, AES192, and AES256. The block size is implicit since it is always 128.

The basic function xor_128 is used to support x-or operation of CBC-MAC for the message block, ciphertext blocks, and keys. The block size is always 128 regardless of the key size.

The rfc4493 is not mentioning the AES192 or AES256. This doesn't mean that one cannot use any other than AES128. The rfc4493 only provides a test code for AES128.

The NIST provides test vectors in NIST: Block Cipher Modes of Operation - CMAC Mode for Authentication for AES128, AES192, and AES256.

The Generate_Subkey algorithm also needs the xor-128 to derive the keys, since the keys are xored with the blocks. This can be seen from the code

  Step 4.  if flag is true                                        
           then M_last := M_n XOR K1;                             
           else M_last := padding(M_n) XOR K2;

The constants are the same and the standard can be found in NIST 800-38B: Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ thanks for the clear answer and the links. I'll check them out $\endgroup$ – PolarBear May 26 at 20:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.