1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00

Make crypto_stream_salsa20.h architecture-independent.

Move implementation-specific functions to compat.c
This commit is contained in:
Frank Denis 2013-12-11 19:45:11 -08:00
parent 5ad45ee98c
commit 5133638024
6 changed files with 44 additions and 19 deletions

1
.gitignore vendored
View File

@ -48,7 +48,6 @@ src/curvecp/curvecpprintkey
src/curvecp/curvecpserver
src/libsodium/*.def
src/libsodium/include/sodium/crypto_scalarmult_curve25519.h
src/libsodium/include/sodium/crypto_stream_salsa20.h
src/libsodium/include/sodium/version.h
stamp-*
test/default/*.res

View File

@ -398,7 +398,6 @@ AC_CONFIG_FILES([Makefile
src/libsodium/include/Makefile
src/libsodium/include/sodium/version.h
src/libsodium/include/sodium/crypto_scalarmult_curve25519.h
src/libsodium/include/sodium/crypto_stream_salsa20.h
test/default/Makefile
test/Makefile
])

View File

@ -1,7 +1,5 @@
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/@HAVE_AMD64_ASM_V@/0/ < src\libsodium\include\sodium\crypto_stream_salsa20.h.in > src\libsodium\include\sodium\crypto_stream_salsa20.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

View File

@ -33,6 +33,7 @@ SODIUM_EXPORT = \
sodium/crypto_stream.h \
sodium/crypto_stream_aes128ctr.h \
sodium/crypto_stream_aes256estream.h \
sodium/crypto_stream_salsa20.h \
sodium/crypto_stream_salsa2012.h \
sodium/crypto_stream_salsa208.h \
sodium/crypto_stream_xsalsa20.h \
@ -52,7 +53,6 @@ SODIUM_EXPORT = \
EXTRA_SRC = $(SODIUM_EXPORT) \
sodium/crypto_scalarmult_curve25519.h.in \
sodium/crypto_stream_salsa20.h.in \
sodium/version.h.in
nobase_include_HEADERS = $(SODIUM_EXPORT)

View File

@ -9,12 +9,6 @@
* the crypto_box functions.
*/
#if @HAVE_AMD64_ASM_V@
# ifndef SODIUM_HAVE_AMD64_ASM
# define SODIUM_HAVE_AMD64_ASM
# endif
#endif
#include <stddef.h>
#include "export.h"
@ -39,14 +33,6 @@ int crypto_stream_salsa20(unsigned char *,unsigned long long,const unsigned char
SODIUM_EXPORT
int crypto_stream_salsa20_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
#ifdef SODIUM_HAVE_AMD64_ASM
# define crypto_stream_salsa20_amd64_xmm6 crypto_stream_salsa20
# define crypto_stream_salsa20_amd64_xmm6_xor crypto_stream_salsa20_xor
#else
# define crypto_stream_salsa20_ref crypto_stream_salsa20
# define crypto_stream_salsa20_ref_xor crypto_stream_salsa20_xor
#endif
#ifdef __cplusplus
}
#endif

View File

@ -8,6 +8,7 @@
#include "crypto_scalarmult_curve25519.h"
#include "crypto_secretbox_xsalsa20poly1305.h"
#include "crypto_sign_ed25519.h"
#include "crypto_stream_salsa20.h"
#include "crypto_stream_xsalsa20.h"
#include "crypto_verify_16.h"
#include "crypto_verify_32.h"
@ -243,6 +244,48 @@ crypto_onetimeauth_poly1305_ref(unsigned char *out,
return crypto_onetimeauth_poly1305(out, in, inlen, k);
}
#undef crypto_stream_salsa20_amd64_xmm6
SODIUM_EXPORT int
crypto_stream_salsa20_amd64_xmm6(unsigned char *c,
unsigned long long clen,
const unsigned char *n,
const unsigned char *k)
{
return crypto_stream_salsa20(c, clen, n, k);
}
#undef crypto_stream_salsa20_ref
SODIUM_EXPORT int
crypto_stream_salsa20_ref(unsigned char *c,
unsigned long long clen,
const unsigned char *n,
const unsigned char *k)
{
return crypto_stream_salsa20(c, clen, n, k);
}
#undef crypto_stream_salsa20_amd64_xmm6_xor
SODIUM_EXPORT int
crypto_stream_salsa20_amd64_xmm6_xor(unsigned char *c,
const unsigned char *m,
unsigned long long mlen,
const unsigned char *n,
const unsigned char *k)
{
return crypto_stream_salsa20_xor(c, m, mlen, n, k);
}
#undef crypto_stream_salsa20_ref_xor
SODIUM_EXPORT int
crypto_stream_salsa20_ref_xor(unsigned char *c,
const unsigned char *m,
unsigned long long mlen,
const unsigned char *n,
const unsigned char *k)
{
return crypto_stream_salsa20_xor(c, m, mlen, n, k);
}
#ifdef __cplusplus
}
#endif