diff --git a/AUTHORS b/AUTHORS index ec947e5f..e3d97bdf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,7 +12,7 @@ Copyright (c) 2014 AppDynamics Inc. Individual Contributors ======================= -AJ Lewis +AJ Lewis Alexej Lotz Andrew Thompson Asko Kauppi @@ -36,10 +36,11 @@ Christian Kamm Chuck Remes Conrad D. Steenberg Constantin Rack -Dhammika Pathirana +Daniel J. Bernstein +Dhammika Pathirana Dhruva Krishnamurthy Dirk O. Kaar -Douglas Creager +Douglas Creager Drew Crawford Erich Heine Erik Hugne diff --git a/CMakeLists.txt b/CMakeLists.txt index 6180ee57..93dea034 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,13 +26,14 @@ elseif (WITH_SODIUM) find_package (Sodium) if (SODIUM_FOUND) message (STATUS "Using libsodium for CURVE security") - add_definitions (-DZMQ_HAVE_CURVE -DHAVE_LIBSODIUM) include_directories (${SODIUM_INCLUDE_DIRS}) # On Solaris, libsodium depends on libssp if (${CMAKE_SYSTEM_NAME} matches "SunOS") target_link_libraries (libzmq ssp) endif () + set (HAVE_LIBSODIUM 1) + set (ZMQ_HAVE_CURVE 1) else () message (FATAL_ERROR "libsodium is not installed. Install it, then run CMake again") @@ -40,17 +41,9 @@ elseif (WITH_SODIUM) else () message (STATUS "Using tweetnacl for CURVE security") - add_definitions (-DZMQ_HAVE_CURVE -DHAVE_TWEETNACL) - include_directories (tweetnacl/contrib/randombytes tweetnacl/src) - list (APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/tweetnacl/src/tweetnacl.c) - # TODO: this should be a single coherent source file - if (WIN32) - list (APPEND sources - ${CMAKE_CURRENT_SOURCE_DIR}/tweetnacl/contrib/randombytes/winrandom.c) - else () - list (APPEND sources - ${CMAKE_CURRENT_SOURCE_DIR}/tweetnacl/contrib/randombytes/devurandom.c) - endif () + list (APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/src/tweetnacl.c) + set (ZMQ_USE_TWEETNACL 1) + set (ZMQ_HAVE_CURVE 1) endif () set (POLLER "" CACHE STRING "Choose polling system. valid values are @@ -565,8 +558,6 @@ if (NOT ZMQ_BUILD_FRAMEWORK) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/libzmq.pc DESTINATION lib/pkgconfig) endif () - - if (MSVC) if (CMAKE_CL_64) set (nsis-template ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/NSIS.template64.in) diff --git a/Makefile.am b/Makefile.am index fd754c69..e25fa260 100644 --- a/Makefile.am +++ b/Makefile.am @@ -192,6 +192,8 @@ src_libzmq_la_SOURCES = \ src/tipc_listener.hpp \ src/trie.cpp \ src/trie.hpp \ + src/tweetnacl.c \ + src/tweetnacl.h \ src/udp_address.cpp \ src/udp_address.hpp \ src/udp_engine.cpp \ @@ -269,15 +271,6 @@ src_libzmq_la_CPPFLAGS = src_libzmq_la_CXXFLAGS = @LIBZMQ_EXTRA_CXXFLAGS@ src_libzmq_la_LIBADD = -if USE_TWEETNACL -src_libzmq_la_SOURCES += \ - tweetnacl/src/tweetnacl.c \ - tweetnacl/contrib/randombytes/devurandom.c -src_libzmq_la_CXXFLAGS += \ - -I$(top_builddir)/tweetnacl/contrib/randombytes \ - -I$(top_builddir)/tweetnacl/src -endif - if USE_LIBSODIUM src_libzmq_la_CPPFLAGS += ${sodium_CFLAGS} src_libzmq_la_LIBADD += ${sodium_LIBS} @@ -753,7 +746,6 @@ EXTRA_DIST = \ MAINTAINERS \ src/libzmq.pc.cmake.in \ src/libzmq.vers \ - tweetnacl \ tools/curve_keygen.cpp MAINTAINERCLEANFILES = \ diff --git a/builds/cmake/platform.hpp.in b/builds/cmake/platform.hpp.in index 21930c42..e5254d73 100644 --- a/builds/cmake/platform.hpp.in +++ b/builds/cmake/platform.hpp.in @@ -9,7 +9,6 @@ #cmakedefine ZMQ_FORCE_MUTEXES - #cmakedefine HAVE_FORK #cmakedefine HAVE_CLOCK_GETTIME #cmakedefine HAVE_GETHRTIME @@ -31,6 +30,9 @@ #cmakedefine ZMQ_HAVE_OPENPGM #cmakedefine ZMQ_MAKE_VALGRIND_HAPPY +#cmakedefine ZMQ_HAVE_CURVE +#cmakedefine HAVE_TWEETNACL +#cmakedefine HAVE_LIBSODIUM #ifdef _AIX #define ZMQ_HAVE_AIX @@ -86,4 +88,4 @@ #cmakedefine ZMQ_HAVE_WINDOWS -#endif \ No newline at end of file +#endif diff --git a/configure.ac b/configure.ac index 041fb56b..0d8c57af 100644 --- a/configure.ac +++ b/configure.ac @@ -456,7 +456,7 @@ elif test "x$with_libsodium" == "xyes"; then else AC_MSG_NOTICE([Using tweetnacl for CURVE security]) AC_DEFINE(ZMQ_HAVE_CURVE, [1], [Using curve encryption]) - AC_DEFINE(HAVE_TWEETNACL, [1], [Using tweetnacl for curve encryption]) + AC_DEFINE(ZMQ_USE_TWEETNACL, [1], [Using tweetnacl for curve encryption]) curve_library="tweetnacl" libzmq_pedantic="no" # Disable pedantic warnings fi diff --git a/src/ctx.cpp b/src/ctx.cpp index 4a6e7079..d702cece 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -48,8 +48,8 @@ #include "err.hpp" #include "msg.hpp" -#if defined (HAVE_TWEETNACL) -# include "randombytes.h" +#if defined (ZMQ_USE_TWEETNACL) +# include "tweetnacl.h" #elif defined (HAVE_LIBSODIUM) # include "sodium.h" #endif diff --git a/src/curve_client.cpp b/src/curve_client.cpp index f87907b6..12bb941e 100644 --- a/src/curve_client.cpp +++ b/src/curve_client.cpp @@ -53,7 +53,7 @@ zmq::curve_client_t::curve_client_t (const options_t &options_) : memcpy (secret_key, options_.curve_secret_key, crypto_box_SECRETKEYBYTES); memcpy (server_key, options_.curve_server_key, crypto_box_PUBLICKEYBYTES); scoped_lock_t lock (sync); -#if defined(HAVE_TWEETNACL) +#if defined (ZMQ_USE_TWEETNACL) // allow opening of /dev/urandom unsigned char tmpbytes[4]; randombytes(tmpbytes, 4); diff --git a/src/curve_client.hpp b/src/curve_client.hpp index 4f8ba162..fcc10bd8 100644 --- a/src/curve_client.hpp +++ b/src/curve_client.hpp @@ -35,9 +35,8 @@ #include "platform.hpp" #include "mutex.hpp" -#if defined (HAVE_TWEETNACL) -# include "tweetnacl_base.h" -# include "randombytes.h" +#if defined (ZMQ_USE_TWEETNACL) +# include "tweetnacl.h" #elif defined (HAVE_LIBSODIUM) # include "sodium.h" #endif @@ -47,7 +46,7 @@ || crypto_box_SECRETKEYBYTES != 32 \ || crypto_box_ZEROBYTES != 32 \ || crypto_box_BOXZEROBYTES != 16 -# error "libsodium not built properly" +# error "CURVE library not built properly" #endif #include "mechanism.hpp" diff --git a/src/curve_server.cpp b/src/curve_server.cpp index ed4cf93f..1c0638df 100644 --- a/src/curve_server.cpp +++ b/src/curve_server.cpp @@ -56,10 +56,10 @@ zmq::curve_server_t::curve_server_t (session_base_t *session_, // Fetch our secret key from socket options memcpy (secret_key, options_.curve_secret_key, crypto_box_SECRETKEYBYTES); scoped_lock_t lock (sync); -#if defined(HAVE_TWEETNACL) +#if defined (ZMQ_USE_TWEETNACL) // allow opening of /dev/urandom unsigned char tmpbytes[4]; - randombytes(tmpbytes, 4); + randombytes (tmpbytes, 4); #else rc = sodium_init (); zmq_assert (rc != -1); diff --git a/src/curve_server.hpp b/src/curve_server.hpp index 36b87827..6e2b7c74 100644 --- a/src/curve_server.hpp +++ b/src/curve_server.hpp @@ -34,9 +34,8 @@ #include "platform.hpp" -#if defined (HAVE_TWEETNACL) -# include "tweetnacl_base.h" -# include "randombytes.h" +#if defined (ZMQ_USE_TWEETNACL) +# include "tweetnacl.h" #elif defined (HAVE_LIBSODIUM) # include "sodium.h" #endif @@ -49,7 +48,7 @@ || crypto_secretbox_NONCEBYTES != 24 \ || crypto_secretbox_ZEROBYTES != 32 \ || crypto_secretbox_BOXZEROBYTES != 16 -# error "libsodium not built properly" +# error "CURVE library not built properly" #endif #include "mechanism.hpp" diff --git a/tweetnacl/src/tweetnacl.c b/src/tweetnacl.c similarity index 83% rename from tweetnacl/src/tweetnacl.c rename to src/tweetnacl.c index 4e0f367c..01cbb7e1 100644 --- a/tweetnacl/src/tweetnacl.c +++ b/src/tweetnacl.c @@ -1,23 +1,40 @@ -#if defined(HAVE_NACL_COMPABILTY) -/* NaCL Compabilty */ +/* + Copyright (c) 2016 Contributors as noted in the AUTHORS file + + This file is part of libzmq, the ZeroMQ core engine in C++. + + libzmq is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License (LGPL) as published + by the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + As a special exception, the Contributors give you permission to link + this library with independent modules to produce an executable, + regardless of the license terms of these independent modules, and to + copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the + terms and conditions of the license of that module. An independent + module is a module which is not derived from or based on this library. + If you modify this library, you must extend this exception to your + version of the library. + + libzmq is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#include "platform.hpp" +#if defined (ZMQ_USE_TWEETNACL) + #include "tweetnacl.h" -#else -/* direct tweetnacl usage */ -#include "tweetnacl_base.h" -#endif #define FOR(i,n) for (i = 0;i < n;++i) #define sv static void -#ifndef TWEETNACL_BASE_H -typedef unsigned char u8; -typedef unsigned long u32; -typedef unsigned long long u64; -typedef long long i64; -typedef i64 gf[16]; -#endif -extern void randombytes(u8 *,u64); - static const u8 _0[16], _9[32] = {9}; @@ -816,3 +833,102 @@ int crypto_sign_open(u8 *m,u64 *mlen,const u8 *sm,u64 n,const u8 *pk) *mlen = n; return 0; } + + +#ifdef ZMQ_HAVE_WINDOWS + +#include +#include + +#define NCP ((HCRYPTPROV) 0) + +HCRYPTPROV hProvider = NCP; + +void randombytes(unsigned char *x,unsigned long long xlen) +{ + unsigned i; + BOOL ret; + + if (hProvider == NCP) { + for (;;) { + ret = CryptAcquireContext(&hProvider, NULL, NULL, + PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT); + if (ret != FALSE) + break; + Sleep (1); + } + } + while (xlen > 0) { + if (xlen < 1048576) + i = (unsigned) xlen; + else + i = 1048576; + + ret = CryptGenRandom(hProvider, i, x); + if (ret == FALSE) { + Sleep(1); + continue; + } + x += i; + xlen -= i; + } +} + +int randombytes_close(void) +{ + int rc = -1; + if ((hProvider != NCP) && (CryptReleaseContext(hProvider, 0) != FALSE)) { + hProvider = NCP; + rc = 0; + } + return rc; +} + +#else + +#include +#include +#include +#include + +static int fd = -1; + +void randombytes (unsigned char *x,unsigned long long xlen) +{ + int i; + if (fd == -1) { + for (;;) { + fd = open("/dev/urandom",O_RDONLY); + if (fd != -1) break; + sleep (1); + } + } + while (xlen > 0) { + if (xlen < 1048576) + i = xlen; + else + i = 1048576; + + i = read(fd,x,i); + if (i < 1) { + sleep (1); + continue; + } + x += i; + xlen -= i; + } +} + +int randombytes_close (void) +{ + int rc = -1; + if (fd != -1 && close(fd) == 0) { + fd = -1; + rc = 0; + } + return rc; +} + +#endif + +#endif diff --git a/src/tweetnacl.h b/src/tweetnacl.h new file mode 100644 index 00000000..b152642e --- /dev/null +++ b/src/tweetnacl.h @@ -0,0 +1,72 @@ +/* + Copyright (c) 2016 Contributors as noted in the AUTHORS file + + This file is part of libzmq, the ZeroMQ core engine in C++. + + libzmq is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License (LGPL) as published + by the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + As a special exception, the Contributors give you permission to link + this library with independent modules to produce an executable, + regardless of the license terms of these independent modules, and to + copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the + terms and conditions of the license of that module. An independent + module is a module which is not derived from or based on this library. + If you modify this library, you must extend this exception to your + version of the library. + + libzmq is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef TWEETNACL_H +#define TWEETNACL_H + +#include "platform.hpp" +#if defined (ZMQ_USE_TWEETNACL) + +#define crypto_box_SECRETKEYBYTES 32 +#define crypto_box_BOXZEROBYTES 16 +#define crypto_box_NONCEBYTES 24 +#define crypto_box_ZEROBYTES 32 +#define crypto_box_PUBLICKEYBYTES 32 +#define crypto_box_BEFORENMBYTES 32 +#define crypto_secretbox_KEYBYTES 32 +#define crypto_secretbox_NONCEBYTES 24 +#define crypto_secretbox_ZEROBYTES 32 +#define crypto_secretbox_BOXZEROBYTES 16 +typedef unsigned char u8; +typedef unsigned long u32; +typedef unsigned long long u64; +typedef long long i64; +typedef i64 gf[16]; + +#ifdef __cplusplus +extern "C" { +#endif +void randombytes (unsigned char *, unsigned long long); +int randombytes_close (void); + +int crypto_box_keypair(u8 *y,u8 *x); +int crypto_box_afternm(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *k); +int crypto_box_open_afternm(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *k); +int crypto_box(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *y,const u8 *x); +int crypto_box_open(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *y,const u8 *x); +int crypto_box_beforenm(u8 *k,const u8 *y,const u8 *x); +int crypto_secretbox(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *k); +int crypto_secretbox_open(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *k); +#ifdef __cplusplus +} +#endif + +#endif + +#endif diff --git a/src/zmq_utils.cpp b/src/zmq_utils.cpp index 24709106..c151f130 100644 --- a/src/zmq_utils.cpp +++ b/src/zmq_utils.cpp @@ -38,14 +38,13 @@ #include #if !defined ZMQ_HAVE_WINDOWS -#include +# include #else -#include "windows.hpp" +# include "windows.hpp" #endif -#if defined (HAVE_TWEETNACL) -# include "tweetnacl_base.h" -# include "randombytes.h" +#if defined (ZMQ_USE_TWEETNACL) +# include "tweetnacl.h" #elif defined (HAVE_LIBSODIUM) # include "sodium.h" #endif diff --git a/tweetnacl/contrib/randombytes/devurandom.c b/tweetnacl/contrib/randombytes/devurandom.c deleted file mode 100644 index 4fdd40ad..00000000 --- a/tweetnacl/contrib/randombytes/devurandom.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include - -/* it's really stupid that there isn't a syscall for this */ - -static int fd = -1; - -void randombytes(unsigned char *x,unsigned long long xlen) -{ - int i; - - if (fd == -1) { - for (;;) { - fd = open("/dev/urandom",O_RDONLY); - if (fd != -1) break; - sleep(1); - } - } - - while (xlen > 0) { - if (xlen < 1048576) i = xlen; else i = 1048576; - - i = read(fd,x,i); - if (i < 1) { - sleep(1); - continue; - } - - x += i; - xlen -= i; - } -} - -int randombytes_close(void) -{ - int rc = -1; - if(fd != -1 && close(fd) == 0) { - fd = -1; - rc = 0; - } - return rc; -} diff --git a/tweetnacl/contrib/randombytes/randombytes.h b/tweetnacl/contrib/randombytes/randombytes.h deleted file mode 100644 index 2945738b..00000000 --- a/tweetnacl/contrib/randombytes/randombytes.h +++ /dev/null @@ -1,21 +0,0 @@ -/* -randombytes/randombytes.h version 20080713 -D. J. Bernstein -Public domain. -*/ - -#ifndef randombytes_H -#define randombytes_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern void randombytes(unsigned char *,unsigned long long); -extern int randombytes_close(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tweetnacl/contrib/randombytes/winrandom.c b/tweetnacl/contrib/randombytes/winrandom.c deleted file mode 100644 index 4d649f74..00000000 --- a/tweetnacl/contrib/randombytes/winrandom.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -#define NCP ((HCRYPTPROV) 0) - -HCRYPTPROV hProvider = NCP; - -void randombytes(unsigned char *x,unsigned long long xlen) -{ - unsigned i; - BOOL ret; - - if (hProvider == NCP) { - for(;;) { - ret = CryptAcquireContext(&hProvider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT); - if (ret != FALSE) break; - Sleep(1); - } - } - - while (xlen > 0) { - if (xlen < 1048576) i = (unsigned) xlen; else i = 1048576; - - ret = CryptGenRandom(hProvider, i, x); - if (ret == FALSE) { - Sleep(1); - continue; - } - - x += i; - xlen -= i; - } -} - -int randombytes_close(void) -{ - int rc = -1; - if((hProvider != NCP) && (CryptReleaseContext(hProvider, 0) != FALSE)) { - hProvider = NCP; - rc = 0; - } - return rc; -} diff --git a/tweetnacl/src/tweetnacl.h b/tweetnacl/src/tweetnacl.h deleted file mode 100644 index d5607994..00000000 --- a/tweetnacl/src/tweetnacl.h +++ /dev/null @@ -1,273 +0,0 @@ -#ifndef TWEETNACL_H -#define TWEETNACL_H -#define crypto_auth_PRIMITIVE "hmacsha512256" -#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_IMPLEMENTATION crypto_auth_hmacsha512256_IMPLEMENTATION -#define crypto_auth_VERSION crypto_auth_hmacsha512256_VERSION -#define crypto_auth_hmacsha512256_tweet_BYTES 32 -#define crypto_auth_hmacsha512256_tweet_KEYBYTES 32 -extern int crypto_auth_hmacsha512256_tweet(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *); -extern int crypto_auth_hmacsha512256_tweet_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *); -#define crypto_auth_hmacsha512256_tweet_VERSION "-" -#define crypto_auth_hmacsha512256 crypto_auth_hmacsha512256_tweet -#define crypto_auth_hmacsha512256_verify crypto_auth_hmacsha512256_tweet_verify -#define crypto_auth_hmacsha512256_BYTES crypto_auth_hmacsha512256_tweet_BYTES -#define crypto_auth_hmacsha512256_KEYBYTES crypto_auth_hmacsha512256_tweet_KEYBYTES -#define crypto_auth_hmacsha512256_VERSION crypto_auth_hmacsha512256_tweet_VERSION -#define crypto_auth_hmacsha512256_IMPLEMENTATION "crypto_auth/hmacsha512256/tweet" -#define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305" -#define crypto_box crypto_box_curve25519xsalsa20poly1305 -#define crypto_box_open crypto_box_curve25519xsalsa20poly1305_open -#define crypto_box_keypair crypto_box_curve25519xsalsa20poly1305_keypair -#define crypto_box_beforenm crypto_box_curve25519xsalsa20poly1305_beforenm -#define crypto_box_afternm crypto_box_curve25519xsalsa20poly1305_afternm -#define crypto_box_open_afternm crypto_box_curve25519xsalsa20poly1305_open_afternm -#define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES -#define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES -#define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES -#define crypto_box_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_NONCEBYTES -#define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES -#define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES -#define crypto_box_IMPLEMENTATION crypto_box_curve25519xsalsa20poly1305_IMPLEMENTATION -#define crypto_box_VERSION crypto_box_curve25519xsalsa20poly1305_VERSION -#define crypto_box_curve25519xsalsa20poly1305_tweet_PUBLICKEYBYTES 32 -#define crypto_box_curve25519xsalsa20poly1305_tweet_SECRETKEYBYTES 32 -#define crypto_box_curve25519xsalsa20poly1305_tweet_BEFORENMBYTES 32 -#define crypto_box_curve25519xsalsa20poly1305_tweet_NONCEBYTES 24 -#define crypto_box_curve25519xsalsa20poly1305_tweet_ZEROBYTES 32 -#define crypto_box_curve25519xsalsa20poly1305_tweet_BOXZEROBYTES 16 -extern int crypto_box_curve25519xsalsa20poly1305_tweet(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *); -extern int crypto_box_curve25519xsalsa20poly1305_tweet_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *); -extern int crypto_box_curve25519xsalsa20poly1305_tweet_keypair(unsigned char *,unsigned char *); -extern int crypto_box_curve25519xsalsa20poly1305_tweet_beforenm(unsigned char *,const unsigned char *,const unsigned char *); -extern int crypto_box_curve25519xsalsa20poly1305_tweet_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); -extern int crypto_box_curve25519xsalsa20poly1305_tweet_open_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); -#define crypto_box_curve25519xsalsa20poly1305_tweet_VERSION "-" -#define crypto_box_curve25519xsalsa20poly1305 crypto_box_curve25519xsalsa20poly1305_tweet -#define crypto_box_curve25519xsalsa20poly1305_open crypto_box_curve25519xsalsa20poly1305_tweet_open -#define crypto_box_curve25519xsalsa20poly1305_keypair crypto_box_curve25519xsalsa20poly1305_tweet_keypair -#define crypto_box_curve25519xsalsa20poly1305_beforenm crypto_box_curve25519xsalsa20poly1305_tweet_beforenm -#define crypto_box_curve25519xsalsa20poly1305_afternm crypto_box_curve25519xsalsa20poly1305_tweet_afternm -#define crypto_box_curve25519xsalsa20poly1305_open_afternm crypto_box_curve25519xsalsa20poly1305_tweet_open_afternm -#define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_tweet_PUBLICKEYBYTES -#define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_tweet_SECRETKEYBYTES -#define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_tweet_BEFORENMBYTES -#define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_tweet_NONCEBYTES -#define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_tweet_ZEROBYTES -#define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_tweet_BOXZEROBYTES -#define crypto_box_curve25519xsalsa20poly1305_VERSION crypto_box_curve25519xsalsa20poly1305_tweet_VERSION -#define crypto_box_curve25519xsalsa20poly1305_IMPLEMENTATION "crypto_box/curve25519xsalsa20poly1305/tweet" -#define crypto_core_PRIMITIVE "salsa20" -#define crypto_core crypto_core_salsa20 -#define crypto_core_OUTPUTBYTES crypto_core_salsa20_OUTPUTBYTES -#define crypto_core_INPUTBYTES crypto_core_salsa20_INPUTBYTES -#define crypto_core_KEYBYTES crypto_core_salsa20_KEYBYTES -#define crypto_core_CONSTBYTES crypto_core_salsa20_CONSTBYTES -#define crypto_core_IMPLEMENTATION crypto_core_salsa20_IMPLEMENTATION -#define crypto_core_VERSION crypto_core_salsa20_VERSION -#define crypto_core_salsa20_tweet_OUTPUTBYTES 64 -#define crypto_core_salsa20_tweet_INPUTBYTES 16 -#define crypto_core_salsa20_tweet_KEYBYTES 32 -#define crypto_core_salsa20_tweet_CONSTBYTES 16 -extern int crypto_core_salsa20_tweet(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *); -#define crypto_core_salsa20_tweet_VERSION "-" -#define crypto_core_salsa20 crypto_core_salsa20_tweet -#define crypto_core_salsa20_OUTPUTBYTES crypto_core_salsa20_tweet_OUTPUTBYTES -#define crypto_core_salsa20_INPUTBYTES crypto_core_salsa20_tweet_INPUTBYTES -#define crypto_core_salsa20_KEYBYTES crypto_core_salsa20_tweet_KEYBYTES -#define crypto_core_salsa20_CONSTBYTES crypto_core_salsa20_tweet_CONSTBYTES -#define crypto_core_salsa20_VERSION crypto_core_salsa20_tweet_VERSION -#define crypto_core_salsa20_IMPLEMENTATION "crypto_core/salsa20/tweet" -#define crypto_core_hsalsa20_tweet_OUTPUTBYTES 32 -#define crypto_core_hsalsa20_tweet_INPUTBYTES 16 -#define crypto_core_hsalsa20_tweet_KEYBYTES 32 -#define crypto_core_hsalsa20_tweet_CONSTBYTES 16 -extern int crypto_core_hsalsa20_tweet(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *); -#define crypto_core_hsalsa20_tweet_VERSION "-" -#define crypto_core_hsalsa20 crypto_core_hsalsa20_tweet -#define crypto_core_hsalsa20_OUTPUTBYTES crypto_core_hsalsa20_tweet_OUTPUTBYTES -#define crypto_core_hsalsa20_INPUTBYTES crypto_core_hsalsa20_tweet_INPUTBYTES -#define crypto_core_hsalsa20_KEYBYTES crypto_core_hsalsa20_tweet_KEYBYTES -#define crypto_core_hsalsa20_CONSTBYTES crypto_core_hsalsa20_tweet_CONSTBYTES -#define crypto_core_hsalsa20_VERSION crypto_core_hsalsa20_tweet_VERSION -#define crypto_core_hsalsa20_IMPLEMENTATION "crypto_core/hsalsa20/tweet" -#define crypto_hashblocks_PRIMITIVE "sha512" -#define crypto_hashblocks crypto_hashblocks_sha512 -#define crypto_hashblocks_STATEBYTES crypto_hashblocks_sha512_STATEBYTES -#define crypto_hashblocks_BLOCKBYTES crypto_hashblocks_sha512_BLOCKBYTES -#define crypto_hashblocks_IMPLEMENTATION crypto_hashblocks_sha512_IMPLEMENTATION -#define crypto_hashblocks_VERSION crypto_hashblocks_sha512_VERSION -#define crypto_hashblocks_sha512_tweet_STATEBYTES 64 -#define crypto_hashblocks_sha512_tweet_BLOCKBYTES 128 -extern int crypto_hashblocks_sha512_tweet(unsigned char *,const unsigned char *,unsigned long long); -#define crypto_hashblocks_sha512_tweet_VERSION "-" -#define crypto_hashblocks_sha512 crypto_hashblocks_sha512_tweet -#define crypto_hashblocks_sha512_STATEBYTES crypto_hashblocks_sha512_tweet_STATEBYTES -#define crypto_hashblocks_sha512_BLOCKBYTES crypto_hashblocks_sha512_tweet_BLOCKBYTES -#define crypto_hashblocks_sha512_VERSION crypto_hashblocks_sha512_tweet_VERSION -#define crypto_hashblocks_sha512_IMPLEMENTATION "crypto_hashblocks/sha512/tweet" -#define crypto_hashblocks_sha256_tweet_STATEBYTES 32 -#define crypto_hashblocks_sha256_tweet_BLOCKBYTES 64 -extern int crypto_hashblocks_sha256_tweet(unsigned char *,const unsigned char *,unsigned long long); -#define crypto_hashblocks_sha256_tweet_VERSION "-" -#define crypto_hashblocks_sha256 crypto_hashblocks_sha256_tweet -#define crypto_hashblocks_sha256_STATEBYTES crypto_hashblocks_sha256_tweet_STATEBYTES -#define crypto_hashblocks_sha256_BLOCKBYTES crypto_hashblocks_sha256_tweet_BLOCKBYTES -#define crypto_hashblocks_sha256_VERSION crypto_hashblocks_sha256_tweet_VERSION -#define crypto_hashblocks_sha256_IMPLEMENTATION "crypto_hashblocks/sha256/tweet" -#define crypto_hash_PRIMITIVE "sha512" -#define crypto_hash crypto_hash_sha512 -#define crypto_hash_BYTES crypto_hash_sha512_BYTES -#define crypto_hash_IMPLEMENTATION crypto_hash_sha512_IMPLEMENTATION -#define crypto_hash_VERSION crypto_hash_sha512_VERSION -#define crypto_hash_sha512_tweet_BYTES 64 -extern int crypto_hash_sha512_tweet(unsigned char *,const unsigned char *,unsigned long long); -#define crypto_hash_sha512_tweet_VERSION "-" -#define crypto_hash_sha512 crypto_hash_sha512_tweet -#define crypto_hash_sha512_BYTES crypto_hash_sha512_tweet_BYTES -#define crypto_hash_sha512_VERSION crypto_hash_sha512_tweet_VERSION -#define crypto_hash_sha512_IMPLEMENTATION "crypto_hash/sha512/tweet" -#define crypto_hash_sha256_tweet_BYTES 32 -extern int crypto_hash_sha256_tweet(unsigned char *,const unsigned char *,unsigned long long); -#define crypto_hash_sha256_tweet_VERSION "-" -#define crypto_hash_sha256 crypto_hash_sha256_tweet -#define crypto_hash_sha256_BYTES crypto_hash_sha256_tweet_BYTES -#define crypto_hash_sha256_VERSION crypto_hash_sha256_tweet_VERSION -#define crypto_hash_sha256_IMPLEMENTATION "crypto_hash/sha256/tweet" -#define crypto_onetimeauth_PRIMITIVE "poly1305" -#define crypto_onetimeauth crypto_onetimeauth_poly1305 -#define crypto_onetimeauth_verify crypto_onetimeauth_poly1305_verify -#define crypto_onetimeauth_BYTES crypto_onetimeauth_poly1305_BYTES -#define crypto_onetimeauth_KEYBYTES crypto_onetimeauth_poly1305_KEYBYTES -#define crypto_onetimeauth_IMPLEMENTATION crypto_onetimeauth_poly1305_IMPLEMENTATION -#define crypto_onetimeauth_VERSION crypto_onetimeauth_poly1305_VERSION -#define crypto_onetimeauth_poly1305_tweet_BYTES 16 -#define crypto_onetimeauth_poly1305_tweet_KEYBYTES 32 -extern int crypto_onetimeauth_poly1305_tweet(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *); -extern int crypto_onetimeauth_poly1305_tweet_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *); -#define crypto_onetimeauth_poly1305_tweet_VERSION "-" -#define crypto_onetimeauth_poly1305 crypto_onetimeauth_poly1305_tweet -#define crypto_onetimeauth_poly1305_verify crypto_onetimeauth_poly1305_tweet_verify -#define crypto_onetimeauth_poly1305_BYTES crypto_onetimeauth_poly1305_tweet_BYTES -#define crypto_onetimeauth_poly1305_KEYBYTES crypto_onetimeauth_poly1305_tweet_KEYBYTES -#define crypto_onetimeauth_poly1305_VERSION crypto_onetimeauth_poly1305_tweet_VERSION -#define crypto_onetimeauth_poly1305_IMPLEMENTATION "crypto_onetimeauth/poly1305/tweet" -#define crypto_scalarmult_PRIMITIVE "curve25519" -#define crypto_scalarmult crypto_scalarmult_curve25519 -#define crypto_scalarmult_base crypto_scalarmult_curve25519_base -#define crypto_scalarmult_BYTES crypto_scalarmult_curve25519_BYTES -#define crypto_scalarmult_SCALARBYTES crypto_scalarmult_curve25519_SCALARBYTES -#define crypto_scalarmult_IMPLEMENTATION crypto_scalarmult_curve25519_IMPLEMENTATION -#define crypto_scalarmult_VERSION crypto_scalarmult_curve25519_VERSION -#define crypto_scalarmult_curve25519_tweet_BYTES 32 -#define crypto_scalarmult_curve25519_tweet_SCALARBYTES 32 -extern int crypto_scalarmult_curve25519_tweet(unsigned char *,const unsigned char *,const unsigned char *); -extern int crypto_scalarmult_curve25519_tweet_base(unsigned char *,const unsigned char *); -#define crypto_scalarmult_curve25519_tweet_VERSION "-" -#define crypto_scalarmult_curve25519 crypto_scalarmult_curve25519_tweet -#define crypto_scalarmult_curve25519_base crypto_scalarmult_curve25519_tweet_base -#define crypto_scalarmult_curve25519_BYTES crypto_scalarmult_curve25519_tweet_BYTES -#define crypto_scalarmult_curve25519_SCALARBYTES crypto_scalarmult_curve25519_tweet_SCALARBYTES -#define crypto_scalarmult_curve25519_VERSION crypto_scalarmult_curve25519_tweet_VERSION -#define crypto_scalarmult_curve25519_IMPLEMENTATION "crypto_scalarmult/curve25519/tweet" -#define crypto_secretbox_PRIMITIVE "xsalsa20poly1305" -#define crypto_secretbox crypto_secretbox_xsalsa20poly1305 -#define crypto_secretbox_open crypto_secretbox_xsalsa20poly1305_open -#define crypto_secretbox_KEYBYTES crypto_secretbox_xsalsa20poly1305_KEYBYTES -#define crypto_secretbox_NONCEBYTES crypto_secretbox_xsalsa20poly1305_NONCEBYTES -#define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES -#define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES -#define crypto_secretbox_IMPLEMENTATION crypto_secretbox_xsalsa20poly1305_IMPLEMENTATION -#define crypto_secretbox_VERSION crypto_secretbox_xsalsa20poly1305_VERSION -#define crypto_secretbox_xsalsa20poly1305_tweet_KEYBYTES 32 -#define crypto_secretbox_xsalsa20poly1305_tweet_NONCEBYTES 24 -#define crypto_secretbox_xsalsa20poly1305_tweet_ZEROBYTES 32 -#define crypto_secretbox_xsalsa20poly1305_tweet_BOXZEROBYTES 16 -extern int crypto_secretbox_xsalsa20poly1305_tweet(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); -extern int crypto_secretbox_xsalsa20poly1305_tweet_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); -#define crypto_secretbox_xsalsa20poly1305_tweet_VERSION "-" -#define crypto_secretbox_xsalsa20poly1305 crypto_secretbox_xsalsa20poly1305_tweet -#define crypto_secretbox_xsalsa20poly1305_open crypto_secretbox_xsalsa20poly1305_tweet_open -#define crypto_secretbox_xsalsa20poly1305_KEYBYTES crypto_secretbox_xsalsa20poly1305_tweet_KEYBYTES -#define crypto_secretbox_xsalsa20poly1305_NONCEBYTES crypto_secretbox_xsalsa20poly1305_tweet_NONCEBYTES -#define crypto_secretbox_xsalsa20poly1305_ZEROBYTES crypto_secretbox_xsalsa20poly1305_tweet_ZEROBYTES -#define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_tweet_BOXZEROBYTES -#define crypto_secretbox_xsalsa20poly1305_VERSION crypto_secretbox_xsalsa20poly1305_tweet_VERSION -#define crypto_secretbox_xsalsa20poly1305_IMPLEMENTATION "crypto_secretbox/xsalsa20poly1305/tweet" -#define crypto_sign_PRIMITIVE "ed25519" -#define crypto_sign crypto_sign_ed25519 -#define crypto_sign_open crypto_sign_ed25519_open -#define crypto_sign_keypair crypto_sign_ed25519_keypair -#define crypto_sign_BYTES crypto_sign_ed25519_BYTES -#define crypto_sign_PUBLICKEYBYTES crypto_sign_ed25519_PUBLICKEYBYTES -#define crypto_sign_SECRETKEYBYTES crypto_sign_ed25519_SECRETKEYBYTES -#define crypto_sign_IMPLEMENTATION crypto_sign_ed25519_IMPLEMENTATION -#define crypto_sign_VERSION crypto_sign_ed25519_VERSION -#define crypto_sign_ed25519_tweet_BYTES 64 -#define crypto_sign_ed25519_tweet_PUBLICKEYBYTES 32 -#define crypto_sign_ed25519_tweet_SECRETKEYBYTES 64 -extern int crypto_sign_ed25519_tweet(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); -extern int crypto_sign_ed25519_tweet_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); -extern int crypto_sign_ed25519_tweet_keypair(unsigned char *,unsigned char *); -#define crypto_sign_ed25519_tweet_VERSION "-" -#define crypto_sign_ed25519 crypto_sign_ed25519_tweet -#define crypto_sign_ed25519_open crypto_sign_ed25519_tweet_open -#define crypto_sign_ed25519_keypair crypto_sign_ed25519_tweet_keypair -#define crypto_sign_ed25519_BYTES crypto_sign_ed25519_tweet_BYTES -#define crypto_sign_ed25519_PUBLICKEYBYTES crypto_sign_ed25519_tweet_PUBLICKEYBYTES -#define crypto_sign_ed25519_SECRETKEYBYTES crypto_sign_ed25519_tweet_SECRETKEYBYTES -#define crypto_sign_ed25519_VERSION crypto_sign_ed25519_tweet_VERSION -#define crypto_sign_ed25519_IMPLEMENTATION "crypto_sign/ed25519/tweet" -#define crypto_stream_PRIMITIVE "xsalsa20" -#define crypto_stream crypto_stream_xsalsa20 -#define crypto_stream_xor crypto_stream_xsalsa20_xor -#define crypto_stream_KEYBYTES crypto_stream_xsalsa20_KEYBYTES -#define crypto_stream_NONCEBYTES crypto_stream_xsalsa20_NONCEBYTES -#define crypto_stream_IMPLEMENTATION crypto_stream_xsalsa20_IMPLEMENTATION -#define crypto_stream_VERSION crypto_stream_xsalsa20_VERSION -#define crypto_stream_xsalsa20_tweet_KEYBYTES 32 -#define crypto_stream_xsalsa20_tweet_NONCEBYTES 24 -extern int crypto_stream_xsalsa20_tweet(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); -extern int crypto_stream_xsalsa20_tweet_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); -#define crypto_stream_xsalsa20_tweet_VERSION "-" -#define crypto_stream_xsalsa20 crypto_stream_xsalsa20_tweet -#define crypto_stream_xsalsa20_xor crypto_stream_xsalsa20_tweet_xor -#define crypto_stream_xsalsa20_KEYBYTES crypto_stream_xsalsa20_tweet_KEYBYTES -#define crypto_stream_xsalsa20_NONCEBYTES crypto_stream_xsalsa20_tweet_NONCEBYTES -#define crypto_stream_xsalsa20_VERSION crypto_stream_xsalsa20_tweet_VERSION -#define crypto_stream_xsalsa20_IMPLEMENTATION "crypto_stream/xsalsa20/tweet" -#define crypto_stream_salsa20_tweet_KEYBYTES 32 -#define crypto_stream_salsa20_tweet_NONCEBYTES 8 -extern int crypto_stream_salsa20_tweet(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); -extern int crypto_stream_salsa20_tweet_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); -#define crypto_stream_salsa20_tweet_VERSION "-" -#define crypto_stream_salsa20 crypto_stream_salsa20_tweet -#define crypto_stream_salsa20_xor crypto_stream_salsa20_tweet_xor -#define crypto_stream_salsa20_KEYBYTES crypto_stream_salsa20_tweet_KEYBYTES -#define crypto_stream_salsa20_NONCEBYTES crypto_stream_salsa20_tweet_NONCEBYTES -#define crypto_stream_salsa20_VERSION crypto_stream_salsa20_tweet_VERSION -#define crypto_stream_salsa20_IMPLEMENTATION "crypto_stream/salsa20/tweet" -#define crypto_verify_PRIMITIVE "16" -#define crypto_verify crypto_verify_16 -#define crypto_verify_BYTES crypto_verify_16_BYTES -#define crypto_verify_IMPLEMENTATION crypto_verify_16_IMPLEMENTATION -#define crypto_verify_VERSION crypto_verify_16_VERSION -#define crypto_verify_16_tweet_BYTES 16 -extern int crypto_verify_16_tweet(const unsigned char *,const unsigned char *); -#define crypto_verify_16_tweet_VERSION "-" -#define crypto_verify_16 crypto_verify_16_tweet -#define crypto_verify_16_BYTES crypto_verify_16_tweet_BYTES -#define crypto_verify_16_VERSION crypto_verify_16_tweet_VERSION -#define crypto_verify_16_IMPLEMENTATION "crypto_verify/16/tweet" -#define crypto_verify_32_tweet_BYTES 32 -extern int crypto_verify_32_tweet(const unsigned char *,const unsigned char *); -#define crypto_verify_32_tweet_VERSION "-" -#define crypto_verify_32 crypto_verify_32_tweet -#define crypto_verify_32_BYTES crypto_verify_32_tweet_BYTES -#define crypto_verify_32_VERSION crypto_verify_32_tweet_VERSION -#define crypto_verify_32_IMPLEMENTATION "crypto_verify/32/tweet" -#endif - diff --git a/tweetnacl/src/tweetnacl_base.h b/tweetnacl/src/tweetnacl_base.h deleted file mode 100644 index 2fe4a4a7..00000000 --- a/tweetnacl/src/tweetnacl_base.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef TWEETNACL_BASE_H -#define TWEETNACL_BASE_H - -/* the original file seems to be a compability layer for NaCL */ - -/* This here is for direct tweetnacl usage */ - -#define crypto_box_SECRETKEYBYTES 32 -#define crypto_box_BOXZEROBYTES 16 -#define crypto_box_NONCEBYTES 24 -#define crypto_box_ZEROBYTES 32 -#define crypto_box_PUBLICKEYBYTES 32 -#define crypto_box_BEFORENMBYTES 32 -#define crypto_secretbox_KEYBYTES 32 -#define crypto_secretbox_NONCEBYTES 24 -#define crypto_secretbox_ZEROBYTES 32 -#define crypto_secretbox_BOXZEROBYTES 16 -typedef unsigned char u8; -typedef unsigned long u32; -typedef unsigned long long u64; -typedef long long i64; -typedef i64 gf[16]; - -#ifdef __cplusplus -extern "C" { -#endif -int crypto_box_keypair(u8 *y,u8 *x); -int crypto_box_afternm(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *k); - - -int crypto_box_open_afternm(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *k); -int crypto_box(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *y,const u8 *x); -int crypto_box_open(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *y,const u8 *x); -int crypto_box_beforenm(u8 *k,const u8 *y,const u8 *x); -int crypto_secretbox(u8 *c,const u8 *m,u64 d,const u8 *n,const u8 *k); -int crypto_secretbox_open(u8 *m,const u8 *c,u64 d,const u8 *n,const u8 *k); -#ifdef __cplusplus -} -#endif - -#endif