Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tpruvot
GitHub Repository: tpruvot/cpuminer-multi
Path: blob/linux/scryptjane/scrypt-jane-hash.h
1201 views
1
#if defined(SCRYPT_BLAKE512)
2
#include "scrypt-jane-hash_blake512.h"
3
#elif defined(SCRYPT_BLAKE256)
4
#include "scrypt-jane-hash_blake256.h"
5
#elif defined(SCRYPT_SHA512)
6
#include "scrypt-jane-hash_sha512.h"
7
#elif defined(SCRYPT_SHA256)
8
#include "scrypt-jane-hash_sha256.h"
9
#elif defined(SCRYPT_SKEIN512)
10
#include "scrypt-jane-hash_skein512.h"
11
#elif defined(SCRYPT_KECCAK512) || defined(SCRYPT_KECCAK256)
12
#include "scrypt-jane-hash_keccak.h"
13
#else
14
#define SCRYPT_HASH "ERROR"
15
#define SCRYPT_HASH_BLOCK_SIZE 64
16
#define SCRYPT_HASH_DIGEST_SIZE 64
17
typedef struct scrypt_hash_state_t { size_t dummy; } scrypt_hash_state;
18
typedef uint8_t scrypt_hash_digest[SCRYPT_HASH_DIGEST_SIZE];
19
static void scrypt_hash_init(scrypt_hash_state *S) {}
20
static void scrypt_hash_update(scrypt_hash_state *S, const uint8_t *in, size_t inlen) {}
21
static void scrypt_hash_finish(scrypt_hash_state *S, uint8_t *hash) {}
22
static const uint8_t scrypt_test_hash_expected[SCRYPT_HASH_DIGEST_SIZE] = {0};
23
#error must define a hash function!
24
#endif
25
26
#include "scrypt-jane-pbkdf2.h"
27
28
#define SCRYPT_TEST_HASH_LEN 257 /* (2 * largest block size) + 1 */
29
30
static int
31
scrypt_test_hash() {
32
scrypt_hash_state st;
33
scrypt_hash_digest hash, final;
34
uint8_t msg[SCRYPT_TEST_HASH_LEN];
35
size_t i;
36
37
for (i = 0; i < SCRYPT_TEST_HASH_LEN; i++)
38
msg[i] = (uint8_t)i;
39
40
scrypt_hash_init(&st);
41
for (i = 0; i < SCRYPT_TEST_HASH_LEN + 1; i++) {
42
scrypt_hash(hash, msg, i);
43
scrypt_hash_update(&st, hash, sizeof(hash));
44
}
45
scrypt_hash_finish(&st, final);
46
return scrypt_verify(final, scrypt_test_hash_expected, SCRYPT_HASH_DIGEST_SIZE);
47
}
48
49
50