browserify / crypto-browserify

partial implementation of node's `crypto` for the browser
MIT License
653 stars 199 forks source link

the argument to define auth tag length in crypto.createDecipheriv cannot work #207

Open duomaomao27 opened 2 years ago

duomaomao27 commented 2 years ago

For 'aes-256-gcm', I've tried to use:

let decipher = crypto.createDecipheriv('aes-256-gcm', serverKeyArr, iv, {authTagLength: 12});

to define auth tag to 12 bytes, however, when I execute decipher.final(), inside that function, the tag it calculated is still 16 bytes, then when it do xor test for the tag function calculated and the auth Tag I've received (which already cut off by server side from 16 bytes to 12 bytes), it will results in error because the length is different.

I wonder why the argument {authTagLength: 12} do not work?

Besides, is there any way I can use shorter auth tag length to pass decipher.final() function, because in my program, I only can get the first 12 bytes auth tag.

Thanks

Suvab-rently commented 2 years ago

I am facing the same issue, any updates on this? Not only for createDecipheriv(), but the same also happens for createCipheriv(). The option authTagLength doesn't seem to work and is simply ignored.