From bf72ee931e415433d674b7946f5e8884eece9802 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 11 Dec 2013 20:17:09 -0800 Subject: [PATCH] Make crypto_scalarmult_curve25519.h architecture-independent --- .gitignore | 1 - configure.ac | 1 - msvc-scripts/process.bat | 2 -- .../crypto_scalarmult/curve25519/donna_c64/api.h | 4 ++-- .../crypto_scalarmult/curve25519/ref/api.h | 4 ++-- src/libsodium/crypto_stream/salsa20/ref/api.h | 4 ++-- src/libsodium/include/Makefile.am | 2 +- ...e25519.h.in => crypto_scalarmult_curve25519.h} | 14 -------------- src/libsodium/sodium/compat.c | 15 +++++++++++++++ 9 files changed, 22 insertions(+), 25 deletions(-) rename src/libsodium/include/sodium/{crypto_scalarmult_curve25519.h.in => crypto_scalarmult_curve25519.h} (58%) diff --git a/.gitignore b/.gitignore index 2dec01a2..2ff9e76a 100644 --- a/.gitignore +++ b/.gitignore @@ -47,7 +47,6 @@ src/curvecp/curvecpmessage src/curvecp/curvecpprintkey src/curvecp/curvecpserver src/libsodium/*.def -src/libsodium/include/sodium/crypto_scalarmult_curve25519.h src/libsodium/include/sodium/version.h stamp-* test/default/*.res diff --git a/configure.ac b/configure.ac index f9d57d8c..989fa2f4 100644 --- a/configure.ac +++ b/configure.ac @@ -397,7 +397,6 @@ AC_CONFIG_FILES([Makefile src/libsodium/Makefile src/libsodium/include/Makefile src/libsodium/include/sodium/version.h - src/libsodium/include/sodium/crypto_scalarmult_curve25519.h test/default/Makefile test/Makefile ]) diff --git a/msvc-scripts/process.bat b/msvc-scripts/process.bat index 0f3381e6..f8a89b03 100755 --- a/msvc-scripts/process.bat +++ b/msvc-scripts/process.bat @@ -1,5 +1,3 @@ -cscript msvc-scripts/rep.vbs //Nologo s/@HAVE_TI_MODE_V@/0/ < src\libsodium\include\sodium\crypto_scalarmult_curve25519.h.in > src\libsodium\include\sodium\crypto_scalarmult_curve25519.h - cscript msvc-scripts/rep.vbs //Nologo s/@VERSION@/0.4.5/ < src\libsodium\include\sodium\version.h.in > tmp cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MAJOR@/4/ < tmp > tmp2 cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MINOR@/4/ < tmp2 > src\libsodium\include\sodium\version.h diff --git a/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h b/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h index 373c6aa8..5c9bba7e 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +++ b/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h @@ -4,6 +4,6 @@ #define crypto_scalarmult_curve25519_implementation_name \ crypto_scalarmult_curve25519_donna_c64_implementation_name -#define crypto_scalarmult crypto_scalarmult_curve25519_donna_c64 -#define crypto_scalarmult_base crypto_scalarmult_curve25519_donna_c64_base +#define crypto_scalarmult crypto_scalarmult_curve25519 +#define crypto_scalarmult_base crypto_scalarmult_curve25519_base diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref/api.h b/src/libsodium/crypto_scalarmult/curve25519/ref/api.h index 7c664421..40793b20 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref/api.h +++ b/src/libsodium/crypto_scalarmult/curve25519/ref/api.h @@ -4,5 +4,5 @@ #define crypto_scalarmult_curve25519_implementation_name \ crypto_scalarmult_curve25519_ref_implementation_name -#define crypto_scalarmult crypto_scalarmult_curve25519_ref -#define crypto_scalarmult_base crypto_scalarmult_curve25519_ref_base +#define crypto_scalarmult crypto_scalarmult_curve25519 +#define crypto_scalarmult_base crypto_scalarmult_curve25519_base diff --git a/src/libsodium/crypto_stream/salsa20/ref/api.h b/src/libsodium/crypto_stream/salsa20/ref/api.h index 4e9a8fc1..2d8945e6 100644 --- a/src/libsodium/crypto_stream/salsa20/ref/api.h +++ b/src/libsodium/crypto_stream/salsa20/ref/api.h @@ -4,5 +4,5 @@ #define crypto_stream_salsa20_implementation_name \ crypto_stream_salsa20_ref_implementation_name -#define crypto_stream crypto_stream_salsa20_ref -#define crypto_stream_xor crypto_stream_salsa20_ref_xor +#define crypto_stream crypto_stream_salsa20 +#define crypto_stream_xor crypto_stream_salsa20_xor diff --git a/src/libsodium/include/Makefile.am b/src/libsodium/include/Makefile.am index 5c5bee14..c014141c 100644 --- a/src/libsodium/include/Makefile.am +++ b/src/libsodium/include/Makefile.am @@ -23,6 +23,7 @@ SODIUM_EXPORT = \ sodium/crypto_onetimeauth_poly1305_53.h \ sodium/crypto_onetimeauth_poly1305_donna.h \ sodium/crypto_scalarmult.h \ + sodium/crypto_scalarmult_curve25519.h \ sodium/crypto_secretbox.h \ sodium/crypto_secretbox_xsalsa20poly1305.h \ sodium/crypto_shorthash.h \ @@ -52,7 +53,6 @@ SODIUM_EXPORT = \ sodium/utils.h EXTRA_SRC = $(SODIUM_EXPORT) \ - sodium/crypto_scalarmult_curve25519.h.in \ sodium/version.h.in nobase_include_HEADERS = $(SODIUM_EXPORT) diff --git a/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h.in b/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h similarity index 58% rename from src/libsodium/include/sodium/crypto_scalarmult_curve25519.h.in rename to src/libsodium/include/sodium/crypto_scalarmult_curve25519.h index cc30155d..d3b69bd2 100644 --- a/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h.in +++ b/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h @@ -1,12 +1,6 @@ #ifndef crypto_scalarmult_curve25519_H #define crypto_scalarmult_curve25519_H -#if @HAVE_TI_MODE_V@ -# ifndef SODIUM_HAVE_TI_MODE -# define SODIUM_HAVE_TI_MODE -# endif -#endif - #include #include "export.h" @@ -29,14 +23,6 @@ int crypto_scalarmult_curve25519(unsigned char *,const unsigned char *,const uns SODIUM_EXPORT int crypto_scalarmult_curve25519_base(unsigned char *,const unsigned char *); -#ifdef SODIUM_HAVE_TI_MODE -# define crypto_scalarmult_curve25519_donna_c64 crypto_scalarmult_curve25519 -# define crypto_scalarmult_curve25519_donna_c64_base crypto_scalarmult_curve25519_base -#else -# define crypto_scalarmult_curve25519_ref crypto_scalarmult_curve25519 -# define crypto_scalarmult_curve25519_ref_base crypto_scalarmult_curve25519_base -#endif - #ifdef __cplusplus } #endif diff --git a/src/libsodium/sodium/compat.c b/src/libsodium/sodium/compat.c index 44e8dd07..3b276f21 100644 --- a/src/libsodium/sodium/compat.c +++ b/src/libsodium/sodium/compat.c @@ -148,6 +148,21 @@ crypto_scalarmult_curve25519_ref(unsigned char *q, const unsigned char *n, return crypto_scalarmult_curve25519(q, n, p); } +#undef crypto_scalarmult_curve25519_donna_c64_base +SODIUM_EXPORT int +crypto_scalarmult_curve25519_donna_c64_base(unsigned char *q, const unsigned char *n) +{ + return crypto_scalarmult_curve25519_base(q, n); +} + +#undef crypto_scalarmult_curve25519_donna_c64 +SODIUM_EXPORT int +crypto_scalarmult_curve25519_donna_c64(unsigned char *q, const unsigned char *n, + const unsigned char *p) +{ + return crypto_scalarmult_curve25519(q, n, p); +} + #undef crypto_secretbox_xsalsa20poly1305_ref SODIUM_EXPORT int crypto_secretbox_xsalsa20poly1305_ref(unsigned char *c,