zliz
zliz

Reputation: 59

nodejs AES-128-GCM "invalid initialization vector length"

I looked on Wikipedia and it says "Both GCM and GMAC can accept initialization vectors of arbitrary length."

However, when I try to

crypto.createCipheriv(
  'aes-128-gcm',
  KEY,
  new Buffer(crypto.randomBytes(16))
)

I get "Uncaught TypeError: invalid iv length 16" - I add a few breakpoints and find that the nodejs crypto iv length is set at 12? Is there a reason for the difference?

Upvotes: 1

Views: 14552

Answers (1)

zinfandel
zinfandel

Reputation: 458

This has been fixed in newer Node versions (>=6.3). Here's the relevant GitHub thread and PR: https://github.com/nodejs/node/pull/6376

It seems the developers just implemented the recommended default value before tackling arbitrary lengths.

Upvotes: 2

Related Questions