diff options
author | LRN <lrn1986@gmail.com> | 2013-03-03 01:57:04 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-03-03 01:57:04 +0000 |
commit | 63346db616d6478416ec5686746a7818acf81ed6 (patch) | |
tree | e852f16fb85560b97986b87db09f966f2455664e | |
parent | 9d1521268727d41c5c9ef30d3568125d6f0ac379 (diff) | |
download | gnunet-63346db616d6478416ec5686746a7818acf81ed6.tar.gz gnunet-63346db616d6478416ec5686746a7818acf81ed6.zip |
Implement and use GNUNET_CRYPTO_rsa_get_public_key_hash
-rw-r--r-- | src/fs/fs_namespace.c | 4 | ||||
-rw-r--r-- | src/fs/fs_search.c | 7 | ||||
-rw-r--r-- | src/fs/fs_unindex.c | 7 | ||||
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 11 | ||||
-rw-r--r-- | src/util/crypto_rsa.c | 16 |
5 files changed, 30 insertions, 15 deletions
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c index 46121aa9c..9781cf6b7 100644 --- a/src/fs/fs_namespace.c +++ b/src/fs/fs_namespace.c | |||
@@ -509,7 +509,6 @@ process_namespace (void *cls, const char *filename) | |||
509 | { | 509 | { |
510 | struct ProcessNamespaceContext *pnc = cls; | 510 | struct ProcessNamespaceContext *pnc = cls; |
511 | struct GNUNET_CRYPTO_RsaPrivateKey *key; | 511 | struct GNUNET_CRYPTO_RsaPrivateKey *key; |
512 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk; | ||
513 | struct GNUNET_HashCode id; | 512 | struct GNUNET_HashCode id; |
514 | const char *name; | 513 | const char *name; |
515 | const char *t; | 514 | const char *t; |
@@ -525,9 +524,8 @@ process_namespace (void *cls, const char *filename) | |||
525 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); | 524 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); |
526 | return GNUNET_OK; | 525 | return GNUNET_OK; |
527 | } | 526 | } |
528 | GNUNET_CRYPTO_rsa_key_get_public (key, &pk); | 527 | GNUNET_CRYPTO_rsa_get_public_key_hash (key, &id); |
529 | GNUNET_CRYPTO_rsa_key_free (key); | 528 | GNUNET_CRYPTO_rsa_key_free (key); |
530 | GNUNET_CRYPTO_hash (&pk, sizeof (pk), &id); | ||
531 | name = filename; | 529 | name = filename; |
532 | while (NULL != (t = strstr (name, DIR_SEPARATOR_STR))) | 530 | while (NULL != (t = strstr (name, DIR_SEPARATOR_STR))) |
533 | name = t + 1; | 531 | name = t + 1; |
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index ffa2d61aa..718af912a 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -1304,12 +1304,7 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc) | |||
1304 | GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc); | 1304 | GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc); |
1305 | pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc); | 1305 | pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc); |
1306 | GNUNET_assert (NULL != pk); | 1306 | GNUNET_assert (NULL != pk); |
1307 | GNUNET_CRYPTO_rsa_key_get_public (pk, &pub); | 1307 | GNUNET_CRYPTO_rsa_get_public_key_hash (pk, &sc->requests[i].query); |
1308 | GNUNET_CRYPTO_rsa_key_free (pk); | ||
1309 | GNUNET_CRYPTO_hash (&pub, | ||
1310 | sizeof (struct | ||
1311 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
1312 | &sc->requests[i].query); | ||
1313 | sc->requests[i].mandatory = (sc->uri->data.ksk.keywords[i][0] == '+'); | 1308 | sc->requests[i].mandatory = (sc->uri->data.ksk.keywords[i][0] == '+'); |
1314 | if (sc->requests[i].mandatory) | 1309 | if (sc->requests[i].mandatory) |
1315 | sc->mandatory_count++; | 1310 | sc->mandatory_count++; |
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 221760328..028ded44a 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -571,12 +571,7 @@ GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc) | |||
571 | GNUNET_CRYPTO_hash (keyword, strlen (keyword), &uc->key); | 571 | GNUNET_CRYPTO_hash (keyword, strlen (keyword), &uc->key); |
572 | pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&uc->key); | 572 | pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&uc->key); |
573 | GNUNET_assert (pk != NULL); | 573 | GNUNET_assert (pk != NULL); |
574 | GNUNET_CRYPTO_rsa_key_get_public (pk, &pub); | 574 | GNUNET_CRYPTO_rsa_get_public_key_hash (pk, &uc->query); |
575 | GNUNET_CRYPTO_rsa_key_free (pk); | ||
576 | GNUNET_CRYPTO_hash (&pub, | ||
577 | sizeof (struct | ||
578 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
579 | &uc->query); | ||
580 | uc->first_uid = 0; | 575 | uc->first_uid = 0; |
581 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, | 576 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, |
582 | uc->roff++, | 577 | uc->roff++, |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 99d4ac58f..8c7f31010 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -1081,6 +1081,17 @@ GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey | |||
1081 | 1081 | ||
1082 | 1082 | ||
1083 | /** | 1083 | /** |
1084 | * Get hash of the public key that corresponds to a private key. | ||
1085 | * | ||
1086 | * @param key RSA private key | ||
1087 | * @param id buffer for hash of the public key | ||
1088 | */ | ||
1089 | void | ||
1090 | GNUNET_CRYPTO_rsa_get_public_key_hash (struct GNUNET_CRYPTO_RsaPrivateKey *key, | ||
1091 | struct GNUNET_HashCode *id); | ||
1092 | |||
1093 | |||
1094 | /** | ||
1084 | * Encrypt a block with the public key of another host that uses the | 1095 | * Encrypt a block with the public key of another host that uses the |
1085 | * same cyper. | 1096 | * same cyper. |
1086 | * | 1097 | * |
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 6857a1221..07eff6696 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -195,6 +195,22 @@ GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey | |||
195 | 195 | ||
196 | 196 | ||
197 | /** | 197 | /** |
198 | * Get hash of the public key that corresponds to a private key. | ||
199 | * | ||
200 | * @param key RSA private key | ||
201 | * @param id buffer for hash of the public key | ||
202 | */ | ||
203 | void | ||
204 | GNUNET_CRYPTO_rsa_get_public_key_hash (struct GNUNET_CRYPTO_RsaPrivateKey *key, | ||
205 | struct GNUNET_HashCode *id) | ||
206 | { | ||
207 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk; | ||
208 | GNUNET_CRYPTO_rsa_key_get_public (key, &pk); | ||
209 | GNUNET_CRYPTO_hash (&pk, sizeof (pk), id); | ||
210 | } | ||
211 | |||
212 | |||
213 | /** | ||
198 | * Convert a public key to a string. | 214 | * Convert a public key to a string. |
199 | * | 215 | * |
200 | * @param pub key to convert | 216 | * @param pub key to convert |