diff --git a/cmake/randomx.cmake b/cmake/randomx.cmake index 17ca23b0b5..1c004b1915 100644 --- a/cmake/randomx.cmake +++ b/cmake/randomx.cmake @@ -40,12 +40,12 @@ if (WITH_RANDOMX) src/crypto/rx/RxDataset.cpp src/crypto/rx/RxQueue.cpp src/crypto/rx/RxVm.cpp - src/crypto/randomx/defyx/KangarooTwelve.c - src/crypto/randomx/defyx/KeccakP-1600-reference.c - src/crypto/randomx/defyx/KeccakSpongeWidth1600.c - src/crypto/randomx/defyx/yescrypt-best.c - src/crypto/randomx/panthera/sha256.c - src/crypto/randomx/panthera/yespower-opt.c + src/crypto/k12/KangarooTwelve.c + src/crypto/keccak/KeccakP-1600-reference.c + src/crypto/keccak/KeccakSpongeWidth1600.c + src/crypto/yes/sha256.c + src/crypto/yes/yescrypt-best.c + src/crypto/yes/yespower-opt.c ) if (CMAKE_C_COMPILER_ID MATCHES MSVC) diff --git a/src/crypto/randomx/defyx/align.h b/src/crypto/align.h similarity index 100% rename from src/crypto/randomx/defyx/align.h rename to src/crypto/align.h diff --git a/src/crypto/randomx/defyx/KangarooTwelve.c b/src/crypto/k12/KangarooTwelve.c similarity index 100% rename from src/crypto/randomx/defyx/KangarooTwelve.c rename to src/crypto/k12/KangarooTwelve.c diff --git a/src/crypto/randomx/defyx/KangarooTwelve.h b/src/crypto/k12/KangarooTwelve.h similarity index 98% rename from src/crypto/randomx/defyx/KangarooTwelve.h rename to src/crypto/k12/KangarooTwelve.h index 0e9ed41ecd..616e8938c8 100644 --- a/src/crypto/randomx/defyx/KangarooTwelve.h +++ b/src/crypto/k12/KangarooTwelve.h @@ -15,8 +15,8 @@ and related or neighboring rights to the source code in this file. #ifndef KeccakP1600_excluded #include -#include "align.h" -#include "KeccakSpongeWidth1600.h" +#include "../align.h" +#include "../keccak/KeccakSpongeWidth1600.h" #include "Phases.h" typedef KCP_Phases KangarooTwelve_Phases; diff --git a/src/crypto/randomx/defyx/Phases.h b/src/crypto/k12/Phases.h similarity index 100% rename from src/crypto/randomx/defyx/Phases.h rename to src/crypto/k12/Phases.h diff --git a/src/crypto/randomx/defyx/KeccakP-1600-SnP.h b/src/crypto/keccak/KeccakP-1600-SnP.h similarity index 100% rename from src/crypto/randomx/defyx/KeccakP-1600-SnP.h rename to src/crypto/keccak/KeccakP-1600-SnP.h diff --git a/src/crypto/randomx/defyx/KeccakP-1600-reference.c b/src/crypto/keccak/KeccakP-1600-reference.c similarity index 100% rename from src/crypto/randomx/defyx/KeccakP-1600-reference.c rename to src/crypto/keccak/KeccakP-1600-reference.c diff --git a/src/crypto/randomx/defyx/KeccakSponge-common.h b/src/crypto/keccak/KeccakSponge-common.h similarity index 98% rename from src/crypto/randomx/defyx/KeccakSponge-common.h rename to src/crypto/keccak/KeccakSponge-common.h index 8fb3ba1a08..e4643c2af6 100644 --- a/src/crypto/randomx/defyx/KeccakSponge-common.h +++ b/src/crypto/keccak/KeccakSponge-common.h @@ -15,7 +15,7 @@ and related or neighboring rights to the source code in this file. #define _KeccakSpongeCommon_h_ #include -#include "align.h" +#include "../align.h" #define KCP_DeclareSpongeStructure(prefix, size, alignment) \ ALIGN(alignment) typedef struct prefix##_SpongeInstanceStruct { \ diff --git a/src/crypto/randomx/defyx/KeccakSponge.inc b/src/crypto/keccak/KeccakSponge.inc similarity index 100% rename from src/crypto/randomx/defyx/KeccakSponge.inc rename to src/crypto/keccak/KeccakSponge.inc diff --git a/src/crypto/randomx/defyx/KeccakSpongeWidth1600.c b/src/crypto/keccak/KeccakSpongeWidth1600.c similarity index 100% rename from src/crypto/randomx/defyx/KeccakSpongeWidth1600.c rename to src/crypto/keccak/KeccakSpongeWidth1600.c diff --git a/src/crypto/randomx/defyx/KeccakSpongeWidth1600.h b/src/crypto/keccak/KeccakSpongeWidth1600.h similarity index 100% rename from src/crypto/randomx/defyx/KeccakSpongeWidth1600.h rename to src/crypto/keccak/KeccakSpongeWidth1600.h diff --git a/src/crypto/randomx/defyx/brg_endian.h b/src/crypto/keccak/brg_endian.h similarity index 100% rename from src/crypto/randomx/defyx/brg_endian.h rename to src/crypto/keccak/brg_endian.h diff --git a/src/crypto/randomx/panthera/insecure_memzero.h b/src/crypto/randomx/panthera/insecure_memzero.h deleted file mode 100644 index 5a0ba75c45..0000000000 --- a/src/crypto/randomx/panthera/insecure_memzero.h +++ /dev/null @@ -1 +0,0 @@ -#define insecure_memzero(buf, len) /* empty */ diff --git a/src/crypto/randomx/panthera/sha256.h b/src/crypto/randomx/panthera/sha256.h deleted file mode 100644 index 6210502ff1..0000000000 --- a/src/crypto/randomx/panthera/sha256.h +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * Copyright 2005-2016 Colin Percival - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _SHA256_H_ -#define _SHA256_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Use #defines in order to avoid namespace collisions with anyone else's - * SHA256 code (e.g., the code in OpenSSL). - */ -#define SHA256_Init libcperciva_SHA256_Init -#define SHA256_Update libcperciva_SHA256_Update -#define SHA256_Final libcperciva_SHA256_Final -#define SHA256_Buf libcperciva_SHA256_Buf -#define SHA256_CTX libcperciva_SHA256_CTX -#define HMAC_SHA256_Init libcperciva_HMAC_SHA256_Init -#define HMAC_SHA256_Update libcperciva_HMAC_SHA256_Update -#define HMAC_SHA256_Final libcperciva_HMAC_SHA256_Final -#define HMAC_SHA256_Buf libcperciva_HMAC_SHA256_Buf -#define HMAC_SHA256_CTX libcperciva_HMAC_SHA256_CTX - -/* Context structure for SHA256 operations. */ -typedef struct { - uint32_t state[8]; - uint64_t count; - uint8_t buf[64]; -} SHA256_CTX; - -/** - * SHA256_Init(ctx): - * Initialize the SHA256 context ${ctx}. - */ -void SHA256_Init(SHA256_CTX *); - -/** - * SHA256_Update(ctx, in, len): - * Input ${len} bytes from ${in} into the SHA256 context ${ctx}. - */ -void SHA256_Update(SHA256_CTX *, const void *, size_t); - -/** - * SHA256_Final(digest, ctx): - * Output the SHA256 hash of the data input to the context ${ctx} into the - * buffer ${digest}. - */ -void SHA256_Final(uint8_t[32], SHA256_CTX *); - -/** - * SHA256_Buf(in, len, digest): - * Compute the SHA256 hash of ${len} bytes from ${in} and write it to ${digest}. - */ -void SHA256_Buf(const void *, size_t, uint8_t[32]); - -/* Context structure for HMAC-SHA256 operations. */ -typedef struct { - SHA256_CTX ictx; - SHA256_CTX octx; -} HMAC_SHA256_CTX; - -/** - * HMAC_SHA256_Init(ctx, K, Klen): - * Initialize the HMAC-SHA256 context ${ctx} with ${Klen} bytes of key from - * ${K}. - */ -void HMAC_SHA256_Init(HMAC_SHA256_CTX *, const void *, size_t); - -/** - * HMAC_SHA256_Update(ctx, in, len): - * Input ${len} bytes from ${in} into the HMAC-SHA256 context ${ctx}. - */ -void HMAC_SHA256_Update(HMAC_SHA256_CTX *, const void *, size_t); - -/** - * HMAC_SHA256_Final(digest, ctx): - * Output the HMAC-SHA256 of the data input to the context ${ctx} into the - * buffer ${digest}. - */ -void HMAC_SHA256_Final(uint8_t[32], HMAC_SHA256_CTX *); - -/** - * HMAC_SHA256_Buf(K, Klen, in, len, digest): - * Compute the HMAC-SHA256 of ${len} bytes from ${in} using the key ${K} of - * length ${Klen}, and write the result to ${digest}. - */ -void HMAC_SHA256_Buf(const void *, size_t, const void *, size_t, uint8_t[32]); - -/** - * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): - * 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, - uint64_t, uint8_t *, size_t); - -#ifdef __cplusplus -} -#endif - -#endif /* !_SHA256_H_ */ diff --git a/src/crypto/randomx/panthera/sysendian.h b/src/crypto/randomx/panthera/sysendian.h deleted file mode 100644 index 52c1fe73b2..0000000000 --- a/src/crypto/randomx/panthera/sysendian.h +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright 2007-2014 Colin Percival - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _SYSENDIAN_H_ -#define _SYSENDIAN_H_ - -#include - -/* Avoid namespace collisions with BSD . */ -#define be32dec libcperciva_be32dec -#define be32enc libcperciva_be32enc -#define be64enc libcperciva_be64enc -#define le32dec libcperciva_le32dec -#define le32enc libcperciva_le32enc - -static inline uint32_t -be32dec(const void * pp) -{ - const uint8_t * p = (uint8_t const *)pp; - - return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) + - ((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24)); -} - -static inline void -be32enc(void * pp, uint32_t x) -{ - uint8_t * p = (uint8_t *)pp; - - p[3] = x & 0xff; - p[2] = (x >> 8) & 0xff; - p[1] = (x >> 16) & 0xff; - p[0] = (x >> 24) & 0xff; -} - -static inline void -be64enc(void * pp, uint64_t x) -{ - uint8_t * p = (uint8_t *)pp; - - p[7] = x & 0xff; - p[6] = (x >> 8) & 0xff; - p[5] = (x >> 16) & 0xff; - p[4] = (x >> 24) & 0xff; - p[3] = (x >> 32) & 0xff; - p[2] = (x >> 40) & 0xff; - p[1] = (x >> 48) & 0xff; - p[0] = (x >> 56) & 0xff; -} - -static inline uint32_t -le32dec(const void * pp) -{ - const uint8_t * p = (uint8_t const *)pp; - - return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) + - ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24)); -} - -static inline void -le32enc(void * pp, uint32_t x) -{ - uint8_t * p = (uint8_t *)pp; - - p[0] = x & 0xff; - p[1] = (x >> 8) & 0xff; - p[2] = (x >> 16) & 0xff; - p[3] = (x >> 24) & 0xff; -} - -#endif /* !_SYSENDIAN_H_ */ diff --git a/src/crypto/randomx/randomx.cpp b/src/crypto/randomx/randomx.cpp index 5871c1fd6f..7acc96f669 100644 --- a/src/crypto/randomx/randomx.cpp +++ b/src/crypto/randomx/randomx.cpp @@ -48,9 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include extern "C" { -#include "crypto/randomx/defyx/yescrypt.h" -#include "crypto/randomx/panthera/yespower.h" -#include "crypto/randomx/defyx/KangarooTwelve.h" +#include "crypto/yes/yescrypt.h" +#include "crypto/yes/yespower.h" +#include "crypto/k12/KangarooTwelve.h" } #include "base/tools/Profiler.h" @@ -591,8 +591,8 @@ extern "C" { assert(inputSize == 0 || input != nullptr); assert(output != nullptr); alignas(16) uint64_t tempHash[8]; - switch (algo) { - case xmrig::Algorithm::RX_XLA: rx_yespower_k12(tempHash, sizeof(tempHash), input, inputSize); break; + switch (algo) { + case xmrig::Algorithm::RX_XLA: rx_yespower_k12(tempHash, sizeof(tempHash), input, inputSize); break; default: rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), input, inputSize); } machine->initScratchpad(&tempHash); @@ -606,8 +606,8 @@ extern "C" { } void randomx_calculate_hash_first(randomx_vm* machine, uint64_t (&tempHash)[8], const void* input, size_t inputSize, const xmrig::Algorithm algo) { - switch (algo) { - case xmrig::Algorithm::RX_XLA: rx_yespower_k12(tempHash, sizeof(tempHash), input, inputSize); break; + switch (algo) { + case xmrig::Algorithm::RX_XLA: rx_yespower_k12(tempHash, sizeof(tempHash), input, inputSize); break; default: rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), input, inputSize); } machine->initScratchpad(tempHash); @@ -624,8 +624,8 @@ extern "C" { machine->run(&tempHash); // Finish current hash and fill the scratchpad for the next hash at the same time - switch (algo) { - case xmrig::Algorithm::RX_XLA: rx_yespower_k12(tempHash, sizeof(tempHash), nextInput, nextInputSize); break; + switch (algo) { + case xmrig::Algorithm::RX_XLA: rx_yespower_k12(tempHash, sizeof(tempHash), nextInput, nextInputSize); break; default: rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), nextInput, nextInputSize); } machine->hashAndFill(output, tempHash); diff --git a/src/crypto/randomx/defyx/insecure_memzero.h b/src/crypto/yes/insecure_memzero.h similarity index 100% rename from src/crypto/randomx/defyx/insecure_memzero.h rename to src/crypto/yes/insecure_memzero.h diff --git a/src/crypto/randomx/panthera/sha256.c b/src/crypto/yes/sha256.c similarity index 95% rename from src/crypto/randomx/panthera/sha256.c rename to src/crypto/yes/sha256.c index ee2d5d247f..b355ee58fc 100644 --- a/src/crypto/randomx/panthera/sha256.c +++ b/src/crypto/yes/sha256.c @@ -37,14 +37,22 @@ #ifdef __ICC /* Miscompile with icc 14.0.0 (at least), so don't use restrict there */ #define restrict +#define static_restrict static +#elif defined(_MSC_VER) +#define restrict +#define static_restrict #elif __STDC_VERSION__ >= 199901L /* Have restrict */ +#define static_restrict static restrict #elif defined(__GNUC__) #define restrict __restrict +#define static_restrict static __restrict #else #define restrict +#define static_restrict #endif + /* * Encode a length len*2 vector of (uint32_t) into a length len*8 vector of * (uint8_t) in big-endian form. @@ -132,9 +140,9 @@ static const uint32_t Krnd[64] = { * the 512-bit input block to produce a new state. */ static void -SHA256_Transform(uint32_t state[static restrict 8], - const uint8_t block[static restrict 64], - uint32_t W[static restrict 64], uint32_t S[static restrict 8]) +SHA256_Transform(uint32_t state[static_restrict 8], + const uint8_t block[static_restrict 64], + uint32_t W[static_restrict 64], uint32_t S[static_restrict 8]) { int i; @@ -203,7 +211,7 @@ static const uint8_t PAD[64] = { /* Add padding and terminating bit-count. */ static void -SHA256_Pad(SHA256_CTX * ctx, uint32_t tmp32[static restrict 72]) +SHA256_Pad(SHA256_CTX * ctx, uint32_t tmp32[static_restrict 72]) { size_t r; @@ -257,7 +265,7 @@ SHA256_Init(SHA256_CTX * ctx) */ static void _SHA256_Update(SHA256_CTX * ctx, const void * in, size_t len, - uint32_t tmp32[static restrict 72]) + uint32_t tmp32[static_restrict 72]) { uint32_t r; const uint8_t * src = in; @@ -315,7 +323,7 @@ SHA256_Update(SHA256_CTX * ctx, const void * in, size_t len) */ static void _SHA256_Final(uint8_t digest[32], SHA256_CTX * ctx, - uint32_t tmp32[static restrict 72]) + uint32_t tmp32[static_restrict 72]) { /* Add padding. */ @@ -367,8 +375,8 @@ SHA256_Buf(const void * in, size_t len, uint8_t digest[32]) */ static void _HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen, - uint32_t tmp32[static restrict 72], uint8_t pad[static restrict 64], - uint8_t khash[static restrict 32]) + uint32_t tmp32[static_restrict 72], uint8_t pad[static_restrict 64], + uint8_t khash[static_restrict 32]) { const uint8_t * K = _K; size_t i; @@ -420,7 +428,7 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen) */ static void _HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void * in, size_t len, - uint32_t tmp32[static restrict 72]) + uint32_t tmp32[static_restrict 72]) { /* Feed data to the inner SHA256 operation. */ @@ -447,7 +455,7 @@ HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void * in, size_t len) */ static void _HMAC_SHA256_Final(uint8_t digest[32], HMAC_SHA256_CTX * ctx, - uint32_t tmp32[static restrict 72], uint8_t ihash[static restrict 32]) + uint32_t tmp32[static_restrict 72], uint8_t ihash[static_restrict 32]) { /* Finish the inner SHA256 operation. */ @@ -500,8 +508,8 @@ HMAC_SHA256_Buf(const void * K, size_t Klen, const void * in, size_t len, /* Add padding and terminating bit-count, but don't invoke Transform yet. */ static int -SHA256_Pad_Almost(SHA256_CTX * ctx, uint8_t len[static restrict 8], - uint32_t tmp32[static restrict 72]) +SHA256_Pad_Almost(SHA256_CTX * ctx, uint8_t len[static_restrict 8], + uint32_t tmp32[static_restrict 72]) { uint32_t r; diff --git a/src/crypto/randomx/defyx/sha256.h b/src/crypto/yes/sha256.h similarity index 100% rename from src/crypto/randomx/defyx/sha256.h rename to src/crypto/yes/sha256.h diff --git a/src/crypto/randomx/defyx/sysendian.h b/src/crypto/yes/sysendian.h similarity index 80% rename from src/crypto/randomx/defyx/sysendian.h rename to src/crypto/yes/sysendian.h index 52c1fe73b2..c51730d1cd 100644 --- a/src/crypto/randomx/defyx/sysendian.h +++ b/src/crypto/yes/sysendian.h @@ -35,6 +35,8 @@ #define be64enc libcperciva_be64enc #define le32dec libcperciva_le32dec #define le32enc libcperciva_le32enc +#define le64dec libcperciva_le64dec +#define le64enc libcperciva_le64enc static inline uint32_t be32dec(const void * pp) @@ -91,4 +93,30 @@ le32enc(void * pp, uint32_t x) p[3] = (x >> 24) & 0xff; } +static inline uint64_t +le64dec(const void * pp) +{ + const uint8_t * p = (uint8_t const *)pp; + + return ((uint64_t)(p[0]) + ((uint64_t)(p[1]) << 8) + + ((uint64_t)(p[2]) << 16) + ((uint64_t)(p[3]) << 24) + + ((uint64_t)(p[4]) << 32) + ((uint64_t)(p[5]) << 40) + + ((uint64_t)(p[6]) << 48) + ((uint64_t)(p[7]) << 56)); +} + +static inline void +le64enc(void * pp, uint64_t x) +{ + uint8_t * p = (uint8_t *)pp; + + p[0] = x & 0xff; + p[1] = (x >> 8) & 0xff; + p[2] = (x >> 16) & 0xff; + p[3] = (x >> 24) & 0xff; + p[4] = (x >> 32) & 0xff; + p[5] = (x >> 40) & 0xff; + p[6] = (x >> 48) & 0xff; + p[7] = (x >> 56) & 0xff; +} + #endif /* !_SYSENDIAN_H_ */ diff --git a/src/crypto/randomx/defyx/yescrypt-best.c b/src/crypto/yes/yescrypt-best.c similarity index 100% rename from src/crypto/randomx/defyx/yescrypt-best.c rename to src/crypto/yes/yescrypt-best.c diff --git a/src/crypto/randomx/defyx/yescrypt-common.c b/src/crypto/yes/yescrypt-common.c similarity index 100% rename from src/crypto/randomx/defyx/yescrypt-common.c rename to src/crypto/yes/yescrypt-common.c diff --git a/src/crypto/randomx/defyx/yescrypt-neon.c b/src/crypto/yes/yescrypt-neon.c similarity index 100% rename from src/crypto/randomx/defyx/yescrypt-neon.c rename to src/crypto/yes/yescrypt-neon.c diff --git a/src/crypto/randomx/defyx/yescrypt-opt.c b/src/crypto/yes/yescrypt-opt.c similarity index 100% rename from src/crypto/randomx/defyx/yescrypt-opt.c rename to src/crypto/yes/yescrypt-opt.c diff --git a/src/crypto/randomx/defyx/yescrypt-platform.c b/src/crypto/yes/yescrypt-platform.c similarity index 100% rename from src/crypto/randomx/defyx/yescrypt-platform.c rename to src/crypto/yes/yescrypt-platform.c diff --git a/src/crypto/randomx/defyx/yescrypt-ref.c b/src/crypto/yes/yescrypt-ref.c similarity index 100% rename from src/crypto/randomx/defyx/yescrypt-ref.c rename to src/crypto/yes/yescrypt-ref.c diff --git a/src/crypto/randomx/defyx/yescrypt-simd.c b/src/crypto/yes/yescrypt-simd.c similarity index 100% rename from src/crypto/randomx/defyx/yescrypt-simd.c rename to src/crypto/yes/yescrypt-simd.c diff --git a/src/crypto/randomx/defyx/yescrypt.h b/src/crypto/yes/yescrypt.h similarity index 100% rename from src/crypto/randomx/defyx/yescrypt.h rename to src/crypto/yes/yescrypt.h diff --git a/src/crypto/randomx/panthera/yespower-opt.c b/src/crypto/yes/yespower-opt.c similarity index 99% rename from src/crypto/randomx/panthera/yespower-opt.c rename to src/crypto/yes/yespower-opt.c index 02f71406c9..441620d870 100644 --- a/src/crypto/randomx/panthera/yespower-opt.c +++ b/src/crypto/yes/yespower-opt.c @@ -49,6 +49,7 @@ * no slowdown from the prefixes is generally observed on AMD CPUs supporting * XOP, some slowdown is sometimes observed on Intel CPUs with AVX. */ +#if !defined(_MSC_VER) #ifdef __XOP__ #warning "Note: XOP is enabled. That's great." #elif defined(__AVX__) @@ -60,6 +61,7 @@ #else #warning "Note: building generic code for non-x86. That's OK." #endif +#endif /* * The SSE4 code version has fewer instructions than the generic SSE2 version, @@ -102,6 +104,10 @@ #include "yespower-platform.c" +#if defined(_MSC_VER) +#define __thread +#endif + #if __STDC_VERSION__ >= 199901L /* Have restrict */ #elif defined(__GNUC__) @@ -527,7 +533,9 @@ static volatile uint64_t Smask2var = Smask2; /* 64-bit without AVX. This relies on out-of-order execution and register * renaming. It may actually be fastest on CPUs with AVX(2) as well - e.g., * it runs great on Haswell. */ +#if !defined(_MSC_VER) #warning "Note: using x86-64 inline assembly for pwxform. That's great." +#endif #undef MAYBE_MEMORY_BARRIER #define MAYBE_MEMORY_BARRIER \ __asm__("" : : : "memory"); diff --git a/src/crypto/randomx/panthera/yespower-platform.c b/src/crypto/yes/yespower-platform.c similarity index 100% rename from src/crypto/randomx/panthera/yespower-platform.c rename to src/crypto/yes/yespower-platform.c diff --git a/src/crypto/randomx/panthera/yespower-ref.c b/src/crypto/yes/yespower-ref.c similarity index 99% rename from src/crypto/randomx/panthera/yespower-ref.c rename to src/crypto/yes/yespower-ref.c index ad0f607ea6..3aa725be8d 100644 --- a/src/crypto/randomx/panthera/yespower-ref.c +++ b/src/crypto/yes/yespower-ref.c @@ -44,7 +44,9 @@ * yespower-opt.c. */ +#if !defined(_MSC_VER) #warning "This reference implementation is deliberately mostly not optimized. Use yespower-opt.c instead unless you're testing (against) the reference implementation on purpose." +#endif #include #include diff --git a/src/crypto/randomx/panthera/yespower.h b/src/crypto/yes/yespower.h similarity index 100% rename from src/crypto/randomx/panthera/yespower.h rename to src/crypto/yes/yespower.h