You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
crypto.pbkdf2 fails silently with NaN bitlength #2987
'use strict';functionsha256(buf){returncrypto.createHash('sha256').update(buf).digest('hex');}varcrypto=require('crypto');varsecret='my special secret';varappPbkdf2Salt=sha256(newBuffer("MY_SALT"));variterations=1000;varbitLength;// oops, forgot to define bit lengthvarkeyByteLength=bitLength/8;varhashname='sha256';crypto.pbkdf2(secret,appPbkdf2Salt,iterations,keyByteLength,hashname,function(err,bytes){if(err){throwerr;}console.log('bytes',bytes.toString('hex'));});
I'm assuming that NaN is coerced to 0. I would think that 0 should also throw an error.
Activity
[-]crypto.pbkdf2 fails silently with NaN length[/-][+]crypto.pbkdf2 fails silently with NaN bitlength[/+]coolaj86 commentedon Sep 24, 2015
Thank you @johannhof, @brendanashworth!
crypto: add more keylen sanity checks in pbkdf2
crypto: add more keylen sanity checks in pbkdf2