Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown message digest in crypto and Node 10

Here is part of my code that uses crypto and works fine with Node v8.15.0:

const crypto = require('crypto');
...
const sign = crypto.createSign('DSA');

When I switched to Node 10:

nvm install 10
node --version
v10.15.1

The same source code returns error:

     Error: Unknown message digest
      at new Sign (internal/crypto/sig.js:26:16)
      at Object.createSign (crypto.js:137:10)

How to get DSA in Node 10 and crypto?


Additional information: Node 10 crypto.getHashes() returns (no DSA!):

[ 'RSA-MD4',
  'RSA-MD5',
  'RSA-MDC2',
  'RSA-RIPEMD160',
  'RSA-SHA1',
  'RSA-SHA1-2',
  'RSA-SHA224',
  'RSA-SHA256',
  'RSA-SHA384',
  'RSA-SHA512',
  'blake2b512',
  'blake2s256',
  'md4',
  'md4WithRSAEncryption',
  'md5',
  'md5-sha1',
  'md5WithRSAEncryption',
  'mdc2',
  'mdc2WithRSA',
  'ripemd',
  'ripemd160',
  'ripemd160WithRSA',
  'rmd160',
  'sha1',
  'sha1WithRSAEncryption',
  'sha224',
  'sha224WithRSAEncryption',
  'sha256',
  'sha256WithRSAEncryption',
  'sha384',
  'sha384WithRSAEncryption',
  'sha512',
  'sha512WithRSAEncryption',
  'ssl3-md5',
  'ssl3-sha1',
  'whirlpool' ]

While in Node 8 I get (truncated as SO doesn't like too much code):

[ 'DSA',
  'DSA-SHA',
  'DSA-SHA1',
  'DSA-SHA1-old',
  'RSA-MD4',
  'RSA-MD5',
  ...
  'whirlpool' ]

like image 505
iaforek Avatar asked Jan 21 '26 08:01

iaforek


1 Answers

There is an issue for this in the GitHub repository for Node.js. It basically comes does to the fact that support for DSA has been removed in the underlying OpenSSL, which is being used by Node.js.

According to this comment:

DSA-SHA1 has been renamed to DSS1

But:

However, if I run in node v10.15.1 crypto.getHashes() then I don't get DSS1 too.

So, from my point of view your only option is to switch to another signature algorithm, or to try to find a third party module that implements what you need independent of Node.js's crypto module (and hence, independent of OpenSSL).

like image 101
Golo Roden Avatar answered Jan 23 '26 23:01

Golo Roden