Sunday, 7 May 2017

Does Node's crypto.createHmac() function supply an initialization vector?

In using Node's HMAC, I am trying to figure out of if this is sufficient. I.E. the IV is supplied internally:

let crypto = require('crypto');
let hash = crypto.createHmac('sha256', secret);
hash.update('the text to be signed');
let hmac = hash.digest();

Or, if I need to do this instead. I.E. I need to supply and keep track of the IV:

let crypto = require('crypto');
let iv = crypto.randomBytes(16);
let hash = crypto.createHmac('sha256', secret);
hash.update(iv);
hash.update('the text to be signed');
let hmac = hash.digest();

I did attempt to read the source but I'm not familiar enough with Node and Javascript to follow it.



via RichAmberale

No comments:

Post a Comment