mirror of
https://github.com/GOSTSec/gostcoin
synced 2025-01-30 00:14:20 +00:00
faster conversion to little endian
This commit is contained in:
parent
3be62d5577
commit
708673ac5d
2
i2pd
2
i2pd
@ -1 +1 @@
|
||||
Subproject commit 4448884a3ebf822ecca7b39f2fe9777a79ae1863
|
||||
Subproject commit abf0f5ac8780c9cb0088e4ccefcd0d0274e63965
|
@ -22,12 +22,12 @@ inline uint256 Hash(const T1 pbegin, const T1 pend)
|
||||
static unsigned char pblank[1];
|
||||
uint8_t hash1[64];
|
||||
i2p::crypto::GOSTR3411_2012_512 ((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), hash1);
|
||||
uint8_t digest[32];
|
||||
i2p::crypto::GOSTR3411_2012_256 (hash1, 64, digest);
|
||||
uint32_t digest[8];
|
||||
i2p::crypto::GOSTR3411_2012_256 (hash1, 64, (uint8_t *)digest);
|
||||
// to little endian
|
||||
uint256 hash2;
|
||||
for (int i = 0; i < 32; i++)
|
||||
hash2.begin ()[i] = digest[31-i];
|
||||
for (int i = 0; i < 8; i++)
|
||||
hash2.pn[i] = ByteReverse (digest[7-i]);
|
||||
return hash2;
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,9 @@ inline int Testuint256AdHoc(std::vector<std::string> vArg);
|
||||
template<unsigned int BITS>
|
||||
class base_uint
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
enum { WIDTH=BITS/32 };
|
||||
uint32_t pn[WIDTH];
|
||||
public:
|
||||
|
||||
bool operator!() const
|
||||
{
|
||||
|
@ -552,12 +552,13 @@ void RenameThread(const char* name);
|
||||
|
||||
inline uint32_t ByteReverse(uint32_t value)
|
||||
{
|
||||
#if 0
|
||||
// #if defined(__x86_64__)
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
__asm__
|
||||
(
|
||||
"bswap %%eax"
|
||||
: "=a"(value) ::
|
||||
"bswap %0"
|
||||
: "=r"(value)
|
||||
: "0"(value)
|
||||
:
|
||||
);
|
||||
return value;
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user