mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-11 05:14:40 +00:00
Added hugepages support for Argon2.
This commit is contained in:
parent
77eb474b29
commit
b1db0803cf
4 changed files with 41 additions and 7 deletions
8
src/3rdparty/argon2/include/argon2.h
vendored
8
src/3rdparty/argon2/include/argon2.h
vendored
|
@ -308,6 +308,14 @@ ARGON2_PUBLIC int argon2id_hash_raw(const uint32_t t_cost,
|
||||||
const size_t saltlen, void *hash,
|
const size_t saltlen, void *hash,
|
||||||
const size_t hashlen);
|
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 */
|
/* generic function underlying the above ones */
|
||||||
ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
|
ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
|
||||||
const uint32_t parallelism, const void *pwd,
|
const uint32_t parallelism, const void *pwd,
|
||||||
|
|
28
src/3rdparty/argon2/lib/argon2.c
vendored
28
src/3rdparty/argon2/lib/argon2.c
vendored
|
@ -259,6 +259,34 @@ int argon2id_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
|
||||||
ARGON2_VERSION_NUMBER);
|
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) {
|
static int argon2_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
|
||||||
size_t i;
|
size_t i;
|
||||||
uint8_t d = 0U;
|
uint8_t d = 0U;
|
||||||
|
|
2
src/3rdparty/argon2/lib/core.c
vendored
2
src/3rdparty/argon2/lib/core.c
vendored
|
@ -139,7 +139,7 @@ void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Memory clear flag defaults to true. */
|
/* 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) {
|
void clear_internal_memory(void *v, size_t n) {
|
||||||
if (FLAG_clear_internal_memory && v) {
|
if (FLAG_clear_internal_memory && v) {
|
||||||
secure_wipe_memory(v, n);
|
secure_wipe_memory(v, n);
|
||||||
|
|
|
@ -27,23 +27,21 @@
|
||||||
|
|
||||||
|
|
||||||
#include "3rdparty/argon2.h"
|
#include "3rdparty/argon2.h"
|
||||||
|
#include "crypto/cn/CryptoNight.h"
|
||||||
#include "crypto/common/Algorithm.h"
|
#include "crypto/common/Algorithm.h"
|
||||||
|
|
||||||
|
|
||||||
struct cryptonight_ctx;
|
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig { namespace argon2 {
|
namespace xmrig { namespace argon2 {
|
||||||
|
|
||||||
|
|
||||||
template<Algorithm::Id ALGO>
|
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) {
|
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) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue