Add Chukwa support
This commit is contained in:
parent
1d4bc030fb
commit
dcf9c68334
70 changed files with 7240 additions and 4 deletions
45
src/crypto/Argon2.h
Normal file
45
src/crypto/Argon2.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#ifndef XMRIG_ARGON2_H
|
||||
#define XMRIG_ARGON2_H
|
||||
|
||||
#include <argon2.h>
|
||||
|
||||
#include "crypto/Argon2_constants.h"
|
||||
|
||||
static bool argon_optimization_selected = false;
|
||||
|
||||
template<xmrig::Variant VARIANT>
|
||||
inline void argon2_hash_function(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height)
|
||||
{
|
||||
/* If this is the first time we've called this hash function then
|
||||
we need to have the Argon2 library check to see if any of the
|
||||
available CPU instruction sets are going to help us out */
|
||||
if (!argon_optimization_selected)
|
||||
{
|
||||
/* Call the library quick benchmark test to set which CPU
|
||||
instruction sets will be used */
|
||||
argon2_select_impl(NULL, NULL);
|
||||
|
||||
argon_optimization_selected = true;
|
||||
}
|
||||
|
||||
uint8_t salt[xmrig::ARGON2_SALTLEN];
|
||||
|
||||
memcpy(salt, input, sizeof(salt));
|
||||
|
||||
const uint32_t ITERS = xmrig::argon2_select_iters(VARIANT);
|
||||
const uint32_t MEMORY = xmrig::argon2_select_memory(VARIANT);
|
||||
const uint32_t PARALLELISM = xmrig::argon2_select_parallelism(VARIANT);
|
||||
const int ALGO = xmrig::argon2_select_algo(VARIANT);
|
||||
|
||||
switch (ALGO)
|
||||
{
|
||||
case xmrig::Argon2Algo::I:
|
||||
argon2i_hash_raw(ITERS, MEMORY, PARALLELISM, input, size, salt, xmrig::ARGON2_SALTLEN, output, xmrig::ARGON2_HASHLEN);
|
||||
case xmrig::Argon2Algo::D:
|
||||
argon2d_hash_raw(ITERS, MEMORY, PARALLELISM, input, size, salt, xmrig::ARGON2_SALTLEN, output, xmrig::ARGON2_HASHLEN);
|
||||
case xmrig::Argon2Algo::ID:
|
||||
argon2id_hash_raw(ITERS, MEMORY, PARALLELISM, input, size, salt, xmrig::ARGON2_SALTLEN, output, xmrig::ARGON2_HASHLEN);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
72
src/crypto/Argon2_constants.h
Normal file
72
src/crypto/Argon2_constants.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
#ifndef XMRIG_ARGON2_CONSTANTS_H
|
||||
#define XMRIG_ARGON2_CONSTANTS_H
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "common/xmrig.h"
|
||||
|
||||
namespace xmrig
|
||||
{
|
||||
enum Argon2Algo {
|
||||
I = 0,
|
||||
D = 1,
|
||||
ID = 2
|
||||
};
|
||||
|
||||
constexpr const size_t ARGON2_SALTLEN = 16;
|
||||
constexpr const size_t ARGON2_HASHLEN = 32;
|
||||
|
||||
constexpr const size_t ARGON2_MEMORY_CHUKWA = 512;
|
||||
constexpr const size_t ARGON2_ITERS_CHUKWA = 3;
|
||||
constexpr const size_t ARGON2_PARALLELISM_CHUKWA = 1;
|
||||
constexpr const int ARGON2_ALGO_CHUKWA = Argon2Algo::ID;
|
||||
|
||||
inline int argon2_select_algo(Variant variant)
|
||||
{
|
||||
switch (variant)
|
||||
{
|
||||
case VARIANT_CHUKWA:
|
||||
return ARGON2_ALGO_CHUKWA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline uint32_t argon2_select_memory(Variant variant)
|
||||
{
|
||||
switch (variant)
|
||||
{
|
||||
case VARIANT_CHUKWA:
|
||||
return ARGON2_MEMORY_CHUKWA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline uint32_t argon2_select_iters(Variant variant)
|
||||
{
|
||||
switch (variant)
|
||||
{
|
||||
case VARIANT_CHUKWA:
|
||||
return ARGON2_ITERS_CHUKWA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline uint32_t argon2_select_parallelism(Variant variant)
|
||||
{
|
||||
switch (variant)
|
||||
{
|
||||
case VARIANT_CHUKWA:
|
||||
return ARGON2_PARALLELISM_CHUKWA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
0
src/crypto/Argon2_test.h
Normal file
0
src/crypto/Argon2_test.h
Normal file
Loading…
Add table
Add a link
Reference in a new issue