![]() |
GNUnet
0.11.x
|
SHA-512 GNUNET_CRYPTO_hash() related functions. More...
#include "platform.h"
#include "gnunet_crypto_lib.h"
#include "gnunet_strings_lib.h"
#include "benchmark.h"
#include <gcrypt.h>
Go to the source code of this file.
Data Structures | |
struct | GNUNET_HashContext |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-hash", __VA_ARGS__) |
#define | LOG_STRERROR_FILE(kind, syscall, filename) |
Functions | |
void | GNUNET_CRYPTO_hash (const void *block, size_t size, struct GNUNET_HashCode *ret) |
Compute hash of a given block. More... | |
void | GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result) |
Convert hash to ASCII encoding. More... | |
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'. More... | |
unsigned int | GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b) |
Compute the distance between 2 hashcodes. More... | |
void | GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result) |
Create a random hash code. More... | |
void | GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result) |
compute result = b - a More... | |
void | GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *delta, struct GNUNET_HashCode *result) |
compute result = a + delta More... | |
void | GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result) |
compute result = a ^ b More... | |
void | GNUNET_CRYPTO_hash_to_aes_key (const struct GNUNET_HashCode *hc, struct GNUNET_CRYPTO_SymmetricSessionKey *skey, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv) |
Convert a hashcode into a key. More... | |
unsigned int | GNUNET_CRYPTO_hash_count_leading_zeros (const struct GNUNET_HashCode *h) |
Count the number of leading 0 bits in h. More... | |
unsigned int | GNUNET_CRYPTO_hash_count_tailing_zeros (const struct GNUNET_HashCode *h) |
Count the number of tailing 0 bits in h. More... | |
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. More... | |
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). More... | |
void | GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, const void *salt, size_t salt_len,...) |
Derive an authentication key. More... | |
void | GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, const void *salt, size_t salt_len, va_list argp) |
Derive an authentication key. More... | |
void | GNUNET_CRYPTO_hmac_raw (const void *key, size_t key_len, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac) |
Calculate HMAC of a message (RFC 2104) TODO: Shouldn't this be the standard hmac function and the above be renamed? More... | |
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) More... | |
struct GNUNET_HashContext * | GNUNET_CRYPTO_hash_context_start () |
Start incremental hashing operation. More... | |
void | GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, const void *buf, size_t size) |
Add data to be hashed. More... | |
struct GNUNET_HashContext * | GNUNET_CRYPTO_hash_context_copy (const struct GNUNET_HashContext *hc) |
Make a copy of the hash computation. More... | |
void | GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash) |
Finish the hash computation. More... | |
void | GNUNET_CRYPTO_hash_context_abort (struct GNUNET_HashContext *hc) |
Abort hashing, do not bother calculating final result. More... | |
SHA-512 GNUNET_CRYPTO_hash() related functions.
Definition in file crypto_hash.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-crypto-hash", __VA_ARGS__) |
Definition at line 32 of file crypto_hash.c.
#define LOG_STRERROR_FILE | ( | kind, | |
syscall, | |||
filename | |||
) |
Definition at line 34 of file crypto_hash.c.
unsigned int GNUNET_CRYPTO_hash_count_leading_zeros | ( | const struct GNUNET_HashCode * | h | ) |
Count the number of leading 0 bits in h.
h | a hash |
Definition at line 176 of file crypto_hash.c.
References GNUNET_ntohll(), GNUNET_static_assert, h, and ret.
Referenced by add_known_to_bloom(), datacache_get_iterator(), find_proof(), get_matching_bits(), and select_peer().
unsigned int GNUNET_CRYPTO_hash_count_tailing_zeros | ( | const struct GNUNET_HashCode * | h | ) |
Count the number of tailing 0 bits in h.
h | a hash |
Definition at line 198 of file crypto_hash.c.
References GNUNET_ntohll(), GNUNET_static_assert, h, and ret.
void GNUNET_CRYPTO_hmac_raw | ( | const void * | key, |
size_t | key_len, | ||
const void * | plaintext, | ||
size_t | plaintext_len, | ||
struct GNUNET_HashCode * | hmac | ||
) |
Calculate HMAC of a message (RFC 2104) TODO: Shouldn't this be the standard hmac function and the above be renamed?
key | secret key |
key_len | secret key length |
plaintext | input plaintext |
plaintext_len | length of plaintext |
hmac | where to store the hmac |
Definition at line 299 of file crypto_hash.c.
References GNUNET_HashCode::bits, GNUNET_assert, GNUNET_memcpy, key, mc, and once.
Referenced by calculate_hmac(), GNUNET_CRYPTO_hmac(), and OIDC_generate_id_token().
struct GNUNET_HashContext* GNUNET_CRYPTO_hash_context_start | ( | void | ) |
Start incremental hashing operation.
Definition at line 348 of file crypto_hash.c.
References BENCHMARK_END, BENCHMARK_START, GNUNET_assert, GNUNET_new, and GNUNET_HashContext::hd.
Referenced by create_randomized_element_iterator(), decode_and_send(), GCCH_get_id(), GNUNET_CRYPTO_edx25519_private_key_derive(), GNUNET_SET_element_hash(), GNUNET_SETI_element_hash(), GNUNET_SETU_element_hash(), handle_union_p2p_inquiry(), and hash_addresses().
void GNUNET_CRYPTO_hash_context_read | ( | struct GNUNET_HashContext * | hc, |
const void * | buf, | ||
size_t | size | ||
) |
Add data to be hashed.
hc | cumulative hash context |
buf | data to add |
size | number of bytes in buf |
Definition at line 364 of file crypto_hash.c.
References BENCHMARK_END, BENCHMARK_START, buf, GNUNET_HashContext::hd, and size.
Referenced by create_randomized_element_iterator(), decode_and_send(), GCCH_get_id(), GNUNET_CRYPTO_edx25519_private_key_derive(), GNUNET_SET_element_hash(), GNUNET_SETI_element_hash(), GNUNET_SETU_element_hash(), handle_union_p2p_inquiry(), and hash_addresses().
struct GNUNET_HashContext* GNUNET_CRYPTO_hash_context_copy | ( | const struct GNUNET_HashContext * | hc | ) |
Make a copy of the hash computation.
hc | hash context to use (to continue hashing independently) |
Definition at line 375 of file crypto_hash.c.
References GNUNET_assert, GNUNET_new, and GNUNET_HashContext::hd.
void GNUNET_CRYPTO_hash_context_finish | ( | struct GNUNET_HashContext * | hc, |
struct GNUNET_HashCode * | r_hash | ||
) |
Finish the hash computation.
hc | hash context to use, is freed in the process |
r_hash | where to write the latest / final hash code |
Definition at line 388 of file crypto_hash.c.
References BENCHMARK_END, BENCHMARK_START, GNUNET_assert, GNUNET_CRYPTO_hash_context_abort(), GNUNET_memcpy, GNUNET_HashContext::hd, and res.
Referenced by create_randomized_element_iterator(), decode_and_send(), GCCH_get_id(), GNUNET_CRYPTO_edx25519_private_key_derive(), GNUNET_SET_element_hash(), GNUNET_SETI_element_hash(), GNUNET_SETU_element_hash(), handle_union_p2p_inquiry(), and hash_addresses().
void GNUNET_CRYPTO_hash_context_abort | ( | struct GNUNET_HashContext * | hc | ) |
Abort hashing, do not bother calculating final result.
hc | hash context to destroy |
Definition at line 406 of file crypto_hash.c.
References GNUNET_free, and GNUNET_HashContext::hd.
Referenced by GNUNET_CRYPTO_hash_context_finish().