aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/src
diff options
context:
space:
mode:
authorHans Svensson <[email protected]>2019-02-04 10:47:25 +0100
committerHans Svensson <[email protected]>2019-02-04 12:03:56 +0100
commitc106a56a415bcef201bca8c1f1454ab6fe9bdb46 (patch)
treea05d8edd3caca82a7c92d92dd404919519b157af /lib/crypto/src
parent4bdbb313f621d54038a9c17c6d9895650d539eab (diff)
downloadotp-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/src')
-rw-r--r--lib/crypto/src/crypto.erl7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 987bc3fe0f..de8cfac9a2 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -287,6 +287,7 @@
-type sha1() :: sha .
-type sha2() :: sha224 | sha256 | sha384 | sha512 .
-type sha3() :: sha3_224 | sha3_256 | sha3_384 | sha3_512 .
+-type blake2() :: blake2b | blake2s .
-type compatibility_only_hash() :: md5 | md4 .
@@ -329,11 +330,11 @@ stop() ->
| {macs, Macs}
| {curves, Curves}
| {rsa_opts, RSAopts},
- Hashs :: [sha1() | sha2() | sha3() | ripemd160 | compatibility_only_hash()],
+ Hashs :: [sha1() | sha2() | sha3() | blake2() | ripemd160 | compatibility_only_hash()],
Ciphers :: [stream_cipher()
| block_cipher_with_iv() | block_cipher_without_iv()
| aead_cipher()
- ],
+ ],
PKs :: [rsa | dss | ecdsa | dh | ecdh | ec_gf2m],
Macs :: [hmac | cmac | poly1305],
Curves :: [ec_named_curve() | edwards_curve_dh() | edwards_curve_ed()],
@@ -367,7 +368,7 @@ enable_fips_mode(_) -> ?nif_stub.
%%%
%%%================================================================
--define(HASH_HASH_ALGORITHM, sha1() | sha2() | sha3() | ripemd160 | compatibility_only_hash() ).
+-define(HASH_HASH_ALGORITHM, sha1() | sha2() | sha3() | blake2() | ripemd160 | compatibility_only_hash() ).
-spec hash(Type, Data) -> Digest when Type :: ?HASH_HASH_ALGORITHM,
Data :: iodata(),