diff --git a/libsodium.vcxproj b/libsodium.vcxproj
index 4b723ccb..f7815ed3 100644
--- a/libsodium.vcxproj
+++ b/libsodium.vcxproj
@@ -318,6 +318,7 @@
+
@@ -374,6 +375,9 @@
+
+
+
diff --git a/libsodium.vcxproj.filters b/libsodium.vcxproj.filters
index e766cc40..2bcd0ddc 100644
--- a/libsodium.vcxproj.filters
+++ b/libsodium.vcxproj.filters
@@ -24,6 +24,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -190,6 +193,9 @@
Source Files
+
+ Source Files
+
Source Files
@@ -199,12 +205,18 @@
Source Files
+
+ Source Files
+
Source Files
Source Files
+
+ Source Files
+
Source Files
diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am
index 13da6ec6..7e75f28d 100644
--- a/src/libsodium/Makefile.am
+++ b/src/libsodium/Makefile.am
@@ -7,6 +7,10 @@ libsodium_la_SOURCES = \
crypto_auth/hmacsha256/cp/api.h \
crypto_auth/hmacsha256/cp/hmac_hmacsha256.c \
crypto_auth/hmacsha256/cp/verify_hmacsha256.c \
+ crypto_auth/hmacsha512/auth_hmacsha512_api.c \
+ crypto_auth/hmacsha512/cp/api.h \
+ crypto_auth/hmacsha512/cp/hmac_hmacsha512.c \
+ crypto_auth/hmacsha512/cp/verify_hmacsha512.c \
crypto_auth/hmacsha512256/auth_hmacsha512256_api.c \
crypto_auth/hmacsha512256/cp/api.h \
crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c \
diff --git a/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c b/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c
new file mode 100644
index 00000000..0fdbf013
--- /dev/null
+++ b/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c
@@ -0,0 +1,16 @@
+#include "crypto_auth_hmacsha512.h"
+
+size_t
+crypto_auth_hmacsha512_bytes(void) {
+ return crypto_auth_hmacsha512_BYTES;
+}
+
+size_t
+crypto_auth_hmacsha512_keybytes(void) {
+ return crypto_auth_hmacsha512_KEYBYTES;
+}
+
+const char *
+crypto_auth_hmacsha512_primitive(void) {
+ return "hmacsha512";
+}
diff --git a/src/libsodium/crypto_auth/hmacsha512/cp/api.h b/src/libsodium/crypto_auth/hmacsha512/cp/api.h
new file mode 100644
index 00000000..e8402aa3
--- /dev/null
+++ b/src/libsodium/crypto_auth/hmacsha512/cp/api.h
@@ -0,0 +1,10 @@
+
+#include "crypto_auth_hmacsha512.h"
+
+#define crypto_auth crypto_auth_hmacsha512
+#define crypto_auth_verify crypto_auth_hmacsha512_verify
+#define crypto_auth_BYTES crypto_auth_hmacsha512_BYTES
+#define crypto_auth_KEYBYTES crypto_auth_hmacsha512_KEYBYTES
+#define crypto_auth_PRIMITIVE "hmacsha512"
+#define crypto_auth_IMPLEMENTATION crypto_auth_hmacsha512_IMPLEMENTATION
+#define crypto_auth_VERSION crypto_auth_hmacsha512_VERSION
diff --git a/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c b/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c
new file mode 100644
index 00000000..8d841543
--- /dev/null
+++ b/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c
@@ -0,0 +1,110 @@
+
+/*-
+ * Copyright 2005,2007,2009 Colin Percival
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "api.h"
+#include "crypto_auth_hmacsha512.h"
+#include "crypto_hash_sha512.h"
+#include "utils.h"
+
+#include
+
+#include
+#include
+
+int
+crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
+ const unsigned char *key,
+ size_t keylen)
+{
+ unsigned char pad[128];
+ unsigned char khash[64];
+ size_t i;
+
+ if (keylen > 128) {
+ crypto_hash_sha512_init(&state->ictx);
+ crypto_hash_sha512_update(&state->ictx, key, keylen);
+ crypto_hash_sha512_final(&state->ictx, khash);
+ key = khash;
+ keylen = 64;
+ }
+ crypto_hash_sha512_init(&state->ictx);
+ memset(pad, 0x36, 128);
+ for (i = 0; i < keylen; i++) {
+ pad[i] ^= key[i];
+ }
+ crypto_hash_sha512_update(&state->ictx, pad, 128);
+
+ crypto_hash_sha512_init(&state->octx);
+ memset(pad, 0x5c, 128);
+ for (i = 0; i < keylen; i++) {
+ pad[i] ^= key[i];
+ }
+ crypto_hash_sha512_update(&state->octx, pad, 128);
+
+ sodium_memzero((void *) khash, 64);
+
+ return 0;
+}
+
+int
+crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
+ const unsigned char *in,
+ unsigned long long inlen)
+{
+ crypto_hash_sha512_update(&state->ictx, in, inlen);
+
+ return 0;
+}
+
+int
+crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state,
+ unsigned char *out)
+{
+ unsigned char ihash[64];
+
+ crypto_hash_sha512_final(&state->ictx, ihash);
+ crypto_hash_sha512_update(&state->octx, ihash, 64);
+ crypto_hash_sha512_final(&state->octx, out);
+
+ sodium_memzero((void *) ihash, 64);
+
+ return 0;
+}
+
+int
+crypto_auth(unsigned char *out, const unsigned char *in,
+ unsigned long long inlen, const unsigned char *k)
+{
+ crypto_auth_hmacsha512_state state;
+
+ crypto_auth_hmacsha512_init(&state, k, crypto_auth_KEYBYTES);
+ crypto_auth_hmacsha512_update(&state, in, inlen);
+ crypto_auth_hmacsha512_final(&state, out);
+
+ return 0;
+}
diff --git a/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c b/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c
new file mode 100644
index 00000000..fccdc1a4
--- /dev/null
+++ b/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c
@@ -0,0 +1,10 @@
+#include "api.h"
+#include "crypto_verify_64.h"
+
+int crypto_auth_verify(const unsigned char *h, const unsigned char *in,
+ unsigned long long inlen, const unsigned char *k)
+{
+ unsigned char correct[64];
+ crypto_auth(correct,in,inlen,k);
+ return crypto_verify_64(h,correct);
+}
diff --git a/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c b/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c
index 27a14943..4b476c33 100644
--- a/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c
+++ b/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c
@@ -1,33 +1,7 @@
-/*-
- * Copyright 2005,2007,2009 Colin Percival
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
#include "api.h"
#include "crypto_auth_hmacsha512256.h"
+#include "crypto_auth_hmacsha512.h"
#include "crypto_hash_sha512.h"
#include "utils.h"
@@ -36,66 +10,6 @@
#include
#include
-int
-crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
- const unsigned char *key,
- size_t keylen)
-{
- unsigned char pad[128];
- unsigned char khash[64];
- size_t i;
-
- if (keylen > 128) {
- crypto_hash_sha512_init(&state->ictx);
- crypto_hash_sha512_update(&state->ictx, key, keylen);
- crypto_hash_sha512_final(&state->ictx, khash);
- key = khash;
- keylen = 64;
- }
- crypto_hash_sha512_init(&state->ictx);
- memset(pad, 0x36, 128);
- for (i = 0; i < keylen; i++) {
- pad[i] ^= key[i];
- }
- crypto_hash_sha512_update(&state->ictx, pad, 128);
-
- crypto_hash_sha512_init(&state->octx);
- memset(pad, 0x5c, 128);
- for (i = 0; i < keylen; i++) {
- pad[i] ^= key[i];
- }
- crypto_hash_sha512_update(&state->octx, pad, 128);
-
- sodium_memzero((void *) khash, 64);
-
- return 0;
-}
-
-int
-crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
- const unsigned char *in,
- unsigned long long inlen)
-{
- crypto_hash_sha512_update(&state->ictx, in, inlen);
-
- return 0;
-}
-
-int
-crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state,
- unsigned char *out)
-{
- unsigned char ihash[64];
-
- crypto_hash_sha512_final(&state->ictx, ihash);
- crypto_hash_sha512_update(&state->octx, ihash, 64);
- crypto_hash_sha512_final(&state->octx, out);
-
- sodium_memzero((void *) ihash, 64);
-
- return 0;
-}
-
int
crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state,
const unsigned char *key,
diff --git a/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c b/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c
index b6cf4893..1e6e18db 100644
--- a/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c
+++ b/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c
@@ -1,7 +1,8 @@
#include "api.h"
#include "crypto_verify_32.h"
-int crypto_auth_verify(const unsigned char *h,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)
{
unsigned char correct[32];
crypto_auth(correct,in,inlen,k);
diff --git a/src/libsodium/include/Makefile.am b/src/libsodium/include/Makefile.am
index 9f713e97..260472be 100644
--- a/src/libsodium/include/Makefile.am
+++ b/src/libsodium/include/Makefile.am
@@ -4,6 +4,7 @@ SODIUM_EXPORT = \
sodium/core.h \
sodium/crypto_auth.h \
sodium/crypto_auth_hmacsha256.h \
+ sodium/crypto_auth_hmacsha512.h \
sodium/crypto_auth_hmacsha512256.h \
sodium/crypto_box.h \
sodium/crypto_box_curve25519xsalsa20poly1305.h \
diff --git a/src/libsodium/include/sodium.h b/src/libsodium/include/sodium.h
index 818909c6..4b2022e4 100644
--- a/src/libsodium/include/sodium.h
+++ b/src/libsodium/include/sodium.h
@@ -5,6 +5,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/src/libsodium/include/sodium/crypto_auth_hmacsha512.h b/src/libsodium/include/sodium/crypto_auth_hmacsha512.h
new file mode 100644
index 00000000..34764ff2
--- /dev/null
+++ b/src/libsodium/include/sodium/crypto_auth_hmacsha512.h
@@ -0,0 +1,59 @@
+#ifndef crypto_auth_hmacsha512_H
+#define crypto_auth_hmacsha512_H
+
+#include
+#include "crypto_hash_sha512.h"
+#include "export.h"
+
+#define crypto_auth_hmacsha512_BYTES 64U
+#define crypto_auth_hmacsha512_KEYBYTES 32U
+
+#ifdef __cplusplus
+# if __GNUC__
+# pragma GCC diagnostic ignored "-Wlong-long"
+# endif
+extern "C" {
+#endif
+
+typedef struct crypto_auth_hmacsha512_state {
+ crypto_hash_sha512_state ictx;
+ crypto_hash_sha512_state octx;
+} crypto_auth_hmacsha512_state;
+
+SODIUM_EXPORT
+size_t crypto_auth_hmacsha512_bytes(void);
+
+SODIUM_EXPORT
+size_t crypto_auth_hmacsha512_keybytes(void);
+
+SODIUM_EXPORT
+const char * crypto_auth_hmacsha512_primitive(void);
+
+SODIUM_EXPORT
+int crypto_auth_hmacsha512(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
+
+SODIUM_EXPORT
+int crypto_auth_hmacsha512_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
+
+SODIUM_EXPORT
+int crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
+ const unsigned char *key,
+ size_t keylen);
+
+SODIUM_EXPORT
+int crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
+ const unsigned char *in,
+ unsigned long long inlen);
+
+SODIUM_EXPORT
+int crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state,
+ unsigned char *out);
+
+#ifdef __cplusplus
+}
+#endif
+
+#define crypto_auth_hmacsha512_cp crypto_auth_hmacsha512
+#define crypto_auth_hmacsha512_cp_verify crypto_auth_hmacsha512_verify
+
+#endif
diff --git a/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h b/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h
index 07413144..07cbe532 100644
--- a/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h
+++ b/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h
@@ -2,7 +2,7 @@
#define crypto_auth_hmacsha512256_H
#include
-#include "crypto_hash_sha512.h"
+#include "crypto_auth_hmacsha512.h"
#include "export.h"
#define crypto_auth_hmacsha512256_BYTES 32U
@@ -15,11 +15,6 @@
extern "C" {
#endif
-typedef struct crypto_auth_hmacsha512_state {
- crypto_hash_sha512_state ictx;
- crypto_hash_sha512_state octx;
-} crypto_auth_hmacsha512_state;
-
typedef struct crypto_auth_hmacsha512_state crypto_auth_hmacsha512256_state;
SODIUM_EXPORT
@@ -37,6 +32,20 @@ int crypto_auth_hmacsha512256(unsigned char *,const unsigned char *,unsigned lon
SODIUM_EXPORT
int crypto_auth_hmacsha512256_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
+SODIUM_EXPORT
+int crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state,
+ const unsigned char *key,
+ size_t keylen);
+
+SODIUM_EXPORT
+int crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state,
+ const unsigned char *in,
+ unsigned long long inlen);
+
+SODIUM_EXPORT
+int crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state,
+ unsigned char *out);
+
#ifdef __cplusplus
}
#endif