aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-11 21:43:28 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-11 21:43:34 +0200
commit90ff9edfa9c5fcfa3a36d1653ff105e89b888e21 (patch)
tree780a2071f5072c8e8e044db741eb295c3f3ea2a7 /src/core
parent3bcfe59f1ce533246bda271f00b3ee957cae304d (diff)
downloadgnunet-90ff9edfa9c5fcfa3a36d1653ff105e89b888e21.tar.gz
gnunet-90ff9edfa9c5fcfa3a36d1653ff105e89b888e21.zip
fixing #6149
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gnunet-service-core.c26
-rw-r--r--src/core/gnunet-service-core_kx.c49
2 files changed, 36 insertions, 39 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 04e6d0141..34f8440ae 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -912,14 +912,15 @@ run (void *cls,
912 const struct GNUNET_CONFIGURATION_Handle *c, 912 const struct GNUNET_CONFIGURATION_Handle *c,
913 struct GNUNET_SERVICE_Handle *service) 913 struct GNUNET_SERVICE_Handle *service)
914{ 914{
915 struct GNUNET_CRYPTO_EddsaPrivateKey *pk; 915 struct GNUNET_CRYPTO_EddsaPrivateKey pk;
916 char *keyfile; 916 char *keyfile;
917 917
918 GSC_cfg = c; 918 GSC_cfg = c;
919 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (GSC_cfg, 919 if (GNUNET_OK !=
920 "PEER", 920 GNUNET_CONFIGURATION_get_value_filename (GSC_cfg,
921 "PRIVATE_KEY", 921 "PEER",
922 &keyfile)) 922 "PRIVATE_KEY",
923 &keyfile))
923 { 924 {
924 GNUNET_log ( 925 GNUNET_log (
925 GNUNET_ERROR_TYPE_ERROR, 926 GNUNET_ERROR_TYPE_ERROR,
@@ -931,10 +932,19 @@ run (void *cls,
931 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); 932 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
932 GNUNET_SERVICE_suspend (service); 933 GNUNET_SERVICE_suspend (service);
933 GSC_TYPEMAP_init (); 934 GSC_TYPEMAP_init ();
934 pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); 935 if (GNUNET_SYSERR ==
936 GNUNET_CRYPTO_eddsa_key_from_file (keyfile,
937 GNUNET_YES,
938 &pk))
939 {
940 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
941 "Failed to setup peer's private key\n");
942 GNUNET_SCHEDULER_shutdown ();
943 GNUNET_free (keyfile);
944 return;
945 }
935 GNUNET_free (keyfile); 946 GNUNET_free (keyfile);
936 GNUNET_assert (NULL != pk); 947 if (GNUNET_OK != GSC_KX_init (&pk))
937 if (GNUNET_OK != GSC_KX_init (pk))
938 { 948 {
939 GNUNET_SCHEDULER_shutdown (); 949 GNUNET_SCHEDULER_shutdown ();
940 return; 950 return;
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index 315095938..cafe658e8 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -366,12 +366,12 @@ static struct GNUNET_TRANSPORT_CoreHandle *transport;
366/** 366/**
367 * Our private key. 367 * Our private key.
368 */ 368 */
369static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; 369static struct GNUNET_CRYPTO_EddsaPrivateKey my_private_key;
370 370
371/** 371/**
372 * Our ephemeral private key. 372 * Our ephemeral private key.
373 */ 373 */
374static struct GNUNET_CRYPTO_EcdhePrivateKey *my_ephemeral_key; 374static struct GNUNET_CRYPTO_EcdhePrivateKey my_ephemeral_key;
375 375
376/** 376/**
377 * Current message we send for a key exchange. 377 * Current message we send for a key exchange.
@@ -935,9 +935,10 @@ derive_session_keys (struct GSC_KeyExchangeInfo *kx)
935{ 935{
936 struct GNUNET_HashCode key_material; 936 struct GNUNET_HashCode key_material;
937 937
938 if (GNUNET_OK != GNUNET_CRYPTO_ecc_ecdh (my_ephemeral_key, 938 if (GNUNET_OK !=
939 &kx->other_ephemeral_key, 939 GNUNET_CRYPTO_ecc_ecdh (&my_ephemeral_key,
940 &key_material)) 940 &kx->other_ephemeral_key,
941 &key_material))
941 { 942 {
942 GNUNET_break (0); 943 GNUNET_break (0);
943 return; 944 return;
@@ -1850,11 +1851,11 @@ sign_ephemeral_key ()
1850 current_ekm.expiration_time = 1851 current_ekm.expiration_time =
1851 GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS); 1852 GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS);
1852 } 1853 }
1853 GNUNET_CRYPTO_ecdhe_key_get_public (my_ephemeral_key, 1854 GNUNET_CRYPTO_ecdhe_key_get_public (&my_ephemeral_key,
1854 &current_ekm.ephemeral_key); 1855 &current_ekm.ephemeral_key);
1855 current_ekm.origin_identity = GSC_my_identity; 1856 current_ekm.origin_identity = GSC_my_identity;
1856 GNUNET_assert (GNUNET_OK == 1857 GNUNET_assert (GNUNET_OK ==
1857 GNUNET_CRYPTO_eddsa_sign_ (my_private_key, 1858 GNUNET_CRYPTO_eddsa_sign_ (&my_private_key,
1858 &current_ekm.purpose, 1859 &current_ekm.purpose,
1859 &current_ekm.signature)); 1860 &current_ekm.signature));
1860} 1861}
@@ -1871,10 +1872,7 @@ do_rekey (void *cls)
1871 struct GSC_KeyExchangeInfo *pos; 1872 struct GSC_KeyExchangeInfo *pos;
1872 1873
1873 rekey_task = GNUNET_SCHEDULER_add_delayed (REKEY_FREQUENCY, &do_rekey, NULL); 1874 rekey_task = GNUNET_SCHEDULER_add_delayed (REKEY_FREQUENCY, &do_rekey, NULL);
1874 if (NULL != my_ephemeral_key) 1875 GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
1875 GNUNET_free (my_ephemeral_key);
1876 my_ephemeral_key = GNUNET_CRYPTO_ecdhe_key_create ();
1877 GNUNET_assert (NULL != my_ephemeral_key);
1878 sign_ephemeral_key (); 1876 sign_ephemeral_key ();
1879 { 1877 {
1880 struct GNUNET_HashCode eh; 1878 struct GNUNET_HashCode eh;
@@ -1931,17 +1929,10 @@ GSC_KX_init (struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
1931 NULL), 1929 NULL),
1932 GNUNET_MQ_handler_end () }; 1930 GNUNET_MQ_handler_end () };
1933 1931
1934 my_private_key = pk; 1932 my_private_key = *pk;
1935 GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, 1933 GNUNET_CRYPTO_eddsa_key_get_public (&my_private_key,
1936 &GSC_my_identity.public_key); 1934 &GSC_my_identity.public_key);
1937 my_ephemeral_key = GNUNET_CRYPTO_ecdhe_key_create (); 1935 GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
1938 if (NULL == my_ephemeral_key)
1939 {
1940 GNUNET_break (0);
1941 GNUNET_free (my_private_key);
1942 my_private_key = NULL;
1943 return GNUNET_SYSERR;
1944 }
1945 sign_ephemeral_key (); 1936 sign_ephemeral_key ();
1946 { 1937 {
1947 struct GNUNET_HashCode eh; 1938 struct GNUNET_HashCode eh;
@@ -1989,16 +1980,12 @@ GSC_KX_done ()
1989 GNUNET_SCHEDULER_cancel (rekey_task); 1980 GNUNET_SCHEDULER_cancel (rekey_task);
1990 rekey_task = NULL; 1981 rekey_task = NULL;
1991 } 1982 }
1992 if (NULL != my_ephemeral_key) 1983 memset (&my_ephemeral_key,
1993 { 1984 0,
1994 GNUNET_free (my_ephemeral_key); 1985 sizeof (my_ephemeral_key));
1995 my_ephemeral_key = NULL; 1986 memset (&my_private_key,
1996 } 1987 0,
1997 if (NULL != my_private_key) 1988 sizeof (my_private_key));
1998 {
1999 GNUNET_free (my_private_key);
2000 my_private_key = NULL;
2001 }
2002 if (NULL != nc) 1989 if (NULL != nc)
2003 { 1990 {
2004 GNUNET_notification_context_destroy (nc); 1991 GNUNET_notification_context_destroy (nc);