[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22095 - in gnunet/src: include testing
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22095 - in gnunet/src: include testing |
Date: |
Tue, 19 Jun 2012 09:57:02 +0200 |
Author: grothoff
Date: 2012-06-19 09:57:02 +0200 (Tue, 19 Jun 2012)
New Revision: 22095
Modified:
gnunet/src/include/gnunet_crypto_lib.h
gnunet/src/testing/gnunet-testing.c
Log:
-fixes
Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h 2012-06-19 07:52:51 UTC (rev
22094)
+++ gnunet/src/include/gnunet_crypto_lib.h 2012-06-19 07:57:02 UTC (rev
22095)
@@ -895,12 +895,12 @@
/**
* Encode the private key in a format suitable for
* storing it into a file.
- * @returns encoding of the private key.
- * The first 4 bytes give the size of the array, as usual.
+ * @return encoding of the private key
*/
struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *
GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey
*hostkey);
+
/**
* Decode the private key from the data-format back
* to the "normal", internal format.
@@ -911,6 +911,7 @@
struct GNUNET_CRYPTO_RsaPrivateKey *
GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len);
+
/**
* Create a new private key by reading it from a file. If the
* files does not exist, create a new key and write it to the
Modified: gnunet/src/testing/gnunet-testing.c
===================================================================
--- gnunet/src/testing/gnunet-testing.c 2012-06-19 07:52:51 UTC (rev 22094)
+++ gnunet/src/testing/gnunet-testing.c 2012-06-19 07:57:02 UTC (rev 22095)
@@ -27,9 +27,9 @@
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib-new.h"
+
#define HOSTKEYFILESIZE 914
-
/**
* Final status code.
*/
@@ -122,20 +122,28 @@
struct GNUNET_PeerIdentity id;
struct GNUNET_DISK_FileHandle *fd;
struct GNUNET_CRYPTO_RsaPrivateKey *pk;
+ struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb;
system = GNUNET_TESTING_system_create ("testing", NULL);
pk = GNUNET_TESTING_hostkey_get (system, create_no, &id);
+ if (NULL == pk)
+ {
+ fprintf (stderr, _("Could not extract hostkey %u (offset too large?)\n"),
create_no);
+ return 1;
+ }
fd = GNUNET_DISK_file_open (create_hostkey,
GNUNET_DISK_OPEN_READWRITE |
GNUNET_DISK_OPEN_CREATE,
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, pk, HOSTKEYFILESIZE));
+ GNUNET_DISK_file_write (fd, pkb, ntohs (pkb->len)));
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);
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22095 - in gnunet/src: include testing,
gnunet <=