-/**
- * Testing includes a number of pre-created hostkeys for faster peer
- * startup. This function loads such keys into memory from a file.
- *
- * @param system the testing system handle
- * @param filename the path of the hostkeys file
- * @return GNUNET_OK on success; GNUNET_SYSERR on error
- */
-int
-GNUNET_TESTING_hostkeys_load (struct GNUNET_TESTING_System *system,
- const char *filename)
-{
- struct GNUNET_DISK_FileHandle *fd;
- uint64_t fs;
-
- if (GNUNET_YES != GNUNET_DISK_file_test (filename))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Hostkeys file not found: %s\n"), filename);
- return GNUNET_SYSERR;
- }
- /* Check hostkey file size, read entire thing into memory */
- fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
- GNUNET_DISK_PERM_NONE);
- if (NULL == fd)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Could not open hostkeys file: %s\n"), filename);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
- fs = 0;
- if (0 == fs)
- {
- GNUNET_DISK_file_close (fd);
- return GNUNET_SYSERR; /* File is empty */
- }
- if (0 != (fs % HOSTKEYFILESIZE))
- {
- GNUNET_DISK_file_close (fd);
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Incorrect hostkey file format: %s\n"), filename);
- return GNUNET_SYSERR;
- }
- GNUNET_break (NULL == system->hostkeys_data);
- system->total_hostkeys = fs / HOSTKEYFILESIZE;
- system->hostkeys_data = GNUNET_malloc_large (fs); /* free in hostkeys_unload */
- GNUNET_assert (fs == GNUNET_DISK_file_read (fd, system->hostkeys_data, fs));
- GNUNET_DISK_file_close (fd);
- return GNUNET_OK;
-}
-
-
-/**
- * Function to remove the loaded hostkeys
- *
- * @param system the testing system handle
- */
-void
-GNUNET_TESTING_hostkeys_unload (struct GNUNET_TESTING_System *system)
-{
- GNUNET_break (NULL != system->hostkeys_data);
- GNUNET_free_non_null (system->hostkeys_data);
- system->hostkeys_data = NULL;
- system->total_hostkeys = 0;
-}
-
-