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?
source
share