static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_GNSRECORD_Block *block; struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; /* load privat key */ char *hostkey_file; GNUNET_asprintf(&hostkey_file, "zonefiles%s%s", DIR_SEPARATOR_STR, "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s'\n", hostkey_file); privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); GNUNET_free (hostkey_file); GNUNET_assert (privkey != NULL); struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get(); /* get public key */ GNUNET_CRYPTO_ecdsa_key_get_public(privkey, &pubkey); /* create record */ s_name = "DUMMY.dummy.gnunet"; s_rd = create_record (RECORDS); /* Create block */ GNUNET_assert (NULL != (block = GNUNET_GNSRECORD_block_create (privkey, expire,s_name, s_rd, RECORDS))); GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_verify (block)); GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_decrypt (block, &pubkey, s_name, &rd_decrypt_cb, s_name)); GNUNET_free (block); }
static void name_lookup_proc (void *cls, const struct GNUNET_GNSRECORD_Block *block) { const char *name = cls; ncqe = NULL; GNUNET_assert (NULL != cls); if (endbadly_task != NULL) { GNUNET_SCHEDULER_cancel (endbadly_task); endbadly_task = NULL; } if (NULL == block) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Namestore returned no block\n")); if (endbadly_task != NULL) GNUNET_SCHEDULER_cancel (endbadly_task); endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore returned block, decrypting \n"); GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_decrypt(block, &pubkey, name, &rd_decrypt_cb, (void *) name)); }
/** * We obtained a result for our query to the shorten zone from * the namestore. Try to decrypt. * * @param cls the handle to our shorten operation * @param block resulting encrypted block */ static void process_pseu_block_ns (void *cls, const struct GNUNET_GNSRECORD_Block *block) { struct GetPseuAuthorityHandle *gph = cls; struct GNUNET_CRYPTO_EcdsaPublicKey pub; gph->namecache_task = NULL; if (NULL == block) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namecache did not return information for label `%s' \n", gph->current_label); process_pseu_lookup_ns (gph, 0, NULL); return; } GNUNET_CRYPTO_ecdsa_key_get_public (&gph->shorten_zone_key, &pub); if (GNUNET_OK != GNUNET_GNSRECORD_block_decrypt (block, &pub, gph->current_label, &process_pseu_lookup_ns, gph)) { GNUNET_break (0); free_get_pseu_authority_handle (gph); return; } }