Browse Source

Removed original sha2 and made code use sph_sha2

djm34
troky 11 years ago
parent
commit
d83d7bd386
  1. 1
      Makefile.am
  2. 18
      algorithm.c
  3. 10
      sgminer.c
  4. 20
      winbuild/sgminer.vcxproj
  5. 6
      winbuild/sgminer.vcxproj.filters

1
Makefile.am

@ -35,7 +35,6 @@ sgminer_SOURCES := sgminer.c
sgminer_SOURCES += api.c sgminer_SOURCES += api.c
sgminer_SOURCES += elist.h miner.h compat.h bench_block.h sgminer_SOURCES += elist.h miner.h compat.h bench_block.h
sgminer_SOURCES += util.c util.h uthash.h sgminer_SOURCES += util.c util.h uthash.h
sgminer_SOURCES += sha2.c sha2.h
sgminer_SOURCES += logging.c logging.h sgminer_SOURCES += logging.c logging.h
sgminer_SOURCES += driver-opencl.c driver-opencl.h sgminer_SOURCES += driver-opencl.c driver-opencl.h
sgminer_SOURCES += ocl.c ocl.h sgminer_SOURCES += ocl.c ocl.h

18
algorithm.c

@ -8,7 +8,7 @@
*/ */
#include "algorithm.h" #include "algorithm.h"
#include "sha2.h" #include "sph/sph_sha2.h"
#include "ocl.h" #include "ocl.h"
#include "ocl/build_kernel.h" #include "ocl/build_kernel.h"
@ -30,13 +30,25 @@
#include <inttypes.h> #include <inttypes.h>
#include <string.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) void gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash)
{ {
unsigned char hash1[32]; unsigned char hash1[32];
sph_sha256_context ctx_sha2;
sha256(data, len, hash1); sph_sha256_init(&ctx_sha2);
sha256(hash1, 32, hash); 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) #define CL_SET_BLKARG(blkvar) status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->blkvar)

10
sgminer.c

@ -47,7 +47,7 @@
char *curly = ":D"; char *curly = ":D";
#endif #endif
#include <libgen.h> #include <libgen.h>
#include <sha2.h> #include "sph/sph_sha2.h"
#include "compat.h" #include "compat.h"
#include "miner.h" #include "miner.h"
@ -1777,12 +1777,12 @@ static void calc_midstate(struct work *work)
{ {
unsigned char data[64]; unsigned char data[64];
uint32_t *data32 = (uint32_t *)data; uint32_t *data32 = (uint32_t *)data;
sha256_ctx ctx; sph_sha256_context ctx;
flip64(data32, work->data); flip64(data32, work->data);
sha256_init(&ctx); sph_sha256_init(&ctx);
sha256_update(&ctx, data, 64); sph_sha256(&ctx, data, 64);
memcpy(work->midstate, ctx.h, 32); memcpy(work->midstate, ctx.val, 32);
endian_flip32(work->midstate, work->midstate); endian_flip32(work->midstate, work->midstate);
} }

20
winbuild/sgminer.vcxproj

@ -105,7 +105,9 @@
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<OptimizeReferences>false</OptimizeReferences> <OptimizeReferences>false</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>
</LinkTimeCodeGeneration>
<IgnoreSpecificDefaultLibraries>MSVCRT;LIBCMT</IgnoreSpecificDefaultLibraries>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command> <Command>
@ -146,7 +148,9 @@
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<OptimizeReferences>false</OptimizeReferences> <OptimizeReferences>false</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>
</LinkTimeCodeGeneration>
<IgnoreSpecificDefaultLibraries>MSVCRT;LIBCMT</IgnoreSpecificDefaultLibraries>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command> <Command>
@ -188,8 +192,9 @@
<OptimizeReferences>false</OptimizeReferences> <OptimizeReferences>false</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProjectDir)dist\lib\x86</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(ProjectDir)dist\lib\x86</AdditionalLibraryDirectories>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>MSVCRT;LIBCMT</IgnoreSpecificDefaultLibraries>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>
</LinkTimeCodeGeneration>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command> <Command>
@ -232,8 +237,9 @@
<OptimizeReferences>false</OptimizeReferences> <OptimizeReferences>false</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProjectDir)dist\lib\x64</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(ProjectDir)dist\lib\x64</AdditionalLibraryDirectories>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>MSVCRT;LIBCMT</IgnoreSpecificDefaultLibraries>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>
</LinkTimeCodeGeneration>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command> <Command>
@ -290,7 +296,6 @@
<ClCompile Include="..\algorithm\qubitcoin.c" /> <ClCompile Include="..\algorithm\qubitcoin.c" />
<ClCompile Include="..\algorithm\scrypt.c" /> <ClCompile Include="..\algorithm\scrypt.c" />
<ClCompile Include="..\sgminer.c" /> <ClCompile Include="..\sgminer.c" />
<ClCompile Include="..\sha2.c" />
<ClCompile Include="..\algorithm\sifcoin.c" /> <ClCompile Include="..\algorithm\sifcoin.c" />
<ClCompile Include="..\sph\aes_helper.c" /> <ClCompile Include="..\sph\aes_helper.c" />
<ClCompile Include="..\sph\blake.c" /> <ClCompile Include="..\sph\blake.c" />
@ -346,7 +351,6 @@
<ClInclude Include="..\algorithm\quarkcoin.h" /> <ClInclude Include="..\algorithm\quarkcoin.h" />
<ClInclude Include="..\algorithm\qubitcoin.h" /> <ClInclude Include="..\algorithm\qubitcoin.h" />
<ClInclude Include="..\algorithm\scrypt.h" /> <ClInclude Include="..\algorithm\scrypt.h" />
<ClInclude Include="..\sha2.h" />
<ClInclude Include="..\algorithm\sifcoin.h" /> <ClInclude Include="..\algorithm\sifcoin.h" />
<ClInclude Include="..\sph\sph_blake.h" /> <ClInclude Include="..\sph\sph_blake.h" />
<ClInclude Include="..\sph\sph_bmw.h" /> <ClInclude Include="..\sph\sph_bmw.h" />

6
winbuild/sgminer.vcxproj.filters

@ -59,9 +59,6 @@
<ClCompile Include="..\sgminer.c"> <ClCompile Include="..\sgminer.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\sha2.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\util.c"> <ClCompile Include="..\util.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -250,9 +247,6 @@
<ClInclude Include="..\ocl.h"> <ClInclude Include="..\ocl.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\sha2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\uthash.h"> <ClInclude Include="..\uthash.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>

Loading…
Cancel
Save