From 064f1e0df9ad14b9c378d867cc9f37a167b7c548 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 10 Feb 2016 14:12:46 -0600 Subject: [PATCH] crypto: Move hmac_sha1 to crypto.c --- Makefile.am | 1 + src/crypto.c | 7 +++++++ src/crypto.h | 2 ++ src/sha1.c | 16 ---------------- src/sha1.h | 3 --- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Makefile.am b/Makefile.am index a5ef4735..e59b891d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -130,6 +130,7 @@ unit_test_hmac_md5_SOURCES = unit/test-hmac-md5.c \ unit_test_hmac_md5_LDADD = ell/libell-internal.la unit_test_hmac_sha1_SOURCES = unit/test-hmac-sha1.c \ + src/crypto.h src/crypto.c \ src/sha1.h src/sha1.c unit_test_hmac_sha1_LDADD = ell/libell-internal.la diff --git a/src/crypto.c b/src/crypto.c index 8ba4771e..0e839072 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -58,6 +58,13 @@ bool hmac_md5(const void *key, size_t key_len, output, size); } +bool hmac_sha1(const void *key, size_t key_len, + const void *data, size_t data_len, void *output, size_t size) +{ + return hmac_common(L_CHECKSUM_SHA1, key, key_len, data, data_len, + output, size); +} + bool hmac_sha256(const void *key, size_t key_len, const void *data, size_t data_len, void *output, size_t size) { diff --git a/src/crypto.h b/src/crypto.h index ff0a1fb1..306c8d6b 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -39,6 +39,8 @@ struct crypto_ptk { bool hmac_md5(const void *key, size_t key_len, const void *data, size_t data_len, void *output, size_t size); +bool hmac_sha1(const void *key, size_t key_len, + const void *data, size_t data_len, void *output, size_t size); bool hmac_sha256(const void *key, size_t key_len, const void *data, size_t data_len, void *output, size_t size); bool cmac_aes(const void *key, size_t key_len, diff --git a/src/sha1.c b/src/sha1.c index fda70e33..e4f6582b 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -74,22 +74,6 @@ static void __hmac_sha1(struct l_checksum *checksum, size > SHA1_MAC_LEN ? SHA1_MAC_LEN : size); } -bool hmac_sha1(const void *key, size_t key_len, - const void *data, size_t data_len, void *output, size_t size) -{ - struct l_checksum *checksum; - - checksum = l_checksum_new(L_CHECKSUM_SHA1); - if (!checksum) - return false; - - __hmac_sha1(checksum, key, key_len, data, data_len, output, size); - - l_checksum_free(checksum); - - return true; -} - static void F(struct l_checksum *checksum, const char *password, size_t password_len, const char *salt, size_t salt_len, diff --git a/src/sha1.h b/src/sha1.h index eb386f69..765e034f 100644 --- a/src/sha1.h +++ b/src/sha1.h @@ -22,9 +22,6 @@ #include -bool hmac_sha1(const void *key, size_t key_len, - const void *data, size_t data_len, void *output, size_t size); - bool pbkdf2_sha1(const void *password, size_t password_len, const void *salt, size_t salt_len, unsigned int iterations, void *output, size_t size);