aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/src
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-01-14 11:52:07 +0100
committerFredrik Gustafsson <[email protected]>2013-01-14 11:52:07 +0100
commit1066d047e54858cf1a884c7ddbf1af2796c36bd6 (patch)
tree7392de7356e92ae446f75be37642557e9657674b /lib/crypto/src
parent0a80c6c87042c1ff032b4e1b05bf60e5a8f5d8fa (diff)
parent1afbb47ebc0fbde5547146eb21e072c3bc14a034 (diff)
downloadotp-1066d047e54858cf1a884c7ddbf1af2796c36bd6.tar.gz
otp-1066d047e54858cf1a884c7ddbf1af2796c36bd6.tar.bz2
otp-1066d047e54858cf1a884c7ddbf1af2796c36bd6.zip
Merge branch 'sverk/crypto-hmac-enhancements/OTP-10640'
* sverk/crypto-hmac-enhancements/OTP-10640: crypto: Add RFC-4231 test vectors for output truncation crypto: Add test cases for the generic hmac interface in the RFC-4231 tests crypto: Add RFC-2202 test vectors for HMAC-MD5 and HMAC-SHA1 crypto: Provide a generic interface for HMAC generation crypto: Document all types currently available for hmac_init
Diffstat (limited to 'lib/crypto/src')
-rw-r--r--lib/crypto/src/crypto.erl21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index f25d63fe3b..aa89f6cc61 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -35,7 +35,7 @@
-export([sha256_mac/2, sha256_mac/3]).
-export([sha384_mac/2, sha384_mac/3]).
-export([sha512_mac/2, sha512_mac/3]).
--export([hmac_init/2, hmac_update/2, hmac_final/1, hmac_final_n/2]).
+-export([hmac/3, hmac/4, hmac_init/2, hmac_update/2, hmac_final/1, hmac_final_n/2]).
-export([des_cbc_encrypt/3, des_cbc_decrypt/3, des_cbc_ivec/1]).
-export([des_ecb_encrypt/2, des_ecb_decrypt/2]).
-export([des_cfb_encrypt/3, des_cfb_decrypt/3, des_cfb_ivec/2]).
@@ -107,7 +107,7 @@
blowfish_ecb_encrypt, blowfish_ecb_decrypt, blowfish_ofb64_encrypt,
des_cbc_ivec, des_cfb_ivec, erlint, mpint,
hash, hash_init, hash_update, hash_final,
- hmac_init, hmac_update, hmac_final, hmac_final_n, info,
+ hmac, hmac_init, hmac_update, hmac_final, hmac_final_n, info,
rc2_cbc_encrypt, rc2_cbc_decrypt,
info_lib]).
@@ -437,11 +437,28 @@ sha512_final_nif(_Context) -> ?nif_stub.
%%
%% HMAC (multiple hash options)
%%
+
+-spec hmac(_, iodata(), iodata()) -> binary().
+-spec hmac(_, iodata(), iodata(), integer()) -> binary().
-spec hmac_init(atom(), iodata()) -> binary().
-spec hmac_update(binary(), iodata()) -> binary().
-spec hmac_final(binary()) -> binary().
-spec hmac_final_n(binary(), integer()) -> binary().
+hmac(md5, Key, Data) -> md5_mac(Key, Data);
+hmac(sha, Key, Data) -> sha_mac(Key, Data);
+hmac(sha224, Key, Data) -> sha224_mac(Key, Data);
+hmac(sha256, Key, Data) -> sha256_mac(Key, Data);
+hmac(sha384, Key, Data) -> sha384_mac(Key, Data);
+hmac(sha512, Key, Data) -> sha512_mac(Key, Data).
+
+hmac(md5, Key, Data, Size) -> md5_mac_n(Key, Data, Size);
+hmac(sha, Key, Data, Size) -> sha_mac(Key, Data, Size);
+hmac(sha224, Key, Data, Size) -> sha224_mac(Key, Data, Size);
+hmac(sha256, Key, Data, Size) -> sha256_mac(Key, Data, Size);
+hmac(sha384, Key, Data, Size) -> sha384_mac(Key, Data, Size);
+hmac(sha512, Key, Data, Size) -> sha512_mac(Key, Data, Size).
+
hmac_init(_Type, _Key) -> ?nif_stub.
hmac_update(_Context, _Data) -> ? nif_stub.
hmac_final(_Context) -> ? nif_stub.