Link poly1305_sse2

Breakage is expected as partial blocks are not handled yet
This commit is contained in:
Frank Denis 2015-11-14 14:34:34 +01:00
parent a964055487
commit 2742547a27
3 changed files with 36 additions and 2 deletions

View File

@ -299,7 +299,9 @@ libsse2_la_LDFLAGS = $(libsodium_la_LDFLAGS)
libsse2_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \ libsse2_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \
@CFLAGS_SSE2@ @CFLAGS_SSE2@
libsse2_la_SOURCES = \ libsse2_la_SOURCES = \
crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c \
crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c \
crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h
libssse3_la_LDFLAGS = $(libsodium_la_LDFLAGS) libssse3_la_LDFLAGS = $(libsodium_la_LDFLAGS)
libssse3_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \ libssse3_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \

View File

@ -1,7 +1,11 @@
#include "crypto_onetimeauth_poly1305.h" #include "crypto_onetimeauth_poly1305.h"
#include "donna/poly1305_donna.h"
#include "onetimeauth_poly1305.h" #include "onetimeauth_poly1305.h"
#include "runtime.h"
#include "donna/poly1305_donna.h"
#if defined(HAVE_TI_MODE) && defined(HAVE_AMD64_ASM) && defined(HAVE_EMMINTRIN_H)
# include "sse2/poly1305_sse2.h"
#endif
static const crypto_onetimeauth_poly1305_implementation *implementation = static const crypto_onetimeauth_poly1305_implementation *implementation =
&crypto_onetimeauth_poly1305_donna_implementation; &crypto_onetimeauth_poly1305_donna_implementation;
@ -58,5 +62,10 @@ int
_crypto_onetimeauth_poly1305_pick_best_implementation(void) _crypto_onetimeauth_poly1305_pick_best_implementation(void)
{ {
implementation = &crypto_onetimeauth_poly1305_donna_implementation; implementation = &crypto_onetimeauth_poly1305_donna_implementation;
#if defined(HAVE_TI_MODE) && defined(HAVE_AMD64_ASM) && defined(HAVE_EMMINTRIN_H)
if (sodium_runtime_has_sse2()) {
implementation = &crypto_onetimeauth_poly1305_sse2_implementation;
}
#endif
return 0; return 0;
} }

View File

@ -2,6 +2,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include "crypto_verify_16.h"
#include "utils.h" #include "utils.h"
#include "poly1305_sse2.h" #include "poly1305_sse2.h"
#include "../onetimeauth_poly1305.h" #include "../onetimeauth_poly1305.h"
@ -603,4 +604,26 @@ crypto_onetimeauth_poly1305_sse2(unsigned char *out, const unsigned char *m,
return 0; return 0;
} }
static int
crypto_onetimeauth_poly1305_sse2_verify(const unsigned char *h,
const unsigned char *in,
unsigned long long inlen,
const unsigned char *k)
{
unsigned char correct[16];
crypto_onetimeauth_poly1305_sse2(correct,in,inlen,k);
return crypto_verify_16(h,correct);
}
struct crypto_onetimeauth_poly1305_implementation
crypto_onetimeauth_poly1305_sse2_implementation = {
SODIUM_C99(.onetimeauth =) crypto_onetimeauth_poly1305_sse2,
SODIUM_C99(.onetimeauth_verify =) crypto_onetimeauth_poly1305_sse2_verify,
SODIUM_C99(.onetimeauth_init =) crypto_onetimeauth_poly1305_sse2_init,
SODIUM_C99(.onetimeauth_update =) crypto_onetimeauth_poly1305_sse2_update,
SODIUM_C99(.onetimeauth_final =) crypto_onetimeauth_poly1305_sse2_final
};
#endif #endif