Skip to content

crypto.pbkdf2 fails silently with NaN bitlength #2987

Description

@coolaj86

Here's an example:

'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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions