ZONEKEY = $SERVICEHOME/gns/zonekey.zkey
HIJACK_DNS = NO
AUTO_IMPORT_PKEY = YES
+AUTO_IMPORT_ZONEKEY = $SERVICEHOME/gns/shorten_zonekey.zkey
AUTO_IMPORT_CONFIRMATION_REQ = NO
MAX_PARALLEL_BACKGROUND_QUERIES = 25
DEFAULT_LOOKUP_TIMEOUT = 10
*/
struct GNUNET_CRYPTO_ShortHashCode zone;
+ /**
+ * Should we use a shorten zone?
+ */
+ uint32_t use_shorten_zone GNUNET_PACKED;
+
+ /**
+ * If use_shorten_zone is set use this zone for shortening
+ */
+ struct GNUNET_CRYPTO_ShortHashCode shorten_zone;
+
/**
* the type of record to look up
*/
* If use_default_zone is empty this zone is used for lookup
*/
struct GNUNET_CRYPTO_ShortHashCode zone;
+
+ /**
+ * Should we use a shorten zone?
+ */
+ uint32_t use_shorten_zone GNUNET_PACKED;
+ /**
+ * If use_shorten_zone is set use this zone for shortening
+ */
+ struct GNUNET_CRYPTO_ShortHashCode shorten_zone;
+
/* Followed by the name to shorten up */
};
* @param handle handle to the GNS service
* @param name the name to look up
* @param zone the zone to start the resolution in
+ * @param shorten_zone the zone where to shorten names into
* @param type the record type to look up
* @param proc processor to call on result
* @param proc_cls closure for processor
GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
const char * name,
struct GNUNET_CRYPTO_ShortHashCode *zone,
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
enum GNUNET_GNS_RecordType type,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls)
lookup_msg->use_default_zone = htonl(1);
memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
}
-
+
+ if (NULL != shorten_zone)
+ {
+ lookup_msg->use_shorten_zone = htonl(1);
+ memcpy(&lookup_msg->shorten_zone, shorten_zone,
+ sizeof(struct GNUNET_CRYPTO_ShortHashCode));
+ }
+ else
+ {
+ lookup_msg->use_shorten_zone = htonl(0);
+ memset(&lookup_msg->shorten_zone, 0,
+ sizeof(struct GNUNET_CRYPTO_ShortHashCode));
+ }
+
lookup_msg->type = htonl(type);
memcpy(&lookup_msg[1], name, strlen(name));
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls)
{
- return GNUNET_GNS_lookup_zone (handle, name, NULL, type, proc, proc_cls);
+ return GNUNET_GNS_lookup_zone (handle, name,
+ NULL, NULL,
+ type, proc, proc_cls);
}
/**
* @param handle handle to the GNS service
* @param name the name to look up
* @param zone the zone to start the resolution in
+ * @param shorten_zone the zone where to shorten names into
* @param proc function to call on result
* @param proc_cls closure for processor
* @return handle to the operation
GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
const char * name,
struct GNUNET_CRYPTO_ShortHashCode *zone,
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
GNUNET_GNS_ShortenResultProcessor proc,
void *proc_cls)
{
shorten_msg->use_default_zone = htonl(1);
memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
}
-
+
+ if (NULL != shorten_zone)
+ {
+ shorten_msg->use_shorten_zone = htonl(1);
+ memcpy(&shorten_msg->shorten_zone, shorten_zone,
+ sizeof(struct GNUNET_CRYPTO_ShortHashCode));
+ }
+ else
+ {
+ shorten_msg->use_shorten_zone = htonl(0);
+ memset(&shorten_msg->shorten_zone, 0,
+ sizeof(struct GNUNET_CRYPTO_ShortHashCode));
+ }
+
memcpy(&shorten_msg[1], name, strlen(name));
GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail,
GNUNET_GNS_ShortenResultProcessor proc,
void *proc_cls)
{
- return GNUNET_GNS_shorten_zone (handle, name, NULL, proc, proc_cls);
+ return GNUNET_GNS_shorten_zone (handle, name, NULL, NULL, proc, proc_cls);
}
/**
* Perform an authority lookup for a given name.
/* The users local GNS zone hash */
static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone;
+/* The users local shorten zone hash */
+static struct GNUNET_CRYPTO_ShortHashCode local_shorten_zone;
+
/* The CA for SSL certificate generation */
static struct ProxyCA proxy_ca;
/* UNIX domain socket for mhd */
struct GNUNET_NETWORK_Handle *mhd_unix_socket;
+/* Shorten names? */
+int use_shorten;
+
/**
* Checks if name is in tld
*
GNUNET_GNS_lookup_zone (gns_handle,
ctask->host,
&local_gns_zone,
+ &local_shorten_zone,
GNUNET_GNS_RECORD_LEHO,
&process_leho_lookup,
ctask);
return GNUNET_YES;
}
+/**
+ * Loads the users local shorten zone key
+ *
+ * @return GNUNET_YES on success
+ */
+static int
+load_local_shorten_key (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ char *keyfile;
+ struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
+ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
+ struct GNUNET_CRYPTO_ShortHashCode *zone = NULL;
+ struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
+
+ if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "gns",
+ "AUTO_IMPORT_PKEY"))
+ {
+ return GNUNET_NO;
+ }
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+ "AUTO_IMPORT_ZONEKEY",
+ &keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to load zone key config value!\n");
+ return GNUNET_NO;
+ }
+
+ if (GNUNET_NO == GNUNET_DISK_file_test (keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to load zone key!\n");
+ GNUNET_free(keyfile);
+ return GNUNET_NO;
+ }
+
+ key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
+ GNUNET_CRYPTO_short_hash(&pkey,
+ sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &local_shorten_zone);
+ zone = &local_gns_zone;
+ GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using shorten zone: %s!\n", &zonename);
+ GNUNET_CRYPTO_rsa_key_free(key);
+ GNUNET_free(keyfile);
+
+ return GNUNET_YES;
+}
/**
* Main function that will be run
return;
}
+ use_shorten = load_local_shorten_key (cfg);
+
if (NULL == gns_handle)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
&proxy_sockfile))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Specify PROXY_UNIX_SOCK in gns-proxy config section!\n");
+ "Specify PROXY_UNIXPATH in gns-proxy config section!\n");
return;
}
struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
struct GNUNET_CRYPTO_ShortHashCode *zone = NULL;
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone = NULL;
struct GNUNET_CRYPTO_ShortHashCode user_zone;
struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
}
GNUNET_free(keyfile);
}
-
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+ "AUTO_IMPORT_ZONEKEY",
+ &keyfile))
+ {
+ if (!raw)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "No private key for shorten zone found!\n");
+ shorten_zone = NULL;
+ }
+ else
+ {
+ if (GNUNET_YES == GNUNET_DISK_file_test (keyfile))
+ {
+ key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
+ GNUNET_CRYPTO_short_hash(&pkey,
+ sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &user_zone);
+ shorten_zone = &user_zone;
+ GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename);
+ if (!raw)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using zone: %s!\n", &zonename);
+ GNUNET_CRYPTO_rsa_key_free(key);
+ }
+ GNUNET_free(keyfile);
+ }
+
gns = GNUNET_GNS_connect (cfg);
if (lookup_type != NULL)
rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type);
if (shorten_name != NULL)
{
/** shorten name */
- GNUNET_GNS_shorten_zone (gns, shorten_name, zone, &process_shorten_result,
- shorten_name);
+ GNUNET_GNS_shorten_zone (gns, shorten_name,
+ zone, shorten_zone,
+ &process_shorten_result,
+ shorten_name);
}
if (lookup_name != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Lookup\n");
- GNUNET_GNS_lookup_zone (gns, lookup_name, zone, rtype,
- &process_lookup_result, lookup_name);
+ GNUNET_GNS_lookup_zone (gns, lookup_name,
+ zone, shorten_zone,
+ rtype,
+ &process_lookup_result, lookup_name);
}
if (auth_name != NULL)
/* request type */
enum GNUNET_GNS_RecordType type;
- /* optional zone private key used for lookup */
- struct GNUNET_CRYPTO_RsaPrivateKey *zone_key;
+ /* optional zone private key used for shorten */
+ struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key;
/* name to shorten */
char* name;
/* request type */
enum GNUNET_GNS_RecordType type;
- /* optional zone private key used for lookup */
- struct GNUNET_CRYPTO_RsaPrivateKey *zone_key;
+ /* optional zone private key used for shorten */
+ struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key;
/* the name to look up */
char* name; //Needed?
}
/**
- * Lookup the private key for the zone
+ * Lookup the shorten key for the zone
*
* @param zone the zone we want a private key for
* @return NULL of not found else the key
*/
struct GNUNET_CRYPTO_RsaPrivateKey*
-lookup_private_key(struct GNUNET_CRYPTO_ShortHashCode *zone)
+lookup_shorten_key(struct GNUNET_CRYPTO_ShortHashCode *short_zone)
{
char* keydir;
struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Looking for private key\n");
+ "Looking for shorten zonekey\n");
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (GNS_cfg,
"namestore",
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Zonefile directory is %s\n", keydir);
- GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
+ GNUNET_CRYPTO_short_hash_to_enc (short_zone, &zonename);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Zonefile is %s.zkey\n", &zonename);
+ "Zonefile for shorten is %s.zkey\n", &zonename);
GNUNET_asprintf(&location, "%s%s%s.zkey", keydir,
DIR_SEPARATOR_STR, &zonename);
GNUNET_free(rmsg);
GNUNET_free_non_null(csh->name);
- GNUNET_free_non_null(csh->zone_key);
+ GNUNET_free_non_null(csh->shorten_key);
GNUNET_free(csh);
}
csh = GNUNET_malloc(sizeof(struct ClientShortenHandle));
csh->client = client;
csh->unique_id = sh_msg->id;
- csh->zone_key = NULL;
+ csh->shorten_key = NULL;
GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
/* Start shortening */
if (GNUNET_YES == auto_import_pkey)
{
- if (1 == ntohl(sh_msg->use_default_zone))
- key = zone_key;
+ if (0 == ntohl(sh_msg->use_shorten_zone))
+ key = NULL;
else
{
- key = lookup_private_key(&sh_msg->zone);
- csh->zone_key = key;
+ key = lookup_shorten_key(&sh_msg->shorten_zone);
+ csh->shorten_key = key;
}
gns_resolver_shorten_name(zone, zone, name, key,
&send_shorten_response, csh);
GNUNET_free(rmsg);
GNUNET_free(clh->name);
- if (NULL != clh->zone_key)
- GNUNET_free(clh->zone_key);
+ if (NULL != clh->shorten_key)
+ GNUNET_free(clh->shorten_key);
GNUNET_free(clh);
strcpy(clh->name, name);
clh->unique_id = sh_msg->id;
clh->type = ntohl(sh_msg->type);
- clh->zone_key = NULL;
+ clh->shorten_key = NULL;
if (strlen (name) > MAX_DNS_NAME_LENGTH) {
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
if (GNUNET_YES == auto_import_pkey)
{
- if (1 == ntohl(sh_msg->use_default_zone))
+ if (1 == ntohl(sh_msg->use_shorten_zone))
key = zone_key;
else
{
- key = lookup_private_key(&zone);
- clh->zone_key = key;
+ key = lookup_shorten_key(&sh_msg->shorten_zone);
+ clh->shorten_key = key;
}
gns_resolver_lookup_record(zone, zone, clh->type, name,
struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
struct GNUNET_CRYPTO_ShortHashCode alice_hash;
struct GNUNET_CRYPTO_ShortHashCode bob_hash;
+struct GNUNET_CRYPTO_ShortHashCode our_zone;
/**
* Check whether peers successfully shut down.
static void
do_shorten(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_GNS_shorten(gns_handle, TEST_DOMAIN, &process_shorten_result,
+ GNUNET_GNS_shorten_zone (gns_handle, TEST_DOMAIN,
+ &our_zone, &our_zone,
+ &process_shorten_result,
TEST_DOMAIN);
}
"Failed to connect to GNS!\n");
}
- GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+ GNUNET_GNS_lookup_zone (gns_handle, TEST_DOMAIN,
+ &our_zone, &our_zone,
+ GNUNET_GNS_RECORD_TYPE_A,
&on_lookup_result, TEST_DOMAIN);
}
GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey);
GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
+ GNUNET_CRYPTO_short_hash(&our_pkey, sizeof(our_pkey), &our_zone);
struct GNUNET_NAMESTORE_RecordData rd;
rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
* @param handle handle to the GNS service
* @param name the name to look up
* @param zone the zone to start the resolution in
+ * @param shorten_zone the zone where to shorten names into
* @param type the GNUNET_GNS_RecordType to look for
* @param proc function to call on result
* @param proc_cls closure for processor
GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
const char * name,
struct GNUNET_CRYPTO_ShortHashCode *zone,
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
enum GNUNET_GNS_RecordType type,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls);
* @param handle handle to the GNS service
* @param name the name to look up
* @param zone the zone to start the resolution in
+ * @param shorten_zone the zone where to shorten names into
* @param proc function to call on result
* @param proc_cls closure for processor
* @return handle to the operation
GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
const char * name,
struct GNUNET_CRYPTO_ShortHashCode *zone,
+ struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
GNUNET_GNS_ShortenResultProcessor proc,
void *proc_cls);