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
'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.
The text was updated successfully, but these errors were encountered:
coolaj86
changed the title
crypto.pbkdf2 fails silently with NaN length
crypto.pbkdf2 fails silently with NaN bitlength
Sep 21, 2015
issue nodejs#2987 makes the point that crypto.pbkdf2 should not fail silently
and accept invalid but numeric values like NaN and Infinity. We already
check if the keylen is lower than 0, so extending that to NaN and
Infinity should make sense.
Fixes: nodejs#2987
issue #2987 makes the point that crypto.pbkdf2 should not fail silently
and accept invalid but numeric values like NaN and Infinity. We already
check if the keylen is lower than 0, so extending that to NaN and
Infinity should make sense.
Fixes: #2987
PR-URL: #3029
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Here's an example:
I'm assuming that NaN is coerced to 0. I would think that 0 should also throw an error.
The text was updated successfully, but these errors were encountered: