diff options
author | Hans Svensson <[email protected]> | 2019-02-04 10:47:25 +0100 |
---|---|---|
committer | Hans Svensson <[email protected]> | 2019-02-04 12:03:56 +0100 |
commit | c106a56a415bcef201bca8c1f1454ab6fe9bdb46 (patch) | |
tree | a05d8edd3caca82a7c92d92dd404919519b157af /lib/crypto/c_src/algorithms.c | |
parent | 4bdbb313f621d54038a9c17c6d9895650d539eab (diff) | |
download | otp-c106a56a415bcef201bca8c1f1454ab6fe9bdb46.tar.gz otp-c106a56a415bcef201bca8c1f1454ab6fe9bdb46.tar.bz2 otp-c106a56a415bcef201bca8c1f1454ab6fe9bdb46.zip |
Add hash function BLAKE2 to crypto:hash/hmac
Adds two hash functions blake2b and blake2s (64 bit hash and 32 bit hash
respectively). These are modern and standard hash functions used in
blockchains and encrypted communication protocols (e.g. Noise -
http://www.noiseprotocol.org/). The hash functions are available in
OpenSSL since version 1.1.1.
Also add test cases and mention in documentation.
Diffstat (limited to 'lib/crypto/c_src/algorithms.c')
-rw-r--r-- | lib/crypto/c_src/algorithms.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/crypto/c_src/algorithms.c b/lib/crypto/c_src/algorithms.c index 6318c8ad5a..a5bf248ea0 100644 --- a/lib/crypto/c_src/algorithms.c +++ b/lib/crypto/c_src/algorithms.c @@ -21,7 +21,7 @@ #include "algorithms.h" static unsigned int algo_hash_cnt, algo_hash_fips_cnt; -static ERL_NIF_TERM algo_hash[12]; /* increase when extending the list */ +static ERL_NIF_TERM algo_hash[14]; /* increase when extending the list */ static unsigned int algo_pubkey_cnt, algo_pubkey_fips_cnt; static ERL_NIF_TERM algo_pubkey[12]; /* increase when extending the list */ static unsigned int algo_cipher_cnt, algo_cipher_fips_cnt; @@ -62,6 +62,11 @@ void init_algorithms_types(ErlNifEnv* env) #ifdef HAVE_SHA3_512 algo_hash[algo_hash_cnt++] = enif_make_atom(env, "sha3_512"); #endif +#ifdef HAVE_BLAKE2 + algo_hash[algo_hash_cnt++] = enif_make_atom(env, "blake2b"); + algo_hash[algo_hash_cnt++] = enif_make_atom(env, "blake2s"); +#endif + // Non-validated algorithms follow algo_hash_fips_cnt = algo_hash_cnt; algo_hash[algo_hash_cnt++] = enif_make_atom(env, "md4"); @@ -136,7 +141,7 @@ void init_algorithms_types(ErlNifEnv* env) #if defined(HAVE_CHACHA20) algo_cipher[algo_cipher_cnt++] = enif_make_atom(env,"chacha20"); #endif - + // Validated algorithms first algo_mac_cnt = 0; algo_mac[algo_mac_cnt++] = enif_make_atom(env,"hmac"); |