diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_protocols.h | 1 | ||||
-rw-r--r-- | src/include/gnunet_reclaim_service.h | 19 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 198 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 114 | ||||
-rw-r--r-- | src/reclaim/reclaim_api.c | 43 |
5 files changed, 366 insertions, 9 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index f8d424359..367f6fd80 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -3309,6 +3309,7 @@ extern "C" { | |||
3309 | /** | 3309 | /** |
3310 | * Next available: 1500 | 3310 | * Next available: 1500 |
3311 | */ | 3311 | */ |
3312 | #define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE 1500 | ||
3312 | 3313 | ||
3313 | 3314 | ||
3314 | /** | 3315 | /** |
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h index eb6c1bc9e..f839123e5 100644 --- a/src/include/gnunet_reclaim_service.h +++ b/src/include/gnunet_reclaim_service.h | |||
@@ -210,6 +210,25 @@ GNUNET_RECLAIM_attestation_delete ( | |||
210 | const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, | 210 | const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, |
211 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 211 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
212 | void *cont_cls); | 212 | void *cont_cls); |
213 | |||
214 | /** | ||
215 | * Delete an attestation reference. Tickets used to share this reference are updated | ||
216 | * accordingly. | ||
217 | * | ||
218 | * @param h handle to the re:claimID service | ||
219 | * @param pkey Private key of the identity to delete the reference from | ||
220 | * @param attr The reference | ||
221 | * @param cont Continuation to call when done | ||
222 | * @param cont_cls Closure for @a cont | ||
223 | * @return handle Used to to abort the request | ||
224 | */ | ||
225 | struct GNUNET_RECLAIM_Operation * | ||
226 | GNUNET_RECLAIM_attestation_reference_delete ( | ||
227 | struct GNUNET_RECLAIM_Handle *h, | ||
228 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | ||
229 | const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, | ||
230 | GNUNET_RECLAIM_ContinuationWithStatus cont, | ||
231 | void *cont_cls); | ||
213 | /** | 232 | /** |
214 | * List all attributes for a local identity. | 233 | * List all attributes for a local identity. |
215 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` | 234 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` |
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index aea96e61e..1f320e196 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -271,6 +271,10 @@ struct AttributeDeleteHandle | |||
271 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; | 271 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; |
272 | 272 | ||
273 | /** | 273 | /** |
274 | * The reference to delete | ||
275 | */ | ||
276 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference; | ||
277 | /** | ||
274 | * Tickets to update | 278 | * Tickets to update |
275 | */ | 279 | */ |
276 | struct TicketRecordsEntry *tickets_to_update_head; | 280 | struct TicketRecordsEntry *tickets_to_update_head; |
@@ -476,6 +480,8 @@ cleanup_adh (struct AttributeDeleteHandle *adh) | |||
476 | GNUNET_free (adh->claim); | 480 | GNUNET_free (adh->claim); |
477 | if (NULL != adh->attest) | 481 | if (NULL != adh->attest) |
478 | GNUNET_free (adh->attest); | 482 | GNUNET_free (adh->attest); |
483 | if (NULL != adh->reference) | ||
484 | GNUNET_free (adh->reference); | ||
479 | while (NULL != (le = adh->tickets_to_update_head)) | 485 | while (NULL != (le = adh->tickets_to_update_head)) |
480 | { | 486 | { |
481 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, | 487 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, |
@@ -1193,6 +1199,21 @@ ref_error (void *cls) | |||
1193 | } | 1199 | } |
1194 | 1200 | ||
1195 | /** | 1201 | /** |
1202 | * Error looking up potential reference value. Abort. | ||
1203 | * | ||
1204 | * @param cls our attribute delete handle | ||
1205 | */ | ||
1206 | static void | ||
1207 | ref_del_error (void *cls) | ||
1208 | { | ||
1209 | struct AttributeDeleteHandle *adh = cls; | ||
1210 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1211 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1212 | cleanup_adh (adh); | ||
1213 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1214 | return; | ||
1215 | } | ||
1216 | /** | ||
1196 | * Reference store result handler | 1217 | * Reference store result handler |
1197 | * | 1218 | * |
1198 | * @param cls our attribute store handle | 1219 | * @param cls our attribute store handle |
@@ -1306,8 +1327,9 @@ reference_store_task (void *cls) | |||
1306 | { | 1327 | { |
1307 | if (0 == ash->reference->id_attest) | 1328 | if (0 == ash->reference->id_attest) |
1308 | { | 1329 | { |
1309 | ash->reference->id = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, | 1330 | ash->reference->id = GNUNET_CRYPTO_random_u64 ( |
1310 | UINT64_MAX); | 1331 | GNUNET_CRYPTO_QUALITY_STRONG, |
1332 | UINT64_MAX); | ||
1311 | } | 1333 | } |
1312 | else | 1334 | else |
1313 | { | 1335 | { |
@@ -1327,7 +1349,7 @@ reference_store_task (void *cls) | |||
1327 | ash, | 1349 | ash, |
1328 | &ref_add_cb, | 1350 | &ref_add_cb, |
1329 | ash); | 1351 | ash); |
1330 | GNUNET_free (label); | 1352 | GNUNET_free (label); |
1331 | } | 1353 | } |
1332 | 1354 | ||
1333 | /** | 1355 | /** |
@@ -1338,8 +1360,8 @@ reference_store_task (void *cls) | |||
1338 | */ | 1360 | */ |
1339 | static int | 1361 | static int |
1340 | check_reference_store_message (void *cls, | 1362 | check_reference_store_message (void *cls, |
1341 | const struct | 1363 | const struct |
1342 | AttributeStoreMessage *sam) | 1364 | AttributeStoreMessage *sam) |
1343 | { | 1365 | { |
1344 | uint16_t size; | 1366 | uint16_t size; |
1345 | 1367 | ||
@@ -1432,14 +1454,18 @@ ticket_iter (void *cls, | |||
1432 | for (int i = 0; i < rd_count; i++) | 1454 | for (int i = 0; i < rd_count; i++) |
1433 | { | 1455 | { |
1434 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) && | 1456 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) && |
1435 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type)) | 1457 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type) && |
1458 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF != rd[i].record_type)) | ||
1436 | continue; | 1459 | continue; |
1437 | if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) | 1460 | if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) |
1438 | continue; | 1461 | continue; |
1439 | if (0 != memcmp (rd[i].data, (&adh->attest->id), sizeof(uint64_t))) | 1462 | if (0 != memcmp (rd[i].data, (&adh->attest->id), sizeof(uint64_t))) |
1440 | continue; | 1463 | continue; |
1464 | if (0 != memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t))) | ||
1465 | continue; | ||
1466 | |||
1441 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1467 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1442 | "Attribute or Attestation to delete found (%s)\n", | 1468 | "Attribute or Attestation/Reference to delete found (%s)\n", |
1443 | adh->label); | 1469 | adh->label); |
1444 | has_changed = GNUNET_YES; | 1470 | has_changed = GNUNET_YES; |
1445 | break; | 1471 | break; |
@@ -1535,6 +1561,9 @@ update_tickets (void *cls) | |||
1535 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) | 1561 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) |
1536 | && (0 == memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))) | 1562 | && (0 == memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))) |
1537 | continue; | 1563 | continue; |
1564 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF == rd[i].record_type) | ||
1565 | && (0 == memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t)))) | ||
1566 | continue; | ||
1538 | rd_new[j] = rd[i]; | 1567 | rd_new[j] = rd[i]; |
1539 | j++; | 1568 | j++; |
1540 | } | 1569 | } |
@@ -1782,7 +1811,158 @@ handle_attestation_delete_message (void *cls, | |||
1782 | 1811 | ||
1783 | 1812 | ||
1784 | 1813 | ||
1814 | /** | ||
1815 | * Reference deleted callback | ||
1816 | * | ||
1817 | * @param cls our handle | ||
1818 | * @param success success status | ||
1819 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1820 | */ | ||
1821 | static void | ||
1822 | reference_delete_cont (void *cls, int32_t success, const char *emsg) | ||
1823 | { | ||
1824 | struct AttributeDeleteHandle *adh = cls; | ||
1785 | 1825 | ||
1826 | adh->ns_qe = NULL; | ||
1827 | if (GNUNET_SYSERR == success) | ||
1828 | { | ||
1829 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1830 | "Error deleting reference %s\n", | ||
1831 | adh->label); | ||
1832 | send_delete_response (adh, GNUNET_SYSERR); | ||
1833 | cleanup_adh (adh); | ||
1834 | return; | ||
1835 | } | ||
1836 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); | ||
1837 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | ||
1838 | } | ||
1839 | |||
1840 | static void | ||
1841 | ref_del_cb (void *cls, | ||
1842 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
1843 | const char *label, | ||
1844 | unsigned int rd_count, | ||
1845 | const struct GNUNET_GNSRECORD_Data *rd) | ||
1846 | { | ||
1847 | |||
1848 | struct AttributeDeleteHandle *adh = cls; | ||
1849 | char *data_tmp; | ||
1850 | struct GNUNET_GNSRECORD_Data rd_new[rd_count - 1]; | ||
1851 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref; | ||
1852 | size_t attr_len; | ||
1853 | |||
1854 | if (0 == rd_count ) | ||
1855 | { | ||
1856 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1857 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1858 | cleanup_adh (adh); | ||
1859 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1860 | return; | ||
1861 | } | ||
1862 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | ||
1863 | { | ||
1864 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1865 | "Intended Reference location is not an attestation\n"); | ||
1866 | cleanup_adh (adh); | ||
1867 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1868 | return; | ||
1869 | } | ||
1870 | rd_new[0] = rd[0]; | ||
1871 | int i; | ||
1872 | int j = 1; | ||
1873 | for (i = 1; i<rd_count; i++) | ||
1874 | { | ||
1875 | data_tmp = GNUNET_malloc (rd[i].data_size); | ||
1876 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
1877 | attr_len = htons (rd->data_size); | ||
1878 | ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, attr_len); | ||
1879 | if (NULL == ref ) | ||
1880 | { | ||
1881 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1882 | "Unable to parse attestation reference from %s\n", | ||
1883 | data_tmp); | ||
1884 | rd_new[j] = rd[i]; | ||
1885 | j += 1; | ||
1886 | continue; | ||
1887 | } | ||
1888 | if ((strcmp (adh->reference->name,ref->name) == 0)&& | ||
1889 | (strcmp (adh->reference->reference_value,ref->reference_value)==0) ) | ||
1890 | { | ||
1891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1892 | "Found reference to delete.\n"); | ||
1893 | } | ||
1894 | else | ||
1895 | { | ||
1896 | rd_new[j] = rd[i]; | ||
1897 | j += 1; | ||
1898 | } | ||
1899 | GNUNET_free (data_tmp); | ||
1900 | } | ||
1901 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1902 | &adh->identity, | ||
1903 | label, | ||
1904 | j, | ||
1905 | rd_new, | ||
1906 | &reference_delete_cont, | ||
1907 | adh); | ||
1908 | } | ||
1909 | |||
1910 | /** | ||
1911 | * Check an attestation reference delete message | ||
1912 | * | ||
1913 | * @param cls unused | ||
1914 | * @param sam the message to check | ||
1915 | */ | ||
1916 | static int | ||
1917 | check_reference_delete_message (void *cls, | ||
1918 | const struct AttributeDeleteMessage *dam) | ||
1919 | { | ||
1920 | uint16_t size; | ||
1921 | |||
1922 | size = ntohs (dam->header.size); | ||
1923 | if (size <= sizeof(struct AttributeDeleteMessage)) | ||
1924 | { | ||
1925 | GNUNET_break (0); | ||
1926 | return GNUNET_SYSERR; | ||
1927 | } | ||
1928 | return GNUNET_OK; | ||
1929 | } | ||
1930 | |||
1931 | /** | ||
1932 | * Handle reference deletion | ||
1933 | * | ||
1934 | * @param cls our client | ||
1935 | * @param dam deletion message | ||
1936 | */ | ||
1937 | static void | ||
1938 | handle_reference_delete_message (void *cls, | ||
1939 | const struct AttributeDeleteMessage *dam) | ||
1940 | { | ||
1941 | struct AttributeDeleteHandle *adh; | ||
1942 | struct IdpClient *idp = cls; | ||
1943 | size_t data_len; | ||
1944 | |||
1945 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_DELETE message\n"); | ||
1946 | data_len = ntohs (dam->attr_len); | ||
1947 | adh = GNUNET_new (struct AttributeDeleteHandle); | ||
1948 | adh->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &dam[1], | ||
1949 | data_len); | ||
1950 | adh->r_id = ntohl (dam->id); | ||
1951 | adh->identity = dam->identity; | ||
1952 | adh->label | ||
1953 | = GNUNET_STRINGS_data_to_string_alloc (&adh->reference->id, | ||
1954 | sizeof(uint64_t)); | ||
1955 | GNUNET_SERVICE_client_continue (idp->client); | ||
1956 | adh->client = idp; | ||
1957 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | ||
1958 | adh->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | ||
1959 | &adh->identity, | ||
1960 | adh->label, | ||
1961 | &ref_del_error, | ||
1962 | adh, | ||
1963 | &ref_del_cb, | ||
1964 | adh); | ||
1965 | } | ||
1786 | 1966 | ||
1787 | 1967 | ||
1788 | 1968 | ||
@@ -2238,6 +2418,10 @@ GNUNET_SERVICE_MAIN ( | |||
2238 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE, | 2418 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE, |
2239 | struct AttributeStoreMessage, | 2419 | struct AttributeStoreMessage, |
2240 | NULL), | 2420 | NULL), |
2421 | GNUNET_MQ_hd_var_size (reference_delete_message, | ||
2422 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE, | ||
2423 | struct AttributeDeleteMessage, | ||
2424 | NULL), | ||
2241 | GNUNET_MQ_hd_fixed_size ( | 2425 | GNUNET_MQ_hd_fixed_size ( |
2242 | iteration_start, | 2426 | iteration_start, |
2243 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, | 2427 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, |
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index b52cf9650..5066eef58 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -483,7 +483,8 @@ add_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
483 | return; | 483 | return; |
484 | } | 484 | } |
485 | identity = handle->url + strlen ( | 485 | identity = handle->url + strlen ( |
486 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/") + 1; | 486 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/") |
487 | + 1; | ||
487 | for (ego_entry = handle->ego_head; NULL != ego_entry; | 488 | for (ego_entry = handle->ego_head; NULL != ego_entry; |
488 | ego_entry = ego_entry->next) | 489 | ego_entry = ego_entry->next) |
489 | if (0 == strcmp (identity, ego_entry->identifier)) | 490 | if (0 == strcmp (identity, ego_entry->identifier)) |
@@ -734,6 +735,102 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
734 | } | 735 | } |
735 | 736 | ||
736 | /** | 737 | /** |
738 | * Deletes reference from an identity | ||
739 | * | ||
740 | * @param con_handle the connection handle | ||
741 | * @param url the url | ||
742 | * @param cls the RequestHandle | ||
743 | */ | ||
744 | static void | ||
745 | delete_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle, | ||
746 | const char *url, | ||
747 | void *cls) | ||
748 | { | ||
749 | struct RequestHandle *handle = cls; | ||
750 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | ||
751 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr; | ||
752 | struct EgoEntry *ego_entry; | ||
753 | char *identity; | ||
754 | char *identity_id_str; | ||
755 | char *id; | ||
756 | char term_data[handle->rest_handle->data_size + 1]; | ||
757 | json_t *data_json; | ||
758 | json_error_t err; | ||
759 | |||
760 | struct GNUNET_JSON_Specification attrspec[] = | ||
761 | { GNUNET_RECLAIM_JSON_spec_claim_attest_ref (&attr), | ||
762 | GNUNET_JSON_spec_end () }; | ||
763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
764 | "Deleting attestation reference.\n"); | ||
765 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ( | ||
766 | "reference/") + 1 >= strlen ( | ||
767 | handle->url)) | ||
768 | { | ||
769 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | ||
770 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
771 | return; | ||
772 | } | ||
773 | identity_id_str = strdup (handle->url + strlen ( | ||
774 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) | ||
775 | + strlen ("reference/") | ||
776 | + 1); | ||
777 | identity = strtok (identity_id_str, "/"); | ||
778 | id = strtok (NULL, "/"); | ||
779 | |||
780 | if ((NULL == identity) || (NULL == id)) | ||
781 | { | ||
782 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n"); | ||
783 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
784 | return; | ||
785 | } | ||
786 | for (ego_entry = handle->ego_head; NULL != ego_entry; | ||
787 | ego_entry = ego_entry->next) | ||
788 | if (0 == strcmp (identity, ego_entry->identifier)) | ||
789 | break; | ||
790 | handle->resp_object = json_array (); | ||
791 | if (NULL == ego_entry) | ||
792 | { | ||
793 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); | ||
794 | GNUNET_SCHEDULER_add_now (&return_response, handle); | ||
795 | return; | ||
796 | } | ||
797 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | ||
798 | if (0 >= handle->rest_handle->data_size) | ||
799 | { | ||
800 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
801 | return; | ||
802 | } | ||
803 | |||
804 | term_data[handle->rest_handle->data_size] = '\0'; | ||
805 | GNUNET_memcpy (term_data, | ||
806 | handle->rest_handle->data, | ||
807 | handle->rest_handle->data_size); | ||
808 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); | ||
809 | GNUNET_assert (GNUNET_OK == | ||
810 | GNUNET_JSON_parse (data_json, attrspec, NULL, NULL)); | ||
811 | json_decref (data_json); | ||
812 | if (NULL == attr) | ||
813 | { | ||
814 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
815 | "Unable to parse attestation reference from %s\n", | ||
816 | term_data); | ||
817 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
818 | return; | ||
819 | } | ||
820 | GNUNET_STRINGS_string_to_data (id, strlen (id), &attr->id, sizeof(uint64_t)); | ||
821 | |||
822 | handle->idp = GNUNET_RECLAIM_connect (cfg); | ||
823 | handle->idp_op = GNUNET_RECLAIM_attestation_reference_delete (handle->idp, | ||
824 | priv_key, | ||
825 | attr, | ||
826 | & | ||
827 | delete_finished_cb, | ||
828 | handle); | ||
829 | GNUNET_JSON_parse_free (attrspec); | ||
830 | } | ||
831 | |||
832 | |||
833 | /** | ||
737 | * Deletes attestation from an identity | 834 | * Deletes attestation from an identity |
738 | * | 835 | * |
739 | * @param con_handle the connection handle | 836 | * @param con_handle the connection handle |
@@ -745,8 +842,21 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
745 | const char *url, | 842 | const char *url, |
746 | void *cls) | 843 | void *cls) |
747 | { | 844 | { |
748 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | ||
749 | struct RequestHandle *handle = cls; | 845 | struct RequestHandle *handle = cls; |
846 | /* Check for substring "reference" */ | ||
847 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen ( | ||
848 | handle->url)) | ||
849 | { | ||
850 | if ( strncmp ("reference", (handle->url + strlen ( | ||
851 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) | ||
852 | + 1), strlen ( | ||
853 | "reference")) == 0) | ||
854 | { | ||
855 | delete_attestation_ref_cont (con_handle,url,cls); | ||
856 | return; | ||
857 | } | ||
858 | } | ||
859 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | ||
750 | struct GNUNET_RECLAIM_ATTESTATION_Claim attr; | 860 | struct GNUNET_RECLAIM_ATTESTATION_Claim attr; |
751 | struct EgoEntry *ego_entry; | 861 | struct EgoEntry *ego_entry; |
752 | char *identity_id_str; | 862 | char *identity_id_str; |
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index a6ff0237d..7c7261522 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -1163,6 +1163,49 @@ GNUNET_RECLAIM_attestation_reference_store ( | |||
1163 | return op; | 1163 | return op; |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | /** | ||
1167 | * Delete an attestation reference. Tickets used to share this reference are updated | ||
1168 | * accordingly. | ||
1169 | * | ||
1170 | * @param h handle to the re:claimID service | ||
1171 | * @param pkey Private key of the identity to delete the reference from | ||
1172 | * @param attr The reference | ||
1173 | * @param cont Continuation to call when done | ||
1174 | * @param cont_cls Closure for @a cont | ||
1175 | * @return handle Used to to abort the request | ||
1176 | */ | ||
1177 | struct GNUNET_RECLAIM_Operation * | ||
1178 | GNUNET_RECLAIM_attestation_reference_delete ( | ||
1179 | struct GNUNET_RECLAIM_Handle *h, | ||
1180 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | ||
1181 | const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, | ||
1182 | GNUNET_RECLAIM_ContinuationWithStatus cont, | ||
1183 | void *cont_cls) | ||
1184 | { | ||
1185 | |||
1186 | struct GNUNET_RECLAIM_Operation *op; | ||
1187 | struct AttributeDeleteMessage *dam; | ||
1188 | size_t attr_len; | ||
1189 | |||
1190 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); | ||
1191 | op->h = h; | ||
1192 | op->as_cb = cont; | ||
1193 | op->cls = cont_cls; | ||
1194 | op->r_id = h->r_id_gen++; | ||
1195 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | ||
1196 | attr_len = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (attr); | ||
1197 | op->env = GNUNET_MQ_msg_extra (dam, | ||
1198 | attr_len, | ||
1199 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE); | ||
1200 | dam->identity = *pkey; | ||
1201 | dam->id = htonl (op->r_id); | ||
1202 | GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &dam[1]); | ||
1203 | |||
1204 | dam->attr_len = htons (attr_len); | ||
1205 | if (NULL != h->mq) | ||
1206 | GNUNET_MQ_send_copy (h->mq, op->env); | ||
1207 | return op; | ||
1208 | } | ||
1166 | 1209 | ||
1167 | /** | 1210 | /** |
1168 | * List all attributes for a local identity. | 1211 | * List all attributes for a local identity. |