From 8a5165bf068c4af94562c311069f796af036c8d5 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 19 Apr 2013 17:30:17 +0200 Subject: [PATCH] Start replacing macros with real functions. First candidate: crypto_auth --- src/libsodium/Makefile.am | 1 + src/libsodium/crypto_auth/crypto_auth.c | 14 ++++++++++++++ src/libsodium/include/sodium/crypto_auth.h | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/libsodium/crypto_auth/crypto_auth.c diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am index 7570a45f..6d0aaef9 100644 --- a/src/libsodium/Makefile.am +++ b/src/libsodium/Makefile.am @@ -31,6 +31,7 @@ libsodium_la_SOURCES = \ crypto_verify/16/ref/verify_16.c \ crypto_verify/32/ref/api.h \ crypto_verify/32/ref/verify_32.c \ + crypto_auth/crypto_auth.c \ crypto_auth/hmacsha256/ref/api.h \ crypto_auth/hmacsha256/ref/hmac_hmacsha256.c \ crypto_auth/hmacsha256/ref/verify_hmacsha256.c \ diff --git a/src/libsodium/crypto_auth/crypto_auth.c b/src/libsodium/crypto_auth/crypto_auth.c new file mode 100644 index 00000000..57b3a005 --- /dev/null +++ b/src/libsodium/crypto_auth/crypto_auth.c @@ -0,0 +1,14 @@ + +#include "crypto_auth.h" + +int crypto_auth(unsigned char *out, const unsigned char *in, + unsigned long long inlen, const unsigned char *k) +{ + return crypto_auth_hmacsha512256(out, in, inlen, k); +} + +int crypto_auth_verify(const unsigned char *h, const unsigned char *in, + unsigned long long inlen,const unsigned char *k) +{ + return crypto_auth_hmacsha512256_verify(h, in, inlen, k); +} diff --git a/src/libsodium/include/sodium/crypto_auth.h b/src/libsodium/include/sodium/crypto_auth.h index 450152ca..1d6e7963 100644 --- a/src/libsodium/include/sodium/crypto_auth.h +++ b/src/libsodium/include/sodium/crypto_auth.h @@ -3,10 +3,20 @@ #include "crypto_auth_hmacsha512256.h" -#define crypto_auth crypto_auth_hmacsha512256 -#define crypto_auth_verify crypto_auth_hmacsha512256_verify #define crypto_auth_BYTES crypto_auth_hmacsha512256_BYTES #define crypto_auth_KEYBYTES crypto_auth_hmacsha512256_KEYBYTES #define crypto_auth_PRIMITIVE "hmacsha512256" +#ifdef __cplusplus +extern "C" { +#endif +int crypto_auth(unsigned char *out, const unsigned char *in, + unsigned long long inlen, const unsigned char *k); + +int crypto_auth_verify(const unsigned char *h, const unsigned char *in, + unsigned long long inlen,const unsigned char *k); +#ifdef __cplusplus +} +#endif + #endif