Added hugepages support for Argon2.

This commit is contained in:
XMRig 2019-08-17 13:06:14 +07:00
parent 77eb474b29
commit b1db0803cf
4 changed files with 41 additions and 7 deletions

View file

@ -308,6 +308,14 @@ ARGON2_PUBLIC int argon2id_hash_raw(const uint32_t t_cost,
const size_t saltlen, void *hash,
const size_t hashlen);
ARGON2_PUBLIC int argon2id_hash_raw_ex(const uint32_t t_cost,
const uint32_t m_cost,
const uint32_t parallelism, const void *pwd,
const size_t pwdlen, const void *salt,
const size_t saltlen, void *hash,
const size_t hashlen,
void *memory);
/* generic function underlying the above ones */
ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
const uint32_t parallelism, const void *pwd,

View file

@ -259,6 +259,34 @@ int argon2id_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
ARGON2_VERSION_NUMBER);
}
int argon2id_hash_raw_ex(const uint32_t t_cost, const uint32_t m_cost,
const uint32_t parallelism, const void *pwd,
const size_t pwdlen, const void *salt,
const size_t saltlen, void *hash, const size_t hashlen, void *memory) {
argon2_context context;
context.out = (uint8_t *)hash;
context.outlen = (uint32_t)hashlen;
context.pwd = CONST_CAST(uint8_t *)pwd;
context.pwdlen = (uint32_t)pwdlen;
context.salt = CONST_CAST(uint8_t *)salt;
context.saltlen = (uint32_t)saltlen;
context.secret = NULL;
context.secretlen = 0;
context.ad = NULL;
context.adlen = 0;
context.t_cost = t_cost;
context.m_cost = m_cost;
context.lanes = parallelism;
context.threads = parallelism;
context.allocate_cbk = NULL;
context.free_cbk = NULL;
context.flags = ARGON2_DEFAULT_FLAGS;
context.version = ARGON2_VERSION_NUMBER;
return argon2_ctx_mem(&context, Argon2_id, memory, m_cost * 1024);
}
static int argon2_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
size_t i;
uint8_t d = 0U;

View file

@ -139,7 +139,7 @@ void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) {
}
/* Memory clear flag defaults to true. */
int FLAG_clear_internal_memory = 1;
int FLAG_clear_internal_memory = 0;
void clear_internal_memory(void *v, size_t n) {
if (FLAG_clear_internal_memory && v) {
secure_wipe_memory(v, n);

View file

@ -27,23 +27,21 @@
#include "3rdparty/argon2.h"
#include "crypto/cn/CryptoNight.h"
#include "crypto/common/Algorithm.h"
struct cryptonight_ctx;
namespace xmrig { namespace argon2 {
template<Algorithm::Id ALGO>
inline void single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__, uint64_t)
inline void single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t)
{
if (ALGO == Algorithm::AR2_CHUKWA) {
argon2id_hash_raw(3, 512, 1, input, size, input, 16, output, 32);
argon2id_hash_raw_ex(3, 512, 1, input, size, input, 16, output, 32, ctx[0]->memory);
}
else if (ALGO == Algorithm::AR2_WRKZ) {
argon2id_hash_raw(4, 256, 1, input, size, input, 16, output, 32);
argon2id_hash_raw_ex(4, 256, 1, input, size, input, 16, output, 32, ctx[0]->memory);
}
}