aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/lgl/gc-libgcrypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/https/lgl/gc-libgcrypt.c')
-rw-r--r--src/daemon/https/lgl/gc-libgcrypt.c157
1 files changed, 0 insertions, 157 deletions
diff --git a/src/daemon/https/lgl/gc-libgcrypt.c b/src/daemon/https/lgl/gc-libgcrypt.c
index 9d91c45c..3653f0fc 100644
--- a/src/daemon/https/lgl/gc-libgcrypt.c
+++ b/src/daemon/https/lgl/gc-libgcrypt.c
@@ -416,163 +416,6 @@ MHD_gc_hash_close (MHD_gc_hash_handle handle)
416 free (ctx); 416 free (ctx);
417} 417}
418 418
419Gc_rc
420MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
421{
422 int gcryalg;
423
424 switch (hash)
425 {
426#ifdef GNULIB_GC_MD5
427 case GC_MD5:
428 gcryalg = GCRY_MD_MD5;
429 break;
430#endif
431
432#ifdef GNULIB_GC_SHA1
433 case GC_SHA1:
434 gcryalg = GCRY_MD_SHA1;
435 break;
436#endif
437
438#ifdef GNULIB_GC_SHA256
439 case GC_SHA256:
440 gcryalg = GCRY_MD_SHA256;
441 break;
442#endif
443
444#ifdef GNULIB_GC_SHA384
445 case GC_SHA384:
446 gcryalg = GCRY_MD_SHA384;
447 break;
448#endif
449
450#ifdef GNULIB_GC_SHA512
451 case GC_SHA512:
452 gcryalg = GCRY_MD_SHA512;
453 break;
454#endif
455
456#ifdef GNULIB_GC_RMD160
457 case GC_RMD160:
458 gcryalg = GCRY_MD_RMD160;
459 break;
460#endif
461
462 default:
463 return GC_INVALID_HASH;
464 }
465
466 gcry_md_hash_buffer (gcryalg, resbuf, in, inlen);
467
468 return GC_OK;
469}
470
471/* One-call interface. */
472#ifdef GNULIB_GC_MD5
473Gc_rc
474MHD_gc_md5 (const void *in, size_t inlen, void *resbuf)
475{
476 size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
477 gcry_md_hd_t hd;
478 gpg_error_t err;
479 unsigned char *p;
480
481 assert (outlen == GC_MD5_DIGEST_SIZE);
482
483 err = gcry_md_open (&hd, GCRY_MD_MD5, 0);
484 if (err != GPG_ERR_NO_ERROR)
485 return GC_INVALID_HASH;
486
487 gcry_md_write (hd, in, inlen);
488
489 p = gcry_md_read (hd, GCRY_MD_MD5);
490 if (p == NULL)
491 {
492 gcry_md_close (hd);
493 return GC_INVALID_HASH;
494 }
495
496 memcpy (resbuf, p, outlen);
497
498 gcry_md_close (hd);
499
500 return GC_OK;
501}
502#endif
503
504#ifdef GNULIB_GC_SHA1
505Gc_rc
506MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf)
507{
508 size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
509 gcry_md_hd_t hd;
510 gpg_error_t err;
511 unsigned char *p;
512
513 assert (outlen == GC_SHA1_DIGEST_SIZE);
514
515 err = gcry_md_open (&hd, GCRY_MD_SHA1, 0);
516 if (err != GPG_ERR_NO_ERROR)
517 return GC_INVALID_HASH;
518
519 gcry_md_write (hd, in, inlen);
520
521 p = gcry_md_read (hd, GCRY_MD_SHA1);
522 if (p == NULL)
523 {
524 gcry_md_close (hd);
525 return GC_INVALID_HASH;
526 }
527
528 memcpy (resbuf, p, outlen);
529
530 gcry_md_close (hd);
531
532 return GC_OK;
533}
534#endif
535
536#ifdef GNULIB_GC_HMAC_MD5
537Gc_rc
538MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen,
539 const void *in, size_t inlen, char *resbuf)
540{
541 size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
542 gcry_md_hd_t mdh;
543 unsigned char *hash;
544 gpg_error_t err;
545
546 assert (hlen == 16);
547
548 err = gcry_md_open (&mdh, GCRY_MD_MD5, GCRY_MD_FLAG_HMAC);
549 if (err != GPG_ERR_NO_ERROR)
550 return GC_INVALID_HASH;
551
552 err = gcry_md_setkey (mdh, key, keylen);
553 if (err != GPG_ERR_NO_ERROR)
554 {
555 gcry_md_close (mdh);
556 return GC_INVALID_HASH;
557 }
558
559 gcry_md_write (mdh, in, inlen);
560
561 hash = gcry_md_read (mdh, GCRY_MD_MD5);
562 if (hash == NULL)
563 {
564 gcry_md_close (mdh);
565 return GC_INVALID_HASH;
566 }
567
568 memcpy (resbuf, hash, hlen);
569
570 gcry_md_close (mdh);
571
572 return GC_OK;
573}
574#endif
575
576#ifdef GNULIB_GC_HMAC_SHA1 419#ifdef GNULIB_GC_HMAC_SHA1
577Gc_rc 420Gc_rc
578MHD_gc_MHD_hmac_sha1 (const void *key, 421MHD_gc_MHD_hmac_sha1 (const void *key,