aboutsummaryrefslogtreecommitdiff
path: root/src/core/gnunet-service-core_kx.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/gnunet-service-core_kx.c')
-rw-r--r--src/core/gnunet-service-core_kx.c49
1 files changed, 18 insertions, 31 deletions
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);