71 lines
2.0 KiB
C++
71 lines
2.0 KiB
C++
|
/*
|
||
|
* 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
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
extern "C"
|
||
|
{
|
||
|
#include "c_groestl.h"
|
||
|
#include "c_blake256.h"
|
||
|
#include "c_jh.h"
|
||
|
#include "c_skein.h"
|
||
|
}
|
||
|
#include "cryptonight.h"
|
||
|
#include "cryptonight_aesni.h"
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
#ifdef __GNUC__
|
||
|
#include <mm_malloc.h>
|
||
|
#else
|
||
|
#include <malloc.h>
|
||
|
#endif // __GNUC__
|
||
|
|
||
|
#ifdef _WIN32
|
||
|
#include <windows.h>
|
||
|
#else
|
||
|
#include <sys/mman.h>
|
||
|
#include <errno.h>
|
||
|
#include <string.h>
|
||
|
#endif // _WIN32
|
||
|
|
||
|
void do_blake_hash(const void* input, size_t len, char* output) {
|
||
|
blake256_hash((uint8_t*)output, (const uint8_t*)input, len);
|
||
|
}
|
||
|
|
||
|
void do_groestl_hash(const void* input, size_t len, char* output) {
|
||
|
groestl((const uint8_t*)input, len * 8, (uint8_t*)output);
|
||
|
}
|
||
|
|
||
|
void do_jh_hash(const void* input, size_t len, char* output) {
|
||
|
jh_hash(32 * 8, (const uint8_t*)input, 8 * len, (uint8_t*)output);
|
||
|
}
|
||
|
|
||
|
void do_skein_hash(const void* input, size_t len, char* output) {
|
||
|
skein_hash(8 * 32, (const uint8_t*)input, 8 * len, (uint8_t*)output);
|
||
|
}
|
||
|
|
||
|
void (* const extra_hashes[4])(const void *, size_t, char *) = {do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash};
|
||
|
|
||
|
|
||
|
void cryptonight_hash_ctx(const void* input, size_t len, void* output, cryptonight_ctx* ctx)
|
||
|
{
|
||
|
cryptonight_hash<0x80000, MEMORY, true, false>(input, len, output, ctx);
|
||
|
}
|
||
|
|
||
|
void cryptonight_hash_ctx_soft(const void* input, size_t len, void* output, cryptonight_ctx* ctx)
|
||
|
{
|
||
|
cryptonight_hash<0x80000, MEMORY, true, true>(input, len, output, ctx);
|
||
|
}
|
||
|
|