aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crypto_hash.c')
-rw-r--r--src/util/crypto_hash.c214
1 files changed, 103 insertions, 111 deletions
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index b8c9a8082..2ab682494 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -119,14 +119,14 @@ struct GNUNET_CRYPTO_FileHashContext
119 */ 119 */
120static void 120static void
121file_hash_finish (struct GNUNET_CRYPTO_FileHashContext *fhc, 121file_hash_finish (struct GNUNET_CRYPTO_FileHashContext *fhc,
122 const GNUNET_HashCode * res) 122 const GNUNET_HashCode * res)
123{ 123{
124 fhc->callback (fhc->callback_cls, res); 124 fhc->callback (fhc->callback_cls, res);
125 GNUNET_free (fhc->filename); 125 GNUNET_free (fhc->filename);
126 if (!GNUNET_DISK_handle_invalid (fhc->fh)) 126 if (!GNUNET_DISK_handle_invalid (fhc->fh))
127 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh)); 127 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh));
128 gcry_md_close (fhc->md); 128 gcry_md_close (fhc->md);
129 GNUNET_free (fhc); /* also frees fhc->buffer */ 129 GNUNET_free (fhc); /* also frees fhc->buffer */
130} 130}
131 131
132 132
@@ -149,19 +149,19 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
149 if (fhc->fsize - fhc->offset < delta) 149 if (fhc->fsize - fhc->offset < delta)
150 delta = fhc->fsize - fhc->offset; 150 delta = fhc->fsize - fhc->offset;
151 if (delta != GNUNET_DISK_file_read (fhc->fh, fhc->buffer, delta)) 151 if (delta != GNUNET_DISK_file_read (fhc->fh, fhc->buffer, delta))
152 { 152 {
153 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "read", fhc->filename); 153 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "read", fhc->filename);
154 file_hash_finish (fhc, NULL); 154 file_hash_finish (fhc, NULL);
155 return; 155 return;
156 } 156 }
157 gcry_md_write (fhc->md, fhc->buffer, delta); 157 gcry_md_write (fhc->md, fhc->buffer, delta);
158 fhc->offset += delta; 158 fhc->offset += delta;
159 if (fhc->offset == fhc->fsize) 159 if (fhc->offset == fhc->fsize)
160 { 160 {
161 res = (GNUNET_HashCode *) gcry_md_read (fhc->md, GCRY_MD_SHA512); 161 res = (GNUNET_HashCode *) gcry_md_read (fhc->md, GCRY_MD_SHA512);
162 file_hash_finish (fhc, res); 162 file_hash_finish (fhc, res);
163 return; 163 return;
164 } 164 }
165 fhc->task = GNUNET_SCHEDULER_add_now (&file_hash_task, fhc); 165 fhc->task = GNUNET_SCHEDULER_add_now (&file_hash_task, fhc);
166} 166}
167 167
@@ -178,43 +178,43 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
178 */ 178 */
179struct GNUNET_CRYPTO_FileHashContext * 179struct GNUNET_CRYPTO_FileHashContext *
180GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, 180GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority,
181 const char *filename, size_t blocksize, 181 const char *filename, size_t blocksize,
182 GNUNET_CRYPTO_HashCompletedCallback callback, 182 GNUNET_CRYPTO_HashCompletedCallback callback,
183 void *callback_cls) 183 void *callback_cls)
184{ 184{
185 struct GNUNET_CRYPTO_FileHashContext *fhc; 185 struct GNUNET_CRYPTO_FileHashContext *fhc;
186 186
187 GNUNET_assert (blocksize > 0); 187 GNUNET_assert (blocksize > 0);
188 fhc = 188 fhc =
189 GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize); 189 GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_FileHashContext) + blocksize);
190 fhc->callback = callback; 190 fhc->callback = callback;
191 fhc->callback_cls = callback_cls; 191 fhc->callback_cls = callback_cls;
192 fhc->buffer = (unsigned char *) &fhc[1]; 192 fhc->buffer = (unsigned char *) &fhc[1];
193 fhc->filename = GNUNET_strdup (filename); 193 fhc->filename = GNUNET_strdup (filename);
194 if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0)) 194 if (GPG_ERR_NO_ERROR != gcry_md_open (&fhc->md, GCRY_MD_SHA512, 0))
195 { 195 {
196 GNUNET_break (0); 196 GNUNET_break (0);
197 GNUNET_free (fhc); 197 GNUNET_free (fhc);
198 return NULL; 198 return NULL;
199 } 199 }
200 fhc->bsize = blocksize; 200 fhc->bsize = blocksize;
201 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fhc->fsize, GNUNET_NO)) 201 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fhc->fsize, GNUNET_NO))
202 { 202 {
203 GNUNET_free (fhc->filename); 203 GNUNET_free (fhc->filename);
204 GNUNET_free (fhc); 204 GNUNET_free (fhc);
205 return NULL; 205 return NULL;
206 } 206 }
207 fhc->fh = 207 fhc->fh =
208 GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, 208 GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
209 GNUNET_DISK_PERM_NONE); 209 GNUNET_DISK_PERM_NONE);
210 if (!fhc->fh) 210 if (!fhc->fh)
211 { 211 {
212 GNUNET_free (fhc->filename); 212 GNUNET_free (fhc->filename);
213 GNUNET_free (fhc); 213 GNUNET_free (fhc);
214 return NULL; 214 return NULL;
215 } 215 }
216 fhc->task = 216 fhc->task =
217 GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); 217 GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc);
218 return fhc; 218 return fhc;
219} 219}
220 220
@@ -260,7 +260,7 @@ getValue__ (unsigned char a)
260 */ 260 */
261void 261void
262GNUNET_CRYPTO_hash_to_enc (const GNUNET_HashCode * block, 262GNUNET_CRYPTO_hash_to_enc (const GNUNET_HashCode * block,
263 struct GNUNET_CRYPTO_HashAsciiEncoded *result) 263 struct GNUNET_CRYPTO_HashAsciiEncoded *result)
264{ 264{
265 /** 265 /**
266 * 32 characters for encoding (GNUNET_CRYPTO_hash => 32 characters) 266 * 32 characters for encoding (GNUNET_CRYPTO_hash => 32 characters)
@@ -278,23 +278,22 @@ GNUNET_CRYPTO_hash_to_enc (const GNUNET_HashCode * block,
278 rpos = 0; 278 rpos = 0;
279 bits = 0; 279 bits = 0;
280 while ((rpos < sizeof (GNUNET_HashCode)) || (vbit > 0)) 280 while ((rpos < sizeof (GNUNET_HashCode)) || (vbit > 0))
281 {
282 if ((rpos < sizeof (GNUNET_HashCode)) && (vbit < 5))
283 {
284 bits = (bits << 8) | ((unsigned char *) block)[rpos++]; /* eat 8 more bits */
285 vbit += 8;
286 }
287 if (vbit < 5)
281 { 288 {
282 if ((rpos < sizeof (GNUNET_HashCode)) && (vbit < 5)) 289 bits <<= (5 - vbit); /* zero-padding */
283 { 290 GNUNET_assert (vbit == 2); /* padding by 3: 512+3 mod 5 == 0 */
284 bits = (bits << 8) | ((unsigned char *) block)[rpos++]; /* eat 8 more bits */ 291 vbit = 5;
285 vbit += 8;
286 }
287 if (vbit < 5)
288 {
289 bits <<= (5 - vbit); /* zero-padding */
290 GNUNET_assert (vbit == 2); /* padding by 3: 512+3 mod 5 == 0 */
291 vbit = 5;
292 }
293 GNUNET_assert (wpos <
294 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1);
295 result->encoding[wpos++] = encTable__[(bits >> (vbit - 5)) & 31];
296 vbit -= 5;
297 } 292 }
293 GNUNET_assert (wpos < sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1);
294 result->encoding[wpos++] = encTable__[(bits >> (vbit - 5)) & 31];
295 vbit -= 5;
296 }
298 GNUNET_assert (wpos == sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1); 297 GNUNET_assert (wpos == sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1);
299 GNUNET_assert (vbit == 0); 298 GNUNET_assert (vbit == 0);
300 result->encoding[wpos] = '\0'; 299 result->encoding[wpos] = '\0';
@@ -318,22 +317,22 @@ GNUNET_CRYPTO_hash_from_string (const char *enc, GNUNET_HashCode * result)
318 if (strlen (enc) != sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1) 317 if (strlen (enc) != sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1)
319 return GNUNET_SYSERR; 318 return GNUNET_SYSERR;
320 319
321 vbit = 2; /* padding! */ 320 vbit = 2; /* padding! */
322 wpos = sizeof (GNUNET_HashCode); 321 wpos = sizeof (GNUNET_HashCode);
323 rpos = sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1; 322 rpos = sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1;
324 bits = getValue__ (enc[--rpos]) >> 3; 323 bits = getValue__ (enc[--rpos]) >> 3;
325 while (wpos > 0) 324 while (wpos > 0)
325 {
326 GNUNET_assert (rpos > 0);
327 bits = (getValue__ (enc[--rpos]) << vbit) | bits;
328 vbit += 5;
329 if (vbit >= 8)
326 { 330 {
327 GNUNET_assert (rpos > 0); 331 ((unsigned char *) result)[--wpos] = (unsigned char) bits;
328 bits = (getValue__ (enc[--rpos]) << vbit) | bits; 332 bits >>= 8;
329 vbit += 5; 333 vbit -= 8;
330 if (vbit >= 8)
331 {
332 ((unsigned char *) result)[--wpos] = (unsigned char) bits;
333 bits >>= 8;
334 vbit -= 8;
335 }
336 } 334 }
335 }
337 GNUNET_assert (rpos == 0); 336 GNUNET_assert (rpos == 0);
338 GNUNET_assert (vbit == 0); 337 GNUNET_assert (vbit == 0);
339 return GNUNET_OK; 338 return GNUNET_OK;
@@ -352,7 +351,7 @@ GNUNET_CRYPTO_hash_from_string (const char *enc, GNUNET_HashCode * result)
352 */ 351 */
353unsigned int 352unsigned int
354GNUNET_CRYPTO_hash_distance_u32 (const GNUNET_HashCode * a, 353GNUNET_CRYPTO_hash_distance_u32 (const GNUNET_HashCode * a,
355 const GNUNET_HashCode * b) 354 const GNUNET_HashCode * b)
356{ 355{
357 unsigned int x1 = (a->bits[1] - b->bits[1]) >> 16; 356 unsigned int x1 = (a->bits[1] - b->bits[1]) >> 16;
358 unsigned int x2 = (b->bits[1] - a->bits[1]) >> 16; 357 unsigned int x2 = (b->bits[1] - a->bits[1]) >> 16;
@@ -362,7 +361,7 @@ GNUNET_CRYPTO_hash_distance_u32 (const GNUNET_HashCode * a,
362 361
363void 362void
364GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, 363GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode,
365 GNUNET_HashCode * result) 364 GNUNET_HashCode * result)
366{ 365{
367 int i; 366 int i;
368 367
@@ -372,37 +371,33 @@ GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode,
372 371
373void 372void
374GNUNET_CRYPTO_hash_difference (const GNUNET_HashCode * a, 373GNUNET_CRYPTO_hash_difference (const GNUNET_HashCode * a,
375 const GNUNET_HashCode * b, 374 const GNUNET_HashCode * b,
376 GNUNET_HashCode * result) 375 GNUNET_HashCode * result)
377{ 376{
378 int i; 377 int i;
379 378
380 for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0; 379 for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0; i--)
381 i--)
382 result->bits[i] = b->bits[i] - a->bits[i]; 380 result->bits[i] = b->bits[i] - a->bits[i];
383} 381}
384 382
385void 383void
386GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a, 384GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a,
387 const GNUNET_HashCode * delta, 385 const GNUNET_HashCode * delta, GNUNET_HashCode * result)
388 GNUNET_HashCode * result)
389{ 386{
390 int i; 387 int i;
391 388
392 for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0; 389 for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0; i--)
393 i--)
394 result->bits[i] = delta->bits[i] + a->bits[i]; 390 result->bits[i] = delta->bits[i] + a->bits[i];
395} 391}
396 392
397 393
398void 394void
399GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, const GNUNET_HashCode * b, 395GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, const GNUNET_HashCode * b,
400 GNUNET_HashCode * result) 396 GNUNET_HashCode * result)
401{ 397{
402 int i; 398 int i;
403 399
404 for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0; 400 for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0; i--)
405 i--)
406 result->bits[i] = a->bits[i] ^ b->bits[i]; 401 result->bits[i] = a->bits[i] ^ b->bits[i];
407} 402}
408 403
@@ -412,18 +407,17 @@ GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, const GNUNET_HashCode * b,
412 */ 407 */
413void 408void
414GNUNET_CRYPTO_hash_to_aes_key (const GNUNET_HashCode * hc, 409GNUNET_CRYPTO_hash_to_aes_key (const GNUNET_HashCode * hc,
415 struct GNUNET_CRYPTO_AesSessionKey *skey, 410 struct GNUNET_CRYPTO_AesSessionKey *skey,
416 struct GNUNET_CRYPTO_AesInitializationVector 411 struct GNUNET_CRYPTO_AesInitializationVector *iv)
417 *iv)
418{ 412{
419 GNUNET_assert (sizeof (GNUNET_HashCode) >= 413 GNUNET_assert (sizeof (GNUNET_HashCode) >=
420 GNUNET_CRYPTO_AES_KEY_LENGTH + 414 GNUNET_CRYPTO_AES_KEY_LENGTH +
421 sizeof (struct GNUNET_CRYPTO_AesInitializationVector)); 415 sizeof (struct GNUNET_CRYPTO_AesInitializationVector));
422 memcpy (skey, hc, GNUNET_CRYPTO_AES_KEY_LENGTH); 416 memcpy (skey, hc, GNUNET_CRYPTO_AES_KEY_LENGTH);
423 skey->crc32 = 417 skey->crc32 =
424 htonl (GNUNET_CRYPTO_crc32_n (skey, GNUNET_CRYPTO_AES_KEY_LENGTH)); 418 htonl (GNUNET_CRYPTO_crc32_n (skey, GNUNET_CRYPTO_AES_KEY_LENGTH));
425 memcpy (iv, &((char *) hc)[GNUNET_CRYPTO_AES_KEY_LENGTH], 419 memcpy (iv, &((char *) hc)[GNUNET_CRYPTO_AES_KEY_LENGTH],
426 sizeof (struct GNUNET_CRYPTO_AesInitializationVector)); 420 sizeof (struct GNUNET_CRYPTO_AesInitializationVector));
427} 421}
428 422
429 423
@@ -454,13 +448,13 @@ GNUNET_CRYPTO_hash_get_bit (const GNUNET_HashCode * code, unsigned int bit)
454 */ 448 */
455unsigned int 449unsigned int
456GNUNET_CRYPTO_hash_matching_bits (const GNUNET_HashCode * first, 450GNUNET_CRYPTO_hash_matching_bits (const GNUNET_HashCode * first,
457 const GNUNET_HashCode * second) 451 const GNUNET_HashCode * second)
458{ 452{
459 unsigned int i; 453 unsigned int i;
460 454
461 for (i = 0; i < sizeof (GNUNET_HashCode) * 8; i++) 455 for (i = 0; i < sizeof (GNUNET_HashCode) * 8; i++)
462 if (GNUNET_CRYPTO_hash_get_bit (first, i) != 456 if (GNUNET_CRYPTO_hash_get_bit (first, i) !=
463 GNUNET_CRYPTO_hash_get_bit (second, i)) 457 GNUNET_CRYPTO_hash_get_bit (second, i))
464 return i; 458 return i;
465 return sizeof (GNUNET_HashCode) * 8; 459 return sizeof (GNUNET_HashCode) * 8;
466} 460}
@@ -472,8 +466,7 @@ GNUNET_CRYPTO_hash_matching_bits (const GNUNET_HashCode * first,
472 * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2. 466 * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
473 */ 467 */
474int 468int
475GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1, 469GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1, const GNUNET_HashCode * h2)
476 const GNUNET_HashCode * h2)
477{ 470{
478 unsigned int *i1; 471 unsigned int *i1;
479 unsigned int *i2; 472 unsigned int *i2;
@@ -481,14 +474,13 @@ GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1,
481 474
482 i1 = (unsigned int *) h1; 475 i1 = (unsigned int *) h1;
483 i2 = (unsigned int *) h2; 476 i2 = (unsigned int *) h2;
484 for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0; 477 for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0; i--)
485 i--) 478 {
486 { 479 if (i1[i] > i2[i])
487 if (i1[i] > i2[i]) 480 return 1;
488 return 1; 481 if (i1[i] < i2[i])
489 if (i1[i] < i2[i]) 482 return -1;
490 return -1; 483 }
491 }
492 return 0; 484 return 0;
493} 485}
494 486
@@ -500,22 +492,22 @@ GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1,
500 */ 492 */
501int 493int
502GNUNET_CRYPTO_hash_xorcmp (const GNUNET_HashCode * h1, 494GNUNET_CRYPTO_hash_xorcmp (const GNUNET_HashCode * h1,
503 const GNUNET_HashCode * h2, 495 const GNUNET_HashCode * h2,
504 const GNUNET_HashCode * target) 496 const GNUNET_HashCode * target)
505{ 497{
506 int i; 498 int i;
507 unsigned int d1; 499 unsigned int d1;
508 unsigned int d2; 500 unsigned int d2;
509 501
510 for (i = sizeof (GNUNET_HashCode) / sizeof (unsigned int) - 1; i >= 0; i--) 502 for (i = sizeof (GNUNET_HashCode) / sizeof (unsigned int) - 1; i >= 0; i--)
511 { 503 {
512 d1 = ((unsigned int *) h1)[i] ^ ((unsigned int *) target)[i]; 504 d1 = ((unsigned int *) h1)[i] ^ ((unsigned int *) target)[i];
513 d2 = ((unsigned int *) h2)[i] ^ ((unsigned int *) target)[i]; 505 d2 = ((unsigned int *) h2)[i] ^ ((unsigned int *) target)[i];
514 if (d1 > d2) 506 if (d1 > d2)
515 return 1; 507 return 1;
516 else if (d1 < d2) 508 else if (d1 < d2)
517 return -1; 509 return -1;
518 } 510 }
519 return 0; 511 return 0;
520} 512}
521 513
@@ -530,8 +522,8 @@ GNUNET_CRYPTO_hash_xorcmp (const GNUNET_HashCode * h1,
530 */ 522 */
531void 523void
532GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, 524GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
533 const struct GNUNET_CRYPTO_AesSessionKey *rkey, 525 const struct GNUNET_CRYPTO_AesSessionKey *rkey,
534 const void *salt, size_t salt_len, ...) 526 const void *salt, size_t salt_len, ...)
535{ 527{
536 va_list argp; 528 va_list argp;
537 529
@@ -551,12 +543,12 @@ GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
551 */ 543 */
552void 544void
553GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, 545GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
554 const struct GNUNET_CRYPTO_AesSessionKey 546 const struct GNUNET_CRYPTO_AesSessionKey *rkey,
555 *rkey, const void *salt, size_t salt_len, 547 const void *salt, size_t salt_len,
556 va_list argp) 548 va_list argp)
557{ 549{
558 GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key), salt, salt_len, rkey->key, 550 GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key), salt, salt_len, rkey->key,
559 sizeof (rkey->key), argp); 551 sizeof (rkey->key), argp);
560} 552}
561 553
562 554
@@ -570,14 +562,14 @@ GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
570 */ 562 */
571void 563void
572GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, 564GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key,
573 const void *plaintext, size_t plaintext_len, 565 const void *plaintext, size_t plaintext_len,
574 GNUNET_HashCode * hmac) 566 GNUNET_HashCode * hmac)
575{ 567{
576 gcry_md_hd_t md; 568 gcry_md_hd_t md;
577 const unsigned char *mc; 569 const unsigned char *mc;
578 570
579 GNUNET_assert (GPG_ERR_NO_ERROR == 571 GNUNET_assert (GPG_ERR_NO_ERROR ==
580 gcry_md_open (&md, GCRY_MD_SHA512, GCRY_MD_FLAG_HMAC)); 572 gcry_md_open (&md, GCRY_MD_SHA512, GCRY_MD_FLAG_HMAC));
581 gcry_md_setkey (md, key->key, sizeof (key->key)); 573 gcry_md_setkey (md, key->key, sizeof (key->key));
582 gcry_md_write (md, plaintext, plaintext_len); 574 gcry_md_write (md, plaintext, plaintext_len);
583 mc = gcry_md_read (md, GCRY_MD_SHA512); 575 mc = gcry_md_read (md, GCRY_MD_SHA512);