mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 14:58:01 +00:00
Removed original sha2 and made code use sph_sha2
This commit is contained in:
parent
f9a8e66f70
commit
d83d7bd386
@ -35,7 +35,6 @@ sgminer_SOURCES := sgminer.c
|
||||
sgminer_SOURCES += api.c
|
||||
sgminer_SOURCES += elist.h miner.h compat.h bench_block.h
|
||||
sgminer_SOURCES += util.c util.h uthash.h
|
||||
sgminer_SOURCES += sha2.c sha2.h
|
||||
sgminer_SOURCES += logging.c logging.h
|
||||
sgminer_SOURCES += driver-opencl.c driver-opencl.h
|
||||
sgminer_SOURCES += ocl.c ocl.h
|
||||
|
18
algorithm.c
18
algorithm.c
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "sha2.h"
|
||||
#include "sph/sph_sha2.h"
|
||||
#include "ocl.h"
|
||||
#include "ocl/build_kernel.h"
|
||||
|
||||
@ -30,13 +30,25 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
void sha256(const unsigned char *message, unsigned int len, unsigned char *digest)
|
||||
{
|
||||
sph_sha256_context ctx_sha2;
|
||||
|
||||
sph_sha256_init(&ctx_sha2);
|
||||
sph_sha256(&ctx_sha2, message, len);
|
||||
sph_sha256_close(&ctx_sha2, (void*)digest);
|
||||
}
|
||||
|
||||
void gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash)
|
||||
{
|
||||
unsigned char hash1[32];
|
||||
sph_sha256_context ctx_sha2;
|
||||
|
||||
sha256(data, len, hash1);
|
||||
sha256(hash1, 32, hash);
|
||||
sph_sha256_init(&ctx_sha2);
|
||||
sph_sha256(&ctx_sha2, data, len);
|
||||
sph_sha256_close(&ctx_sha2, hash1);
|
||||
sph_sha256(&ctx_sha2, hash1, 32);
|
||||
sph_sha256_close(&ctx_sha2, hash);
|
||||
}
|
||||
|
||||
#define CL_SET_BLKARG(blkvar) status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->blkvar)
|
||||
|
10
sgminer.c
10
sgminer.c
@ -47,7 +47,7 @@
|
||||
char *curly = ":D";
|
||||
#endif
|
||||
#include <libgen.h>
|
||||
#include <sha2.h>
|
||||
#include "sph/sph_sha2.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "miner.h"
|
||||
@ -1777,12 +1777,12 @@ static void calc_midstate(struct work *work)
|
||||
{
|
||||
unsigned char data[64];
|
||||
uint32_t *data32 = (uint32_t *)data;
|
||||
sha256_ctx ctx;
|
||||
sph_sha256_context ctx;
|
||||
|
||||
flip64(data32, work->data);
|
||||
sha256_init(&ctx);
|
||||
sha256_update(&ctx, data, 64);
|
||||
memcpy(work->midstate, ctx.h, 32);
|
||||
sph_sha256_init(&ctx);
|
||||
sph_sha256(&ctx, data, 64);
|
||||
memcpy(work->midstate, ctx.val, 32);
|
||||
endian_flip32(work->midstate, work->midstate);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,9 @@
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<LinkTimeCodeGeneration>
|
||||
</LinkTimeCodeGeneration>
|
||||
<IgnoreSpecificDefaultLibraries>MSVCRT;LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
@ -146,7 +148,9 @@
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<LinkTimeCodeGeneration>
|
||||
</LinkTimeCodeGeneration>
|
||||
<IgnoreSpecificDefaultLibraries>MSVCRT;LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
@ -188,8 +192,9 @@
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)dist\lib\x86</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<IgnoreSpecificDefaultLibraries>MSVCRT;LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||
<LinkTimeCodeGeneration>
|
||||
</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
@ -232,8 +237,9 @@
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)dist\lib\x64</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<IgnoreSpecificDefaultLibraries>MSVCRT;LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||
<LinkTimeCodeGeneration>
|
||||
</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
@ -290,7 +296,6 @@
|
||||
<ClCompile Include="..\algorithm\qubitcoin.c" />
|
||||
<ClCompile Include="..\algorithm\scrypt.c" />
|
||||
<ClCompile Include="..\sgminer.c" />
|
||||
<ClCompile Include="..\sha2.c" />
|
||||
<ClCompile Include="..\algorithm\sifcoin.c" />
|
||||
<ClCompile Include="..\sph\aes_helper.c" />
|
||||
<ClCompile Include="..\sph\blake.c" />
|
||||
@ -346,7 +351,6 @@
|
||||
<ClInclude Include="..\algorithm\quarkcoin.h" />
|
||||
<ClInclude Include="..\algorithm\qubitcoin.h" />
|
||||
<ClInclude Include="..\algorithm\scrypt.h" />
|
||||
<ClInclude Include="..\sha2.h" />
|
||||
<ClInclude Include="..\algorithm\sifcoin.h" />
|
||||
<ClInclude Include="..\sph\sph_blake.h" />
|
||||
<ClInclude Include="..\sph\sph_bmw.h" />
|
||||
|
@ -59,9 +59,6 @@
|
||||
<ClCompile Include="..\sgminer.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sha2.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\util.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -250,9 +247,6 @@
|
||||
<ClInclude Include="..\ocl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\sha2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\uthash.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
Loading…
Reference in New Issue
Block a user