GNUnet  0.11.x
Macros | Functions
Crypto library: hash operations

Provides hashing and operations on hashes. More...

Macros

#define GNUNET_CRYPTO_hash_from_string(enc, result)   GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
 Convert ASCII encoding back to struct GNUNET_HashCode More...
 

Functions

uint8_t GNUNET_CRYPTO_crc8_n (const void *buf, size_t len)
 Calculate the checksum of a buffer in one step. More...
 
uint16_t GNUNET_CRYPTO_crc16_n (const void *buf, size_t len)
 Calculate the checksum of a buffer in one step. More...
 
int32_t GNUNET_CRYPTO_crc32_n (const void *buf, size_t len)
 Compute the CRC32 checksum for the first len bytes of the buffer. 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...
 
uint32_t 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 (const void *block, size_t size, struct GNUNET_HashCode *ret)
 Compute hash of a given block. 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_CRYPTO_FileHashContextGNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls)
 Compute the hash of an entire file. 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...
 
int GNUNET_CRYPTO_hash_get_bit_ltr (const struct GNUNET_HashCode *code, unsigned int bit)
 Obtain a bit from a hashcode. More...
 
unsigned int GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode *first, const struct GNUNET_HashCode *second)
 Determine how many low order bits match in two struct GNUNET_HashCodes. 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_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_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...
 
int GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_algo, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
 Derive key. More...
 
int GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_algo, const void *xts, size_t xts_len, const void *skm, size_t skm_len, va_list argp)
 Derive key. More...
 
int GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
 Derive key. More...
 

Detailed Description

Provides hashing and operations on hashes.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_CRYPTO_hash_from_string

#define GNUNET_CRYPTO_hash_from_string (   enc,
  result 
)    GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)

Convert ASCII encoding back to struct GNUNET_HashCode

Parameters
encthe encoding
resultwhere to store the hash code
Returns
GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding

Definition at line 636 of file gnunet_crypto_lib.h.

Referenced by database_setup(), run(), uri_chk_parse(), and uri_loc_parse().

Function Documentation

◆ GNUNET_CRYPTO_crc8_n()

uint8_t GNUNET_CRYPTO_crc8_n ( const void *  buf,
size_t  len 
)

Calculate the checksum of a buffer in one step.

Parameters
bufbuffer to calculate CRC over
lennumber of bytes in buf
Returns
crc8 value

Definition at line 179 of file crypto_crc.c.

References buf, and data.

181 {
182  const uint8_t *data = buf;
183  unsigned int crc = 0;
184  int i;
185  int j;
186 
187  for (j = len; 0 != j; j--)
188  {
189  crc ^= (*data++ << 8);
190  for (i = 8; 0 != i; i--)
191  {
192  if (0 != (crc & 0x8000))
193  crc ^= (0x1070 << 3);
194  crc <<= 1;
195  }
196  }
197  return (uint8_t) (crc >> 8);
198 }
static char buf[2048]
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...

◆ GNUNET_CRYPTO_crc16_n()

uint16_t GNUNET_CRYPTO_crc16_n ( const void *  buf,
size_t  len 
)

Calculate the checksum of a buffer in one step.

Parameters
bufbuffer to calculate CRC over (must be 16-bit aligned)
lennumber of bytes in buf, must be multiple of 2
Returns
crc16 value
Parameters
bufbuffer to calculate CRC over (must be 16-bit aligned)
lennumber of bytes in hdr, must be multiple of 2
Returns
crc16 value

Definition at line 161 of file crypto_crc.c.

References buf, GNUNET_CRYPTO_crc16_finish(), and GNUNET_CRYPTO_crc16_step().

Referenced by GNUNET_TUN_initialize_ipv4_header().

162 {
163  const uint16_t *hdr = buf;
164  uint32_t sum = GNUNET_CRYPTO_crc16_step (0, hdr, len);
165 
166  return GNUNET_CRYPTO_crc16_finish (sum);
167 }
static char buf[2048]
uint32_t GNUNET_CRYPTO_crc16_step(uint32_t sum, const void *buf, size_t len)
Perform an incremental step in a CRC16 (for TCP/IP) calculation.
Definition: crypto_crc.c:125
uint16_t GNUNET_CRYPTO_crc16_finish(uint32_t sum)
Convert results from GNUNET_CRYPTO_crc16_step() to final crc16.
Definition: crypto_crc.c:144
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_crc32_n()

int32_t GNUNET_CRYPTO_crc32_n ( const void *  buf,
size_t  len 
)

Compute the CRC32 checksum for the first len bytes of the buffer.

Parameters
bufthe data over which we're taking the CRC
lenthe length of the buffer buf in bytes
Returns
the resulting CRC32 checksum
Parameters
bufthe data over which we're taking the CRC
lenthe length of the buffer
Returns
the resulting CRC32 checksum

Definition at line 106 of file crypto_crc.c.

References crc32(), and Z_NULL.

Referenced by do_decrypt(), do_encrypt(), ibf_get_indices(), process_data(), and wlan_plugin_send().

107 {
108  GNUNET_uLong crc;
109 
110  crc = crc32 (0L, Z_NULL, 0);
111  crc = crc32 (crc, (char *) buf, len);
112  return crc;
113 }
#define Z_NULL
Definition: crypto_crc.c:44
static char buf[2048]
static GNUNET_uLong crc32(GNUNET_uLong crc, const char *buf, size_t len)
Definition: crypto_crc.c:87
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_to_enc()

void GNUNET_CRYPTO_hash_to_enc ( const struct GNUNET_HashCode block,
struct GNUNET_CRYPTO_HashAsciiEncoded result 
)

Convert hash to ASCII encoding.

Parameters
blockthe hash code
resultwhere to store the encoding (struct GNUNET_CRYPTO_HashAsciiEncoded can be safely cast to char*, a '\0' termination is set).

Convert hash to ASCII encoding.

The ASCII encoding is rather GNUnet specific. It was chosen such that it only uses characters in [0-9A-V], can be produced without complex arithmetics and uses a small number of characters. The GNUnet encoding uses 103 characters plus a null terminator.

Parameters
blockthe hash code
resultwhere to store the encoding (struct GNUNET_CRYPTO_HashAsciiEncoded can be safely cast to char*, a '\0' termination is set).

Definition at line 73 of file crypto_hash.c.

References GNUNET_assert, and GNUNET_STRINGS_data_to_string().

Referenced by get_update_information_directory(), GNUNET_e2s(), GNUNET_e2s2(), GNUNET_h2s(), GNUNET_h2s2(), GNUNET_h2s_full(), GNUNET_NETWORK_shorten_unixpath(), GNUNET_p2s(), GNUNET_p2s2(), store_and_free_entries(), uri_chk_to_string(), and uri_loc_to_string().

75 {
76  char *np;
77 
78  np = GNUNET_STRINGS_data_to_string ((const unsigned char *) block,
79  sizeof(struct GNUNET_HashCode),
80  (char *) result,
81  sizeof(struct
83  - 1);
84  GNUNET_assert (NULL != np);
85  *np = '\0';
86 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A 512-bit hashcode.
0-terminated ASCII encoding of a struct GNUNET_HashCode.
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.
Definition: strings.c:871
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_from_string2()

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'.

Parameters
encthe encoding
enclennumber of characters in enc (without 0-terminator, which can be missing)
resultwhere to store the hash code
Returns
GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding

Convert ASCII encoding back to a 'struct GNUNET_HashCode'.

Parameters
encthe encoding
enclennumber of characters in enc (without 0-terminator, which can be missing)
resultwhere to store the hash code
Returns
GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding

Definition at line 98 of file crypto_hash.c.

References GNUNET_STRINGS_string_to_data(), and GNUNET_STRINGS_utf8_toupper().

101 {
102  char upper_enc[enclen];
103  char *up_ptr = upper_enc;
104 
106 
107  return GNUNET_STRINGS_string_to_data (upper_enc, enclen,
108  (unsigned char *) result,
109  sizeof(struct GNUNET_HashCode));
110 }
void GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to upper case.
Definition: strings.c:593
A 512-bit hashcode.
static OpusEncoder * enc
OPUS encoder.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:971
Here is the call graph for this function:

◆ GNUNET_CRYPTO_hash_distance_u32()

unsigned int GNUNET_CRYPTO_hash_distance_u32 ( const struct GNUNET_HashCode a,
const struct GNUNET_HashCode b 
)

Compute the distance between 2 hashcodes.

The computation must be fast, not involve a[0] or a[4] (they're used elsewhere), and be somewhat consistent. And of course, the result should be a positive number.

Parameters
asome hash code
bsome hash code
Returns
number between 0 and UINT32_MAX

The computation must be fast, not involve bits[0] or bits[4] (they're used elsewhere), and be somewhat consistent. And of course, the result should be a positive number.

Parameters
asome hash code
bsome hash code
Returns
a positive number which is a measure for hashcode proximity.

Definition at line 127 of file crypto_hash.c.

References GNUNET_HashCode::bits.

Referenced by score_content().

129 {
130  unsigned int x1 = (a->bits[1] - b->bits[1]) >> 16;
131  unsigned int x2 = (b->bits[1] - a->bits[1]) >> 16;
132 
133  return(x1 * x2);
134 }
uint32_t bits[512/8/sizeof(uint32_t)]
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash()

void GNUNET_CRYPTO_hash ( const void *  block,
size_t  size,
struct GNUNET_HashCode ret 
)

Compute hash of a given block.

Parameters
blockthe data to hash
sizesize of the block
retpointer to where to write the hashcode

Compute hash of a given block.

Parameters
blockthe data to GNUNET_CRYPTO_hash, length is given as a second argument
sizethe length of the data to GNUNET_CRYPTO_hash in block
retpointer to where to write the hashcode

Definition at line 48 of file crypto_hash.c.

References BENCHMARK_END, and BENCHMARK_START.

Referenced by add_file(), add_known_to_bloom(), add_to_keyword_counter(), add_to_meta_counter(), advertise_dns_exit(), automaton_create_proofs(), block_plugin_dht_evaluate(), block_plugin_dns_evaluate(), block_plugin_fs_evaluate(), block_plugin_fs_get_key(), block_plugin_gns_evaluate(), block_plugin_gns_get_key(), block_plugin_revocation_evaluate(), block_plugin_revocation_get_key(), block_plugin_template_evaluate(), block_plugin_test_evaluate(), build_authz_response(), calculate_hmac(), client_request_complete_alice(), code_redirect(), collector(), commit_set(), cookie_identity_interpretation(), core_init(), create_response(), data_to_ecdsa_value(), database_setup(), decrypt_new_element(), delayed_put(), derive_aes_key(), derive_auth_key(), derive_iv(), derive_pong_iv(), determine_id(), do_rekey(), ego_get_all(), ego_get_response(), encrypt_existing_match(), evaluate_block_regex(), evaluate_block_regex_accept(), find_advertisable_hello(), find_trees(), forward_reply(), GC_u2h(), GCT_handle_kx_auth(), get_cadet(), get_destination_key_from_ip(), get_fair_encryption_challenge(), get_file_handle(), get_gns_cont(), get_matching_bits(), get_update_information_directory(), get_url_parameter_copy(), GNUNET_BLOCK_mingle_hash(), GNUNET_CONVERSATION_phone_create(), GNUNET_CRYPTO_ecc_ecdh(), GNUNET_CRYPTO_ecdh_ecdsa(), GNUNET_CRYPTO_ecdh_eddsa(), GNUNET_CRYPTO_ecdsa_ecdh(), GNUNET_CRYPTO_eddsa_ecdh(), GNUNET_CRYPTO_rsa_public_key_hash(), GNUNET_e2s(), GNUNET_e2s2(), GNUNET_FS_handle_on_demand_block(), GNUNET_FS_namespace_list_updateable(), GNUNET_FS_publish_ublock_(), GNUNET_FS_search_start_searching_(), GNUNET_FS_tree_encoder_next(), GNUNET_FS_unindex_do_remove_kblocks_(), GNUNET_FS_uri_to_key(), GNUNET_GNSRECORD_query_from_public_key(), GNUNET_HELLO_extract_address(), GNUNET_HELLO_sign_address(), GNUNET_IDENTITY_ego_get_anonymous(), GNUNET_NETWORK_shorten_unixpath(), GNUNET_p2s(), GNUNET_p2s2(), GNUNET_TESTBED_barrier_init_(), GNUNET_TUN_service_name_to_hash(), GSC_KX_encrypt_and_transmit(), GSC_KX_init(), GSC_TYPEMAP_hash(), GSF_cadet_start_server(), handle_barrier_cancel(), handle_barrier_init(), handle_barrier_status(), handle_barrier_wait(), handle_client_decrypt(), handle_core_connect(), handle_encrypted(), handle_ephemeral_key(), handle_identity_set_default(), handle_identity_update(), handle_put(), handle_query_message(), handle_regex_result(), handle_transport_notify_connect(), hash_hosts(), hash_pkey_and_label(), header_iterator(), iface_proc(), init_socket(), insert_decrypt_element(), insert_round1_element(), iterate_initial_edge(), iterateBits(), load_state(), login_cont(), lookup_diff(), lookup_rfn(), lookup_set(), lookup_task(), maint_child_death(), mysql_plugin_put(), namecache_cache_block(), namecache_postgres_cache_block(), namecache_sqlite_cache_block(), namestore_get(), ns_lookup_result_cb(), parse_credentials_basic_auth(), parse_credentials_post_body(), peerinfo_get(), peerstore_flat_store_record(), PEERSTORE_hash_key(), post_data_iter(), postgres_plugin_put(), process_client_result(), process_kblock_for_unindex(), process_reply(), publicize_rm(), put_diff(), put_rfn(), put_set(), put_task(), queue(), queue_destroy(), REGEX_BLOCK_check_proof(), REGEX_BLOCK_get_key(), REGEX_INTERNAL_get_first_key(), remove_high_frequency_keywords(), reset_cadet(), run(), schedule_next_hello(), schedule_transmit_search_request(), score_content(), send_key(), send_kx_auth(), set_result_cb(), setup_filter(), sock_read(), sqlite_plugin_put(), start_intersection(), token_endpoint(), try_connect(), try_match_block(), try_open_exit(), try_top_down_reconstruction(), url_iterator(), and userinfo_endpoint().

51 {
52  BENCHMARK_START (hash);
53  gcry_md_hash_buffer (GCRY_MD_SHA512, ret, block, size);
54  BENCHMARK_END (hash);
55 }
#define BENCHMARK_START(opname)
Definition: benchmark.h:57
#define BENCHMARK_END(opname)
Definition: benchmark.h:58
static unsigned int size
Size of the "table".
Definition: peer.c:67

◆ GNUNET_CRYPTO_hmac()

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)

Parameters
keysecret key
plaintextinput plaintext
plaintext_lenlength of plaintext
hmacwhere to store the hmac

Definition at line 455 of file crypto_hash.c.

References GNUNET_CRYPTO_hmac_raw(), and GNUNET_CRYPTO_AuthKey::key.

Referenced by dv_hmac(), GSC_KX_encrypt_and_transmit(), handle_encrypted(), RPS_sampler_elem_next(), t_ax_hmac_hash(), and t_hmac().

458 {
459  GNUNET_CRYPTO_hmac_raw ((void *) key->key, sizeof(key->key),
460  plaintext, plaintext_len,
461  hmac);
462 }
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&#39; this be the standard hmac function and the abov...
Definition: crypto_hash.c:420
unsigned char key[(512/8)]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_file()

struct GNUNET_CRYPTO_FileHashContext* GNUNET_CRYPTO_hash_file ( enum GNUNET_SCHEDULER_Priority  priority,
const char *  filename,
size_t  blocksize,
GNUNET_CRYPTO_HashCompletedCallback  callback,
void *  callback_cls 
)

Compute the hash of an entire file.

Parameters
priorityscheduling priority to use
filenamename of file to hash
blocksizenumber of bytes to process in one task
callbackfunction to call upon completion
callback_clsclosure for callback
Returns
NULL on (immediate) errror

Definition at line 178 of file crypto_hash_file.c.

References GNUNET_CRYPTO_FileHashContext::bsize, GNUNET_CRYPTO_FileHashContext::buffer, GNUNET_CRYPTO_FileHashContext::callback, GNUNET_CRYPTO_FileHashContext::callback_cls, GNUNET_CRYPTO_FileHashContext::fh, file_hash_task(), GNUNET_CRYPTO_FileHashContext::filename, GNUNET_CRYPTO_FileHashContext::fsize, GNUNET_assert, GNUNET_break, GNUNET_DISK_file_open(), GNUNET_DISK_file_size(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_free, GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_with_priority(), GNUNET_strdup, GNUNET_YES, GNUNET_CRYPTO_FileHashContext::md, GNUNET_CRYPTO_FileHashContext::priority, and GNUNET_CRYPTO_FileHashContext::task.

Referenced by deserialize_unindex_file(), GNUNET_FS_publish_main_(), GNUNET_FS_unindex_start(), and handle_client_index_start().

183 {
184  struct GNUNET_CRYPTO_FileHashContext *fhc;
185 
186  GNUNET_assert (blocksize > 0);
187  fhc =
188  GNUNET_malloc (sizeof(struct GNUNET_CRYPTO_FileHashContext) + blocksize);
189  fhc->callback = callback;
190  fhc->callback_cls = callback_cls;
191  fhc->buffer = (unsigned char *) &fhc[1];
193  if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0))
194  {
195  GNUNET_break (0);
196  GNUNET_free (fhc);
197  return NULL;
198  }
199  fhc->bsize = blocksize;
200  if (GNUNET_OK !=
202  &fhc->fsize,
203  GNUNET_NO,
204  GNUNET_YES))
205  {
206  GNUNET_free (fhc->filename);
207  GNUNET_free (fhc);
208  return NULL;
209  }
213  if (! fhc->fh)
214  {
215  GNUNET_free (fhc->filename);
216  GNUNET_free (fhc);
217  return NULL;
218  }
219  fhc->priority = priority;
222  fhc);
223  return fhc;
224 }
Open the file for reading.
struct GNUNET_SCHEDULER_Task * task
Current task for hashing.
struct GNUNET_DISK_FileHandle * fh
File descriptor.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Nobody is allowed to do anything to the file.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
gcry_md_hd_t md
Cummulated hash.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1223
static char * filename
unsigned char * buffer
IO buffer.
char * filename
Name of the file we are hashing.
uint64_t fsize
Size of the file.
Context used when hashing a file.
int GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:257
enum GNUNET_SCHEDULER_Priority priority
Priority we use.
GNUNET_CRYPTO_HashCompletedCallback callback
Function to call upon completion.
static void file_hash_task(void *cls)
File hashing task.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1203
#define GNUNET_malloc(size)
Wrapper around malloc.
void * callback_cls
Closure for callback.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_create_random()

void GNUNET_CRYPTO_hash_create_random ( enum GNUNET_CRYPTO_Quality  mode,
struct GNUNET_HashCode result 
)

Create a random hash code.

Parameters
modedesired quality level
resulthash code that is randomized

Definition at line 144 of file crypto_hash.c.

References GNUNET_HashCode::bits, and GNUNET_CRYPTO_random_u32().

Referenced by commit_set(), do_consensus(), GDS_DATACACHE_get_random_key(), and run().

146 {
147  int i;
148 
149  for (i = (sizeof(struct GNUNET_HashCode) / sizeof(uint32_t)) - 1; i >= 0; i--)
150  result->bits[i] = GNUNET_CRYPTO_random_u32 (mode, UINT32_MAX);
151 }
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
static enum @8 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
A 512-bit hashcode.
uint32_t bits[512/8/sizeof(uint32_t)]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_difference()

void GNUNET_CRYPTO_hash_difference ( const struct GNUNET_HashCode a,
const struct GNUNET_HashCode b,
struct GNUNET_HashCode result 
)

compute result = b - a

Parameters
asome hash code
bsome hash code
resultset to b - a

compute result = b - a

Parameters
asome hash code
bsome hash code
resultset to b - a

Definition at line 162 of file crypto_hash.c.

References GNUNET_HashCode::bits.

165 {
166  int i;
167 
168  for (i = (sizeof(struct GNUNET_HashCode) / sizeof(unsigned int)) - 1; i >= 0;
169  i--)
170  result->bits[i] = b->bits[i] - a->bits[i];
171 }
A 512-bit hashcode.
uint32_t bits[512/8/sizeof(uint32_t)]

◆ GNUNET_CRYPTO_hash_sum()

void GNUNET_CRYPTO_hash_sum ( const struct GNUNET_HashCode a,
const struct GNUNET_HashCode delta,
struct GNUNET_HashCode result 
)

compute result = a + delta

Parameters
asome hash code
deltasome hash code
resultset to a + delta

compute result = a + delta

Parameters
asome hash code
deltasome hash code
resultset to a + delta

Definition at line 182 of file crypto_hash.c.

References GNUNET_HashCode::bits.

185 {
186  int i;
187 
188  for (i = (sizeof(struct GNUNET_HashCode) / sizeof(unsigned int)) - 1; i >= 0;
189  i--)
190  result->bits[i] = delta->bits[i] + a->bits[i];
191 }
A 512-bit hashcode.
uint32_t bits[512/8/sizeof(uint32_t)]

◆ GNUNET_CRYPTO_hash_xor()

void GNUNET_CRYPTO_hash_xor ( const struct GNUNET_HashCode a,
const struct GNUNET_HashCode b,
struct GNUNET_HashCode result 
)

compute result = a ^ b

Parameters
asome hash code
bsome hash code
resultset to a ^ b
asome hash code
bsome hash code
resultset to a ^ b

Definition at line 202 of file crypto_hash.c.

References GNUNET_HashCode::bits.

Referenced by determine_id(), filter_all(), filtered_map_initialization(), GNUNET_BLOCK_mingle_hash(), initialize_map_unfiltered(), iterator_bf_reduce(), and process_sks_result().

205 {
206  int i;
207 
208  for (i = (sizeof(struct GNUNET_HashCode) / sizeof(unsigned int)) - 1; i >= 0;
209  i--)
210  result->bits[i] = a->bits[i] ^ b->bits[i];
211 }
A 512-bit hashcode.
uint32_t bits[512/8/sizeof(uint32_t)]
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_to_aes_key()

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.

Parameters
hchash code that serves to generate the key
skeyset to a valid session key
ivset to a valid initialization vector

Definition at line 222 of file crypto_hash.c.

References GNUNET_assert, GNUNET_CRYPTO_kdf(), and GNUNET_YES.

Referenced by derive_ublock_encryption_key(), encrypt_existing_match(), GNUNET_FS_handle_on_demand_block(), GNUNET_FS_tree_encoder_next(), process_result_with_request(), and try_match_block().

226 {
228  GNUNET_CRYPTO_kdf (skey, sizeof(struct
230  "Hash key derivation", strlen (
231  "Hash key derivation"),
232  hc, sizeof(struct GNUNET_HashCode),
233  NULL, 0));
235  GNUNET_CRYPTO_kdf (iv, sizeof(struct
237  "Initialization vector derivation", strlen (
238  "Initialization vector derivation"),
239  hc, sizeof(struct GNUNET_HashCode),
240  NULL, 0));
241 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A 512-bit hashcode.
int GNUNET_CRYPTO_kdf(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
Definition: crypto_kdf.c:90
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_get_bit_ltr()

int GNUNET_CRYPTO_hash_get_bit_ltr ( const struct GNUNET_HashCode code,
unsigned int  bit 
)

Obtain a bit from a hashcode.

Parameters
codethe struct GNUNET_HashCode to index bit-wise
bitindex into the hashcode, [0...159] where 0 is the leftmost bit (bytes in code interpreted big endian)
Returns
Bit bit from hashcode code, -1 for invalid index
Parameters
codethe GNUNET_CRYPTO_hash to index bit-wise
bitindex into the hashcode, [0...511] where 0 is the leftmost bit (bytes in code interpreted big endian)
Returns
Bit bit from hashcode code, -1 for invalid index

Definition at line 252 of file crypto_hash.c.

References GNUNET_assert.

Referenced by count_leading_zeroes().

254 {
255  GNUNET_assert (bit < 8 * sizeof(struct GNUNET_HashCode));
256  return (((unsigned char *) code)[bit >> 3] & (128 >> (bit & 7))) > 0;
257 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A 512-bit hashcode.
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_matching_bits()

unsigned int GNUNET_CRYPTO_hash_matching_bits ( const struct GNUNET_HashCode first,
const struct GNUNET_HashCode second 
)

Determine how many low order bits match in two struct GNUNET_HashCodes.

i.e. - 010011 and 011111 share the first two lowest order bits, and therefore the return value is two (NOT XOR distance, nor how many bits match absolutely!).

Parameters
firstthe first hashcode
secondthe hashcode to compare first to
Returns
the number of bits that match

Determine how many low order bits match in two struct GNUNET_HashCodes.

i.e. - 010011 and 011111 share the first two lowest order bits, and therefore the return value is two (NOT XOR distance, nor how many bits match absolutely!).

Parameters
firstthe first hashcode
secondthe hashcode to compare first to
Returns
the number of bits that match

Definition at line 289 of file crypto_hash.c.

References GNUNET_CRYPTO_hash_get_bit_rtl().

Referenced by find_bucket(), GDS_am_closest_peer(), GDS_DATACACHE_handle_put(), get_distance(), get_matching_bits(), handle_dht_p2p_get(), and handle_dht_p2p_put().

291 {
292  unsigned int i;
293 
294  for (i = 0; i < sizeof(struct GNUNET_HashCode) * 8; i++)
295  if (GNUNET_CRYPTO_hash_get_bit_rtl (first, i) !=
296  GNUNET_CRYPTO_hash_get_bit_rtl (second, i))
297  return i;
298  return sizeof(struct GNUNET_HashCode) * 8;
299 }
int GNUNET_CRYPTO_hash_get_bit_rtl(const struct GNUNET_HashCode *code, unsigned int bit)
Obtain a bit from a hashcode.
Definition: crypto_hash.c:268
A 512-bit hashcode.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_cmp()

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.

Parameters
h1some hash code
h2some hash code
Returns
1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
Parameters
h1some hash code
h2some hash code
Returns
1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.

Definition at line 311 of file crypto_hash.c.

Referenced by element_cmp(), find_closest(), handle_client_join(), handle_core_connect(), handle_transport_notify_connect(), op_get_element_iterator(), REGEX_BLOCK_check_proof(), and RPS_sampler_elem_next().

313 {
314  unsigned int *i1;
315  unsigned int *i2;
316  int i;
317 
318  i1 = (unsigned int *) h1;
319  i2 = (unsigned int *) h2;
320  for (i = (sizeof(struct GNUNET_HashCode) / sizeof(unsigned int)) - 1; i >= 0;
321  i--)
322  {
323  if (i1[i] > i2[i])
324  return 1;
325  if (i1[i] < i2[i])
326  return -1;
327  }
328  return 0;
329 }
A 512-bit hashcode.
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hash_xorcmp()

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).

Parameters
h1some hash code
h2some hash code
targetsome hash code
Returns
-1 if h1 is closer, 1 if h2 is closer and 0 if h1== h2.

Find out which of the two GNUNET_CRYPTO_hash codes is closer to target in the XOR metric (Kademlia).

Parameters
h1some hash code
h2some hash code
targetsome hash code
Returns
-1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2.

Definition at line 342 of file crypto_hash.c.

345 {
346  int i;
347  unsigned int d1;
348  unsigned int d2;
349 
350  for (i = sizeof(struct GNUNET_HashCode) / sizeof(unsigned int) - 1; i >= 0;
351  i--)
352  {
353  d1 = ((unsigned int *) h1)[i] ^ ((unsigned int *) target)[i];
354  d2 = ((unsigned int *) h2)[i] ^ ((unsigned int *) target)[i];
355  if (d1 > d2)
356  return 1;
357  else if (d1 < d2)
358  return -1;
359  }
360  return 0;
361 }
A 512-bit hashcode.

◆ GNUNET_CRYPTO_hmac_derive_key_v()

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.

Parameters
keyauthentication key
rkeyroot key
saltsalt
salt_lensize of the salt
argppair of void * & size_t for context chunks, terminated by NULL
keyauthentication key
rkeyroot key
saltsalt
salt_lensize of the salt
argppair of void * & size_t for context chunks, terminated by NULL

Definition at line 395 of file crypto_hash.c.

References GNUNET_CRYPTO_kdf_v(), and GNUNET_CRYPTO_AuthKey::key.

Referenced by GNUNET_CRYPTO_hmac_derive_key().

400 {
401  GNUNET_CRYPTO_kdf_v (key->key, sizeof(key->key),
402  salt, salt_len,
403  rkey, sizeof(struct GNUNET_CRYPTO_SymmetricSessionKey),
404  argp);
405 }
unsigned char key[(512/8)]
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.
int GNUNET_CRYPTO_kdf_v(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len, va_list argp)
Derive key.
Definition: crypto_kdf.c:47
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hmac_derive_key()

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.

Parameters
keyauthentication key
rkeyroot key
saltsalt
salt_lensize of the salt
...pair of void * & size_t for context chunks, terminated by NULL
keyauthentication key
rkeyroot key
saltsalt
salt_lensize of the salt
...pair of void * & size_t for context chunks, terminated by NULL

Definition at line 373 of file crypto_hash.c.

References GNUNET_CRYPTO_hmac_derive_key_v().

Referenced by derive_auth_key(), t_ax_hmac_hash(), and t_hmac().

377 {
378  va_list argp;
379 
380  va_start (argp, salt_len);
381  GNUNET_CRYPTO_hmac_derive_key_v (key, rkey, salt, salt_len, argp);
382  va_end (argp);
383 }
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.
Definition: crypto_hash.c:395
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hkdf()

int GNUNET_CRYPTO_hkdf ( void *  result,
size_t  out_len,
int  xtr_algo,
int  prf_algo,
const void *  xts,
size_t  xts_len,
const void *  skm,
size_t  skm_len,
  ... 
)

Derive key.

Parameters
resultbuffer for the derived key, allocated by caller
out_lendesired length of the derived key
xtr_algohash algorithm for the extraction phase, GCRY_MD_...
prf_algohash algorithm for the expansion phase, GCRY_MD_...
xtssalt
xts_lenlength of xts
skmsource key material
skm_lenlength of skm
...pair of void * & size_t for context chunks, terminated by NULL
Returns
GNUNET_YES on success
Parameters
resultbuffer for the derived key, allocated by caller
out_lendesired length of the derived key
xtr_algohash algorithm for the extraction phase, GCRY_MD_...
prf_algohash algorithm for the expansion phase, GCRY_MD_...
xtssalt
xts_lenlength of xts
skmsource key material
skm_lenlength of skm
Returns
GNUNET_YES on success

Definition at line 320 of file crypto_hkdf.c.

References GNUNET_CRYPTO_hkdf_v(), and ret.

Referenced by calculate_cmac(), get_iv_key(), and get_kid().

323 {
324  va_list argp;
325  int ret;
326 
327  va_start (argp, skm_len);
328  ret =
329  GNUNET_CRYPTO_hkdf_v (result, out_len, xtr_algo, prf_algo, xts, xts_len,
330  skm, skm_len, argp);
331  va_end (argp);
332 
333  return ret;
334 }
int GNUNET_CRYPTO_hkdf_v(void *result, size_t out_len, int xtr_algo, int prf_algo, const void *xts, size_t xts_len, const void *skm, size_t skm_len, va_list argp)
Derive key.
Definition: crypto_hkdf.c:144
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static int result
Global testing status.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_hkdf_v()

int GNUNET_CRYPTO_hkdf_v ( void *  result,
size_t  out_len,
int  xtr_algo,
int  prf_algo,
const void *  xts,
size_t  xts_len,
const void *  skm,
size_t  skm_len,
va_list  argp 
)

Derive key.

Parameters
resultbuffer for the derived key, allocated by caller
out_lendesired length of the derived key
xtr_algohash algorithm for the extraction phase, GCRY_MD_...
prf_algohash algorithm for the expansion phase, GCRY_MD_...
xtssalt
xts_lenlength of xts
skmsource key material
skm_lenlength of skm
argpva_list of void * & size_t pairs for context chunks
Returns
GNUNET_YES on success

Definition at line 144 of file crypto_hkdf.c.

References gnunet-chk::args, BENCHMARK_END, BENCHMARK_START, ctx, doHMAC(), dump, getPRK(), GNUNET_break, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_SYSERR, GNUNET_YES, len, ret, and t.

Referenced by GNUNET_CRYPTO_hkdf(), and GNUNET_CRYPTO_kdf_v().

147 {
148  gcry_md_hd_t xtr;
149  gcry_md_hd_t prf;
150  const void *hc;
151  unsigned long i;
152  unsigned long t;
153  unsigned long d;
154  unsigned int k = gcry_md_get_algo_dlen (prf_algo);
155  unsigned int xtr_len = gcry_md_get_algo_dlen (xtr_algo);
156  char prk[xtr_len];
157  int ret;
158  size_t ctx_len;
159  va_list args;
160 
161  BENCHMARK_START (hkdf);
162 
163  if (0 == k)
164  return GNUNET_SYSERR;
165  if (GPG_ERR_NO_ERROR !=
166  gcry_md_open (&xtr, xtr_algo, GCRY_MD_FLAG_HMAC))
167  return GNUNET_SYSERR;
168  if (GPG_ERR_NO_ERROR !=
169  gcry_md_open (&prf, prf_algo, GCRY_MD_FLAG_HMAC))
170  {
171  gcry_md_close (xtr);
172  return GNUNET_SYSERR;
173  }
174  va_copy (args, argp);
175 
176  ctx_len = 0;
177  while (NULL != va_arg (args, void *))
178  {
179  size_t nxt = va_arg (args, size_t);
180  if (nxt + ctx_len < nxt)
181  {
182  /* integer overflow */
183  GNUNET_break (0);
184  va_end (args);
185  goto hkdf_error;
186  }
187  ctx_len += nxt;
188  }
189 
190  va_end (args);
191 
192  if ( (k + ctx_len < ctx_len) ||
193  (k + ctx_len + 1 < ctx_len) )
194  {
195  /* integer overflow */
196  GNUNET_break (0);
197  goto hkdf_error;
198  }
199 
200  memset (result, 0, out_len);
201  if (getPRK (xtr, xts, xts_len, skm, skm_len, prk) != GNUNET_YES)
202  goto hkdf_error;
203 #if DEBUG_HKDF
204  dump ("PRK", prk, xtr_len);
205 #endif
206 
207  t = out_len / k;
208  d = out_len % k;
209 
210  /* K(1) */
211  {
212  size_t plain_len = k + ctx_len + 1;
213  char *plain;
214  const void *ctx;
215  char *dst;
216 
217  plain = GNUNET_malloc (plain_len);
218  dst = plain + k;
219  va_copy (args, argp);
220  while ((ctx = va_arg (args, void *)))
221  {
222  size_t len;
223 
224  len = va_arg (args, size_t);
225  GNUNET_memcpy (dst, ctx, len);
226  dst += len;
227  }
228  va_end (args);
229 
230  if (t > 0)
231  {
232  plain[k + ctx_len] = (char) 1;
233 #if DEBUG_HKDF
234  dump ("K(1)", plain, plain_len);
235 #endif
236  hc = doHMAC (prf, prk, xtr_len, &plain[k], ctx_len + 1);
237  if (hc == NULL)
238  {
239  GNUNET_free (plain);
240  goto hkdf_error;
241  }
242  GNUNET_memcpy (result, hc, k);
243  result += k;
244  }
245 
246  /* K(i+1) */
247  for (i = 1; i < t; i++)
248  {
249  GNUNET_memcpy (plain, result - k, k);
250  plain[k + ctx_len] = (char) (i + 1);
251  gcry_md_reset (prf);
252 #if DEBUG_HKDF
253  dump ("K(i+1)", plain, plain_len);
254 #endif
255  hc = doHMAC (prf, prk, xtr_len, plain, plain_len);
256  if (hc == NULL)
257  {
258  GNUNET_free (plain);
259  goto hkdf_error;
260  }
261  GNUNET_memcpy (result, hc, k);
262  result += k;
263  }
264 
265  /* K(t):d */
266  if (d > 0)
267  {
268  if (t > 0)
269  {
270  GNUNET_memcpy (plain, result - k, k);
271  i++;
272  }
273  plain[k + ctx_len] = (char) i;
274  gcry_md_reset (prf);
275 #if DEBUG_HKDF
276  dump ("K(t):d", plain, plain_len);
277 #endif
278  if (t > 0)
279  hc = doHMAC (prf, prk, xtr_len, plain, plain_len);
280  else
281  hc = doHMAC (prf, prk, xtr_len, plain + k, plain_len - k);
282  if (hc == NULL)
283  {
284  GNUNET_free (plain);
285  goto hkdf_error;
286  }
287  GNUNET_memcpy (result, hc, d);
288  }
289 #if DEBUG_HKDF
290  dump ("result", result - k, out_len);
291 #endif
292 
293  ret = GNUNET_YES;
294  GNUNET_free (plain);
295  goto hkdf_ok;
296  }
297 hkdf_error:
298  ret = GNUNET_SYSERR;
299 hkdf_ok:
300  gcry_md_close (xtr);
301  gcry_md_close (prf);
302  BENCHMARK_END (hkdf);
303  return ret;
304 }
#define BENCHMARK_START(opname)
Definition: benchmark.h:57
#define BENCHMARK_END(opname)
Definition: benchmark.h:58
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_SCHEDULER_Task * t
Main task.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static int result
Global testing status.
static const void * doHMAC(gcry_md_hd_t mac, const void *key, size_t key_len, const void *buf, size_t buf_len)
Compute the HMAC.
Definition: crypto_hkdf.c:77
static int getPRK(gcry_md_hd_t mac, const void *xts, size_t xts_len, const void *skm, size_t skm_len, void *prk)
Generate pseudo-random key.
Definition: crypto_hkdf.c:98
static int dump
Dump the database.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_kdf()

int GNUNET_CRYPTO_kdf ( void *  result,
size_t  out_len,
const void *  xts,
size_t  xts_len,
const void *  skm,
size_t  skm_len,
  ... 
)

Derive key.

Parameters
resultbuffer for the derived key, allocated by caller
out_lendesired length of the derived key
xtssalt
xts_lenlength of xts
skmsource key material
skm_lenlength of skm
...void * & size_t pairs for context chunks
Returns
GNUNET_YES on success

Definition at line 90 of file crypto_kdf.c.

References GNUNET_CRYPTO_kdf_v(), and ret.

Referenced by compute_global_id(), derive_aes_key(), derive_block_aes_key(), derive_h(), derive_ublock_encryption_key(), dv_setup_key_state_from_km(), get_ibf_key(), GNUNET_CRYPTO_hash_to_aes_key(), GNUNET_CRYPTO_kdf_mod_mpi(), hash_from_share_val(), run(), setup_cipher(), t_ax_decrypt_and_validate(), t_ax_encrypt(), t_hmac_derive_key(), and update_ax_by_kx().

96 {
97  va_list argp;
98  int ret;
99 
100  va_start (argp, skm_len);
102  out_len,
103  xts,
104  xts_len,
105  skm,
106  skm_len,
107  argp);
108  va_end (argp);
109 
110  return ret;
111 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
int GNUNET_CRYPTO_kdf_v(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len, va_list argp)
Derive key.
Definition: crypto_kdf.c:47
static int result
Global testing status.
Here is the call graph for this function:
Here is the caller graph for this function: