Exemplo n.º 1
0
#elif defined TORRENT_USE_LIBCRYPTO
		SHA512_Update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), data.size());
#else
		SHA512_update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), data.size());
#endif
		return *this;
	}

	sha512_hash hasher512::final()
	{
		sha512_hash digest;
#ifdef TORRENT_USE_LIBGCRYPT
		gcry_md_final(m_context);
		digest.assign(reinterpret_cast<char const*>(gcry_md_read(m_context, 0)));
#elif TORRENT_USE_COMMONCRYPTO
		CC_SHA512_Final(reinterpret_cast<unsigned char*>(digest.data()), &m_context);
#elif TORRENT_USE_CRYPTOAPI_SHA_512
		m_context.get_hash(digest.data(), digest.size());
#elif defined TORRENT_USE_LIBCRYPTO
		SHA512_Final(reinterpret_cast<unsigned char*>(digest.data()), &m_context);
#else
		SHA512_final(reinterpret_cast<unsigned char*>(digest.data()), &m_context);
#endif
		return digest;
	}

	void hasher512::reset()
	{
#ifdef TORRENT_USE_LIBGCRYPT
		gcry_md_reset(m_context);
#elif TORRENT_USE_COMMONCRYPTO
Exemplo n.º 2
0
#elif defined TORRENT_USE_LIBCRYPTO
		SHA512_Update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), data.size());
#else
		SHA512_update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), data.size());
#endif
		return *this;
	}

	sha512_hash hasher512::final()
	{
		sha512_hash digest;
#ifdef TORRENT_USE_LIBGCRYPT
		gcry_md_final(m_context);
		digest.assign((char const*)gcry_md_read(m_context, 0));
#elif TORRENT_USE_COMMONCRYPTO
		CC_SHA512_Final(reinterpret_cast<unsigned char*>(digest.data()), &m_context);
#elif TORRENT_USE_CRYPTOAPI

		DWORD size = DWORD(digest.size());
		if (CryptGetHashParam(m_context, HP_HASHVAL
			, reinterpret_cast<BYTE*>(digest.data()), &size, 0) == false)
		{
#ifndef BOOST_NO_EXCEPTIONS
			throw system_error(error_code(GetLastError(), system_category()));
#else
			std::terminate();
#endif
		}
		TORRENT_ASSERT(size == digest.size());
#elif defined TORRENT_USE_LIBCRYPTO
		SHA512_Final(reinterpret_cast<unsigned char*>(digest.data()), &m_context);