Skip to content

Commit

Permalink
Fixed libmultihash compilation error for windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolin1579 committed Jan 18, 2024
1 parent aab7815 commit c9c0981
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 166 deletions.
2 changes: 1 addition & 1 deletion src/Native/libmultihash/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OBJECTS = allium.o bcrypt.o blake.o c11.o dcrypt.o fresh.o lane.o \
equi/crypto/sha1.o equi/crypto/sha512.o equi/crypto/sha256.o \
equi/crypto/hmac_sha256.o equi/crypto/equihash.o equi/crypto/ripemd160.o \
equi/equihashverify.o sha512_256.o sha256dt.o skydoge.o \
yescrypt/sha256.o yescrypt/yescrypt.o yescrypt/yescrypt-opt.o \
yescrypt/sha256_Y.o yescrypt/yescrypt.o yescrypt/yescrypt-opt.o \
yespower/yespower-platform.o yespower/yespower-combined.o yespower/yespower-blake2b.o yespower/crypto/blake2b-yp.o

all: $(TARGET)
Expand Down
16 changes: 4 additions & 12 deletions src/Native/libmultihash/libmultihash.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp14</LanguageStandard>
<AdditionalIncludeDirectories>C:\local\boost_1_76_0</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down Expand Up @@ -247,7 +248,6 @@
<ClInclude Include="sha3\sph_shavite.h" />
<ClInclude Include="sha3\sph_simd.h" />
<ClInclude Include="sha3\sph_skein.h" />
<ClInclude Include="sha3\sph_skein2.h" />
<ClInclude Include="sha3\sph_sm3.h" />
<ClInclude Include="sha3\sph_tiger.h" />
<ClInclude Include="sha3\sph_types.h" />
Expand All @@ -263,7 +263,7 @@
<ClInclude Include="targetver.h" />
<ClInclude Include="verthash\h2.h" />
<ClInclude Include="verthash\tiny_sha3\sha3.h" />
<ClInclude Include="yescrypt\sha256.h" />
<ClInclude Include="yescrypt\sha256_Y.h" />
<ClInclude Include="yescrypt\yescrypt.h" />
<ClInclude Include="yespower\crypto\blake2b-yp.h" />
<ClInclude Include="yespower\crypto\sph_types.h" />
Expand Down Expand Up @@ -298,16 +298,10 @@
<ClCompile Include="blake2\ref\blake2xs-ref.c" />
<ClCompile Include="blake3\blake3.c" />
<ClCompile Include="blake3\blake3_avx2.c" />
<ClCompile Include="blake3\blake3_avx2_x86-64_unix.S" />
<ClCompile Include="blake3\blake3_avx512.c" />
<ClCompile Include="blake3\blake3_avx512_x86-64_unix.S" />
<ClCompile Include="blake3\blake3_avx512_x86-64_windows_gnu.S" />
<ClCompile Include="blake3\blake3_dispatch.c" />
<ClCompile Include="blake3\blake3_neon.c" />
<ClCompile Include="blake3\blake3_portable.c" />
<ClCompile Include="blake3\blake3_sse41.c" />
<ClCompile Include="blake3\blake3_sse41_x86-64_unix.S" />
<ClCompile Include="blake3\blake3_sse41_x86-64_windows_gnu.S" />
<ClCompile Include="c11.c" />
<ClCompile Include="dcrypt.c" />
<ClCompile Include="dllmain.cpp" />
Expand Down Expand Up @@ -377,7 +371,6 @@
<ClCompile Include="sha3\sph_shavite.c" />
<ClCompile Include="sha3\sph_simd.c" />
<ClCompile Include="sha3\sph_skein.c" />
<ClCompile Include="sha3\sph_skein2.c" />
<ClCompile Include="sha3\sph_tiger.c" />
<ClCompile Include="sha3\sph_whirlpool.c" />
<ClCompile Include="sha3\SWIFFTX.c" />
Expand All @@ -389,10 +382,9 @@
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="verthash\h2.c" />
<ClCompile Include="verthash\tiny_sha3\sha3.c" />
<ClCompile Include="yescrypt\sha256.c" />
<ClCompile Include="yescrypt\sha256_Y.c" />
<ClCompile Include="yescrypt\yescrypt.c" />
<ClCompile Include="yescrypt\yescrypt-opt.c" />
<ClCompile Include="yescrypt\yescrypt.c" />
<ClCompile Include="yespower\crypto\blake2b-yp.c" />
<ClCompile Include="yespower\yespower-blake2b.c" />
<ClCompile Include="yespower\yespower-combined.c" />
Expand Down Expand Up @@ -421,4 +413,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions src/Native/libmultihash/skydoge.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

#include "sha3/sph_blake.h"
#include "sha3/sph_bmw.h"
Expand Down
16 changes: 5 additions & 11 deletions src/Native/libmultihash/x20r.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

#include "sha3/sph_blake.h"
#include "sha3/sph_bmw.h"
Expand All @@ -23,8 +24,6 @@
#include "sha3/sph_panama.h"
#include "sha3/gost_streebog.h"

#define _ALIGN(x) __attribute__ ((aligned(x)))

enum Algo {
BLAKE = 0,
BMW,
Expand All @@ -49,9 +48,6 @@
HASH_FUNC_COUNT
};

static __thread uint32_t s_ntime = UINT32_MAX;
static __thread char hashOrder[HASH_FUNC_COUNT + 1] = { 0 };

static void getAlgoString(const uint8_t* prevblock, char *output)
{
char *sptr = output;
Expand All @@ -70,7 +66,8 @@ static void getAlgoString(const uint8_t* prevblock, char *output)

void x20r_hash(const char* input, char* output, uint32_t len)
{
uint32_t _ALIGN(128) hash[64/4];
uint32_t hash[64/4];
char hashOrder[HASH_FUNC_COUNT + 1] = { 0 };

sph_blake512_context ctx_blake;
sph_bmw512_context ctx_bmw;
Expand All @@ -96,10 +93,7 @@ void x20r_hash(const char* input, char* output, uint32_t len)
void *in = (void*) input;
int size = len;

if (s_ntime == UINT32_MAX) {
const uint8_t* in8 = (uint8_t*) input;
getAlgoString(&in8[4], hashOrder);
}
getAlgoString(&input[4], hashOrder);

for (int i = 0; i < 20; i++)
{
Expand Down Expand Up @@ -215,4 +209,4 @@ void x20r_hash(const char* input, char* output, uint32_t len)
size = 64;
}
memcpy(output, hash, 32);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "sysendian.h"

#include "sha256.h"
#include "sha256_Y.h"

/*
* Encode a length len/4 vector of (uint32_t) into a length len vector of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void HMAC_SHA256_Final_Y(unsigned char [32], HMAC_SHA256_CTX_Y *);
* Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
* write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
*/
void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t,
void PBKDF2_SHA256_Y(const uint8_t *, size_t, const uint8_t *, size_t,
uint64_t, uint8_t *, size_t);

#endif /* !_SHA256_H_ */
2 changes: 1 addition & 1 deletion src/Native/libmultihash/yescrypt/yescrypt-opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <stdint.h>
#include <stdlib.h>

#include "sha256.h"
#include "sha256_Y.h"
#include "sysendian.h"

#include "yescrypt-platform.c"
Expand Down
Loading

0 comments on commit c9c0981

Please sign in to comment.