fix windows-version=xp build (#1327)
fix sha512 support for windows xp, pre sp3
This commit is contained in:
parent
5490f802ec
commit
998daf6e0e
6
Jamfile
6
Jamfile
|
@ -339,6 +339,12 @@ rule building ( properties * )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if <target-os>windows in $(properties)
|
||||||
|
&& <windows-version>xp in $(properties)
|
||||||
|
{
|
||||||
|
result += <source>src/sha512.cpp ;
|
||||||
|
}
|
||||||
|
|
||||||
if ( <toolset>darwin in $(properties)
|
if ( <toolset>darwin in $(properties)
|
||||||
|| <toolset>gcc in $(properties)
|
|| <toolset>gcc in $(properties)
|
||||||
|| <toolset>clang in $(properties)
|
|| <toolset>clang in $(properties)
|
||||||
|
|
|
@ -237,6 +237,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
// unless some other crypto library has been specified, default to the native
|
// unless some other crypto library has been specified, default to the native
|
||||||
// windows CryptoAPI
|
// windows CryptoAPI
|
||||||
#define TORRENT_USE_CRYPTOAPI 1
|
#define TORRENT_USE_CRYPTOAPI 1
|
||||||
|
|
||||||
|
#ifdef NTDDI_VERSION
|
||||||
|
# if (NTDDI_VERSION > NTDDI_WINXPSP2)
|
||||||
|
# define TORRENT_USE_CRYPTOAPI_SHA_512 1
|
||||||
|
# endif
|
||||||
|
#else // NTDDI_VERSION not defined so use simple _WIN32_WINNT check
|
||||||
|
# if _WIN32_WINNT >= 0x0600
|
||||||
|
# define TORRENT_USE_CRYPTOAPI_SHA_512 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TORRENT_USE_GETADAPTERSADDRESSES 1
|
#define TORRENT_USE_GETADAPTERSADDRESSES 1
|
||||||
|
@ -398,6 +409,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_USE_CRYPTOAPI 0
|
#define TORRENT_USE_CRYPTOAPI 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
|
#define TORRENT_USE_CRYPTOAPI_SHA_512 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_HAVE_MMAP
|
#ifndef TORRENT_HAVE_MMAP
|
||||||
#define TORRENT_HAVE_MMAP 0
|
#define TORRENT_HAVE_MMAP 0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#elif TORRENT_USE_COMMONCRYPTO
|
#elif TORRENT_USE_COMMONCRYPTO
|
||||||
#include <CommonCrypto/CommonDigest.h>
|
#include <CommonCrypto/CommonDigest.h>
|
||||||
|
|
||||||
#elif TORRENT_USE_CRYPTOAPI
|
#elif TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wincrypt.h>
|
#include <wincrypt.h>
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ extern "C" {
|
||||||
#else
|
#else
|
||||||
#include "libtorrent/sha512.hpp"
|
#include "libtorrent/sha512.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
|
@ -112,7 +113,7 @@ namespace libtorrent
|
||||||
gcry_md_hd_t m_context;
|
gcry_md_hd_t m_context;
|
||||||
#elif TORRENT_USE_COMMONCRYPTO
|
#elif TORRENT_USE_COMMONCRYPTO
|
||||||
CC_SHA512_CTX m_context;
|
CC_SHA512_CTX m_context;
|
||||||
#elif TORRENT_USE_CRYPTOAPI
|
#elif TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
HCRYPTHASH m_context;
|
HCRYPTHASH m_context;
|
||||||
#elif defined TORRENT_USE_LIBCRYPTO
|
#elif defined TORRENT_USE_LIBCRYPTO
|
||||||
SHA512_CTX m_context;
|
SHA512_CTX m_context;
|
||||||
|
|
|
@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/aux_/openssl.hpp"
|
#include "libtorrent/aux_/openssl.hpp"
|
||||||
|
|
||||||
#if TORRENT_USE_CRYPTOAPI
|
#if TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
HCRYPTPROV make_crypt_provider()
|
HCRYPTPROV make_crypt_provider()
|
||||||
|
@ -76,7 +76,7 @@ namespace libtorrent
|
||||||
gcry_md_open(&m_context, GCRY_MD_SHA512, 0);
|
gcry_md_open(&m_context, GCRY_MD_SHA512, 0);
|
||||||
#elif TORRENT_USE_COMMONCRYPTO
|
#elif TORRENT_USE_COMMONCRYPTO
|
||||||
CC_SHA512_Init(&m_context);
|
CC_SHA512_Init(&m_context);
|
||||||
#elif TORRENT_USE_CRYPTOAPI
|
#elif TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
if (CryptCreateHash(get_crypt_provider(), CALG_SHA_512, 0, 0, &m_context) == false)
|
if (CryptCreateHash(get_crypt_provider(), CALG_SHA_512, 0, 0, &m_context) == false)
|
||||||
{
|
{
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
@ -111,7 +111,7 @@ namespace libtorrent
|
||||||
gcry_md_copy(&m_context, h.m_context);
|
gcry_md_copy(&m_context, h.m_context);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#elif TORRENT_USE_CRYPTOAPI
|
#elif TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
hasher512::hasher512(hasher512 const& h)
|
hasher512::hasher512(hasher512 const& h)
|
||||||
{
|
{
|
||||||
if (CryptDuplicateHash(h.m_context, 0, 0, &m_context) == false)
|
if (CryptDuplicateHash(h.m_context, 0, 0, &m_context) == false)
|
||||||
|
@ -150,7 +150,7 @@ namespace libtorrent
|
||||||
gcry_md_write(m_context, data.data(), data.size());
|
gcry_md_write(m_context, data.data(), data.size());
|
||||||
#elif TORRENT_USE_COMMONCRYPTO
|
#elif TORRENT_USE_COMMONCRYPTO
|
||||||
CC_SHA512_Update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), data.size());
|
CC_SHA512_Update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), data.size());
|
||||||
#elif TORRENT_USE_CRYPTOAPI
|
#elif TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
if (CryptHashData(m_context, reinterpret_cast<BYTE const*>(data.data()), int(data.size()), 0) == false)
|
if (CryptHashData(m_context, reinterpret_cast<BYTE const*>(data.data()), int(data.size()), 0) == false)
|
||||||
{
|
{
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
@ -175,7 +175,7 @@ namespace libtorrent
|
||||||
digest.assign((char const*)gcry_md_read(m_context, 0));
|
digest.assign((char const*)gcry_md_read(m_context, 0));
|
||||||
#elif TORRENT_USE_COMMONCRYPTO
|
#elif TORRENT_USE_COMMONCRYPTO
|
||||||
CC_SHA512_Final(reinterpret_cast<unsigned char*>(digest.data()), &m_context);
|
CC_SHA512_Final(reinterpret_cast<unsigned char*>(digest.data()), &m_context);
|
||||||
#elif TORRENT_USE_CRYPTOAPI
|
#elif TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
|
|
||||||
DWORD size = DWORD(digest.size());
|
DWORD size = DWORD(digest.size());
|
||||||
if (CryptGetHashParam(m_context, HP_HASHVAL
|
if (CryptGetHashParam(m_context, HP_HASHVAL
|
||||||
|
@ -202,7 +202,7 @@ namespace libtorrent
|
||||||
gcry_md_reset(m_context);
|
gcry_md_reset(m_context);
|
||||||
#elif TORRENT_USE_COMMONCRYPTO
|
#elif TORRENT_USE_COMMONCRYPTO
|
||||||
CC_SHA512_Init(&m_context);
|
CC_SHA512_Init(&m_context);
|
||||||
#elif TORRENT_USE_CRYPTOAPI
|
#elif TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
CryptDestroyHash(m_context);
|
CryptDestroyHash(m_context);
|
||||||
if (CryptCreateHash(get_crypt_provider(), CALG_SHA_512, 0, 0, &m_context) == false)
|
if (CryptCreateHash(get_crypt_provider(), CALG_SHA_512, 0, 0, &m_context) == false)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,7 @@ namespace libtorrent
|
||||||
|
|
||||||
hasher512::~hasher512()
|
hasher512::~hasher512()
|
||||||
{
|
{
|
||||||
#if TORRENT_USE_CRYPTOAPI
|
#if TORRENT_USE_CRYPTOAPI_SHA_512
|
||||||
CryptDestroyHash(m_context);
|
CryptDestroyHash(m_context);
|
||||||
#elif defined TORRENT_USE_LIBGCRYPT
|
#elif defined TORRENT_USE_LIBGCRYPT
|
||||||
gcry_md_close(m_context);
|
gcry_md_close(m_context);
|
||||||
|
|
Loading…
Reference in New Issue