Sync changes.
This commit is contained in:
parent
fa11cb623d
commit
45d12314f4
2 changed files with 24 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright (c) 2013-2020 Frank Denis <j at pureftpd dot org>
|
* Copyright (c) 2013-2020 Frank Denis <j at pureftpd dot org>
|
||||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -34,11 +34,6 @@
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
#ifndef XMRIG_SODIUM
|
|
||||||
static std::random_device randomDevice;
|
|
||||||
static std::mt19937 randomEngine(randomDevice());
|
|
||||||
|
|
||||||
|
|
||||||
static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigned char *const bin, const size_t bin_len)
|
static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigned char *const bin, const size_t bin_len)
|
||||||
{
|
{
|
||||||
size_t i = 0U;
|
size_t i = 0U;
|
||||||
|
@ -69,6 +64,11 @@ static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigne
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XMRIG_SODIUM
|
||||||
|
static std::random_device randomDevice;
|
||||||
|
static std::mt19937 randomEngine(randomDevice());
|
||||||
|
|
||||||
|
|
||||||
static int cvt_hex2bin(unsigned char *const bin, const size_t bin_maxlen, const char *const hex, const size_t hex_len, const char *const ignore, size_t *const bin_len, const char **const hex_end)
|
static int cvt_hex2bin(unsigned char *const bin, const size_t bin_maxlen, const char *const hex, const size_t hex_len, const char *const ignore, size_t *const bin_len, const char **const hex_end)
|
||||||
{
|
{
|
||||||
size_t bin_pos = 0U;
|
size_t bin_pos = 0U;
|
||||||
|
@ -275,3 +275,17 @@ xmrig::String xmrig::Cvt::toHex(const uint8_t *in, size_t size)
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Cvt::randomBytes(void *buf, size_t size)
|
||||||
|
{
|
||||||
|
# ifndef XMRIG_SODIUM
|
||||||
|
std::uniform_int_distribution<> dis(0, 255);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < size; ++i) {
|
||||||
|
static_cast<uint8_t *>(buf)[i] = static_cast<char>(dis(randomEngine));
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
randombytes_buf(buf, size);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -52,6 +52,7 @@ public:
|
||||||
static rapidjson::Value toHex(const std::string &data, rapidjson::Document &doc);
|
static rapidjson::Value toHex(const std::string &data, rapidjson::Document &doc);
|
||||||
static rapidjson::Value toHex(const uint8_t *in, size_t size, rapidjson::Document &doc);
|
static rapidjson::Value toHex(const uint8_t *in, size_t size, rapidjson::Document &doc);
|
||||||
static String toHex(const uint8_t *in, size_t size);
|
static String toHex(const uint8_t *in, size_t size);
|
||||||
|
static void randomBytes(void *buf, size_t size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue