I'm trying to find a list of strings
that can be used a a crypto algorithm to fit into this function, replacing SHA256
.
crypto.createHmac("SHA256", secret).update(string).digest('base64'),
I've come to the understanding that crypto uses openssl
, and that the algorithms are specific to each system running node.js.
With the following commands you can see a list of all algorithms available for your system.
openssl list-cipher-algorithms
openssl list-cipher-commands
I've outputted the content of those two commands to this gist.
What bothers me is that SHA256
is not in either of those lists.
I would really like the definitive algorithm list.
SHA-256 is not a cipher, it is a hash algorithm. That is probably why you didn't find it in a list of ciphers. The same goes for MD5 and all the various SHA algorithms.
Indeed, a hash algorithm is exactly what you need for HMAC. If you want to construct a MAC based on a block cipher, you'll need to use some other construction, such as OMAC/CMAC, PMAC or CBC-MAC.
The learning here is that
ciphers
andhashes
are different and use different algorithms. With node'scrypto
use.getCiphers()
and.getHashes()
methods to return an array with the names of the supportedciphers
andhashes
respectively.Which logs the following ciphers:
And the following
hashes
:Here's my settings:
openssl version
isOpenSSL 0.9.8zg 14 July 2015
node --version
isv0.12.4
The openssl docs have a page listing all valid cipher strings: http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS
I checked all of the cipher strings and everything in my gist and these are the only algo's that work with cipher to create a HMAC.