mirror of https://github.com/aria2/aria2
Use mpz_pown_sec where available
parent
ead6685b18
commit
aa02545fba
|
@ -427,6 +427,10 @@ if test "x$have_openssl" != "xyes"; then
|
|||
AC_SEARCH_LIBS([__gmpz_init], [gmp], [have_libgmp=yes], [have_libgmp=no])
|
||||
if test "x$have_libgmp" = "xyes"; then
|
||||
AC_DEFINE([HAVE_LIBGMP], [1], [Define to 1 if you have libgmp.])
|
||||
AC_CHECK_FUNCS([__gmpz_powm_sec], [have_mpz_powm_sec=yes])
|
||||
if test "x$have_mpz_powm_sec" = "xyes"; then
|
||||
AC_DEFINE([HAVE_GMP_SEC], [1], [Define to 1 if you have a GMP with sec functions.])
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN([libgmp not found])
|
||||
if test "x$with_libgmp_requested" = "xyes"; then
|
||||
|
|
|
@ -86,7 +86,11 @@ void DHKeyExchange::init
|
|||
|
||||
void DHKeyExchange::generatePublicKey()
|
||||
{
|
||||
#if HAVE_GMP_SEC
|
||||
mpz_powm_sec(publicKey_, generator_, privateKey_, prime_);
|
||||
#else // HAVE_GMP_SEC
|
||||
mpz_powm(publicKey_, generator_, privateKey_, prime_);
|
||||
#endif // HAVE_GMP_SEC
|
||||
}
|
||||
|
||||
size_t DHKeyExchange::getPublicKey(unsigned char* out, size_t outLength) const
|
||||
|
@ -126,7 +130,13 @@ size_t DHKeyExchange::computeSecret
|
|||
mpz_import(peerPublicKey, peerPublicKeyLength, 1, 1, 1, 0, peerPublicKeyData);
|
||||
mpz_t secret;
|
||||
mpz_init(secret);
|
||||
|
||||
#if HAVE_GMP_SEC
|
||||
mpz_powm_sec(secret, peerPublicKey, privateKey_, prime_);
|
||||
#else // HAVE_GMP_SEC
|
||||
mpz_powm(secret, peerPublicKey, privateKey_, prime_);
|
||||
#endif // HAVE_GMP_SEC
|
||||
|
||||
mpz_clear(peerPublicKey);
|
||||
|
||||
memset(out, 0, outLength);
|
||||
|
|
Loading…
Reference in New Issue