diff options
author | LRN <lrn1986@gmail.com> | 2013-03-03 01:57:10 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-03-03 01:57:10 +0000 |
commit | 058c49560ff702057bd8799c2d21b1fd70cb7134 (patch) | |
tree | a4a1d481f45cac006aa452aef2a451f16d03097a /src | |
parent | 63346db616d6478416ec5686746a7818acf81ed6 (diff) | |
download | gnunet-058c49560ff702057bd8799c2d21b1fd70cb7134.tar.gz gnunet-058c49560ff702057bd8799c2d21b1fd70cb7134.zip |
Implement and use GNUNET_FS_namespace_get_public_key_hash
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/fs_namespace.c | 19 | ||||
-rw-r--r-- | src/fs/fs_uri.c | 3 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 13 |
3 files changed, 33 insertions, 2 deletions
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c index 9781cf6b7..177af7efc 100644 --- a/src/fs/fs_namespace.c +++ b/src/fs/fs_namespace.c | |||
@@ -496,6 +496,25 @@ struct ProcessNamespaceContext | |||
496 | 496 | ||
497 | 497 | ||
498 | /** | 498 | /** |
499 | * Get hash of the public key of a namespace. | ||
500 | * | ||
501 | * @param ns namespace | ||
502 | * @param id buffer to store the key in | ||
503 | * @return GNUNET_OK on success | ||
504 | * GNUNET_SYSERR on failure (contents of id remain intact) | ||
505 | */ | ||
506 | int | ||
507 | GNUNET_FS_namespace_get_public_key_hash (struct GNUNET_FS_Namespace *ns, | ||
508 | struct GNUNET_HashCode *id) | ||
509 | { | ||
510 | if ((NULL == ns) || (NULL == id)) | ||
511 | return GNUNET_SYSERR; | ||
512 | GNUNET_CRYPTO_rsa_get_public_key_hash (ns->key, id); | ||
513 | return GNUNET_OK; | ||
514 | } | ||
515 | |||
516 | |||
517 | /** | ||
499 | * Function called with a filename of a namespace. Reads the key and | 518 | * Function called with a filename of a namespace. Reads the key and |
500 | * calls the callback. | 519 | * calls the callback. |
501 | * | 520 | * |
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index d38a5354d..d929eec64 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -948,8 +948,7 @@ GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id, | |||
948 | 948 | ||
949 | ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 949 | ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
950 | ns_uri->type = GNUNET_FS_URI_SKS; | 950 | ns_uri->type = GNUNET_FS_URI_SKS; |
951 | GNUNET_CRYPTO_rsa_key_get_public (ns->key, &pk); | 951 | GNUNET_FS_namespace_get_public_key_hash (ns, &ns_uri->data.sks.ns); |
952 | GNUNET_CRYPTO_hash (&pk, sizeof (pk), &ns_uri->data.sks.ns); | ||
953 | ns_uri->data.sks.identifier = GNUNET_strdup (id); | 952 | ns_uri->data.sks.identifier = GNUNET_strdup (id); |
954 | return ns_uri; | 953 | return ns_uri; |
955 | } | 954 | } |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index d6b26d927..1cb5028b3 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -2289,6 +2289,19 @@ GNUNET_FS_namespace_dup (struct GNUNET_FS_Namespace *ns); | |||
2289 | 2289 | ||
2290 | 2290 | ||
2291 | /** | 2291 | /** |
2292 | * Get hash of the public key of a namespace. | ||
2293 | * | ||
2294 | * @param ns namespace | ||
2295 | * @param id buffer to store the key in | ||
2296 | * @return GNUNET_OK on success | ||
2297 | * GNUNET_SYSERR on failure (contents of id remain intact) | ||
2298 | */ | ||
2299 | int | ||
2300 | GNUNET_FS_namespace_get_public_key_hash (struct GNUNET_FS_Namespace *ns, | ||
2301 | struct GNUNET_HashCode *id); | ||
2302 | |||
2303 | |||
2304 | /** | ||
2292 | * Delete a namespace handle. Can be used for a clean shutdown (free | 2305 | * Delete a namespace handle. Can be used for a clean shutdown (free |
2293 | * memory) or also to freeze the namespace to prevent further | 2306 | * memory) or also to freeze the namespace to prevent further |
2294 | * insertions by anyone. | 2307 | * insertions by anyone. |