31#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-hash", __VA_ARGS__)
33#define LOG_STRERROR_FILE(kind, syscall, \
34 filename) GNUNET_log_from_strerror_file (kind, \
45 crypto_hash_sha512 ((
unsigned char*)
ret,
96 unsigned int x1 = (a->
bits[1] - b->
bits[1]) >> 16;
97 unsigned int x2 = (b->
bits[1] - a->
bits[1]) >> 16;
108 for (ssize_t i = (
sizeof(
struct GNUNET_HashCode) /
sizeof(
unsigned int)) - 1;
120 for (ssize_t i = (
sizeof(
struct GNUNET_HashCode) /
sizeof(
unsigned int)) - 1;
132 const unsigned long long *lla = (
const unsigned long long *) a;
133 const unsigned long long *llb = (
const unsigned long long *) b;
134 unsigned long long *llr = (
unsigned long long *)
result;
139 for (
int i =
sizeof (*
result) /
sizeof (*llr) - 1; i>=0; i--)
140 llr[i] = lla[i] ^ llb[i];
147 const unsigned long long *llp = (
const unsigned long long *)
h;
148 unsigned int ret = 0;
153 for (i = 0; i<
sizeof (*h) /
sizeof (*llp); i++)
157 ret +=
sizeof (*llp) * 8;
159 if (
ret == 8 *
sizeof (*
h))
169 const unsigned long long *llp = (
const unsigned long long *)
h;
170 unsigned int ret = 0;
175 for (i =
sizeof (*
h) /
sizeof (*llp) - 1; i>=0; i--)
179 ret +=
sizeof (*llp) * 8;
181 if (
ret == 8 *
sizeof (*
h))
195 i1 = (
unsigned int *) h1;
196 i2 = (
unsigned int *) h2;
197 for (ssize_t i = (
sizeof(
struct GNUNET_HashCode) /
sizeof(
unsigned int)) - 1;
215 const unsigned long long *l1 = (
const unsigned long long *) h1;
216 const unsigned long long *l2 = (
const unsigned long long *) h2;
217 const unsigned long long *
t = (
const unsigned long long *) target;
220 for (
size_t i = 0; i <
sizeof(*h1) /
sizeof(*l1); i++)
222 unsigned long long x1 = l1[i] ^
t[i];
223 unsigned long long x2 = l2[i] ^
t[i];
237 const void *plaintext,
238 size_t plaintext_len,
241 crypto_auth_hmacsha512_state
state;
242 crypto_auth_hmacsha512_init (&
state,
245 crypto_auth_hmacsha512_update (&
state,
248 crypto_auth_hmacsha512_final (&
state,
249 (
unsigned char*) hmac);
255 const void *plaintext,
size_t plaintext_len,
271 crypto_hash_sha512_state
hd;
282 crypto_hash_sha512_init (&hc->
hd);
294 crypto_hash_sha512_update (&hc->
hd,
318 crypto_hash_sha512_final (&hc->
hd,
319 (
unsigned char*) r_hash);
benchmarking for various operations
#define BENCHMARK_START(opname)
#define BENCHMARK_END(opname)
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int ret
Final status code.
struct GNUNET_HashCode key
The key used in the DHT.
static OpusEncoder * enc
OPUS encoder.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static int state
The current state of the parser.
static int result
Global testing status.
void GNUNET_CRYPTO_hash_difference(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = b - a
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
void GNUNET_CRYPTO_hmac(const struct GNUNET_CRYPTO_AuthKey *key, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104)
void GNUNET_CRYPTO_hmac_raw(const unsigned char *key, unsigned int keylen, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104) with arbitrary key length.
void GNUNET_CRYPTO_hash_sum(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *delta, struct GNUNET_HashCode *result)
compute result = a + delta
void GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
int GNUNET_CRYPTO_hash_xorcmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2, const struct GNUNET_HashCode *target)
Find out which of the two GNUNET_CRYPTO_hash codes is closer to target in the XOR metric (Kademlia).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hash_from_string2(const char *enc, size_t enclen, struct GNUNET_HashCode *result)
Convert ASCII encoding back to a 'struct GNUNET_HashCode'.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
unsigned int GNUNET_CRYPTO_hash_distance_u32(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b)
Compute the distance between 2 hashcodes.
unsigned int GNUNET_CRYPTO_hash_count_leading_zeros(const struct GNUNET_HashCode *h)
Count the number of leading 0 bits in h.
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_copy(const struct GNUNET_HashContext *hc)
Make a copy of the hash computation.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
void GNUNET_CRYPTO_hash_context_abort(struct GNUNET_HashContext *hc)
Abort hashing, do not bother calculating final result.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
unsigned int GNUNET_CRYPTO_hash_count_tailing_zeros(const struct GNUNET_HashCode *h)
Count the number of tailing 0 bits in h.
GNUNET_GenericReturnValue
Named constants for return values.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start()
Start incremental hashing operation.
#define GNUNET_static_assert(cond)
Assertion to be checked (if supported by C compiler) at compile time, otherwise checked at runtime an...
uint32_t bits[512/8/sizeof(uint32_t)]
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_STRINGS_data_to_string(const void *data, size_t size, char *out, size_t out_size)
Convert binary data to ASCII encoding using CrockfordBase32.
char * GNUNET_STRINGS_utf8_toupper(const char *input)
Convert the utf-8 input string to upper case.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
static unsigned int size
Size of the "table".
static struct GNUNET_TIME_Relative delta
type for (message) authentication keys
0-terminated ASCII encoding of a struct GNUNET_HashCode.
crypto_hash_sha512_state hd
Internal state of the hash function.