0

I have a question regarding understanding representation of length in AES-GCM while doing padding for the IV to calculate ICB/J0. In the aes GCM test vectors testcase5 I see the IV is of length 8 bytes as follows:

IV cafebabefacedbad

But len({})||len(IV ) is mentioned as

00000000000000000000000000000040

but since the length of IV is of 8 bytes in length the representation len({})||len(IV ) should be as follows

00000000000000000000000000000008

Can someone help me in understanding whether how the len(IV) which is of 8 bytes is of 40 instead of 8.

Edit 1:

For IV of length 60, I see it was represented as

000000000000000000000000000001e0

As it was mentioned in comments, if we see the pattern whatever the IV length is it is multiplied by 8 when its get represented with len(IV). Any thoughts on this?

sg777
  • 485
  • 1
  • 4
  • 13

1 Answers1

1

Usually in lower level algorithm descriptions the size indications - such as key size - is indicated in bits, not bytes. So internally we see that the IV size is also described in bits.

So the value that you are seeing is 0x40 in hex or 64 in decimals, itself encoded in a static amount of bits. Although the IV is generally always a multiple of bytes, the algorithm uses bit-length. So for your 8 bytes, the 0x40 value is correct, as 8 x 8 = 64.

Maarten Bodewes
  • 96,351
  • 14
  • 169
  • 323