#include "gnunet_identity_service.h"
#include "gnunet_signatures.h"
+/**
+ * Init flag
+ */
+static int init;
+
/**
* List attribute flag
*/
static void
ns_error_cb (void *cls)
{
+ ns_qe = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Failed.");
do_cleanup(NULL);
int32_t success,
const char*emsg)
{
+ ns_qe = NULL;
if (GNUNET_SYSERR == success) {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%s\n", emsg);
int32_t success,
const char*emsg)
{
+ ns_qe = NULL;
if (GNUNET_SYSERR == success) {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%s\n", emsg);
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);
static void
iter_finished (void *cls)
{
+ ns_iterator = NULL;
GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
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<rd_count;i++) {
if (GNUNET_GNSRECORD_TYPE_ID_ATTR != rd[i].record_type)
continue;
- GNUNET_CRYPTO_cpabe_decrypt_master (rd[i].data,
- rd[i].data_size,
- abe_key,
- &attr_value);
+ attrs[0] = (char*)label;
+ attrs[1] = 0;
+ key = GNUNET_CRYPTO_cpabe_create_key (abe_key,
+ attrs);
+ GNUNET_CRYPTO_cpabe_decrypt (rd[i].data,
+ rd[i].data_size,
+ key,
+ (void**)&attr_value);
+ GNUNET_free (key);
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"%s: %s\n", label, attr_value);
}
struct GNUNET_CRYPTO_AbeMasterKey *new_key;
int i;
ssize_t size;
-
+ ns_qe = NULL;
for (i=0;i<rd_count;i++) {
if (GNUNET_GNSRECORD_TYPE_ABE_MASTER != rd[i].record_type)
continue;
NULL);
return;
}
+ if (init) {
+ GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
+ return;
+ }
if (list) {
ns_iterator = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
const char *name)
{
const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey;
+ if (NULL == name)
+ return;
if (0 != strcmp (name, ego_name))
return;
pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
return;
}
- if ((NULL == attr_name) && !list)
+ if ((NULL == attr_name) && !list && !init)
{
return;
}
- if ((NULL == attr_value) && !list)
+ if ((NULL == attr_value) && !list && !init)
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
_("Value is required\n"));
NULL,
gettext_noop ("Ego"),
&ego_name),
- GNUNET_GETOPT_option_flag ('l',
- "list",
+ GNUNET_GETOPT_option_flag ('D',
+ "dump",
gettext_noop ("List attributes for Ego"),
&list),
-
+ GNUNET_GETOPT_option_flag ('i',
+ "init",
+ gettext_noop ("Initialize attribute store"),
+ &init),
GNUNET_GETOPT_OPTION_END
};
return GNUNET_PROGRAM_run (argc, argv, "ct",
--- /dev/null
+@INLINE@ test_idp_defaults.conf
+
+[PATHS]
+GNUNET_TEST_HOME = /tmp/test-gnunet-idp-peer-1/
+
+[dht]
+AUTOSTART = YES
+
+[transport]
+PLUGINS =
+
+[identity-provider]
+AUTOSTART = YES
+PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/idplog
+
+[gns]
+#PREFIX = valgrind --leak-check=full --track-origins=yes
+AUTOSTART = YES
+AUTO_IMPORT_PKEY = YES
+MAX_PARALLEL_BACKGROUND_QUERIES = 10
+DEFAULT_LOOKUP_TIMEOUT = 15 s
+RECORD_PUT_INTERVAL = 1 h
+ZONE_PUBLISH_TIME_WINDOW = 1 h
+DNS_ROOT=PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0
+
--- /dev/null
+#!/bin/bash
+trap "gnunet-arm -e -c test_idp_lookup.conf" SIGINT
+
+LOCATION=$(which gnunet-config)
+if [ -z $LOCATION ]
+then
+ LOCATION="gnunet-config"
+fi
+$LOCATION --version 1> /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
--- /dev/null
+@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
+
bswabe_pub_t* pub;
bswabe_msk_t* msk;
bswabe_prv_t* prv;
- gchar* pub_data;
gsize len;
pub = bswabe_pub_unserialize(key->pub, 0);
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);