aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-02-05 20:49:21 +0000
committerChristian Grothoff <christian@grothoff.org>2013-02-05 20:49:21 +0000
commitca35f67faee8371fa763bdf49f04a8d5d4cdc021 (patch)
tree5535df5e5a2428ed838c6a0e60b2c6c68a7842c5 /src/testing
parentdd7cca21c5dbaef4d56f92bab3932f0f73d092d1 (diff)
downloadgnunet-ca35f67faee8371fa763bdf49f04a8d5d4cdc021.tar.gz
gnunet-ca35f67faee8371fa763bdf49f04a8d5d4cdc021.zip
switching to ECDHE cryptography f, implementation is incomplete and INSECURE, do not use for anything but testing
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/gnunet-testing.c22
-rw-r--r--src/testing/testing.c23
2 files changed, 27 insertions, 18 deletions
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c
index 28c5be965..eb85e155e 100644
--- a/src/testing/gnunet-testing.c
+++ b/src/testing/gnunet-testing.c
@@ -28,7 +28,7 @@
28#include "gnunet_testing_lib.h" 28#include "gnunet_testing_lib.h"
29 29
30 30
31#define HOSTKEYFILESIZE 914 31#define HOSTKEYFILESIZE 1024
32 32
33/** 33/**
34 * Final status code. 34 * Final status code.
@@ -119,11 +119,13 @@ create_unique_cfgs (const char * template, const unsigned int no)
119static int 119static int
120create_hostkeys (const unsigned int no) 120create_hostkeys (const unsigned int no)
121{ 121{
122 static char pad[HOSTKEYFILESIZE];
122 struct GNUNET_TESTING_System *system; 123 struct GNUNET_TESTING_System *system;
123 struct GNUNET_PeerIdentity id; 124 struct GNUNET_PeerIdentity id;
124 struct GNUNET_DISK_FileHandle *fd; 125 struct GNUNET_DISK_FileHandle *fd;
125 struct GNUNET_CRYPTO_RsaPrivateKey *pk; 126 struct GNUNET_CRYPTO_EccPrivateKey *pk;
126 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb; 127 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkb;
128 ssize_t ret;
127 129
128 system = GNUNET_TESTING_system_create ("testing", NULL, NULL); 130 system = GNUNET_TESTING_system_create ("testing", NULL, NULL);
129 pk = GNUNET_TESTING_hostkey_get (system, create_no, &id); 131 pk = GNUNET_TESTING_hostkey_get (system, create_no, &id);
@@ -140,14 +142,20 @@ create_hostkeys (const unsigned int no)
140 GNUNET_DISK_PERM_USER_READ | 142 GNUNET_DISK_PERM_USER_READ |
141 GNUNET_DISK_PERM_USER_WRITE); 143 GNUNET_DISK_PERM_USER_WRITE);
142 GNUNET_assert (fd != NULL); 144 GNUNET_assert (fd != NULL);
143 pkb = GNUNET_CRYPTO_rsa_encode_key (pk); 145 pkb = GNUNET_CRYPTO_ecc_encode_key (pk);
144 GNUNET_assert (HOSTKEYFILESIZE == 146 ret = GNUNET_DISK_file_write (fd, pkb,
145 GNUNET_DISK_file_write (fd, pkb, ntohs (pkb->len))); 147 ntohs (pkb->size));
148 GNUNET_assert (ntohs (pkb->size) == ret);
149 GNUNET_assert (ntohs (pkb->size) < HOSTKEYFILESIZE);
150 GNUNET_assert (HOSTKEYFILESIZE - ret ==
151 GNUNET_DISK_file_write (fd, pad,
152 HOSTKEYFILESIZE - ret));
153
146 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); 154 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
147 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 155 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
148 "Wrote hostkey to file: `%s'\n", create_hostkey); 156 "Wrote hostkey to file: `%s'\n", create_hostkey);
149 GNUNET_free (pkb); 157 GNUNET_free (pkb);
150 GNUNET_CRYPTO_rsa_key_free (pk); 158 GNUNET_CRYPTO_ecc_key_free (pk);
151 GNUNET_TESTING_system_destroy (system, GNUNET_YES); 159 GNUNET_TESTING_system_destroy (system, GNUNET_YES);
152 return 0; 160 return 0;
153} 161}
diff --git a/src/testing/testing.c b/src/testing/testing.c
index dd80f6ea5..16f902890 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -202,7 +202,7 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
202 202
203 GNUNET_assert (NULL == system->hostkeys_data); 203 GNUNET_assert (NULL == system->hostkeys_data);
204 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); 204 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
205 GNUNET_asprintf (&filename, "%s/testing_hostkeys.dat", data_dir); 205 GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir);
206 GNUNET_free (data_dir); 206 GNUNET_free (data_dir);
207 207
208 if (GNUNET_YES != GNUNET_DISK_file_test (filename)) 208 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
@@ -525,13 +525,13 @@ reserve_path (struct GNUNET_TESTING_System *system)
525 * key; if NULL, GNUNET_SYSERR is returned immediately 525 * key; if NULL, GNUNET_SYSERR is returned immediately
526 * @return NULL on error (not enough keys) 526 * @return NULL on error (not enough keys)
527 */ 527 */
528struct GNUNET_CRYPTO_RsaPrivateKey * 528struct GNUNET_CRYPTO_EccPrivateKey *
529GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, 529GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
530 uint32_t key_number, 530 uint32_t key_number,
531 struct GNUNET_PeerIdentity *id) 531 struct GNUNET_PeerIdentity *id)
532{ 532{
533 struct GNUNET_CRYPTO_RsaPrivateKey *private_key; 533 struct GNUNET_CRYPTO_EccPrivateKey *private_key;
534 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; 534 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key;
535 535
536 if ((NULL == id) || (NULL == system->hostkeys_data)) 536 if ((NULL == id) || (NULL == system->hostkeys_data))
537 return NULL; 537 return NULL;
@@ -541,7 +541,7 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
541 _("Key number %u does not exist\n"), key_number); 541 _("Key number %u does not exist\n"), key_number);
542 return NULL; 542 return NULL;
543 } 543 }
544 private_key = GNUNET_CRYPTO_rsa_decode_key (system->hostkeys_data + 544 private_key = GNUNET_CRYPTO_ecc_decode_key (system->hostkeys_data +
545 (key_number * 545 (key_number *
546 GNUNET_TESTING_HOSTKEYFILESIZE), 546 GNUNET_TESTING_HOSTKEYFILESIZE),
547 GNUNET_TESTING_HOSTKEYFILESIZE); 547 GNUNET_TESTING_HOSTKEYFILESIZE);
@@ -551,9 +551,9 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
551 _("Error while decoding key %u\n"), key_number); 551 _("Error while decoding key %u\n"), key_number);
552 return NULL; 552 return NULL;
553 } 553 }
554 GNUNET_CRYPTO_rsa_key_get_public (private_key, &public_key); 554 GNUNET_CRYPTO_ecc_key_get_public (private_key, &public_key);
555 GNUNET_CRYPTO_hash (&public_key, 555 GNUNET_CRYPTO_hash (&public_key,
556 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 556 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded),
557 &(id->hashPubKey)); 557 &(id->hashPubKey));
558 return private_key; 558 return private_key;
559} 559}
@@ -855,7 +855,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
855 char *config_filename; 855 char *config_filename;
856 char *libexec_binary; 856 char *libexec_binary;
857 char *emsg_; 857 char *emsg_;
858 struct GNUNET_CRYPTO_RsaPrivateKey *pk; 858 struct GNUNET_CRYPTO_EccPrivateKey *pk;
859 859
860 if (NULL != emsg) 860 if (NULL != emsg)
861 *emsg = NULL; 861 *emsg = NULL;
@@ -897,12 +897,13 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
897 return NULL; 897 return NULL;
898 } 898 }
899 if (NULL != pk) 899 if (NULL != pk)
900 GNUNET_CRYPTO_rsa_key_free (pk); 900 GNUNET_CRYPTO_ecc_key_free (pk);
901 GNUNET_assert (GNUNET_OK == 901 GNUNET_assert (GNUNET_OK ==
902 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", 902 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS",
903 "SERVICEHOME", 903 "SERVICEHOME",
904 &service_home)); 904 &service_home));
905 GNUNET_snprintf (hostkey_filename, sizeof (hostkey_filename), "%s/.hostkey", 905 /* FIXME: might be better to evaluate actual configuration option here... */
906 GNUNET_snprintf (hostkey_filename, sizeof (hostkey_filename), "%s/private.ecc",
906 service_home); 907 service_home);
907 GNUNET_free (service_home); 908 GNUNET_free (service_home);
908 fd = GNUNET_DISK_file_open (hostkey_filename, 909 fd = GNUNET_DISK_file_open (hostkey_filename,
@@ -978,7 +979,7 @@ void
978GNUNET_TESTING_peer_get_identity (const struct GNUNET_TESTING_Peer *peer, 979GNUNET_TESTING_peer_get_identity (const struct GNUNET_TESTING_Peer *peer,
979 struct GNUNET_PeerIdentity *id) 980 struct GNUNET_PeerIdentity *id)
980{ 981{
981 GNUNET_CRYPTO_rsa_key_free (GNUNET_TESTING_hostkey_get (peer->system, 982 GNUNET_CRYPTO_ecc_key_free (GNUNET_TESTING_hostkey_get (peer->system,
982 peer->key_number, 983 peer->key_number,
983 id)); 984 id));
984} 985}