5 #include <openssl/sha.h>
9 #include "yescrypt/yescrypt.h"
11 int do_scanhash(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done, void (*hash_func)(const char *, char *, uint32_t))
13 uint32_t _ALIGN(64) vhash[8];
14 uint32_t _ALIGN(64) endiandata[20];
15 uint32_t *pdata = work->data;
16 uint32_t *ptarget = work->target;
18 const uint32_t Htarg = ptarget[7];
19 const uint32_t first_nonce = pdata[19];
21 uint32_t n = first_nonce;
23 for (int i=0; i < 19; i++) {
24 be32enc(&endiandata[i], pdata[i]);
28 be32enc(&endiandata[19], n);
29 hash_func((char*) endiandata, (char*) vhash, 80);
30 if (vhash[7] < Htarg && fulltest(vhash, ptarget)) {
31 work_set_target_ratio(work, vhash);
32 *hashes_done = n - first_nonce + 1;
38 } while (n < max_nonce && !work_restart[thr_id].restart);
40 *hashes_done = n - first_nonce + 1;
46 int scanhash_yescrypt(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
48 return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash));
51 int scanhash_yescryptr8(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
53 return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r8));
56 int scanhash_yescryptr16(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
58 return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r16));
61 int scanhash_yescryptr32(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
63 return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r32));