Implement and use GNUNET_FS_namespace_get_public_key_hash
authorLRN <lrn1986@gmail.com>
Sun, 3 Mar 2013 01:57:10 +0000 (01:57 +0000)
committerLRN <lrn1986@gmail.com>
Sun, 3 Mar 2013 01:57:10 +0000 (01:57 +0000)
src/fs/fs_namespace.c
src/fs/fs_uri.c
src/include/gnunet_fs_service.h

index 9781cf6b7da2ec99807247871f6914f60ce96061..177af7efc3cb9eba5f05cb7277f46ea1397b6820 100644 (file)
@@ -495,6 +495,25 @@ struct ProcessNamespaceContext
 };
 
 
+/**
+ * Get hash of the public key of a namespace.
+ *
+ * @param ns namespace
+ * @param id buffer to store the key in
+ * @return GNUNET_OK on success
+ *         GNUNET_SYSERR on failure (contents of id remain intact)
+ */
+int
+GNUNET_FS_namespace_get_public_key_hash (struct GNUNET_FS_Namespace *ns,
+    struct GNUNET_HashCode *id)
+{
+  if ((NULL == ns) || (NULL == id))
+    return GNUNET_SYSERR;
+  GNUNET_CRYPTO_rsa_get_public_key_hash (ns->key, id);
+  return GNUNET_OK;
+}
+
+
 /**
  * Function called with a filename of a namespace. Reads the key and
  * calls the callback.
index d38a5354ddb71e2e5ec9177f193362a3a6b6a4be..d929eec64e4c7730991ee43b268846c8abb6eede 100644 (file)
@@ -948,8 +948,7 @@ GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id,
 
   ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
   ns_uri->type = GNUNET_FS_URI_SKS;
-  GNUNET_CRYPTO_rsa_key_get_public (ns->key, &pk);
-  GNUNET_CRYPTO_hash (&pk, sizeof (pk), &ns_uri->data.sks.ns);
+  GNUNET_FS_namespace_get_public_key_hash (ns, &ns_uri->data.sks.ns);
   ns_uri->data.sks.identifier = GNUNET_strdup (id);
   return ns_uri;
 }
index d6b26d92794924c275f6b9dd5ba4189cbfef9e59..1cb5028b388d4cba6eb83eb9572c976fbcde19e3 100644 (file)
@@ -2288,6 +2288,19 @@ struct GNUNET_FS_Namespace *
 GNUNET_FS_namespace_dup (struct GNUNET_FS_Namespace *ns);
 
 
+/**
+ * Get hash of the public key of a namespace.
+ *
+ * @param ns namespace
+ * @param id buffer to store the key in
+ * @return GNUNET_OK on success
+ *         GNUNET_SYSERR on failure (contents of id remain intact)
+ */
+int
+GNUNET_FS_namespace_get_public_key_hash (struct GNUNET_FS_Namespace *ns,
+    struct GNUNET_HashCode *id);
+
+
 /**
  * Delete a namespace handle.  Can be used for a clean shutdown (free
  * memory) or also to freeze the namespace to prevent further