[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14559 - in gnunet/src: include testing util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14559 - in gnunet/src: include testing util |
Date: |
Wed, 2 Mar 2011 12:39:01 +0100 |
Author: nevans
Date: 2011-03-02 12:39:01 +0100 (Wed, 02 Mar 2011)
New Revision: 14559
Modified:
gnunet/src/include/gnunet_crypto_lib.h
gnunet/src/testing/testing.c
gnunet/src/util/crypto_rsa.c
Log:
Remove useless hostkey dilly-dallying in testing.
Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h 2011-03-02 10:52:08 UTC (rev
14558)
+++ gnunet/src/include/gnunet_crypto_lib.h 2011-03-02 11:39:01 UTC (rev
14559)
@@ -690,6 +690,16 @@
struct GNUNET_CRYPTO_RsaPrivateKey *GNUNET_CRYPTO_rsa_key_create (void);
/**
+ * Decode the private key from the data-format back
+ * to the "normal", internal format.
+ *
+ * @param buf the buffer where the private key data is stored
+ * @param len the length of the data in 'buffer'
+ */
+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
* file. Caller must free return value. Note that this function
Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c 2011-03-02 10:52:08 UTC (rev 14558)
+++ gnunet/src/testing/testing.c 2011-03-02 11:39:01 UTC (rev 14559)
@@ -435,6 +435,8 @@
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully got hostkey!\n");
#endif
+ /* Fall through */
+ case SP_HOSTKEY_CREATED:
if (d->hostkey_callback != NULL)
{
d->hostkey_callback (d->hostkey_cls, &d->id, d, NULL);
@@ -444,8 +446,6 @@
{
d->phase = SP_TOPOLOGY_SETUP;
}
- /* Fall through */
- case SP_HOSTKEY_CREATED:
/* wait for topology finished */
if ((GNUNET_YES == d->dead)
|| (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value ==
@@ -903,6 +903,8 @@
char *hostkeyfile;
char *temp_file_name;
struct GNUNET_DISK_FileHandle *fn;
+ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
+ struct GNUNET_CRYPTO_RsaPrivateKey *private_key;
ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon));
ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname);
@@ -1065,7 +1067,18 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No need to copy configuration file since we are running
locally.\n");
#endif
- ret->phase = SP_COPIED;
+ if (hostkey != NULL) /* Get the peer identity from the hostkey */
+ {
+ private_key = GNUNET_CRYPTO_rsa_decode_key(hostkey, HOSTKEYFILESIZE);
+ GNUNET_assert(private_key != NULL);
+ GNUNET_CRYPTO_rsa_key_get_public (private_key,
+ &public_key);
+ GNUNET_CRYPTO_hash(&public_key, sizeof(struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &ret->id.hashPubKey);
+ ret->shortname = GNUNET_strdup(GNUNET_i2s(&ret->id));
+ ret->phase = SP_HOSTKEY_CREATED;
+ }
+ else
+ ret->phase = SP_COPIED;
GNUNET_SCHEDULER_add_continuation (&start_fsm,
ret,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
Modified: gnunet/src/util/crypto_rsa.c
===================================================================
--- gnunet/src/util/crypto_rsa.c 2011-03-02 10:52:08 UTC (rev 14558)
+++ gnunet/src/util/crypto_rsa.c 2011-03-02 11:39:01 UTC (rev 14559)
@@ -380,17 +380,26 @@
/**
* Decode the private key from the file-format back
* to the "normal", internal format.
+ *
+ * @param buf the buffer where the private key data is stored
+ * @param len the length of the data in 'buffer'
*/
-static struct GNUNET_CRYPTO_RsaPrivateKey *
-rsa_decode_key (const struct RsaPrivateKeyBinaryEncoded *encoding)
+struct GNUNET_CRYPTO_RsaPrivateKey *
+GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len)
{
struct GNUNET_CRYPTO_RsaPrivateKey *ret;
+ const struct RsaPrivateKeyBinaryEncoded *encoding = (const struct
RsaPrivateKeyBinaryEncoded *)buf;
gcry_sexp_t res;
gcry_mpi_t n, e, d, p, q, u;
int rc;
size_t size;
int pos;
+ uint16_t enc_len;
+ enc_len = ntohs(encoding->len);
+ if (len != enc_len)
+ return NULL;
+
pos = 0;
size = ntohs (encoding->sizen);
rc = gcry_mpi_scan (&n,
@@ -718,7 +727,7 @@
GNUNET_assert (fs == GNUNET_DISK_file_read (fd, enc, fs));
len = ntohs (enc->len);
ret = NULL;
- if ((len != fs) || (NULL == (ret = rsa_decode_key (enc))))
+ if ((len != fs) || (NULL == (ret = GNUNET_CRYPTO_rsa_decode_key ((char
*)enc, len))))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14559 - in gnunet/src: include testing util,
gnunet <=