pbkdf2 icon indicating copy to clipboard operation
pbkdf2 copied to clipboard

The value "NaN" is invalid for option "size"

Open Cherviakov opened this issue 4 years ago • 1 comments

https://github.com/calvinmetcalf/crypto-pouch/issues/75 - using that package, got error, investigated and found that for some reason digest argument on the other side become fully capitalized, which in turn make package failed to get size of corresponding digest in sync-browser.js file:

  var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
  var opad = Buffer.allocUnsafe(blocksize + sizes[alg])

as alg === 'SHA-256', sizes['SHA-256'] is undefined, so result sum is NaN.

Cherviakov avatar Aug 19 '20 10:08 Cherviakov

So this should raise a helpful error message when you input an unsupported digest string? In the sync version only those strings are supported with no aliases:

var sizes = {
  md5: 16,
  sha1: 20,
  sha224: 28,
  sha256: 32,
  sha384: 48,
  sha512: 64,
  rmd160: 20,
  ripemd160: 20
}

webmaster128 avatar Apr 13 '21 10:04 webmaster128

Thanks, I think that explains it.

ghost avatar Jun 12 '23 11:06 ghost