#include "gnunet_disk_lib.h"
#include <gcrypt.h>
+#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+
+#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
/**
* Hash block of given size.
*/
GNUNET_SCHEDULER_TaskIdentifier task;
+ /**
+ * Priority we use.
+ */
+ enum GNUNET_SCHEDULER_Priority priority;
+
/**
* Blocksize.
*/
delta = fhc->fsize - fhc->offset;
if (delta != GNUNET_DISK_file_read (fhc->fh, fhc->buffer, delta))
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", fhc->filename);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "read", fhc->filename);
file_hash_finish (fhc, NULL);
return;
}
file_hash_finish (fhc, res);
return;
}
- fhc->task = GNUNET_SCHEDULER_add_now (&file_hash_task, fhc);
+ fhc->task = GNUNET_SCHEDULER_add_with_priority (fhc->priority,
+ &file_hash_task, fhc);
}
*/
struct GNUNET_CRYPTO_FileHashContext *
GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority,
- const char *filename,
- size_t blocksize,
+ const char *filename, size_t blocksize,
GNUNET_CRYPTO_HashCompletedCallback callback,
void *callback_cls)
{
GNUNET_free (fhc);
return NULL;
}
- fhc->fh = GNUNET_DISK_file_open (filename,
- GNUNET_DISK_OPEN_READ,
- GNUNET_DISK_PERM_NONE);
+ fhc->fh =
+ GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_NONE);
if (!fhc->fh)
{
GNUNET_free (fhc->filename);
GNUNET_free (fhc);
return NULL;
}
- fhc->task
- = GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc);
+ fhc->priority = priority;
+ fhc->task =
+ GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc);
return fhc;
}
* 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.
- *
+ *
* @param a some hash code
* @param b some hash code
* @return a positive number which is a measure for
void
-GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a,
- const GNUNET_HashCode * b, GNUNET_HashCode * result)
+GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, const GNUNET_HashCode * b,
+ GNUNET_HashCode * result)
{
int i;
void
GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
const struct GNUNET_CRYPTO_AesSessionKey *rkey,
- const void *salt,
- size_t salt_len, va_list argp)
+ const void *salt, size_t salt_len,
+ va_list argp)
{
- GNUNET_CRYPTO_kdf_v (key->key,
- sizeof (key->key),
- salt, salt_len, rkey->key, sizeof (rkey->key), argp);
+ GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key), salt, salt_len, rkey->key,
+ sizeof (rkey->key), argp);
}
*/
void
GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key,
- const void *plaintext,
- size_t plaintext_len, GNUNET_HashCode * hmac)
+ const void *plaintext, size_t plaintext_len,
+ GNUNET_HashCode * hmac)
{
gcry_md_hd_t md;
const unsigned char *mc;
- GNUNET_assert (GPG_ERR_NO_ERROR == gcry_md_open (&md,
- GCRY_MD_SHA512,
- GCRY_MD_FLAG_HMAC));
+ GNUNET_assert (GPG_ERR_NO_ERROR ==
+ gcry_md_open (&md, GCRY_MD_SHA512, GCRY_MD_FLAG_HMAC));
gcry_md_setkey (md, key->key, sizeof (key->key));
gcry_md_write (md, plaintext, plaintext_len);
mc = gcry_md_read (md, GCRY_MD_SHA512);