diff options
Diffstat (limited to 'src/util/crypto_hash.c')
-rw-r--r-- | src/util/crypto_hash.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index c693ed081..6438784ba 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -175,8 +175,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
175 | */ | 175 | */ |
176 | struct GNUNET_CRYPTO_FileHashContext * | 176 | struct GNUNET_CRYPTO_FileHashContext * |
177 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | 177 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, |
178 | const char *filename, | 178 | const char *filename, size_t blocksize, |
179 | size_t blocksize, | ||
180 | GNUNET_CRYPTO_HashCompletedCallback callback, | 179 | GNUNET_CRYPTO_HashCompletedCallback callback, |
181 | void *callback_cls) | 180 | void *callback_cls) |
182 | { | 181 | { |
@@ -202,17 +201,17 @@ GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | |||
202 | GNUNET_free (fhc); | 201 | GNUNET_free (fhc); |
203 | return NULL; | 202 | return NULL; |
204 | } | 203 | } |
205 | fhc->fh = GNUNET_DISK_file_open (filename, | 204 | fhc->fh = |
206 | GNUNET_DISK_OPEN_READ, | 205 | GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, |
207 | GNUNET_DISK_PERM_NONE); | 206 | GNUNET_DISK_PERM_NONE); |
208 | if (!fhc->fh) | 207 | if (!fhc->fh) |
209 | { | 208 | { |
210 | GNUNET_free (fhc->filename); | 209 | GNUNET_free (fhc->filename); |
211 | GNUNET_free (fhc); | 210 | GNUNET_free (fhc); |
212 | return NULL; | 211 | return NULL; |
213 | } | 212 | } |
214 | fhc->task | 213 | fhc->task = |
215 | = GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); | 214 | GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); |
216 | return fhc; | 215 | return fhc; |
217 | } | 216 | } |
218 | 217 | ||
@@ -390,8 +389,8 @@ GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a, | |||
390 | 389 | ||
391 | 390 | ||
392 | void | 391 | void |
393 | GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, | 392 | GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, const GNUNET_HashCode * b, |
394 | const GNUNET_HashCode * b, GNUNET_HashCode * result) | 393 | GNUNET_HashCode * result) |
395 | { | 394 | { |
396 | int i; | 395 | int i; |
397 | 396 | ||
@@ -542,12 +541,11 @@ GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, | |||
542 | void | 541 | void |
543 | GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, | 542 | GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, |
544 | const struct GNUNET_CRYPTO_AesSessionKey *rkey, | 543 | const struct GNUNET_CRYPTO_AesSessionKey *rkey, |
545 | const void *salt, | 544 | const void *salt, size_t salt_len, |
546 | size_t salt_len, va_list argp) | 545 | va_list argp) |
547 | { | 546 | { |
548 | GNUNET_CRYPTO_kdf_v (key->key, | 547 | GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key), salt, salt_len, rkey->key, |
549 | sizeof (key->key), | 548 | sizeof (rkey->key), argp); |
550 | salt, salt_len, rkey->key, sizeof (rkey->key), argp); | ||
551 | } | 549 | } |
552 | 550 | ||
553 | 551 | ||
@@ -561,15 +559,14 @@ GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, | |||
561 | */ | 559 | */ |
562 | void | 560 | void |
563 | GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | 561 | GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, |
564 | const void *plaintext, | 562 | const void *plaintext, size_t plaintext_len, |
565 | size_t plaintext_len, GNUNET_HashCode * hmac) | 563 | GNUNET_HashCode * hmac) |
566 | { | 564 | { |
567 | gcry_md_hd_t md; | 565 | gcry_md_hd_t md; |
568 | const unsigned char *mc; | 566 | const unsigned char *mc; |
569 | 567 | ||
570 | GNUNET_assert (GPG_ERR_NO_ERROR == gcry_md_open (&md, | 568 | GNUNET_assert (GPG_ERR_NO_ERROR == |
571 | GCRY_MD_SHA512, | 569 | gcry_md_open (&md, GCRY_MD_SHA512, GCRY_MD_FLAG_HMAC)); |
572 | GCRY_MD_FLAG_HMAC)); | ||
573 | gcry_md_setkey (md, key->key, sizeof (key->key)); | 570 | gcry_md_setkey (md, key->key, sizeof (key->key)); |
574 | gcry_md_write (md, plaintext, plaintext_len); | 571 | gcry_md_write (md, plaintext, plaintext_len); |
575 | mc = gcry_md_read (md, GCRY_MD_SHA512); | 572 | mc = gcry_md_read (md, GCRY_MD_SHA512); |