aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_ksk.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-06-25 15:37:07 +0000
committerChristian Grothoff <christian@grothoff.org>2010-06-25 15:37:07 +0000
commit94f01bdd2fda575769f01f8072689fa6936af8f4 (patch)
treec2ffd2a36b7babe0b47335f407b3f20e71bb25ba /src/util/crypto_ksk.c
parent2d4ae427e8d2a4bc305c42100d5cb35a75916879 (diff)
downloadgnunet-94f01bdd2fda575769f01f8072689fa6936af8f4.tar.gz
gnunet-94f01bdd2fda575769f01f8072689fa6936af8f4.zip
cleaning argz mess
Diffstat (limited to 'src/util/crypto_ksk.c')
-rw-r--r--src/util/crypto_ksk.c93
1 files changed, 3 insertions, 90 deletions
diff --git a/src/util/crypto_ksk.c b/src/util/crypto_ksk.c
index 888c08384..1aa493ca8 100644
--- a/src/util/crypto_ksk.c
+++ b/src/util/crypto_ksk.c
@@ -684,8 +684,6 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding)
684} 684}
685 685
686 686
687
688
689typedef struct 687typedef struct
690{ 688{
691 GNUNET_HashCode hc; 689 GNUNET_HashCode hc;
@@ -693,6 +691,7 @@ typedef struct
693} KBlockKeyCacheLine; 691} KBlockKeyCacheLine;
694 692
695static KBlockKeyCacheLine **cache; 693static KBlockKeyCacheLine **cache;
694
696static unsigned int cacheSize; 695static unsigned int cacheSize;
697 696
698/** 697/**
@@ -724,92 +723,6 @@ GNUNET_CRYPTO_rsa_key_create_from_hash (const GNUNET_HashCode * hc)
724} 723}
725 724
726 725
727/**
728 * Process ID of the "find" process that we use for
729 * entropy gathering.
730 */
731static pid_t genproc;
732
733/**
734 * Function called by libgcrypt whenever we are
735 * blocked gathering entropy.
736 */
737static void
738entropy_generator (void *cls,
739 const char *what, int printchar, int current, int total)
740{
741 unsigned long code;
742 enum GNUNET_OS_ProcessStatusType type;
743 int ret;
744
745 if (0 != strcmp (what, "need_entropy"))
746 return;
747 if (current == total)
748 {
749 if (genproc != 0)
750 {
751 if (0 != PLIBC_KILL (genproc, SIGTERM))
752 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
753 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
754 genproc = 0;
755 }
756 return;
757 }
758 if (genproc != 0)
759 {
760 ret = GNUNET_OS_process_status (genproc, &type, &code);
761 if (ret == GNUNET_NO)
762 return; /* still running */
763 if (ret == GNUNET_SYSERR)
764 {
765 GNUNET_break (0);
766 return;
767 }
768 if (0 != PLIBC_KILL (genproc, SIGTERM))
769 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
770 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
771 genproc = 0;
772 }
773 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
774 _("Starting `%s' process to generate entropy\n"), "find");
775 genproc = GNUNET_OS_start_process (NULL, NULL, "sh",
776 "sh",
777 "-c",
778 "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null",
779 NULL);
780}
781
782
783static void
784killfind ()
785{
786 if (genproc != 0)
787 {
788 PLIBC_KILL (genproc, SIGKILL);
789 genproc = 0;
790 }
791}
792
793
794void __attribute__ ((constructor)) GNUNET_CRYPTO_ksk_init ()
795{
796 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
797 if (!gcry_check_version (GCRYPT_VERSION))
798 {
799 fprintf (stderr,
800 _
801 ("libgcrypt has not the expected version (version %s is required).\n"),
802 GCRYPT_VERSION);
803 abort ();
804 }
805#ifdef gcry_fast_random_poll
806 gcry_fast_random_poll ();
807#endif
808 gcry_set_progress_handler (&entropy_generator, NULL);
809 atexit (&killfind);
810}
811
812
813void __attribute__ ((destructor)) GNUNET_CRYPTO_ksk_fini () 726void __attribute__ ((destructor)) GNUNET_CRYPTO_ksk_fini ()
814{ 727{
815 int i; 728 int i;
@@ -820,7 +733,7 @@ void __attribute__ ((destructor)) GNUNET_CRYPTO_ksk_fini ()
820 GNUNET_free (cache[i]); 733 GNUNET_free (cache[i]);
821 } 734 }
822 GNUNET_array_grow (cache, cacheSize, 0); 735 GNUNET_array_grow (cache, cacheSize, 0);
823 gcry_set_progress_handler (NULL, NULL);
824} 736}
825 737
826/* end of kblockkey.c */ 738
739/* end of crypto_ksk.c */