-To compute `GHASH`, we first need to represent the data we want to authenticate as a sequence of 128-bit blocks. This is done by splitting the data into 128-bit blocks and then padding the last block with null bytes if it is not already 128 bits long. We do this separately for the associated data and the ciphertext, so for example if we wanted to authenticated the associated data `deadbeef` and the ciphertext `cafeaffe`, we'd use the blocks `deadbeef000000000000000000000000` and `cafeaffe000000000000000000000000` as the input to `GHASH`. To make sure the size of the data is not lost, we add one more block at the end that contains the length of the associated data in bits as a 64-bit big-endian integer and the length of the ciphertext in bits as a 64-bit big-endian integer concatenated together, so in this case `00000000000000200000000000000020` for the associated data `deadbeef` and the ciphertext `cafeaffe`.
0 commit comments