aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/src
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-05-14 17:01:17 +0200
committerHans Nilsson <[email protected]>2019-06-14 13:33:07 +0200
commit160cea3f655913b370650f93b0c8f6c1bd163e32 (patch)
treee03013d6f39625ac2bac84ddc2cd7b9757328fbb /lib/crypto/src
parentae4c8e6ee26e3c606054e4a845ac06f95ade1e57 (diff)
downloadotp-160cea3f655913b370650f93b0c8f6c1bd163e32.tar.gz
otp-160cea3f655913b370650f93b0c8f6c1bd163e32.tar.bz2
otp-160cea3f655913b370650f93b0c8f6c1bd163e32.zip
crypto: MAC nif unifying HMAC, CMAC and POLY1305
into one nif using the EVP_DigestSign interface. This enables acceleration if available in lower layers, that is, in cryptolib and lower. However, for older cryptolibs the old HMAC and CMAC low-level interfaces are used, but moved from hmac.c and cmac.c into mac.c.
Diffstat (limited to 'lib/crypto/src')
-rw-r--r--lib/crypto/src/crypto.erl16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 169c0f2e91..fd4b9df5e0 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -62,7 +62,8 @@
crypto_one_time_aead/6, crypto_one_time_aead/7,
crypto_dyn_iv_init/3,
crypto_dyn_iv_update/3,
- supports/1
+ supports/1,
+ mac/3, mac/4, mac/5
]).
@@ -602,6 +603,19 @@ hash_final(Context) ->
%%%
%%%================================================================
+mac(Type, SubType, Key, Data, MacLength) ->
+ erlang:binary_part(mac(Type, SubType, Key, Data), 0, MacLength).
+
+mac(poly1305, _, Key, Data) -> mac_nif(poly1305, undefined, Key, Data);
+mac(Type, SubType, Key, Data) -> mac_nif(Type, SubType, Key, Data).
+
+mac(poly1305, Key, Data) -> mac(poly1305, undefined, Key, Data).
+
+
+
+mac_nif(_Type, _SubType, _Key, _Data) -> ?nif_stub.
+
+
%%%---- HMAC
-type hmac_hash_algorithm() :: sha1() | sha2() | sha3() | compatibility_only_hash().