Does node.js crypto use a fixed tag size with GCM mode?

I am implementing a GCM mode encryption scheme in node.js.

I need to add / add a GCM tag to ciphertext to check integrity. However, I'm not sure how big the tag will be!

In the crypto ++ wiki , I read that size can change and that it is actually a parameter of the GCM mode. Quoting from the wiki, I focus on:

Parameters to be supplied and used by both parties:

  • key and key size
  • iv and iv size
  • tag size

However, in the node documentation , the tag size does not exist. Just that the tag exists. Quoting from the documentation:

cipher.getAuthTag ()

For authenticated encryption modes (currently supported: GCM), this method returns a buffer that represents the authentication tag that was calculated from the data. Must be called after encryption is completed using the final method!

Should I expect the tag to resize and just keep the tag size along with the ciphertext? Or can I just assume that the tag size is always less than 128 bits and put it with zeros on the left?

+1
source share
1 answer

Both are node.js, and the crypto browser uses 128-bit tags.

I did not find the actual code, but this is obvious if you look at the tests.

Node.js , .

+1

Source: https://habr.com/ru/post/1617780/


All Articles