From 59c5988e74fdaeb193d3daa2dee12b620c7eee75 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 8 Mar 2012 17:26:46 +0000 Subject: [PATCH] namestore manages zonekey files with private keys --- src/namestore/gnunet-service-namestore.c | 193 +++++++++++++++++- src/namestore/namestore.conf.in | 1 + src/namestore/test_namestore_api.c | 6 +- src/namestore/test_namestore_api.conf | 3 +- src/namestore/test_namestore_api_create.c | 7 +- .../test_namestore_api_create_update.c | 7 +- src/namestore/test_namestore_api_lookup.c | 6 +- .../test_namestore_api_lookup_specific_type.c | 6 +- src/namestore/test_namestore_api_put.c | 7 +- src/namestore/test_namestore_api_remove.c | 6 +- ...namestore_api_remove_not_existing_record.c | 6 +- .../test_namestore_api_sign_verify.c | 6 +- .../test_namestore_api_zone_iteration.c | 13 +- ...mestore_api_zone_iteration_specific_zone.c | 11 +- .../test_namestore_api_zone_iteration_stop.c | 11 +- .../test_namestore_api_zone_to_name.c | 6 +- ...19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone} | Bin ...MHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zone} | Bin 18 files changed, 268 insertions(+), 27 deletions(-) rename src/namestore/{hostkey => zonefiles/4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone} (100%) rename src/namestore/{hostkey2 => zonefiles/KJI3AL00K91EDPFJF58DAJM7H61D189TLP70N56JL8SVDCJE1SJ3SNNBOQPPONTL37FMHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zone} (100%) diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 703944a5c..c5b15244d 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c @@ -31,7 +31,7 @@ #include "gnunet_signatures.h" #include "namestore.h" - +#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) /** * A namestore operation. @@ -69,25 +69,129 @@ struct GNUNET_NAMESTORE_Client struct GNUNET_NAMESTORE_ZoneIteration *op_tail; }; +struct GNUNET_NAMESTORE_CryptoContainer +{ + struct GNUNET_NAMESTORE_CryptoContainer *next; + struct GNUNET_NAMESTORE_CryptoContainer *prev; + + char * filename; + + GNUNET_HashCode zone; + struct GNUNET_CRYPTO_RsaPrivateKey *privkey; + struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey; +}; /** - * Configuration handle. - */ +* Configuration handle. +*/ const struct GNUNET_CONFIGURATION_Handle *GSN_cfg; -static struct GNUNET_NAMESTORE_PluginFunctions *GSN_database; +/** +* Database handle +*/ +struct GNUNET_NAMESTORE_PluginFunctions *GSN_database; + +/** +* Zonefile directory +*/ +static char *zonefile_directory; + +static char *db_lib_name; + /** * Our notification context. */ static struct GNUNET_SERVER_NotificationContext *snc; -static char *db_lib_name; - static struct GNUNET_NAMESTORE_Client *client_head; static struct GNUNET_NAMESTORE_Client *client_tail; +struct GNUNET_NAMESTORE_CryptoContainer *c_head; +struct GNUNET_NAMESTORE_CryptoContainer *c_tail; + + +/** + * Write zonefile to disk + * @param file where to write + * @param ret the key + * + * @return GNUNET_OK on success, GNUNET_SYSERR on fail + */ + +int write_key_to_file (const char *filename, struct GNUNET_NAMESTORE_CryptoContainer *c) +{ + struct GNUNET_CRYPTO_RsaPrivateKey *ret = c->privkey; + struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *enc; + struct GNUNET_DISK_FileHandle *fd; + + if (GNUNET_YES == GNUNET_DISK_file_test (filename)) + { + GNUNET_HashCode zone; + struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; + struct GNUNET_CRYPTO_RsaPrivateKey * privkey; + + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(filename); + if (privkey == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("File zone `%s' but corrupt content already exists, failed to write! \n"), GNUNET_h2s (&zone)); + return GNUNET_SYSERR; + } + + GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); + GNUNET_CRYPTO_hash(&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone); + GNUNET_CRYPTO_rsa_key_free(privkey); + + if (0 == memcmp (&zone, &c->zone, sizeof(zone))) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("File zone `%s' containing this key already exists\n"), GNUNET_h2s (&zone)); + return GNUNET_OK; + } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("File zone `%s' but different zone key already exists, failed to write! \n"), GNUNET_h2s (&zone)); + return GNUNET_OK; + } + } + fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_FAILIFEXISTS, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); + if (NULL == fd) + { + if (errno == EEXIST) + { + if (GNUNET_YES != GNUNET_DISK_file_test (filename)) + { + /* must exist but not be accessible, fail for good! */ + if (0 != ACCESS (filename, R_OK)) + LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", filename); + else + GNUNET_break (0); /* what is going on!? */ + return GNUNET_SYSERR; + } + } + LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename); + return GNUNET_SYSERR; + } + + if (GNUNET_YES != GNUNET_DISK_file_lock (fd, 0, sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded), GNUNET_YES)) + return GNUNET_SYSERR; + enc = GNUNET_CRYPTO_rsa_encode_key (ret); + GNUNET_assert (enc != NULL); + GNUNET_assert (ntohs (enc->len) == GNUNET_DISK_file_write (fd, enc, ntohs (enc->len))); + GNUNET_free (enc); + GNUNET_DISK_file_sync (fd); + if (GNUNET_YES != GNUNET_DISK_file_unlock (fd, 0, sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded))) + LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); + GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); + + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Stored zonekey for zone `%s' in file `%s'\n"),GNUNET_h2s(&c->zone), c->filename); + return GNUNET_OK; +} + /** * Task run during shutdown. @@ -99,15 +203,32 @@ static void cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n"); - struct GNUNET_NAMESTORE_ZoneIteration * no; struct GNUNET_NAMESTORE_ZoneIteration * tmp; struct GNUNET_NAMESTORE_Client * nc; struct GNUNET_NAMESTORE_Client * next; + struct GNUNET_NAMESTORE_CryptoContainer *c; GNUNET_SERVER_notification_context_destroy (snc); snc = NULL; + for (c = c_head; c != NULL; c = c_head) + { + if (c->filename != NULL) + write_key_to_file(c->filename, c); + else + { + GNUNET_asprintf(&c->filename, "%s/%s.zone", zonefile_directory, GNUNET_h2s_full (&c->zone)); + write_key_to_file(c->filename, c); + } + + GNUNET_CONTAINER_DLL_remove(c_head, c_tail, c); + GNUNET_CRYPTO_rsa_key_free(c->privkey); + GNUNET_free (c->pubkey); + GNUNET_free(c->filename); + GNUNET_free (c); + } + for (nc = client_head; nc != NULL; nc = next) { next = nc->next; @@ -125,6 +246,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, GSN_database)); GNUNET_free (db_lib_name); + GNUNET_free_non_null(zonefile_directory); } static struct GNUNET_NAMESTORE_Client * @@ -1403,6 +1525,30 @@ static void handle_iteration_next (void *cls, GNUNET_SERVER_receive_done (client, GNUNET_OK); } +int zonekey_file_it (void *cls, const char *filename) +{ + int *counter = cls; + if ((filename != NULL) && (NULL != strstr(filename, ".zone"))) + { + struct GNUNET_CRYPTO_RsaPrivateKey * privkey; + struct GNUNET_NAMESTORE_CryptoContainer *c; + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(filename); + if (privkey == NULL) + return GNUNET_OK; + + c = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_CryptoContainer)); + c->pubkey = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); + c->privkey = privkey; + GNUNET_CRYPTO_rsa_key_get_public(privkey, c->pubkey); + GNUNET_CRYPTO_hash(c->pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &c->zone); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found zonefile for zone `%s'\n", GNUNET_h2s (&c->zone)); + + GNUNET_CONTAINER_DLL_insert(c_head, c_tail, c); + (*counter) ++; + } + return GNUNET_OK; +} /** @@ -1417,7 +1563,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { char * database; - + int counter = 0; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting namestore service\n"); static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -1444,6 +1590,31 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, GSN_cfg = cfg; + /* Load private keys from disk */ + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore", "zonefile_directory", + &zonefile_directory)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No directory to load zonefiles specified in configuration\n")); + GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); + return; + } + + if (GNUNET_NO == GNUNET_DISK_file_test (zonefile_directory)) + { + if (GNUNET_SYSERR == GNUNET_DISK_directory_create (zonefile_directory)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Creating directory `%s' for zone files failed!\n"), zonefile_directory); + GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); + return; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created directory `%s' for zone files\n", zonefile_directory); + } + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scanning directory `%s' for zone files\n", zonefile_directory); + GNUNET_DISK_directory_scan (zonefile_directory, zonekey_file_it, &counter); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u zone files\n", counter); + /* Loading database plugin */ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "namestore", "database", @@ -1453,9 +1624,13 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", database); GSN_database = GNUNET_PLUGIN_load (db_lib_name, (void *) GSN_cfg); if (GSN_database == NULL) + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load database backend `%s'\n", db_lib_name); - GNUNET_free (database); + GNUNET_free (database); + GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); + return; + } /* Configuring server handles */ GNUNET_SERVER_add_handlers (server, handlers); diff --git a/src/namestore/namestore.conf.in b/src/namestore/namestore.conf.in index c9b9984e9..d93aea6cc 100644 --- a/src/namestore/namestore.conf.in +++ b/src/namestore/namestore.conf.in @@ -11,6 +11,7 @@ BINARY = gnunet-service-namestore ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; DATABASE = sqlite +ZONEFILE_DIRECTORY = $SERVICEHOME/namestore/zonefiles [namestore-sqlite] FILENAME = $SERVICEHOME/namestore/sqlite.db diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c index 21e65af29..85ad50804 100644 --- a/src/namestore/test_namestore_api.c +++ b/src/namestore/test_namestore_api.c @@ -167,7 +167,11 @@ run (void *cls, char *const *args, const char *cfgfile, delete_existing_db(cfg); endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api.conf b/src/namestore/test_namestore_api.conf index a1ddd10e4..eaeeae859 100644 --- a/src/namestore/test_namestore_api.conf +++ b/src/namestore/test_namestore_api.conf @@ -4,7 +4,7 @@ DEFAULTSERVICES = namestore UNIXPATH = /tmp/gnunet-p1-service-arm.sock [namestore] -#PREFIX = valgrind --leak-check=full --track-origins=yes +PREFIX = valgrind --leak-check=full --track-origins=yes AUTOSTART = YES UNIXPATH = /tmp/gnunet-service-namestore.sock UNIX_MATCH_UID = YES @@ -17,6 +17,7 @@ BINARY = gnunet-service-namestore ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; DATABASE = sqlite +ZONEFILE_DIRECTORY = zonefiles [namestore-sqlite] FILENAME = $SERVICEHOME/namestore/sqlite_test.db diff --git a/src/namestore/test_namestore_api_create.c b/src/namestore/test_namestore_api_create.c index a2e1366c8..1bda272e6 100644 --- a/src/namestore/test_namestore_api_create.c +++ b/src/namestore/test_namestore_api_create.c @@ -400,8 +400,11 @@ run (void *cls, char *const *args, const char *cfgfile, size_t rd_ser_len; /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); - GNUNET_assert (privkey != NULL); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api_create_update.c b/src/namestore/test_namestore_api_create_update.c index ca2cde10c..4f8f6e05f 100644 --- a/src/namestore/test_namestore_api_create_update.c +++ b/src/namestore/test_namestore_api_create_update.c @@ -444,7 +444,12 @@ run (void *cls, char *const *args, const char *cfgfile, size_t rd_ser_len; /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); + GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api_lookup.c b/src/namestore/test_namestore_api_lookup.c index 7d748447c..17477294a 100644 --- a/src/namestore/test_namestore_api_lookup.c +++ b/src/namestore/test_namestore_api_lookup.c @@ -256,7 +256,11 @@ run (void *cls, char *const *args, const char *cfgfile, size_t rd_ser_len; /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api_lookup_specific_type.c b/src/namestore/test_namestore_api_lookup_specific_type.c index a74c602f2..3facec50f 100644 --- a/src/namestore/test_namestore_api_lookup_specific_type.c +++ b/src/namestore/test_namestore_api_lookup_specific_type.c @@ -324,7 +324,11 @@ run (void *cls, char *const *args, const char *cfgfile, size_t rd_ser_len; /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api_put.c b/src/namestore/test_namestore_api_put.c index 2b01391ae..310c9a331 100644 --- a/src/namestore/test_namestore_api_put.c +++ b/src/namestore/test_namestore_api_put.c @@ -174,7 +174,12 @@ run (void *cls, char *const *args, const char *cfgfile, endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); + GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c index 78a5be56a..88c4771d1 100644 --- a/src/namestore/test_namestore_api_remove.c +++ b/src/namestore/test_namestore_api_remove.c @@ -288,7 +288,11 @@ run (void *cls, char *const *args, const char *cfgfile, size_t rd_ser_len; /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c index 4ee633598..431e7d1a5 100644 --- a/src/namestore/test_namestore_api_remove_not_existing_record.c +++ b/src/namestore/test_namestore_api_remove_not_existing_record.c @@ -222,7 +222,11 @@ run (void *cls, char *const *args, const char *cfgfile, size_t rd_ser_len; /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api_sign_verify.c b/src/namestore/test_namestore_api_sign_verify.c index 084285ede..1fb479611 100644 --- a/src/namestore/test_namestore_api_sign_verify.c +++ b/src/namestore/test_namestore_api_sign_verify.c @@ -74,7 +74,11 @@ run (void *cls, char *const *args, const char *cfgfile, struct GNUNET_CRYPTO_RsaSignature * signature; /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c index 92e8e7988..f06411061 100644 --- a/src/namestore/test_namestore_api_zone_iteration.c +++ b/src/namestore/test_namestore_api_zone_iteration.c @@ -387,12 +387,21 @@ run (void *cls, char *const *args, const char *cfgfile, delete_existing_db(cfg); endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); GNUNET_CRYPTO_hash(&pubkey, sizeof (pubkey), &zone); - privkey2 = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey2"); + + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "KJI3AL00K91EDPFJF58DAJM7H61D189TLP70N56JL8SVDCJE1SJ3SNNBOQPPONTL37FMHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey2 = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); + GNUNET_assert (privkey2 != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c index 7cdcea42a..4b0ce817f 100644 --- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c +++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c @@ -368,12 +368,19 @@ run (void *cls, char *const *args, const char *cfgfile, delete_existing_db(cfg); endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); GNUNET_CRYPTO_hash(&pubkey, sizeof (pubkey), &zone); - privkey2 = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey2"); + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "KJI3AL00K91EDPFJF58DAJM7H61D189TLP70N56JL8SVDCJE1SJ3SNNBOQPPONTL37FMHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey2 = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey2 != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c index 0c2fe0624..4093ff3bb 100644 --- a/src/namestore/test_namestore_api_zone_iteration_stop.c +++ b/src/namestore/test_namestore_api_zone_iteration_stop.c @@ -408,12 +408,19 @@ run (void *cls, char *const *args, const char *cfgfile, delete_existing_db(cfg); endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); GNUNET_CRYPTO_hash(&pubkey, sizeof (pubkey), &zone); - privkey2 = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey2"); + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "KJI3AL00K91EDPFJF58DAJM7H61D189TLP70N56JL8SVDCJE1SJ3SNNBOQPPONTL37FMHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey2 = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey2 != NULL); GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c index 0ed3b63c2..498b1197d 100644 --- a/src/namestore/test_namestore_api_zone_to_name.c +++ b/src/namestore/test_namestore_api_zone_to_name.c @@ -220,7 +220,11 @@ run (void *cls, char *const *args, const char *cfgfile, /* load privat key */ - privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey"); + char *hostkey_file; + GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); + privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); + GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); /* get public key */ GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); diff --git a/src/namestore/hostkey b/src/namestore/zonefiles/4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone similarity index 100% rename from src/namestore/hostkey rename to src/namestore/zonefiles/4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone diff --git a/src/namestore/hostkey2 b/src/namestore/zonefiles/KJI3AL00K91EDPFJF58DAJM7H61D189TLP70N56JL8SVDCJE1SJ3SNNBOQPPONTL37FMHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zone similarity index 100% rename from src/namestore/hostkey2 rename to src/namestore/zonefiles/KJI3AL00K91EDPFJF58DAJM7H61D189TLP70N56JL8SVDCJE1SJ3SNNBOQPPONTL37FMHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zone -- 2.25.1