- struct AdvertisementContext *ac = cls;
- const char *keyword;
- GNUNET_HashCode key;
- GNUNET_HashCode query;
- struct GNUNET_CRYPTO_AesSessionKey skey;
- struct GNUNET_CRYPTO_AesInitializationVector iv;
- struct GNUNET_CRYPTO_RsaPrivateKey *pk;
-
- if (GNUNET_OK != success)
- {
- /* error! */
- GNUNET_DATASTORE_disconnect (ac->dsh, GNUNET_NO);
- ac->cont (ac->cont_cls, NULL, msg);
- GNUNET_FS_uri_destroy (ac->ksk_uri);
- GNUNET_free (ac->pt);
- GNUNET_free (ac->nb);
- GNUNET_FS_namespace_delete (ac->ns, GNUNET_NO);
- GNUNET_free (ac);
- return;
- }
- if (ac->pos == ac->ksk_uri->data.ksk.keywordCount)
- {
- /* done! */
- GNUNET_DATASTORE_disconnect (ac->dsh, GNUNET_NO);
- ac->cont (ac->cont_cls, ac->ksk_uri, NULL);
- GNUNET_FS_uri_destroy (ac->ksk_uri);
- GNUNET_free (ac->pt);
- GNUNET_free (ac->nb);
- GNUNET_FS_namespace_delete (ac->ns, GNUNET_NO);
- GNUNET_free (ac);
- return;
- }
- keyword = ac->ksk_uri->data.ksk.keywords[ac->pos++];
- /* first character of keyword indicates if it is
- mandatory or not -- ignore for hashing */
- GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key);
- GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
- GNUNET_CRYPTO_aes_encrypt (ac->pt,
- ac->pt_size,
- &skey,
- &iv,
- &ac->nb[1]);
- GNUNET_break (GNUNET_OK ==
- GNUNET_CRYPTO_rsa_sign (ac->ns->key,
- &ac->nb->ns_purpose,
- &ac->nb->ns_signature));
- pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
- GNUNET_CRYPTO_rsa_key_get_public (pk, &ac->nb->keyspace);
- GNUNET_CRYPTO_hash (&ac->nb->keyspace,
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
- &query);
- GNUNET_break (GNUNET_OK ==
- GNUNET_CRYPTO_rsa_sign (pk,
- &ac->nb->ksk_purpose,
- &ac->nb->ksk_signature));
- GNUNET_CRYPTO_rsa_key_free (pk);
- GNUNET_DATASTORE_put (ac->dsh,
- 0 /* no reservation */,
- &query,
- ac->pt_size + sizeof (struct NBlock),
- ac->nb,
- GNUNET_BLOCK_TYPE_NBLOCK,
- ac->priority,
- ac->anonymity,
- ac->expiration,
- -2, 1,
- GNUNET_CONSTANTS_SERVICE_TIMEOUT,
- &advertisement_cont,
- ac);
+ char *dn;
+ char *ret;
+ struct GNUNET_CRYPTO_EcdsaPublicKey pub;
+ struct GNUNET_HashCode hc;
+ struct GNUNET_CRYPTO_HashAsciiEncoded enc;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "UPDATE_DIR",
+ &dn))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "fs", "UPDATE_DIR");
+ return NULL;
+ }
+ GNUNET_CRYPTO_ecdsa_key_get_public (ns, &pub);
+ GNUNET_CRYPTO_hash (&pub, sizeof (pub), &hc);
+ GNUNET_CRYPTO_hash_to_enc (&hc,
+ &enc);
+ GNUNET_asprintf (&ret, "%s%s%s",
+ dn,
+ DIR_SEPARATOR_STR,
+ (const char *) enc.encoding);
+ GNUNET_free (dn);
+ return ret;