From: Schanzenbach, Martin Date: Sun, 9 Jul 2017 17:16:46 +0000 (+0200) Subject: -add cli X-Git-Tag: gnunet-0.11.0rc0~24^2~69 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=32b2ebbdc17d168f3ab60ff72b6b5ea64951422c;p=oweals%2Fgnunet.git -add cli --- diff --git a/src/identity-provider/gnunet-idp.c b/src/identity-provider/gnunet-idp.c index 017e0dbb5..77bb0a433 100644 --- a/src/identity-provider/gnunet-idp.c +++ b/src/identity-provider/gnunet-idp.c @@ -30,6 +30,11 @@ #include "gnunet_identity_service.h" #include "gnunet_signatures.h" +/** + * Init flag + */ +static int init; + /** * List attribute flag */ @@ -93,6 +98,7 @@ do_cleanup(void *cls) static void ns_error_cb (void *cls) { + ns_qe = NULL; GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Failed."); do_cleanup(NULL); @@ -104,6 +110,7 @@ store_attr_cont (void *cls, int32_t success, const char*emsg) { + ns_qe = NULL; if (GNUNET_SYSERR == success) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); @@ -120,6 +127,7 @@ store_abe_cont (void *cls, int32_t success, const char*emsg) { + ns_qe = NULL; if (GNUNET_SYSERR == success) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); @@ -133,6 +141,7 @@ store_abe_cont (void *cls, static void iter_error (void *cls) { + ns_iterator = NULL; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); @@ -141,6 +150,7 @@ iter_error (void *cls) static void iter_finished (void *cls) { + ns_iterator = NULL; GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); } @@ -151,16 +161,22 @@ iter_cb (void *cls, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd) { + struct GNUNET_CRYPTO_AbeKey *key; int i; char *attr_value; - + char* attrs[2]; for (i=0;i /dev/null +if test $? != 0 +then + echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" + exit 77 +fi + +rm -rf `gnunet-config -c test_idp.conf -s PATHS -o GNUNET_HOME -f` + +# (1) PKEY1.user -> PKEY2.resu.user +# (2) PKEY2.resu -> PKEY3 +# (3) PKEY3.user -> PKEY4 + + +which timeout &> /dev/null && DO_TIMEOUT="timeout 30" + +TEST_ATTR="test" +gnunet-arm -s -c test_idp.conf +gnunet-identity -C testego -c test_idp.conf +$DO_TIMEOUT valgrind gnunet-idp -e testego --init -c test_idp.conf +$DO_TIMEOUT valgrind gnunet-idp -e testego -a email -V john@doe.gnu -c test_idp.conf +STATUS=$? +gnunet-namestore -z testego -D -c test_idp.conf +$DO_TIMEOUT valgrind --leak-check=full gnunet-idp -e testego -D -c test_idp.conf + +if test $? != 0 +then + echo "Error issuing..." + exit 1 +fi +#Try import +gnunet-arm -e -c test_idp_lookup.conf +exit $RES diff --git a/src/identity-provider/test_idp_defaults.conf b/src/identity-provider/test_idp_defaults.conf new file mode 100644 index 000000000..10d89c2fb --- /dev/null +++ b/src/identity-provider/test_idp_defaults.conf @@ -0,0 +1,24 @@ +@INLINE@ ../../contrib/no_forcestart.conf + +[PATHS] +GNUNET_TEST_HOME = /tmp/test-gnunet-idp-testing/ + +[namestore-sqlite] +FILENAME = $GNUNET_TEST_HOME/namestore/sqlite_test.db + +[namecache-sqlite] +FILENAME=$GNUNET_TEST_HOME/namecache/namecache.db + +[identity] +# Directory where we store information about our egos +EGODIR = $GNUNET_TEST_HOME/identity/egos/ + +[dhtcache] +DATABASE = heap + +[transport] +PLUGINS = tcp + +[transport-tcp] +BINDTO = 127.0.0.1 + diff --git a/src/util/crypto_abe.c b/src/util/crypto_abe.c index 38812b412..f835a38dd 100644 --- a/src/util/crypto_abe.c +++ b/src/util/crypto_abe.c @@ -156,7 +156,6 @@ GNUNET_CRYPTO_cpabe_create_key (struct GNUNET_CRYPTO_AbeMasterKey *key, bswabe_pub_t* pub; bswabe_msk_t* msk; bswabe_prv_t* prv; - gchar* pub_data; gsize len; pub = bswabe_pub_unserialize(key->pub, 0); @@ -164,73 +163,62 @@ GNUNET_CRYPTO_cpabe_create_key (struct GNUNET_CRYPTO_AbeMasterKey *key, prv = bswabe_keygen(pub, msk, attrs); prv_key = GNUNET_new (struct GNUNET_CRYPTO_AbeKey); prv_key->prv = bswabe_prv_serialize(prv); - pub_data = g_strndup ((gchar*)key->pub->data, - key->pub->len); + len = key->pub->len; - prv_key->pub = g_byte_array_new_take ((guint8*)pub_data, len); + printf ("Keylen %lu\n", len); + prv_key->pub = bswabe_pub_serialize (pub); GNUNET_assert (NULL != prv_key->prv); return prv_key; } ssize_t write_cpabe (void **result, GByteArray* cph_buf, - int file_len, GByteArray* aes_buf) + uint32_t file_len, GByteArray* aes_buf) { char *ptr; + uint32_t *len; int i; - ssize_t size; - size = aes_buf->len + cph_buf->len + 12; - *result = GNUNET_malloc (size); + *result = GNUNET_malloc (12 + cph_buf->len + aes_buf->len); ptr = *result; - for(i=3; i >= 0; i--) { - *ptr = (file_len & 0xff<<(i*8))>>(i*8); - ptr++; - } - for(i=3; i >= 0; i--) { - *ptr = (aes_buf->len & 0xff<<(i*8))>>(i*8); - ptr++; - } + len = (uint32_t*) ptr; + *len = htonl (file_len); + ptr += 4; + len = (uint32_t*) ptr; + *len = htonl (aes_buf->len); + ptr += 4; memcpy (ptr, aes_buf->data, aes_buf->len); ptr += aes_buf->len; - for(i=3; i >= 0; i--) { - *ptr = (cph_buf->len & 0xff<<(i*8))>>(i*8); - ptr++; - } + len = (uint32_t*) ptr; + *len = htonl (cph_buf->len); + ptr += 4; memcpy (ptr, cph_buf->data, cph_buf->len); - return size; + return 12 + cph_buf->len + aes_buf->len; } ssize_t read_cpabe (const void *data, GByteArray** cph_buf, GByteArray** aes_buf) { int i; - ssize_t buf_len; - ssize_t tmp_len; + int buf_len; + int tmp_len; char *ptr; + uint32_t *len; *cph_buf = g_byte_array_new(); *aes_buf = g_byte_array_new(); ptr = (char*)data; - - buf_len = 0; - for(i=3; i >= 0; i--) { - buf_len |= *ptr<<(i*8); - ptr++; - } - - tmp_len = 0; - for(i=3; i >= 0; i--) { - tmp_len |= *ptr<<(i*8); - ptr++; - } + len = (uint32_t*)ptr; + buf_len = ntohl (*len); + ptr += 4; + len = (uint32_t*)ptr; + tmp_len = ntohl (*len); + ptr += 4; g_byte_array_set_size(*aes_buf, tmp_len); memcpy((*aes_buf)->data, ptr, tmp_len); ptr += tmp_len; - tmp_len = 0; - for(i=3; i >= 0; i--) { - tmp_len |= *ptr<<(i*8); - ptr++; - } + len = (uint32_t*)ptr; + tmp_len = ntohl (*len); + ptr += 4; g_byte_array_set_size(*cph_buf, tmp_len); memcpy((*cph_buf)->data, ptr, tmp_len);