|
|
@ -4,10 +4,12 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include "argon2src/argon2.h" |
|
|
|
#include "argon2src/argon2.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define _CRT_SECURE_NO_WARNINGS |
|
|
|
|
|
|
|
|
|
|
|
//#include <android/log.h>
|
|
|
|
//#include <android/log.h>
|
|
|
|
|
|
|
|
|
|
|
|
//extern "C" __attribute__((visibility("default"))) __attribute__((used))
|
|
|
|
//extern "C" __attribute__((visibility("default"))) __attribute__((used))
|
|
|
|
int32_t native_add(int32_t x, int32_t y) { |
|
|
|
ARGON2_PUBLIC int32_t native_add(int32_t x, int32_t y) { |
|
|
|
return x + y; |
|
|
|
return x + y; |
|
|
|
} |
|
|
|
} |
|
|
|
//EOF
|
|
|
|
//EOF
|
|
|
@ -81,7 +83,11 @@ char *hashStuff(char *hashPwd) { |
|
|
|
uint8_t salt[SALTLEN]; |
|
|
|
uint8_t salt[SALTLEN]; |
|
|
|
memset(salt, 0x00, SALTLEN); |
|
|
|
memset(salt, 0x00, SALTLEN); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _MSC_VER |
|
|
|
|
|
|
|
uint8_t *pwd = (uint8_t *) _strdup(PWD); |
|
|
|
|
|
|
|
#else |
|
|
|
uint8_t *pwd = (uint8_t *) strdup(PWD); |
|
|
|
uint8_t *pwd = (uint8_t *) strdup(PWD); |
|
|
|
|
|
|
|
#endif |
|
|
|
uint32_t pwdlen = strlen((char *) pwd); |
|
|
|
uint32_t pwdlen = strlen((char *) pwd); |
|
|
|
|
|
|
|
|
|
|
|
uint32_t t_cost = 2; // 1-pass computation
|
|
|
|
uint32_t t_cost = 2; // 1-pass computation
|
|
|
@ -100,12 +106,12 @@ void debugBytes(uint8_t *bytes, int length) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
char *hp_argon2_hash(uint8_t *key, uint32_t keylen, uint8_t *salt, uint32_t saltlen, |
|
|
|
ARGON2_PUBLIC char *hp_argon2_hash(uint8_t *key, uint32_t keylen, uint8_t *salt, uint32_t saltlen, |
|
|
|
uint32_t m_cost, |
|
|
|
uint32_t m_cost, |
|
|
|
uint32_t t_cost /* iterations*/, uint32_t parallelism, |
|
|
|
uint32_t t_cost /* iterations*/, uint32_t parallelism, |
|
|
|
uint32_t hashlen, |
|
|
|
uint32_t hashlen, |
|
|
|
uint8_t type, int32_t version) { |
|
|
|
uint8_t type, int32_t version) { |
|
|
|
uint8_t hash1[hashlen]; |
|
|
|
uint8_t *hash1 = malloc(sizeof(uint8_t) * hashlen); |
|
|
|
PRINT_DEBUG("keylen: %ld, saltlen: %ld, m_cost: %ld, t_cost: %ld, parallelism: %ld, hashlen: %ld, type: %d, version: %02x\n", |
|
|
|
PRINT_DEBUG("keylen: %ld, saltlen: %ld, m_cost: %ld, t_cost: %ld, parallelism: %ld, hashlen: %ld, type: %d, version: %02x\n", |
|
|
|
(long)keylen, (long)saltlen, (long)m_cost, (long)t_cost, (long)parallelism, (long)hashlen, type, version); |
|
|
|
(long)keylen, (long)saltlen, (long)m_cost, (long)t_cost, (long)parallelism, (long)hashlen, type, version); |
|
|
|
PRINT_DEBUG("key: "); |
|
|
|
PRINT_DEBUG("key: "); |
|
|
@ -132,6 +138,7 @@ char *hp_argon2_hash(uint8_t *key, uint32_t keylen, uint8_t *salt, uint32_t salt |
|
|
|
debugBytes(hash1, hashlen); |
|
|
|
debugBytes(hash1, hashlen); |
|
|
|
PRINT_DEBUG("\n"); |
|
|
|
PRINT_DEBUG("\n"); |
|
|
|
char *b64ret = b64_encode(hash1, hashlen); |
|
|
|
char *b64ret = b64_encode(hash1, hashlen); |
|
|
|
|
|
|
|
free(hash1); |
|
|
|
return b64ret; |
|
|
|
return b64ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|