mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Pick the best working poly1305 implementation at runtime.
This commit is contained in:
@@ -53,6 +53,7 @@ libsodium_la_SOURCES = \
|
||||
crypto_stream/xsalsa20/ref/stream_xsalsa20.c \
|
||||
crypto_stream/xsalsa20/ref/xor_xsalsa20.c \
|
||||
crypto_onetimeauth/poly1305/onetimeauth_poly1305.c \
|
||||
crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c \
|
||||
crypto_onetimeauth/poly1305/53/auth_poly1305_53.c \
|
||||
crypto_onetimeauth/poly1305/53/crypto_onetimeauth.h \
|
||||
crypto_onetimeauth/poly1305/53/verify_poly1305_53.c \
|
||||
|
||||
@@ -25,9 +25,12 @@ typedef struct crypto_onetimeauth_poly1305_implementation {
|
||||
} crypto_onetimeauth_poly1305_implementation;
|
||||
|
||||
const char *crypto_onetimeauth_poly1305_ref_implementation_name(void);
|
||||
|
||||
|
||||
int crypto_onetimeauth_poly1305_set_implementation(crypto_onetimeauth_poly1305_implementation *impl);
|
||||
|
||||
crypto_onetimeauth_poly1305_implementation *
|
||||
crypto_onetimeauth_pick_best_implementation(void);
|
||||
|
||||
int crypto_onetimeauth_poly1305(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void sodium_memzero(void * const pnt, const size_t size);
|
||||
void sodium_memzero(void * const pnt, const size_t len);
|
||||
|
||||
void *_sodium_alignedcalloc(void ** const unaligned_p, const size_t len);
|
||||
void *_sodium_alignedcalloc(unsigned char ** const unaligned_p,
|
||||
const size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
|
||||
#include "core.h"
|
||||
#include "crypto_onetimeauth.h"
|
||||
|
||||
static char initialized;
|
||||
|
||||
int
|
||||
sodium_init(void)
|
||||
{
|
||||
if (__sync_lock_test_and_set(&initialized, 1) != 0) {
|
||||
return 1;
|
||||
}
|
||||
if (crypto_onetimeauth_pick_best_implementation() == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,22 +13,22 @@
|
||||
#endif
|
||||
|
||||
void
|
||||
sodium_memzero(void * const pnt, const size_t size)
|
||||
sodium_memzero(void * const pnt, const size_t len)
|
||||
{
|
||||
#ifdef HAVE_SECUREZEROMEMORY
|
||||
SecureZeroMemory(pnt, size);
|
||||
SecureZeroMemory(pnt, len);
|
||||
#else
|
||||
volatile unsigned char *pnt_ = (volatile unsigned char *) pnt;
|
||||
size_t i = (size_t) 0U;
|
||||
|
||||
while (i < size) {
|
||||
while (i < len) {
|
||||
pnt_[i++] = 0U;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void *
|
||||
_sodium_alignedcalloc(void ** const unaligned_p, const size_t len)
|
||||
_sodium_alignedcalloc(unsigned char ** const unaligned_p, const size_t len)
|
||||
{
|
||||
unsigned char *aligned;
|
||||
unsigned char *unaligned;
|
||||
|
||||
Reference in New Issue
Block a user