sha256csm init

This commit is contained in:
Pavel Rosický 2022-07-26 23:54:26 +02:00
parent 4c57b60e59
commit 90a826cbe4
17 changed files with 166 additions and 18 deletions

View file

@ -454,6 +454,12 @@ const static uint8_t test_output_gr[256] = {
};
#endif
#ifdef XMRIG_ALGO_SHA256CSM
// "SHA256CSM"
const static uint8_t test_output_sha256csm[32] = {
};
#endif
} // namespace xmrig

View file

@ -783,6 +783,22 @@ void sha256d(void* hash, const void* data, int len)
sph_sha256_full(hash, hash, 32);
}
void sha256csm(void* hash, const void* data, int len)
{
char emptybuffer[112];
memset(emptybuffer, 0, sizeof(emptybuffer));
memcpy(emptybuffer, data, 80);
sph_sha256_context cc;
sph_sha256_init( &cc );
sph_sha256( &cc, emptybuffer, 112 );
sph_sha256_close( &cc, hash );
sph_sha256_init( &cc );
sph_sha256( &cc, hash, 32 );
sph_sha256_close( &cc, hash );
}
/* see sph_sha2.h */
//void
//sph_sha224_comp(const sph_u32 msg[16], sph_u32 val[8])

View file

@ -208,6 +208,7 @@ void sph_sha256_comp(const sph_u32 msg[16], sph_u32 val[8]);
void sph_sha256_full( void *dst, const void *data, size_t len );
void sha256d(void* hash, const void* data, int len);
void sha256csm(void* hash, const void* data, int len);
// These shouldn't be called directly, use sha256-hash.h generic functions
// sha256_transform_le & sha256_transform_be instead.

View file

@ -94,6 +94,9 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu
# endif
# ifdef XMRIG_ALGO_GHOSTRIDER
&& (f != Algorithm::GHOSTRIDER)
# endif
# ifdef XMRIG_ALGO_SHA256CSM
&& (f != Algorithm::SHA256CSM)
# endif
) {
# ifdef XMRIG_FEATURE_MSR
@ -121,6 +124,12 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu
}
# endif
# ifdef XMRIG_ALGO_SHA256CSM
if (f == Algorithm::SHA256CSM) {
return true;
}
# endif
randomx_set_scratchpad_prefetch_mode(config.scratchpadPrefetchMode());
randomx_set_huge_pages_jit(cpu.isHugePagesJit());
randomx_set_optimized_dataset_init(config.initDatasetAVX2());

View file

@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0069 NEW)
project(sha256)
#set(HEADERS
# sha2.h
#)
#set(SOURCES
# sha2.c
#)
if (CMAKE_C_COMPILER_ID MATCHES MSVC)
# set_source_files_properties(sha2.c PROPERTIES COMPILE_FLAGS "/O1 /Oi /Os")
elseif (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
# set_source_files_properties(sha2.c PROPERTIES COMPILE_FLAGS "-Os -s")
endif()
include_directories(.)
include_directories(../..)
include_directories(${UV_INCLUDE_DIR})
add_library(sha256 STATIC ${HEADERS} ${SOURCES})