- fix
[oweals/gnunet.git] / src / testing / gnunet-testing.c
index 8f7c6393d79c3bb091ea6c7b3b763aa4f557410a..8c92068ab7060674a7c8faff0f306ba6c7e45308 100644 (file)
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_testing_lib-new.h"
+#include "gnunet_testing_lib.h"
 
 
-#define HOSTKEYFILESIZE 914
-
 /**
  * Final status code.
  */
@@ -119,11 +117,13 @@ create_unique_cfgs (const char * template, const unsigned int no)
 static int
 create_hostkeys (const unsigned int no)
 {
+  static char pad[GNUNET_TESTING_HOSTKEYFILESIZE];
   struct GNUNET_TESTING_System *system;
   struct GNUNET_PeerIdentity id;
   struct GNUNET_DISK_FileHandle *fd;
-  struct GNUNET_CRYPTO_RsaPrivateKey *pk;
-  struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb;
+  struct GNUNET_CRYPTO_EccPrivateKey *pk;
+  struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkb;
+  ssize_t ret;
 
   system = GNUNET_TESTING_system_create ("testing", NULL, NULL);
   pk = GNUNET_TESTING_hostkey_get (system, create_no, &id);
@@ -140,14 +140,20 @@ create_hostkeys (const unsigned int no)
                              GNUNET_DISK_PERM_USER_READ |
                              GNUNET_DISK_PERM_USER_WRITE);
   GNUNET_assert (fd != NULL);
-  pkb = GNUNET_CRYPTO_rsa_encode_key (pk);
-  GNUNET_assert (HOSTKEYFILESIZE ==
-                GNUNET_DISK_file_write (fd, pkb, ntohs (pkb->len)));
+  pkb = GNUNET_CRYPTO_ecc_encode_key (pk);
+  ret = GNUNET_DISK_file_write (fd, pkb, 
+                               ntohs (pkb->size));
+  GNUNET_assert (ntohs (pkb->size) == ret);
+  GNUNET_assert (ntohs (pkb->size) < GNUNET_TESTING_HOSTKEYFILESIZE);
+  GNUNET_assert (GNUNET_TESTING_HOSTKEYFILESIZE - ret ==
+                GNUNET_DISK_file_write (fd, pad, 
+                                        GNUNET_TESTING_HOSTKEYFILESIZE - ret));
+  
   GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
                   "Wrote hostkey to file: `%s'\n", create_hostkey);
   GNUNET_free (pkb);
-  GNUNET_CRYPTO_rsa_key_free (pk);
+  GNUNET_CRYPTO_ecc_key_free (pk);
   GNUNET_TESTING_system_destroy (system, GNUNET_YES);
   return 0;
 }