Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tpruvot
GitHub Repository: tpruvot/cpuminer-multi
Path: blob/linux/crypto/hash-ops.h
1201 views
1
// Copyright (c) 2012-2013 The Cryptonote developers
2
// Distributed under the MIT/X11 software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#pragma once
6
7
#if !defined(__cplusplus)
8
9
#include <assert.h>
10
#include <stdbool.h>
11
#include <stddef.h>
12
#include <stdint.h>
13
14
#include "int-util.h"
15
16
#if 0
17
static inline void *padd(void *p, size_t i) {
18
return (char *) p + i;
19
}
20
21
static inline const void *cpadd(const void *p, size_t i) {
22
return (const char *) p + i;
23
}
24
25
static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length) {
26
if (sizeof(size_t) == 4) {
27
*(uint32_t*) padd(buffer, bufsize - 4) = swap32be(length);
28
} else {
29
*(uint64_t*) padd(buffer, bufsize - 8) = swap64be(length);
30
}
31
}
32
#endif
33
34
#pragma pack(push, 1)
35
union hash_state {
36
uint8_t b[200];
37
uint64_t w[25];
38
};
39
#pragma pack(pop)
40
41
void hash_permutation(union hash_state *state);
42
void hash_process(union hash_state *state, const uint8_t *buf, int count);
43
44
#endif
45
46
enum {
47
HASH_SIZE = 32,
48
HASH_DATA_AREA = 136
49
};
50
51
void cn_fast_hash(const void *data, int len, char *hash);
52
void cn_slow_hash(const void *data, size_t length, char *hash);
53
54
void hash_extra_blake(const void *data, size_t length, char *hash);
55
void hash_extra_groestl(const void *data, size_t length, char *hash);
56
void hash_extra_jh(const void *data, size_t length, char *hash);
57
void hash_extra_skein(const void *data, size_t length, char *hash);
58
59
void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash);
60
61