Skip to content

Commit

Permalink
Fixed Compile Error for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolin1579 committed Jan 17, 2024
1 parent 4d640af commit 23a4148
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 17 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
21 changes: 21 additions & 0 deletions src/Native/libmultihash/blake3/blake3.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,24 @@ void blake3_hash(const char *input, char *output, size_t input_len)
// Finalize the hash. BLAKE3_OUT_LEN is the default output length, 32 bytes.
blake3_hasher_finalize(&hasher, (uint8_t *)output, BLAKE3_OUT_LEN);
}

void blake3(const char *input, char *output, size_t input_len, const char *context, size_t context_len)
{
// Initialize the hasher.
blake3_hasher hasher;

if( context_len > 0 )
{
//blake3_hasher_init_derive_key(&hasher, context);
blake3_hasher_init_keyed(&hasher, context);
}
else
{
blake3_hasher_init(&hasher);
}

blake3_hasher_update(&hasher, input, input_len);

// Finalize the hash. BLAKE3_OUT_LEN is the default output length, 32 bytes.
blake3_hasher_finalize(&hasher, (uint8_t *)output, BLAKE3_OUT_LEN);
}
2 changes: 2 additions & 0 deletions src/Native/libmultihash/blake3/blake3.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek,

void blake3_hash(const char* input, char* output, size_t input_len);

void blake3(const char* input, char* output, size_t input_len, const char* context, size_t context_len);

#ifdef __cplusplus
}
#endif
Expand Down
19 changes: 7 additions & 12 deletions src/Native/libmultihash/libmultihash.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
Expand All @@ -158,6 +157,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 @@ -262,8 +262,10 @@
<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\sysendian.h" />
<ClInclude Include="yescrypt\yescrypt.h" />
<ClInclude Include="yescrypt\yescrypt-platform.h" />
<ClInclude Include="yespower\crypto\blake2b-yp.h" />
<ClInclude Include="yespower\crypto\sph_types.h" />
<ClInclude Include="yespower\insecure_memzero.h" />
Expand Down Expand Up @@ -297,16 +299,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 @@ -387,10 +383,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-platform.c" />
<ClCompile Include="yespower\crypto\blake2b-yp.c" />
<ClCompile Include="yespower\yespower-blake2b.c" />
<ClCompile Include="yespower\yespower-combined.c" />
Expand Down Expand Up @@ -419,4 +414,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
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 @@ -26,8 +26,8 @@
* $FreeBSD: src/lib/libmd/sha256_Y.h,v 1.2 2006/01/17 15:35:56 phk Exp $
*/

#ifndef _SHA256_H_
#define _SHA256_H_
#ifndef _SHA256_Y_H_
#define _SHA256_Y_H_

#ifdef __cplusplus
extern "C" {
Expand Down
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.h"
Expand Down

0 comments on commit 23a4148

Please sign in to comment.