diff options
Diffstat (limited to '3rd_party/libsrp6a-sha512')
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/Makefile.am | 3 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/cstr.c | 62 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/cstr.h | 14 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/t_defines.h | 4 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/t_math.c | 6 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/t_misc.c | 12 | ||||
| -rw-r--r-- | 3rd_party/libsrp6a-sha512/t_truerand.c | 8 | 
7 files changed, 30 insertions, 79 deletions
| diff --git a/3rd_party/libsrp6a-sha512/Makefile.am b/3rd_party/libsrp6a-sha512/Makefile.am index 2acd582..bdacb5f 100644 --- a/3rd_party/libsrp6a-sha512/Makefile.am +++ b/3rd_party/libsrp6a-sha512/Makefile.am @@ -25,7 +25,8 @@ libsrp6a_sha512_la_SOURCES = \    t_truerand.c cstr.c \    srp.c srp6a_sha512_client.c \    srp.h srp_aux.h cstr.h \ -  t_sha.c +  t_defines.h t_pwd.h \ +  t_sha.c t_sha.h  #if !HAVE_OPENSSL  #libsrp6a_sha512_la_SOURCES += t_sha.c  #endif diff --git a/3rd_party/libsrp6a-sha512/cstr.c b/3rd_party/libsrp6a-sha512/cstr.c index 9856f46..58a5638 100644 --- a/3rd_party/libsrp6a-sha512/cstr.c +++ b/3rd_party/libsrp6a-sha512/cstr.c @@ -8,72 +8,31 @@  #define MINSIZE		4		/* Absolute minimum - one word */  static char cstr_empty_string[] = { '\0' }; -static cstr_allocator * default_alloc = NULL; - -/* - * It is assumed, for efficiency, that it is okay to pass more arguments - * to a function than are called for, as long as the required arguments - * are in proper form.  If extra arguments to malloc() and free() cause - * problems, define PEDANTIC_ARGS below. - */ -#ifdef PEDANTIC_ARGS -static void * Cmalloc(int n, void * heap) { return malloc(n); } -static void Cfree(void * p, void * heap) { free(p); } -static cstr_allocator malloc_allocator = { Cmalloc, Cfree, NULL }; -#else -static cstr_allocator malloc_allocator = { malloc, free, NULL }; -#endif - -_TYPE( void ) -cstr_set_allocator(cstr_allocator * alloc) -{ -  default_alloc = alloc; -}  _TYPE( cstr * ) -cstr_new_alloc(cstr_allocator * alloc) +cstr_new()  {    cstr * str; -  if(alloc == NULL) { -    if(default_alloc == NULL) { -      default_alloc = &malloc_allocator; -    } -    alloc = default_alloc; -  } - -  str = (cstr *) (*alloc->alloc)(sizeof(cstr), alloc->heap); +  str = (cstr *) malloc(sizeof(cstr));    if(str) {      str->data = cstr_empty_string;      str->length = str->cap = 0;      str->ref = 1; -    str->allocator = alloc;    }    return str;  }  _TYPE( cstr * ) -cstr_new() -{ -  return cstr_new_alloc(NULL); -} - -_TYPE( cstr * ) -cstr_dup_alloc(const cstr * str, cstr_allocator * alloc) +cstr_dup(const cstr * str)  { -  cstr * nstr = cstr_new_alloc(alloc); +  cstr * nstr = cstr_new();    if(nstr)      cstr_setn(nstr, str->data, str->length);    return nstr;  }  _TYPE( cstr * ) -cstr_dup(const cstr * str) -{ -  return cstr_dup_alloc(str, NULL); -} - -_TYPE( cstr * )  cstr_create(const char * s)  {    return cstr_createn(s, strlen(s)); @@ -101,9 +60,9 @@ cstr_clear_free(cstr * str)    if(--str->ref == 0) {      if(str->cap > 0) {        memset(str->data, 0, str->cap); -      (*str->allocator->free)(str->data, str->allocator->heap); +      free(str->data);      } -    (*str->allocator->free)(str, str->allocator->heap); +    free(str);    }  } @@ -112,8 +71,8 @@ cstr_free(cstr * str)  {    if(--str->ref == 0) {      if(str->cap > 0) -      (*str->allocator->free)(str->data, str->allocator->heap); -    (*str->allocator->free)(str, str->allocator->heap); +      free(str->data); +    free(str);    }  } @@ -121,7 +80,7 @@ _TYPE( void )  cstr_empty(cstr * str)  {    if(str->cap > 0) -    (*str->allocator->free)(str->data, str->allocator->heap); +    free(str->data);    str->data = cstr_empty_string;    str->length = str->cap = 0;  } @@ -137,8 +96,7 @@ cstr_alloc(cstr * str, int len)      if(len < MINSIZE)        len = MINSIZE; -    t = (char *) (*str->allocator->alloc)(len * sizeof(char), -					  str->allocator->heap); +    t = (char *) malloc(len * sizeof(char));      if(t) {        if(str->data) {  	t[str->length] = 0; diff --git a/3rd_party/libsrp6a-sha512/cstr.h b/3rd_party/libsrp6a-sha512/cstr.h index 7cc019a..29afea7 100644 --- a/3rd_party/libsrp6a-sha512/cstr.h +++ b/3rd_party/libsrp6a-sha512/cstr.h @@ -38,7 +38,7 @@  #define _MSVC15DEXPORT  #define _MSVC20EXPORT  #define _DLLAPI -#if defined(WINDOWS) || defined(WIN32) +#if defined(WINDOWS) || defined(_WIN32)  #define _CDECL _cdecl  #else  #define _CDECL @@ -51,27 +51,15 @@  extern "C" {  #endif /* __cplusplus */ -/* Arguments to allocator methods ordered this way for compatibility */ -typedef struct cstr_alloc_st { -  void * (_CDECL * alloc)(size_t n, void * heap); -  void (_CDECL * free)(void * p, void * heap); -  void * heap; -} cstr_allocator; -  typedef struct cstr_st {    char * data;	/* Okay to access data and length fields directly */    int length;    int cap;    int ref;	/* Simple reference counter */ -  cstr_allocator * allocator;  } cstr; -_TYPE( void ) cstr_set_allocator P((cstr_allocator * alloc)); -  _TYPE( cstr * ) cstr_new P((void)); -_TYPE( cstr * ) cstr_new_alloc P((cstr_allocator * alloc));  _TYPE( cstr * ) cstr_dup P((const cstr * str)); -_TYPE( cstr * ) cstr_dup_alloc P((const cstr * str, cstr_allocator * alloc));  _TYPE( cstr * ) cstr_create P((const char * s));  _TYPE( cstr * ) cstr_createn P((const char * s, int len)); diff --git a/3rd_party/libsrp6a-sha512/t_defines.h b/3rd_party/libsrp6a-sha512/t_defines.h index 447263f..a2a5fe5 100644 --- a/3rd_party/libsrp6a-sha512/t_defines.h +++ b/3rd_party/libsrp6a-sha512/t_defines.h @@ -65,7 +65,7 @@  #define _MSVC15DEXPORT  #define _MSVC20EXPORT  #define _DLLAPI -#if defined(WINDOWS) || defined(WIN32) +#if defined(WINDOWS) || defined(_WIN32)  #define _CDECL _cdecl  #else  #define _CDECL @@ -122,7 +122,7 @@ char *strchr(), *strrchr(), *strtok();  #define USE_SGTTY  #endif -#ifdef WIN32 +#ifdef _WIN32  #define USE_FTIME 1  #define USE_RENAME 1  #define NO_FCHMOD 1 diff --git a/3rd_party/libsrp6a-sha512/t_math.c b/3rd_party/libsrp6a-sha512/t_math.c index 037650e..dac19ec 100644 --- a/3rd_party/libsrp6a-sha512/t_math.c +++ b/3rd_party/libsrp6a-sha512/t_math.c @@ -720,7 +720,11 @@ BigIntegerModExp(BigInteger r, BigInteger b, BigInteger e, BigInteger m, BigInte    else if(a == NULL) {      BN_mod_exp(r, b, e, m, c);    } -#if OPENSSL_VERSION_NUMBER >= 0x00906000 +/* + * In LibreSSL BN_mod_exp_mont_word() is not a public symbol where BN_mod_exp() + * and BN_mod_exp_mont() will use the word optimization when appropriate. + */ +#if OPENSSL_VERSION_NUMBER >= 0x00906000 && !defined(LIBRESSL_VERSION_NUMBER)    else if(B > 0 && B < ULONG_MAX) {  /* 0.9.6 and above has mont_word optimization */      BN_mod_exp_mont_word(r, B, e, m, c, a);    } diff --git a/3rd_party/libsrp6a-sha512/t_misc.c b/3rd_party/libsrp6a-sha512/t_misc.c index 3a2cda1..abd8e55 100644 --- a/3rd_party/libsrp6a-sha512/t_misc.c +++ b/3rd_party/libsrp6a-sha512/t_misc.c @@ -38,7 +38,7 @@  #include <sys/stat.h>  #include <fcntl.h> -#ifdef WIN32 +#ifdef _WIN32  #include <process.h>  #include <io.h>  #endif @@ -207,7 +207,7 @@ t_initrand()  #if defined(OPENSSL)	/* OpenSSL has nifty win32 entropy-gathering code */  #if OPENSSL_VERSION_NUMBER >= 0x00905100    r = RAND_status(); -#if defined(WINDOWS) || defined(WIN32) +#if defined(WINDOWS) || defined(_WIN32)    if(r)		/* Don't do the Unix-y stuff on Windows if possible */      return;  #else @@ -220,7 +220,7 @@ t_initrand()    if(r > 0) {      yarrow_add_entropy(entropy, r, &g_rng);      memset(entropy, 0, sizeof(entropy)); -# if defined(WINDOWS) || defined(WIN32) +# if defined(WINDOWS) || defined(_WIN32)      /* Don't do the Unix-y stuff on Windows if possible */      yarrow_ready(&g_rng);      return; @@ -228,13 +228,13 @@ t_initrand()    }  #endif -#if !defined(WINDOWS) && !defined(WIN32) +#if !defined(WINDOWS) && !defined(_WIN32)    i = open("/dev/urandom", O_RDONLY);    if(i > 0) {      r += read(i, preseed.devrand, sizeof(preseed.devrand));      close(i);    } -#endif /* !WINDOWS && !WIN32 */ +#endif /* !WINDOWS && !_WIN32 */    /* Resort to truerand only if desperate for some Real entropy */    if(r == 0) @@ -250,7 +250,7 @@ t_initrand()    preseed.subsec = t.tv_usec;  #endif    preseed.pid = getpid(); -#ifndef WIN32 +#ifndef _WIN32    preseed.ppid = getppid();  #endif    t_envhash(preseed.envh); diff --git a/3rd_party/libsrp6a-sha512/t_truerand.c b/3rd_party/libsrp6a-sha512/t_truerand.c index f995ed7..cd27d0d 100644 --- a/3rd_party/libsrp6a-sha512/t_truerand.c +++ b/3rd_party/libsrp6a-sha512/t_truerand.c @@ -54,7 +54,7 @@  #include "t_defines.h" -#ifdef WIN32 +#ifdef _WIN32  # ifdef CRYPTOLIB @@ -69,7 +69,7 @@ raw_truerand()  	return truerand();  } -# else /* !CRYPTOLIB && WIN32 */ +# else /* !CRYPTOLIB && _WIN32 */  #include <windows.h>  #include <wtypes.h> @@ -128,7 +128,7 @@ raw_truerand() {  # endif /* CRYPTOLIB */ -#else /* !WIN32 */ +#else /* !_WIN32 */  #include <signal.h>  #include <setjmp.h> @@ -238,4 +238,4 @@ raw_n_truerand(int n)  	return v % n;  } -#endif /* !CRYPTOLIB || !WIN32 */ +#endif /* !CRYPTOLIB || !_WIN32 */ | 
