diff options
author | jospaeth <spaethj@in.tum.de> | 2020-08-28 12:27:32 +0200 |
---|---|---|
committer | jospaeth <spaethj@in.tum.de> | 2020-08-28 12:27:32 +0200 |
commit | 5f7d255ae5221c447367c4ac7a157ddcd27bcd57 (patch) | |
tree | 22fae70a54ad97c15a59f62e4c8bb9498a0d2e53 /src/include | |
parent | 62d6be2695969cd430351b503b033057a1b50f47 (diff) | |
parent | bbf9540c93da3c6b950920ee7eaae479c95403c5 (diff) | |
download | gnunet-5f7d255ae5221c447367c4ac7a157ddcd27bcd57.tar.gz gnunet-5f7d255ae5221c447367c4ac7a157ddcd27bcd57.zip |
Merge branch 'master' into spaeth/escrow_plugins
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/gnunet_block_lib.h | 13 | ||||
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 12 | ||||
-rw-r--r-- | src/include/gnunet_curl_lib.h | 22 | ||||
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 7 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 215 | ||||
-rw-r--r-- | src/include/gnunet_reclaim_lib.h | 401 | ||||
-rw-r--r-- | src/include/gnunet_reclaim_plugin.h | 197 | ||||
-rw-r--r-- | src/include/gnunet_reclaim_service.h | 79 | ||||
-rw-r--r-- | src/include/gnunet_seti_service.h | 369 | ||||
-rw-r--r-- | src/include/gnunet_setu_service.h | 390 | ||||
-rw-r--r-- | src/include/gnunet_uri_lib.h | 122 |
12 files changed, 1670 insertions, 158 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index d2c254ae6..e542038d3 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -119,5 +119,6 @@ gnunetinclude_HEADERS = \ | |||
119 | gnunet_transport_monitor_service.h \ | 119 | gnunet_transport_monitor_service.h \ |
120 | gnunet_transport_plugin.h \ | 120 | gnunet_transport_plugin.h \ |
121 | gnunet_tun_lib.h \ | 121 | gnunet_tun_lib.h \ |
122 | gnunet_uri_lib.h \ | ||
122 | gnunet_util_lib.h \ | 123 | gnunet_util_lib.h \ |
123 | gnunet_vpn_service.h | 124 | gnunet_vpn_service.h |
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h index 18ca6f63f..73b51252e 100644 --- a/src/include/gnunet_block_lib.h +++ b/src/include/gnunet_block_lib.h | |||
@@ -137,6 +137,19 @@ enum GNUNET_BLOCK_Type | |||
137 | * Contains either special marker elements or a nested block. | 137 | * Contains either special marker elements or a nested block. |
138 | */ | 138 | */ |
139 | GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT = 25, | 139 | GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT = 25, |
140 | |||
141 | /** | ||
142 | * Block for testing set intersection. If first byte of the block | ||
143 | * is non-zero, the block is considered invalid. | ||
144 | */ | ||
145 | GNUNET_BLOCK_TYPE_SETI_TEST = 24, | ||
146 | |||
147 | /** | ||
148 | * Block for testing set union. If first byte of the block | ||
149 | * is non-zero, the block is considered invalid. | ||
150 | */ | ||
151 | GNUNET_BLOCK_TYPE_SETU_TEST = 24, | ||
152 | |||
140 | }; | 153 | }; |
141 | 154 | ||
142 | 155 | ||
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index a072ae54e..efd696b36 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -50,6 +50,7 @@ extern "C" { | |||
50 | #endif | 50 | #endif |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <sodium.h> | ||
53 | 54 | ||
54 | /** | 55 | /** |
55 | * The identity of the host (wraps the signing key of the peer). | 56 | * The identity of the host (wraps the signing key of the peer). |
@@ -668,6 +669,15 @@ GNUNET_CRYPTO_hash (const void *block, | |||
668 | 669 | ||
669 | 670 | ||
670 | /** | 671 | /** |
672 | * Value for a salt for #GNUNET_CRYPTO_pow_hash(). | ||
673 | */ | ||
674 | struct GNUNET_CRYPTO_PowSalt | ||
675 | { | ||
676 | char salt[crypto_pwhash_argon2id_SALTBYTES]; | ||
677 | }; | ||
678 | |||
679 | |||
680 | /** | ||
671 | * Calculate the 'proof-of-work' hash (an expensive hash). | 681 | * Calculate the 'proof-of-work' hash (an expensive hash). |
672 | * | 682 | * |
673 | * @param salt salt for the hash. Must be crypto_pwhash_argon2id_SALTBYTES long. | 683 | * @param salt salt for the hash. Must be crypto_pwhash_argon2id_SALTBYTES long. |
@@ -676,7 +686,7 @@ GNUNET_CRYPTO_hash (const void *block, | |||
676 | * @param result where to write the resulting hash | 686 | * @param result where to write the resulting hash |
677 | */ | 687 | */ |
678 | void | 688 | void |
679 | GNUNET_CRYPTO_pow_hash (const char *salt, | 689 | GNUNET_CRYPTO_pow_hash (const struct GNUNET_CRYPTO_PowSalt *salt, |
680 | const void *buf, | 690 | const void *buf, |
681 | size_t buf_len, | 691 | size_t buf_len, |
682 | struct GNUNET_HashCode *result); | 692 | struct GNUNET_HashCode *result); |
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h index 9de58d608..f291d6b14 100644 --- a/src/include/gnunet_curl_lib.h +++ b/src/include/gnunet_curl_lib.h | |||
@@ -275,9 +275,8 @@ GNUNET_CURL_set_userpass (struct GNUNET_CURL_Context *ctx, | |||
275 | 275 | ||
276 | 276 | ||
277 | /** | 277 | /** |
278 | * Force use of the provided TLS client certificate | 278 | * Force use of the provided TLS client certificate for client authentication |
279 | * for client authentication for all operations performed | 279 | * for all operations performed with @a ctx. |
280 | * with @a ctx. | ||
281 | * | 280 | * |
282 | * Note that if the provided information is incorrect, | 281 | * Note that if the provided information is incorrect, |
283 | * the earliest operation that could fail is | 282 | * the earliest operation that could fail is |
@@ -298,9 +297,9 @@ GNUNET_CURL_set_tlscert (struct GNUNET_CURL_Context *ctx, | |||
298 | 297 | ||
299 | 298 | ||
300 | /** | 299 | /** |
301 | * Schedule a CURL request to be executed and call the given @a jcc | 300 | * Schedule a CURL request to be executed and call the given @a jcc upon its |
302 | * upon its completion. Note that the context will make use of the | 301 | * completion. Note that the context will make use of the CURLOPT_PRIVATE |
303 | * CURLOPT_PRIVATE facility of the CURL @a eh. | 302 | * facility of the CURL @a eh. |
304 | * | 303 | * |
305 | * This function modifies the CURL handle to add the | 304 | * This function modifies the CURL handle to add the |
306 | * "Content-Type: application/json" header if @a add_json is set. | 305 | * "Content-Type: application/json" header if @a add_json is set. |
@@ -345,6 +344,17 @@ GNUNET_CURL_job_add_raw (struct GNUNET_CURL_Context *ctx, | |||
345 | 344 | ||
346 | 345 | ||
347 | /** | 346 | /** |
347 | * Add @a extra_headers to the HTTP headers for @a job. | ||
348 | * | ||
349 | * @param[in,out] job the job to modify | ||
350 | * @param extra_headers headers to append | ||
351 | */ | ||
352 | void | ||
353 | GNUNET_CURL_extend_headers (struct GNUNET_CURL_Job *job, | ||
354 | const struct curl_slist *extra_headers); | ||
355 | |||
356 | |||
357 | /** | ||
348 | * Cancel a job. Must only be called before the job completion | 358 | * Cancel a job. Must only be called before the job completion |
349 | * callback is called for the respective job. | 359 | * callback is called for the respective job. |
350 | * | 360 | * |
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 6ad6801cb..db524ec5b 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -143,12 +143,13 @@ extern "C" { | |||
143 | /** | 143 | /** |
144 | * Record type for an attribute attestation | 144 | * Record type for an attribute attestation |
145 | */ | 145 | */ |
146 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION 65554 | 146 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL 65554 |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * Record type for an attestation reference in a ticket | 149 | * Record type for a presentation of a credential (used |
150 | * in a ticket record set) | ||
150 | */ | 151 | */ |
151 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF 65555 | 152 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555 |
152 | 153 | ||
153 | /** | 154 | /** |
154 | * Record type for an escrow key share (escrow component) | 155 | * Record type for an escrow key share (escrow component) |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 5af58664f..d9821ffe8 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -1659,9 +1659,212 @@ extern "C" { | |||
1659 | 1659 | ||
1660 | 1660 | ||
1661 | /******************************************************************************* | 1661 | /******************************************************************************* |
1662 | * SETU message types | ||
1663 | ******************************************************************************/ | ||
1664 | |||
1665 | |||
1666 | /** | ||
1667 | * Cancel a set operation | ||
1668 | */ | ||
1669 | #define GNUNET_MESSAGE_TYPE_SETU_CANCEL 550 | ||
1670 | |||
1671 | /** | ||
1672 | * Add element to set | ||
1673 | */ | ||
1674 | #define GNUNET_MESSAGE_TYPE_SETU_ADD 551 | ||
1675 | |||
1676 | /** | ||
1677 | * Create a new local set | ||
1678 | */ | ||
1679 | #define GNUNET_MESSAGE_TYPE_SETU_CREATE 552 | ||
1680 | |||
1681 | /** | ||
1682 | * Handle result message from operation | ||
1683 | */ | ||
1684 | #define GNUNET_MESSAGE_TYPE_SETU_RESULT 553 | ||
1685 | |||
1686 | /** | ||
1687 | * Evaluate a set operation | ||
1688 | */ | ||
1689 | #define GNUNET_MESSAGE_TYPE_SETU_EVALUATE 554 | ||
1690 | |||
1691 | /** | ||
1692 | * Listen for operation requests | ||
1693 | */ | ||
1694 | #define GNUNET_MESSAGE_TYPE_SETU_LISTEN 555 | ||
1695 | |||
1696 | /** | ||
1697 | * Reject a set request. | ||
1698 | */ | ||
1699 | #define GNUNET_MESSAGE_TYPE_SETU_REJECT 556 | ||
1700 | |||
1701 | /** | ||
1702 | * Accept an incoming set request | ||
1703 | */ | ||
1704 | #define GNUNET_MESSAGE_TYPE_SETU_ACCEPT 557 | ||
1705 | |||
1706 | /** | ||
1707 | * Notify the client of an incoming request from a remote peer | ||
1708 | */ | ||
1709 | #define GNUNET_MESSAGE_TYPE_SETU_REQUEST 558 | ||
1710 | |||
1711 | |||
1712 | /** | ||
1713 | * Demand the whole element from the other | ||
1714 | * peer, given only the hash code. | ||
1715 | */ | ||
1716 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL 559 | ||
1717 | |||
1718 | /** | ||
1719 | * Demand the whole element from the other | ||
1720 | * peer, given only the hash code. | ||
1721 | */ | ||
1722 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND 560 | ||
1723 | |||
1724 | /** | ||
1725 | * Tell the other peer to send us a list of | ||
1726 | * hashes that match an IBF key. | ||
1727 | */ | ||
1728 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_INQUIRY 561 | ||
1729 | |||
1730 | /** | ||
1731 | * Tell the other peer which hashes match a | ||
1732 | * given IBF key. | ||
1733 | */ | ||
1734 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_OFFER 562 | ||
1735 | |||
1736 | /** | ||
1737 | * Request a set union operation from a remote peer. | ||
1738 | */ | ||
1739 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST 563 | ||
1740 | |||
1741 | /** | ||
1742 | * Strata estimator. | ||
1743 | */ | ||
1744 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_SE 564 | ||
1745 | |||
1746 | /** | ||
1747 | * Invertible bloom filter. | ||
1748 | */ | ||
1749 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_IBF 565 | ||
1750 | |||
1751 | /** | ||
1752 | * Actual set elements. | ||
1753 | */ | ||
1754 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS 566 | ||
1755 | |||
1756 | /** | ||
1757 | * Requests for the elements with the given hashes. | ||
1758 | */ | ||
1759 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENT_REQUESTS 567 | ||
1760 | |||
1761 | /** | ||
1762 | * Set operation is done. | ||
1763 | */ | ||
1764 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_DONE 568 | ||
1765 | |||
1766 | /** | ||
1767 | * Compressed strata estimator. | ||
1768 | */ | ||
1769 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_SEC 569 | ||
1770 | |||
1771 | /** | ||
1772 | * Request all missing elements from the other peer, | ||
1773 | * based on their sets and the elements we previously sent | ||
1774 | * with #GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS. | ||
1775 | */ | ||
1776 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE 570 | ||
1777 | |||
1778 | /** | ||
1779 | * Send a set element, not as response to a demand but because | ||
1780 | * we're sending the full set. | ||
1781 | */ | ||
1782 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT 571 | ||
1783 | |||
1784 | /** | ||
1785 | * Request all missing elements from the other peer, | ||
1786 | * based on their sets and the elements we previously sent | ||
1787 | * with #GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS. | ||
1788 | */ | ||
1789 | #define GNUNET_MESSAGE_TYPE_SETU_P2P_OVER 572 | ||
1790 | |||
1791 | |||
1792 | /******************************************************************************* | ||
1793 | * SETI message types | ||
1794 | ******************************************************************************/ | ||
1795 | |||
1796 | |||
1797 | /** | ||
1798 | * Cancel a set operation | ||
1799 | */ | ||
1800 | #define GNUNET_MESSAGE_TYPE_SETI_CANCEL 580 | ||
1801 | |||
1802 | /** | ||
1803 | * Add element to set. | ||
1804 | */ | ||
1805 | #define GNUNET_MESSAGE_TYPE_SETI_ADD 581 | ||
1806 | |||
1807 | /** | ||
1808 | * Create a new local set | ||
1809 | */ | ||
1810 | #define GNUNET_MESSAGE_TYPE_SETI_CREATE 582 | ||
1811 | |||
1812 | /** | ||
1813 | * Handle result message from operation | ||
1814 | */ | ||
1815 | #define GNUNET_MESSAGE_TYPE_SETI_RESULT 583 | ||
1816 | |||
1817 | /** | ||
1818 | * Evaluate a set operation | ||
1819 | */ | ||
1820 | #define GNUNET_MESSAGE_TYPE_SETI_EVALUATE 584 | ||
1821 | |||
1822 | /** | ||
1823 | * Listen for operation requests | ||
1824 | */ | ||
1825 | #define GNUNET_MESSAGE_TYPE_SETI_LISTEN 585 | ||
1826 | |||
1827 | /** | ||
1828 | * Reject a set request. | ||
1829 | */ | ||
1830 | #define GNUNET_MESSAGE_TYPE_SETI_REJECT 586 | ||
1831 | |||
1832 | /** | ||
1833 | * Accept an incoming set request | ||
1834 | */ | ||
1835 | #define GNUNET_MESSAGE_TYPE_SETI_ACCEPT 587 | ||
1836 | |||
1837 | /** | ||
1838 | * Notify the client of an incoming request from a remote peer | ||
1839 | */ | ||
1840 | #define GNUNET_MESSAGE_TYPE_SETI_REQUEST 588 | ||
1841 | |||
1842 | /** | ||
1843 | * Information about the element count for intersection | ||
1844 | */ | ||
1845 | #define GNUNET_MESSAGE_TYPE_SETI_P2P_ELEMENT_INFO 591 | ||
1846 | |||
1847 | /** | ||
1848 | * Bloom filter message for intersection exchange started by Bob. | ||
1849 | */ | ||
1850 | #define GNUNET_MESSAGE_TYPE_SETI_P2P_BF 592 | ||
1851 | |||
1852 | /** | ||
1853 | * Intersection operation is done. | ||
1854 | */ | ||
1855 | #define GNUNET_MESSAGE_TYPE_SETI_P2P_DONE 593 | ||
1856 | |||
1857 | /** | ||
1858 | * Request to begin set intersection operation. | ||
1859 | */ | ||
1860 | #define GNUNET_MESSAGE_TYPE_SETI_P2P_OPERATION_REQUEST 594 | ||
1861 | |||
1862 | |||
1863 | /******************************************************************************* | ||
1662 | * SET message types | 1864 | * SET message types |
1663 | ******************************************************************************/ | 1865 | ******************************************************************************/ |
1664 | 1866 | ||
1867 | |||
1665 | /** | 1868 | /** |
1666 | * Demand the whole element from the other | 1869 | * Demand the whole element from the other |
1667 | * peer, given only the hash code. | 1870 | * peer, given only the hash code. |
@@ -2697,17 +2900,17 @@ extern "C" { | |||
2697 | 2900 | ||
2698 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE 976 | 2901 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE 976 |
2699 | 2902 | ||
2700 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE 977 | 2903 | #define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE 977 |
2701 | 2904 | ||
2702 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE 978 | 2905 | #define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE 978 |
2703 | 2906 | ||
2704 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT 979 | 2907 | #define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT 979 |
2705 | 2908 | ||
2706 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START 980 | 2909 | #define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START 980 |
2707 | 2910 | ||
2708 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP 981 | 2911 | #define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP 981 |
2709 | 2912 | ||
2710 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT 982 | 2913 | #define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT 982 |
2711 | 2914 | ||
2712 | 2915 | ||
2713 | /************************************************** | 2916 | /************************************************** |
diff --git a/src/include/gnunet_reclaim_lib.h b/src/include/gnunet_reclaim_lib.h index 7d521ffa8..bbf1c3ad3 100644 --- a/src/include/gnunet_reclaim_lib.h +++ b/src/include/gnunet_reclaim_lib.h | |||
@@ -39,26 +39,34 @@ extern "C" { | |||
39 | 39 | ||
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | 41 | ||
42 | enum GNUNET_RECLAIM_AttributeType { | ||
43 | /** | ||
44 | * No value attribute. | ||
45 | */ | ||
46 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE = 0, | ||
42 | 47 | ||
43 | /** | 48 | /** |
44 | * No value attribute. | 49 | * String attribute. |
45 | */ | 50 | */ |
46 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE 0 | 51 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING = 1 |
52 | }; | ||
47 | 53 | ||
48 | /** | 54 | enum GNUNET_RECLAIM_CredentialType { |
49 | * String attribute. | 55 | /** |
50 | */ | 56 | * No value credential. |
51 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1 | 57 | */ |
58 | GNUNET_RECLAIM_CREDENTIAL_TYPE_NONE = 0, | ||
52 | 59 | ||
53 | /** | 60 | /** |
54 | * No value attestation. | 61 | * A JSON Web Token credential. |
55 | */ | 62 | */ |
56 | #define GNUNET_RECLAIM_ATTESTATION_TYPE_NONE 10 | 63 | GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT = 1, |
57 | 64 | ||
58 | /** | 65 | /** |
59 | * A JSON Web Token attestation. | 66 | * libpabc credential |
60 | */ | 67 | */ |
61 | #define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT 11 | 68 | GNUNET_RECLAIM_CREDENTIAL_TYPE_PABC = 2 |
69 | }; | ||
62 | 70 | ||
63 | /** | 71 | /** |
64 | * We want an ID to be a 256-bit symmetric key | 72 | * We want an ID to be a 256-bit symmetric key |
@@ -107,9 +115,10 @@ struct GNUNET_RECLAIM_Attribute | |||
107 | struct GNUNET_RECLAIM_Identifier id; | 115 | struct GNUNET_RECLAIM_Identifier id; |
108 | 116 | ||
109 | /** | 117 | /** |
110 | * Referenced ID of Attestation (may be 0 if self-attested) | 118 | * Referenced ID of credential |
119 | * (may be GNUNET_RECLAIM_ID_ZERO if self-creded) | ||
111 | */ | 120 | */ |
112 | struct GNUNET_RECLAIM_Identifier attestation; | 121 | struct GNUNET_RECLAIM_Identifier credential; |
113 | 122 | ||
114 | /** | 123 | /** |
115 | * Type of Claim | 124 | * Type of Claim |
@@ -141,9 +150,9 @@ struct GNUNET_RECLAIM_Attribute | |||
141 | }; | 150 | }; |
142 | 151 | ||
143 | /** | 152 | /** |
144 | * An attestation. | 153 | * A credential. |
145 | */ | 154 | */ |
146 | struct GNUNET_RECLAIM_Attestation | 155 | struct GNUNET_RECLAIM_Credential |
147 | { | 156 | { |
148 | /** | 157 | /** |
149 | * ID | 158 | * ID |
@@ -161,7 +170,7 @@ struct GNUNET_RECLAIM_Attestation | |||
161 | uint32_t flag; | 170 | uint32_t flag; |
162 | 171 | ||
163 | /** | 172 | /** |
164 | * The name of the attribute. Note "name" must never be individually | 173 | * The name of the credential. Note: must never be individually |
165 | * free'd | 174 | * free'd |
166 | */ | 175 | */ |
167 | const char *name; | 176 | const char *name; |
@@ -172,7 +181,7 @@ struct GNUNET_RECLAIM_Attestation | |||
172 | size_t data_size; | 181 | size_t data_size; |
173 | 182 | ||
174 | /** | 183 | /** |
175 | * Binary value stored as attribute value. Note: "data" must never | 184 | * Binary value stored as credential value. Note: "data" must never |
176 | * be individually 'malloc'ed, but instead always points into some | 185 | * be individually 'malloc'ed, but instead always points into some |
177 | * existing data area. | 186 | * existing data area. |
178 | */ | 187 | */ |
@@ -181,6 +190,36 @@ struct GNUNET_RECLAIM_Attestation | |||
181 | 190 | ||
182 | 191 | ||
183 | /** | 192 | /** |
193 | * A credential presentation. | ||
194 | */ | ||
195 | struct GNUNET_RECLAIM_Presentation | ||
196 | { | ||
197 | /** | ||
198 | * The credential id of which this is a presentation. | ||
199 | */ | ||
200 | struct GNUNET_RECLAIM_Identifier credential_id; | ||
201 | |||
202 | /** | ||
203 | * Type/Format of Claim | ||
204 | */ | ||
205 | uint32_t type; | ||
206 | |||
207 | /** | ||
208 | * Number of bytes in @e data. | ||
209 | */ | ||
210 | size_t data_size; | ||
211 | |||
212 | /** | ||
213 | * Binary value stored as presentation value. Note: "data" must never | ||
214 | * be individually 'malloc'ed, but instead always points into some | ||
215 | * existing data area. | ||
216 | */ | ||
217 | const void *data; | ||
218 | }; | ||
219 | |||
220 | |||
221 | |||
222 | /** | ||
184 | * A list of GNUNET_RECLAIM_Attribute structures. | 223 | * A list of GNUNET_RECLAIM_Attribute structures. |
185 | */ | 224 | */ |
186 | struct GNUNET_RECLAIM_AttributeList | 225 | struct GNUNET_RECLAIM_AttributeList |
@@ -217,56 +256,94 @@ struct GNUNET_RECLAIM_AttributeListEntry | |||
217 | }; | 256 | }; |
218 | 257 | ||
219 | /** | 258 | /** |
220 | * A list of GNUNET_RECLAIM_Attestation structures. | 259 | * A list of GNUNET_RECLAIM_Credential structures. |
221 | */ | 260 | */ |
222 | struct GNUNET_RECLAIM_AttestationList | 261 | struct GNUNET_RECLAIM_CredentialList |
223 | { | 262 | { |
224 | /** | 263 | /** |
225 | * List head | 264 | * List head |
226 | */ | 265 | */ |
227 | struct GNUNET_RECLAIM_AttestationListEntry *list_head; | 266 | struct GNUNET_RECLAIM_CredentialListEntry *list_head; |
228 | 267 | ||
229 | /** | 268 | /** |
230 | * List tail | 269 | * List tail |
231 | */ | 270 | */ |
232 | struct GNUNET_RECLAIM_AttestationListEntry *list_tail; | 271 | struct GNUNET_RECLAIM_CredentialListEntry *list_tail; |
233 | }; | 272 | }; |
234 | 273 | ||
235 | 274 | ||
236 | struct GNUNET_RECLAIM_AttestationListEntry | 275 | struct GNUNET_RECLAIM_CredentialListEntry |
237 | { | 276 | { |
238 | /** | 277 | /** |
239 | * DLL | 278 | * DLL |
240 | */ | 279 | */ |
241 | struct GNUNET_RECLAIM_AttestationListEntry *prev; | 280 | struct GNUNET_RECLAIM_CredentialListEntry *prev; |
242 | 281 | ||
243 | /** | 282 | /** |
244 | * DLL | 283 | * DLL |
245 | */ | 284 | */ |
246 | struct GNUNET_RECLAIM_AttestationListEntry *next; | 285 | struct GNUNET_RECLAIM_CredentialListEntry *next; |
247 | 286 | ||
248 | /** | 287 | /** |
249 | * The attestation | 288 | * The credential |
250 | */ | 289 | */ |
251 | struct GNUNET_RECLAIM_Attestation *attestation; | 290 | struct GNUNET_RECLAIM_Credential *credential; |
252 | 291 | ||
253 | }; | 292 | }; |
254 | 293 | ||
255 | 294 | ||
256 | /** | 295 | /** |
296 | * A list of GNUNET_RECLAIM_Presentation structures. | ||
297 | */ | ||
298 | struct GNUNET_RECLAIM_PresentationList | ||
299 | { | ||
300 | /** | ||
301 | * List head | ||
302 | */ | ||
303 | struct GNUNET_RECLAIM_PresentationListEntry *list_head; | ||
304 | |||
305 | /** | ||
306 | * List tail | ||
307 | */ | ||
308 | struct GNUNET_RECLAIM_PresentationListEntry *list_tail; | ||
309 | }; | ||
310 | |||
311 | |||
312 | struct GNUNET_RECLAIM_PresentationListEntry | ||
313 | { | ||
314 | /** | ||
315 | * DLL | ||
316 | */ | ||
317 | struct GNUNET_RECLAIM_PresentationListEntry *prev; | ||
318 | |||
319 | /** | ||
320 | * DLL | ||
321 | */ | ||
322 | struct GNUNET_RECLAIM_PresentationListEntry *next; | ||
323 | |||
324 | /** | ||
325 | * The credential | ||
326 | */ | ||
327 | struct GNUNET_RECLAIM_Presentation *presentation; | ||
328 | |||
329 | }; | ||
330 | |||
331 | |||
332 | |||
333 | /** | ||
257 | * Create a new attribute claim. | 334 | * Create a new attribute claim. |
258 | * | 335 | * |
259 | * @param attr_name the attribute name | 336 | * @param attr_name the attribute name |
260 | * @param attestation ID of the attestation (may be NULL) | 337 | * @param credential ID of the credential (may be NULL) |
261 | * @param type the attribute type | 338 | * @param type the attribute type |
262 | * @param data the attribute value. Must be the mapped name if attestation not NULL | 339 | * @param data the attribute value. Must be #attr_name if credential not NULL |
263 | * @param data_size the attribute value size | 340 | * @param data_size the attribute value size |
264 | * @return the new attribute | 341 | * @return the new attribute |
265 | */ | 342 | */ |
266 | struct GNUNET_RECLAIM_Attribute * | 343 | struct GNUNET_RECLAIM_Attribute * |
267 | GNUNET_RECLAIM_attribute_new (const char *attr_name, | 344 | GNUNET_RECLAIM_attribute_new (const char *attr_name, |
268 | const struct | 345 | const struct |
269 | GNUNET_RECLAIM_Identifier *attestation, | 346 | GNUNET_RECLAIM_Identifier *credential, |
270 | uint32_t type, | 347 | uint32_t type, |
271 | const void *data, | 348 | const void *data, |
272 | size_t data_size); | 349 | size_t data_size); |
@@ -298,7 +375,7 @@ GNUNET_RECLAIM_attribute_list_destroy ( | |||
298 | * | 375 | * |
299 | * @param attrs the attribute list to add to | 376 | * @param attrs the attribute list to add to |
300 | * @param attr_name the name of the new attribute claim | 377 | * @param attr_name the name of the new attribute claim |
301 | * @param attestation attestation ID (may be NULL) | 378 | * @param credential credential ID (may be NULL) |
302 | * @param type the type of the claim | 379 | * @param type the type of the claim |
303 | * @param data claim payload | 380 | * @param data claim payload |
304 | * @param data_size claim payload size | 381 | * @param data_size claim payload size |
@@ -307,7 +384,7 @@ void | |||
307 | GNUNET_RECLAIM_attribute_list_add ( | 384 | GNUNET_RECLAIM_attribute_list_add ( |
308 | struct GNUNET_RECLAIM_AttributeList *attrs, | 385 | struct GNUNET_RECLAIM_AttributeList *attrs, |
309 | const char *attr_name, | 386 | const char *attr_name, |
310 | const struct GNUNET_RECLAIM_Identifier *attestation, | 387 | const struct GNUNET_RECLAIM_Identifier *credential, |
311 | uint32_t type, | 388 | uint32_t type, |
312 | const void *data, | 389 | const void *data, |
313 | size_t data_size); | 390 | size_t data_size); |
@@ -439,8 +516,8 @@ GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type); | |||
439 | * @return the required buffer size | 516 | * @return the required buffer size |
440 | */ | 517 | */ |
441 | size_t | 518 | size_t |
442 | GNUNET_RECLAIM_attestation_list_serialize_get_size ( | 519 | GNUNET_RECLAIM_credential_list_serialize_get_size ( |
443 | const struct GNUNET_RECLAIM_AttestationList *attestations); | 520 | const struct GNUNET_RECLAIM_CredentialList *credentials); |
444 | 521 | ||
445 | 522 | ||
446 | /** | 523 | /** |
@@ -449,8 +526,8 @@ GNUNET_RECLAIM_attestation_list_serialize_get_size ( | |||
449 | * @param attrs list to destroy | 526 | * @param attrs list to destroy |
450 | */ | 527 | */ |
451 | void | 528 | void |
452 | GNUNET_RECLAIM_attestation_list_destroy ( | 529 | GNUNET_RECLAIM_credential_list_destroy ( |
453 | struct GNUNET_RECLAIM_AttestationList *attestations); | 530 | struct GNUNET_RECLAIM_CredentialList *credentials); |
454 | 531 | ||
455 | 532 | ||
456 | /** | 533 | /** |
@@ -462,8 +539,8 @@ GNUNET_RECLAIM_attestation_list_destroy ( | |||
462 | * @param data_size claim payload size | 539 | * @param data_size claim payload size |
463 | */ | 540 | */ |
464 | void | 541 | void |
465 | GNUNET_RECLAIM_attestation_list_add ( | 542 | GNUNET_RECLAIM_credential_list_add ( |
466 | struct GNUNET_RECLAIM_AttestationList *attrs, | 543 | struct GNUNET_RECLAIM_CredentialList *attrs, |
467 | const char *att_name, | 544 | const char *att_name, |
468 | uint32_t type, | 545 | uint32_t type, |
469 | const void *data, | 546 | const void *data, |
@@ -478,8 +555,8 @@ GNUNET_RECLAIM_attestation_list_add ( | |||
478 | * @return length of serialized data | 555 | * @return length of serialized data |
479 | */ | 556 | */ |
480 | size_t | 557 | size_t |
481 | GNUNET_RECLAIM_attestation_list_serialize ( | 558 | GNUNET_RECLAIM_credential_list_serialize ( |
482 | const struct GNUNET_RECLAIM_AttestationList *attrs, | 559 | const struct GNUNET_RECLAIM_CredentialList *attrs, |
483 | char *result); | 560 | char *result); |
484 | 561 | ||
485 | 562 | ||
@@ -490,75 +567,75 @@ GNUNET_RECLAIM_attestation_list_serialize ( | |||
490 | * @param data_size the length of the serialized data | 567 | * @param data_size the length of the serialized data |
491 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller | 568 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller |
492 | */ | 569 | */ |
493 | struct GNUNET_RECLAIM_AttestationList * | 570 | struct GNUNET_RECLAIM_CredentialList * |
494 | GNUNET_RECLAIM_attestation_list_deserialize (const char *data, | 571 | GNUNET_RECLAIM_credential_list_deserialize (const char *data, |
495 | size_t data_size); | 572 | size_t data_size); |
496 | 573 | ||
497 | 574 | ||
498 | /** | 575 | /** |
499 | * @param attestation the attestation to serialize | 576 | * @param credential the credential to serialize |
500 | * @return the required buffer size | 577 | * @return the required buffer size |
501 | */ | 578 | */ |
502 | size_t | 579 | size_t |
503 | GNUNET_RECLAIM_attestation_serialize_get_size ( | 580 | GNUNET_RECLAIM_credential_serialize_get_size ( |
504 | const struct GNUNET_RECLAIM_Attestation *attestation); | 581 | const struct GNUNET_RECLAIM_Credential *credential); |
505 | 582 | ||
506 | 583 | ||
507 | /** | 584 | /** |
508 | * Serialize an attestation | 585 | * Serialize an credential |
509 | * | 586 | * |
510 | * @param attestation the attestation to serialize | 587 | * @param credential the credential to serialize |
511 | * @param result the serialized attestation | 588 | * @param result the serialized credential |
512 | * @return length of serialized data | 589 | * @return length of serialized data |
513 | */ | 590 | */ |
514 | size_t | 591 | size_t |
515 | GNUNET_RECLAIM_attestation_serialize ( | 592 | GNUNET_RECLAIM_credential_serialize ( |
516 | const struct GNUNET_RECLAIM_Attestation *attestation, | 593 | const struct GNUNET_RECLAIM_Credential *credential, |
517 | char *result); | 594 | char *result); |
518 | 595 | ||
519 | 596 | ||
520 | /** | 597 | /** |
521 | * Deserialize an attestation | 598 | * Deserialize an credential |
522 | * | 599 | * |
523 | * @param data the serialized attestation | 600 | * @param data the serialized credential |
524 | * @param data_size the length of the serialized data | 601 | * @param data_size the length of the serialized data |
525 | * | 602 | * |
526 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 603 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller |
527 | */ | 604 | */ |
528 | struct GNUNET_RECLAIM_Attestation * | 605 | struct GNUNET_RECLAIM_Credential * |
529 | GNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size); | 606 | GNUNET_RECLAIM_credential_deserialize (const char *data, size_t data_size); |
530 | 607 | ||
531 | 608 | ||
532 | /** | 609 | /** |
533 | * Create a new attestation. | 610 | * Create a new credential. |
534 | * | 611 | * |
535 | * @param name the attestation name | 612 | * @param name the credential name |
536 | * @param type the attestation type | 613 | * @param type the credential type |
537 | * @param data the attestation value | 614 | * @param data the credential value |
538 | * @param data_size the attestation value size | 615 | * @param data_size the credential value size |
539 | * @return the new attestation | 616 | * @return the new credential |
540 | */ | 617 | */ |
541 | struct GNUNET_RECLAIM_Attestation * | 618 | struct GNUNET_RECLAIM_Credential * |
542 | GNUNET_RECLAIM_attestation_new (const char *name, | 619 | GNUNET_RECLAIM_credential_new (const char *name, |
543 | uint32_t type, | 620 | uint32_t type, |
544 | const void *data, | 621 | const void *data, |
545 | size_t data_size); | 622 | size_t data_size); |
546 | 623 | ||
547 | /** | 624 | /** |
548 | * Convert the 'claim' of an attestation to a string | 625 | * Convert the 'claim' of an credential to a string |
549 | * | 626 | * |
550 | * @param type the type of attestation | 627 | * @param type the type of credential |
551 | * @param data claim in binary encoding | 628 | * @param data claim in binary encoding |
552 | * @param data_size number of bytes in @a data | 629 | * @param data_size number of bytes in @a data |
553 | * @return NULL on error, otherwise human-readable representation of the claim | 630 | * @return NULL on error, otherwise human-readable representation of the claim |
554 | */ | 631 | */ |
555 | char * | 632 | char * |
556 | GNUNET_RECLAIM_attestation_value_to_string (uint32_t type, | 633 | GNUNET_RECLAIM_credential_value_to_string (uint32_t type, |
557 | const void *data, | 634 | const void *data, |
558 | size_t data_size); | 635 | size_t data_size); |
559 | 636 | ||
560 | /** | 637 | /** |
561 | * Convert human-readable version of a 'claim' of an attestation to the binary | 638 | * Convert human-readable version of a 'claim' of an credential to the binary |
562 | * representation | 639 | * representation |
563 | * | 640 | * |
564 | * @param type type of the claim | 641 | * @param type type of the claim |
@@ -568,48 +645,206 @@ GNUNET_RECLAIM_attestation_value_to_string (uint32_t type, | |||
568 | * @return #GNUNET_OK on success | 645 | * @return #GNUNET_OK on success |
569 | */ | 646 | */ |
570 | int | 647 | int |
571 | GNUNET_RECLAIM_attestation_string_to_value (uint32_t type, | 648 | GNUNET_RECLAIM_credential_string_to_value (uint32_t type, |
572 | const char *s, | 649 | const char *s, |
573 | void **data, | 650 | void **data, |
574 | size_t *data_size); | 651 | size_t *data_size); |
575 | 652 | ||
576 | /** | 653 | /** |
577 | * Convert an attestation type number to the corresponding attestation type string | 654 | * Convert an credential type number to the corresponding credential type string |
578 | * | 655 | * |
579 | * @param type number of a type | 656 | * @param type number of a type |
580 | * @return corresponding typestring, NULL on error | 657 | * @return corresponding typestring, NULL on error |
581 | */ | 658 | */ |
582 | const char * | 659 | const char * |
583 | GNUNET_RECLAIM_attestation_number_to_typename (uint32_t type); | 660 | GNUNET_RECLAIM_credential_number_to_typename (uint32_t type); |
584 | 661 | ||
585 | /** | 662 | /** |
586 | * Convert an attestation type name to the corresponding number | 663 | * Convert an credential type name to the corresponding number |
587 | * | 664 | * |
588 | * @param typename name to convert | 665 | * @param typename name to convert |
589 | * @return corresponding number, UINT32_MAX on error | 666 | * @return corresponding number, UINT32_MAX on error |
590 | */ | 667 | */ |
591 | uint32_t | 668 | uint32_t |
592 | GNUNET_RECLAIM_attestation_typename_to_number (const char *typename); | 669 | GNUNET_RECLAIM_credential_typename_to_number (const char *typename); |
593 | 670 | ||
594 | /** | 671 | /** |
595 | * Convert an attestation type name to the corresponding number | 672 | * Convert an credential type name to the corresponding number |
596 | * | 673 | * |
597 | * @param typename name to convert | 674 | * @param typename name to convert |
598 | * @return corresponding number, UINT32_MAX on error | 675 | * @return corresponding number, UINT32_MAX on error |
599 | */ | 676 | */ |
600 | struct GNUNET_RECLAIM_AttributeList* | 677 | struct GNUNET_RECLAIM_AttributeList* |
601 | GNUNET_RECLAIM_attestation_get_attributes (const struct | 678 | GNUNET_RECLAIM_credential_get_attributes (const struct |
602 | GNUNET_RECLAIM_Attestation *attest); | 679 | GNUNET_RECLAIM_Credential *cred); |
603 | 680 | ||
604 | char* | 681 | char* |
605 | GNUNET_RECLAIM_attestation_get_issuer (const struct | 682 | GNUNET_RECLAIM_credential_get_issuer (const struct |
606 | GNUNET_RECLAIM_Attestation *attest); | 683 | GNUNET_RECLAIM_Credential *cred); |
607 | 684 | ||
608 | int | 685 | int |
609 | GNUNET_RECLAIM_attestation_get_expiration (const struct | 686 | GNUNET_RECLAIM_credential_get_expiration (const struct |
610 | GNUNET_RECLAIM_Attestation *attest, | 687 | GNUNET_RECLAIM_Credential *cred, |
611 | struct GNUNET_TIME_Absolute *exp); | 688 | struct GNUNET_TIME_Absolute *exp); |
612 | 689 | ||
690 | /** | ||
691 | * Get required size for serialization buffer | ||
692 | * | ||
693 | * @param presentations the presentation list to serialize | ||
694 | * @return the required buffer size | ||
695 | */ | ||
696 | size_t | ||
697 | GNUNET_RECLAIM_presentation_list_serialize_get_size ( | ||
698 | const struct GNUNET_RECLAIM_PresentationList *presentations); | ||
699 | |||
700 | |||
701 | /** | ||
702 | * Destroy presentations list | ||
703 | * | ||
704 | * @param presentations list to destroy | ||
705 | */ | ||
706 | void | ||
707 | GNUNET_RECLAIM_presentation_list_destroy ( | ||
708 | struct GNUNET_RECLAIM_PresentationList *presentations); | ||
709 | |||
710 | |||
711 | /** | ||
712 | * Serialize a presentation list | ||
713 | * | ||
714 | * @param presentations the attribute list to serialize | ||
715 | * @param result the serialized list | ||
716 | * @return length of serialized data | ||
717 | */ | ||
718 | size_t | ||
719 | GNUNET_RECLAIM_presentation_list_serialize ( | ||
720 | const struct GNUNET_RECLAIM_PresentationList *presentations, | ||
721 | char *result); | ||
722 | |||
723 | |||
724 | /** | ||
725 | * Deserialize a presentation list | ||
726 | * | ||
727 | * @param data the serialized list | ||
728 | * @param data_size the length of the serialized data | ||
729 | * @return a GNUNET_RECLAIM_PresentationList, must be free'd by caller | ||
730 | */ | ||
731 | struct GNUNET_RECLAIM_PresentationList * | ||
732 | GNUNET_RECLAIM_presentation_list_deserialize (const char *data, | ||
733 | size_t data_size); | ||
734 | |||
735 | |||
736 | /** | ||
737 | * @param presentation the presentation to serialize | ||
738 | * @return the required buffer size | ||
739 | */ | ||
740 | size_t | ||
741 | GNUNET_RECLAIM_presentation_serialize_get_size ( | ||
742 | const struct GNUNET_RECLAIM_Presentation *presentation); | ||
743 | |||
744 | |||
745 | /** | ||
746 | * Serialize a presentation. | ||
747 | * | ||
748 | * @param presentation the presentation to serialize | ||
749 | * @param result the serialized presentation | ||
750 | * @return length of serialized data | ||
751 | */ | ||
752 | size_t | ||
753 | GNUNET_RECLAIM_presentation_serialize ( | ||
754 | const struct GNUNET_RECLAIM_Presentation *presentation, | ||
755 | char *result); | ||
756 | |||
757 | |||
758 | /** | ||
759 | * Deserialize a presentation | ||
760 | * | ||
761 | * @param data the serialized presentation | ||
762 | * @param data_size the length of the serialized data | ||
763 | * | ||
764 | * @return a GNUNET_RECLAIM_Presentation, must be free'd by caller | ||
765 | */ | ||
766 | struct GNUNET_RECLAIM_Presentation * | ||
767 | GNUNET_RECLAIM_presentation_deserialize (const char *data, size_t data_size); | ||
768 | |||
769 | |||
770 | /** | ||
771 | * Convert the 'claim' of a presentation to a string | ||
772 | * | ||
773 | * @param type the type of presentation | ||
774 | * @param data presentation in binary encoding | ||
775 | * @param data_size number of bytes in @a data | ||
776 | * @return NULL on error, otherwise human-readable representation of the claim | ||
777 | */ | ||
778 | char * | ||
779 | GNUNET_RECLAIM_presentation_value_to_string (uint32_t type, | ||
780 | const void *data, | ||
781 | size_t data_size); | ||
782 | |||
783 | struct GNUNET_RECLAIM_Presentation * | ||
784 | GNUNET_RECLAIM_presentation_new (uint32_t type, | ||
785 | const void *data, | ||
786 | size_t data_size); | ||
787 | |||
788 | /** | ||
789 | * Convert human-readable version of a 'claim' of a presentation to the binary | ||
790 | * representation | ||
791 | * | ||
792 | * @param type type of the presentation | ||
793 | * @param s human-readable string | ||
794 | * @param data set to value in binary encoding (will be allocated) | ||
795 | * @param data_size set to number of bytes in @a data | ||
796 | * @return #GNUNET_OK on success | ||
797 | */ | ||
798 | int | ||
799 | GNUNET_RECLAIM_presentation_string_to_value (uint32_t type, | ||
800 | const char *s, | ||
801 | void **data, | ||
802 | size_t *data_size); | ||
803 | |||
804 | /** | ||
805 | * Convert a presentation type number to the corresponding credential type | ||
806 | * string. | ||
807 | * | ||
808 | * @param type number of a type | ||
809 | * @return corresponding typestring, NULL on error | ||
810 | */ | ||
811 | const char * | ||
812 | GNUNET_RECLAIM_presentation_number_to_typename (uint32_t type); | ||
813 | |||
814 | struct GNUNET_RECLAIM_AttributeList* | ||
815 | GNUNET_RECLAIM_presentation_get_attributes (const struct | ||
816 | GNUNET_RECLAIM_Presentation *cred); | ||
817 | |||
818 | char* | ||
819 | GNUNET_RECLAIM_presentation_get_issuer (const struct | ||
820 | GNUNET_RECLAIM_Presentation *cred); | ||
821 | |||
822 | int | ||
823 | GNUNET_RECLAIM_presentation_get_expiration (const struct | ||
824 | GNUNET_RECLAIM_Presentation *cred, | ||
825 | struct GNUNET_TIME_Absolute *exp); | ||
826 | |||
827 | |||
828 | |||
829 | /** | ||
830 | * Create a presentation from a credential and a lift of (selected) | ||
831 | * attributes in the credential. | ||
832 | * FIXME not yet implemented | ||
833 | * | ||
834 | * @param cred the credential to use | ||
835 | * @param attrs the attributes to present from the credential | ||
836 | * @param presentation the credential presentation presenting the attributes according | ||
837 | * to the presentation mechanism of the credential | ||
838 | * or NULL on error. | ||
839 | * @return GNUNET_OK on success. | ||
840 | */ | ||
841 | int | ||
842 | GNUNET_RECLAIM_credential_get_presentation ( | ||
843 | const struct GNUNET_RECLAIM_Credential *cred, | ||
844 | const struct GNUNET_RECLAIM_AttributeList *attrs, | ||
845 | struct GNUNET_RECLAIM_Presentation **presentation); | ||
846 | |||
847 | |||
613 | #if 0 /* keep Emacsens' auto-indent happy */ | 848 | #if 0 /* keep Emacsens' auto-indent happy */ |
614 | { | 849 | { |
615 | #endif | 850 | #endif |
diff --git a/src/include/gnunet_reclaim_plugin.h b/src/include/gnunet_reclaim_plugin.h index ddd98697f..ed6663bb5 100644 --- a/src/include/gnunet_reclaim_plugin.h +++ b/src/include/gnunet_reclaim_plugin.h | |||
@@ -27,8 +27,8 @@ | |||
27 | * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims | 27 | * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims |
28 | * @{ | 28 | * @{ |
29 | */ | 29 | */ |
30 | #ifndef GNUNET_RECLAIM_AttributePLUGIN_H | 30 | #ifndef GNUNET_RECLAIM_PLUGIN_H |
31 | #define GNUNET_RECLAIM_AttributePLUGIN_H | 31 | #define GNUNET_RECLAIM_PLUGIN_H |
32 | 32 | ||
33 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
34 | #include "gnunet_reclaim_lib.h" | 34 | #include "gnunet_reclaim_lib.h" |
@@ -114,7 +114,7 @@ typedef const char *(*GNUNET_RECLAIM_AttributeNumberToTypenameFunction) ( | |||
114 | * @param data_size number of bytes in @a data | 114 | * @param data_size number of bytes in @a data |
115 | * @return NULL on error, otherwise human-readable representation of the value | 115 | * @return NULL on error, otherwise human-readable representation of the value |
116 | */ | 116 | */ |
117 | typedef char *(*GNUNET_RECLAIM_AttestationValueToStringFunction) ( | 117 | typedef char *(*GNUNET_RECLAIM_CredentialValueToStringFunction) ( |
118 | void *cls, | 118 | void *cls, |
119 | uint32_t type, | 119 | uint32_t type, |
120 | const void *data, | 120 | const void *data, |
@@ -133,7 +133,7 @@ typedef char *(*GNUNET_RECLAIM_AttestationValueToStringFunction) ( | |||
133 | * @param data_size set to number of bytes in @a data | 133 | * @param data_size set to number of bytes in @a data |
134 | * @return #GNUNET_OK on success | 134 | * @return #GNUNET_OK on success |
135 | */ | 135 | */ |
136 | typedef int (*GNUNET_RECLAIM_AttestationStringToValueFunction) ( | 136 | typedef int (*GNUNET_RECLAIM_CredentialStringToValueFunction) ( |
137 | void *cls, | 137 | void *cls, |
138 | uint32_t type, | 138 | uint32_t type, |
139 | const char *s, | 139 | const char *s, |
@@ -149,7 +149,7 @@ typedef int (*GNUNET_RECLAIM_AttestationStringToValueFunction) ( | |||
149 | * @param typename name to convert | 149 | * @param typename name to convert |
150 | * @return corresponding number, UINT32_MAX on error | 150 | * @return corresponding number, UINT32_MAX on error |
151 | */ | 151 | */ |
152 | typedef uint32_t (*GNUNET_RECLAIM_AttestationTypenameToNumberFunction) ( | 152 | typedef uint32_t (*GNUNET_RECLAIM_CredentialTypenameToNumberFunction) ( |
153 | void *cls, | 153 | void *cls, |
154 | const char *typename); | 154 | const char *typename); |
155 | 155 | ||
@@ -162,47 +162,151 @@ typedef uint32_t (*GNUNET_RECLAIM_AttestationTypenameToNumberFunction) ( | |||
162 | * @param type number of a type to convert | 162 | * @param type number of a type to convert |
163 | * @return corresponding typestring, NULL on error | 163 | * @return corresponding typestring, NULL on error |
164 | */ | 164 | */ |
165 | typedef const char *(*GNUNET_RECLAIM_AttestationNumberToTypenameFunction) ( | 165 | typedef const char *(*GNUNET_RECLAIM_CredentialNumberToTypenameFunction) ( |
166 | void *cls, | 166 | void *cls, |
167 | uint32_t type); | 167 | uint32_t type); |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Function called to extract attributes from an attestation | 170 | * Function called to extract attributes from a credential |
171 | * | 171 | * |
172 | * @param cls closure | 172 | * @param cls closure |
173 | * @param attest the attestation object | 173 | * @param cred the credential object |
174 | * @return an attribute list | 174 | * @return an attribute list |
175 | */ | 175 | */ |
176 | typedef struct | 176 | typedef struct |
177 | GNUNET_RECLAIM_AttributeList *(* | 177 | GNUNET_RECLAIM_AttributeList *(* |
178 | GNUNET_RECLAIM_AttestationGetAttributesFunction) ( | 178 | GNUNET_RECLAIM_CredentialGetAttributesFunction) ( |
179 | void *cls, | 179 | void *cls, |
180 | const struct GNUNET_RECLAIM_Attestation *attest); | 180 | const struct GNUNET_RECLAIM_Credential *cred); |
181 | 181 | ||
182 | /** | 182 | /** |
183 | * Function called to get the issuer of the attestation (as string) | 183 | * Function called to get the issuer of the credential (as string) |
184 | * | 184 | * |
185 | * @param cls closure | 185 | * @param cls closure |
186 | * @param attest the attestation object | 186 | * @param cred the credential object |
187 | * @return corresponding issuer string | 187 | * @return corresponding issuer string |
188 | */ | 188 | */ |
189 | typedef char *(*GNUNET_RECLAIM_AttestationGetIssuerFunction) ( | 189 | typedef char *(*GNUNET_RECLAIM_CredentialGetIssuerFunction) ( |
190 | void *cls, | 190 | void *cls, |
191 | const struct GNUNET_RECLAIM_Attestation *attest); | 191 | const struct GNUNET_RECLAIM_Credential *cred); |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Function called to get the expiration of the attestation | 194 | * Function called to get the expiration of the credential |
195 | * | 195 | * |
196 | * @param cls closure | 196 | * @param cls closure |
197 | * @param attest the attestation object | 197 | * @param cred the credential object |
198 | * @param where to write the value | 198 | * @param where to write the value |
199 | * @return GNUNET_OK if successful | 199 | * @return GNUNET_OK if successful |
200 | */ | 200 | */ |
201 | typedef int (*GNUNET_RECLAIM_AttestationGetExpirationFunction) ( | 201 | typedef int (*GNUNET_RECLAIM_CredentialGetExpirationFunction) ( |
202 | void *cls, | 202 | void *cls, |
203 | const struct GNUNET_RECLAIM_Attestation *attest, | 203 | const struct GNUNET_RECLAIM_Credential *cred, |
204 | struct GNUNET_TIME_Absolute *expiration); | 204 | struct GNUNET_TIME_Absolute *expiration); |
205 | 205 | ||
206 | /** | ||
207 | * Function called to convert the binary value @a data of an attribute of | ||
208 | * type @a type to a human-readable string. | ||
209 | * | ||
210 | * @param cls closure | ||
211 | * @param type type of the attribute | ||
212 | * @param data value in binary encoding | ||
213 | * @param data_size number of bytes in @a data | ||
214 | * @return NULL on error, otherwise human-readable representation of the value | ||
215 | */ | ||
216 | typedef char *(*GNUNET_RECLAIM_PresentationValueToStringFunction) ( | ||
217 | void *cls, | ||
218 | uint32_t type, | ||
219 | const void *data, | ||
220 | size_t data_size); | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Function called to convert human-readable version of the value @a s | ||
225 | * of an attribute of type @a type to the respective binary | ||
226 | * representation. | ||
227 | * | ||
228 | * @param cls closure | ||
229 | * @param type type of the attribute | ||
230 | * @param s human-readable string | ||
231 | * @param data set to value in binary encoding (will be allocated) | ||
232 | * @param data_size set to number of bytes in @a data | ||
233 | * @return #GNUNET_OK on success | ||
234 | */ | ||
235 | typedef int (*GNUNET_RECLAIM_PresentationStringToValueFunction) ( | ||
236 | void *cls, | ||
237 | uint32_t type, | ||
238 | const char *s, | ||
239 | void **data, | ||
240 | size_t *data_size); | ||
241 | |||
242 | |||
243 | /** | ||
244 | * Function called to convert a type name to the | ||
245 | * corresponding number. | ||
246 | * | ||
247 | * @param cls closure | ||
248 | * @param typename name to convert | ||
249 | * @return corresponding number, UINT32_MAX on error | ||
250 | */ | ||
251 | typedef uint32_t (*GNUNET_RECLAIM_PresentationTypenameToNumberFunction) ( | ||
252 | void *cls, | ||
253 | const char *typename); | ||
254 | |||
255 | |||
256 | /** | ||
257 | * Function called to convert a type number (i.e. 1) to the | ||
258 | * corresponding type string | ||
259 | * | ||
260 | * @param cls closure | ||
261 | * @param type number of a type to convert | ||
262 | * @return corresponding typestring, NULL on error | ||
263 | */ | ||
264 | typedef const char *(*GNUNET_RECLAIM_PresentationNumberToTypenameFunction) ( | ||
265 | void *cls, | ||
266 | uint32_t type); | ||
267 | |||
268 | /** | ||
269 | * Function called to extract attributes from a credential | ||
270 | * | ||
271 | * @param cls closure | ||
272 | * @param cred the credential object | ||
273 | * @return an attribute list | ||
274 | */ | ||
275 | typedef struct | ||
276 | GNUNET_RECLAIM_AttributeList *(* | ||
277 | GNUNET_RECLAIM_PresentationGetAttributesFunction) ( | ||
278 | void *cls, | ||
279 | const struct GNUNET_RECLAIM_Presentation *cred); | ||
280 | |||
281 | /** | ||
282 | * Function called to get the issuer of the credential (as string) | ||
283 | * | ||
284 | * @param cls closure | ||
285 | * @param cred the credential object | ||
286 | * @return corresponding issuer string | ||
287 | */ | ||
288 | typedef char *(*GNUNET_RECLAIM_PresentationGetIssuerFunction) ( | ||
289 | void *cls, | ||
290 | const struct GNUNET_RECLAIM_Presentation *cred); | ||
291 | |||
292 | /** | ||
293 | * Function called to get the expiration of the credential | ||
294 | * | ||
295 | * @param cls closure | ||
296 | * @param cred the credential object | ||
297 | * @param where to write the value | ||
298 | * @return GNUNET_OK if successful | ||
299 | */ | ||
300 | typedef int (*GNUNET_RECLAIM_PresentationGetExpirationFunction) ( | ||
301 | void *cls, | ||
302 | const struct GNUNET_RECLAIM_Presentation *cred, | ||
303 | struct GNUNET_TIME_Absolute *expiration); | ||
304 | |||
305 | typedef int (*GNUNET_RECLAIM_CredentialToPresentation) ( | ||
306 | void *cls, | ||
307 | const struct GNUNET_RECLAIM_Credential *cred, | ||
308 | const struct GNUNET_RECLAIM_AttributeList *attrs, | ||
309 | struct GNUNET_RECLAIM_Presentation **presentation); | ||
206 | 310 | ||
207 | /** | 311 | /** |
208 | * Each plugin is required to return a pointer to a struct of this | 312 | * Each plugin is required to return a pointer to a struct of this |
@@ -241,7 +345,7 @@ struct GNUNET_RECLAIM_AttributePluginFunctions | |||
241 | * Each plugin is required to return a pointer to a struct of this | 345 | * Each plugin is required to return a pointer to a struct of this |
242 | * type as the return value from its entry point. | 346 | * type as the return value from its entry point. |
243 | */ | 347 | */ |
244 | struct GNUNET_RECLAIM_AttestationPluginFunctions | 348 | struct GNUNET_RECLAIM_CredentialPluginFunctions |
245 | { | 349 | { |
246 | /** | 350 | /** |
247 | * Closure for all of the callbacks. | 351 | * Closure for all of the callbacks. |
@@ -251,37 +355,78 @@ struct GNUNET_RECLAIM_AttestationPluginFunctions | |||
251 | /** | 355 | /** |
252 | * Conversion to string. | 356 | * Conversion to string. |
253 | */ | 357 | */ |
254 | GNUNET_RECLAIM_AttestationValueToStringFunction value_to_string; | 358 | GNUNET_RECLAIM_CredentialValueToStringFunction value_to_string; |
359 | |||
360 | /** | ||
361 | * Conversion to binary. | ||
362 | */ | ||
363 | GNUNET_RECLAIM_CredentialStringToValueFunction string_to_value; | ||
364 | |||
365 | /** | ||
366 | * Typename to number. | ||
367 | */ | ||
368 | GNUNET_RECLAIM_CredentialTypenameToNumberFunction typename_to_number; | ||
369 | |||
370 | /** | ||
371 | * Number to typename. | ||
372 | */ | ||
373 | GNUNET_RECLAIM_CredentialNumberToTypenameFunction number_to_typename; | ||
374 | |||
375 | /** | ||
376 | * Attesation attributes. | ||
377 | */ | ||
378 | GNUNET_RECLAIM_CredentialGetAttributesFunction get_attributes; | ||
379 | |||
380 | /** | ||
381 | * Attesation issuer. | ||
382 | */ | ||
383 | GNUNET_RECLAIM_CredentialGetIssuerFunction get_issuer; | ||
384 | |||
385 | /** | ||
386 | * Expiration. | ||
387 | */ | ||
388 | GNUNET_RECLAIM_CredentialGetExpirationFunction get_expiration; | ||
389 | |||
390 | /** | ||
391 | * Conversion to string. | ||
392 | */ | ||
393 | GNUNET_RECLAIM_PresentationValueToStringFunction value_to_string_p; | ||
255 | 394 | ||
256 | /** | 395 | /** |
257 | * Conversion to binary. | 396 | * Conversion to binary. |
258 | */ | 397 | */ |
259 | GNUNET_RECLAIM_AttestationStringToValueFunction string_to_value; | 398 | GNUNET_RECLAIM_PresentationStringToValueFunction string_to_value_p; |
260 | 399 | ||
261 | /** | 400 | /** |
262 | * Typename to number. | 401 | * Typename to number. |
263 | */ | 402 | */ |
264 | GNUNET_RECLAIM_AttestationTypenameToNumberFunction typename_to_number; | 403 | GNUNET_RECLAIM_PresentationTypenameToNumberFunction typename_to_number_p; |
265 | 404 | ||
266 | /** | 405 | /** |
267 | * Number to typename. | 406 | * Number to typename. |
268 | */ | 407 | */ |
269 | GNUNET_RECLAIM_AttestationNumberToTypenameFunction number_to_typename; | 408 | GNUNET_RECLAIM_PresentationNumberToTypenameFunction number_to_typename_p; |
270 | 409 | ||
271 | /** | 410 | /** |
272 | * Attesation attributes. | 411 | * Attesation attributes. |
273 | */ | 412 | */ |
274 | GNUNET_RECLAIM_AttestationGetAttributesFunction get_attributes; | 413 | GNUNET_RECLAIM_PresentationGetAttributesFunction get_attributes_p; |
275 | 414 | ||
276 | /** | 415 | /** |
277 | * Attesation issuer. | 416 | * Attesation issuer. |
278 | */ | 417 | */ |
279 | GNUNET_RECLAIM_AttestationGetIssuerFunction get_issuer; | 418 | GNUNET_RECLAIM_PresentationGetIssuerFunction get_issuer_p; |
280 | 419 | ||
281 | /** | 420 | /** |
282 | * Expiration. | 421 | * Expiration. |
283 | */ | 422 | */ |
284 | GNUNET_RECLAIM_AttestationGetExpirationFunction get_expiration; | 423 | GNUNET_RECLAIM_PresentationGetExpirationFunction get_expiration_p; |
424 | |||
425 | /** | ||
426 | * Get presentation | ||
427 | */ | ||
428 | GNUNET_RECLAIM_CredentialToPresentation create_presentation; | ||
429 | |||
285 | }; | 430 | }; |
286 | 431 | ||
287 | 432 | ||
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h index 139c44ae7..368058f56 100644 --- a/src/include/gnunet_reclaim_service.h +++ b/src/include/gnunet_reclaim_service.h | |||
@@ -92,7 +92,21 @@ struct GNUNET_RECLAIM_Ticket | |||
92 | * @param ticket the ticket | 92 | * @param ticket the ticket |
93 | */ | 93 | */ |
94 | typedef void (*GNUNET_RECLAIM_TicketCallback) ( | 94 | typedef void (*GNUNET_RECLAIM_TicketCallback) ( |
95 | void *cls, const struct GNUNET_RECLAIM_Ticket *ticket); | 95 | void *cls, |
96 | const struct GNUNET_RECLAIM_Ticket *ticket); | ||
97 | |||
98 | /** | ||
99 | * Method called when a token has been issued. | ||
100 | * On success returns a ticket that can be given to a relying party | ||
101 | * in order for it retrive identity attributes | ||
102 | * | ||
103 | * @param cls closure | ||
104 | * @param ticket the ticket | ||
105 | */ | ||
106 | typedef void (*GNUNET_RECLAIM_IssueTicketCallback) ( | ||
107 | void *cls, | ||
108 | const struct GNUNET_RECLAIM_Ticket *ticket, | ||
109 | const struct GNUNET_RECLAIM_PresentationList *presentations); | ||
96 | 110 | ||
97 | 111 | ||
98 | /** | 112 | /** |
@@ -113,7 +127,6 @@ typedef void (*GNUNET_RECLAIM_ContinuationWithStatus) (void *cls, | |||
113 | * @param cls The callback closure | 127 | * @param cls The callback closure |
114 | * @param identity The identity authoritative over the attributes | 128 | * @param identity The identity authoritative over the attributes |
115 | * @param attr The attribute | 129 | * @param attr The attribute |
116 | * @param attestation The attestation for the attribute (may be NULL) | ||
117 | */ | 130 | */ |
118 | typedef void (*GNUNET_RECLAIM_AttributeResult) ( | 131 | typedef void (*GNUNET_RECLAIM_AttributeResult) ( |
119 | void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 132 | void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
@@ -125,25 +138,25 @@ typedef void (*GNUNET_RECLAIM_AttributeResult) ( | |||
125 | * @param cls The callback closure | 138 | * @param cls The callback closure |
126 | * @param identity The identity authoritative over the attributes | 139 | * @param identity The identity authoritative over the attributes |
127 | * @param attr The attribute | 140 | * @param attr The attribute |
128 | * @param attestation The attestation for the attribute (may be NULL) | 141 | * @param presentation The presentation for the credential (may be NULL) |
129 | */ | 142 | */ |
130 | typedef void (*GNUNET_RECLAIM_AttributeTicketResult) ( | 143 | typedef void (*GNUNET_RECLAIM_AttributeTicketResult) ( |
131 | void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 144 | void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
132 | const struct GNUNET_RECLAIM_Attribute *attr, | 145 | const struct GNUNET_RECLAIM_Attribute *attr, |
133 | const struct GNUNET_RECLAIM_Attestation *attestation); | 146 | const struct GNUNET_RECLAIM_Presentation *presentation); |
134 | 147 | ||
135 | 148 | ||
136 | /** | 149 | /** |
137 | * Callback used to notify the client of attestation results. | 150 | * Callback used to notify the client of credential results. |
138 | * | 151 | * |
139 | * @param cls The callback closure | 152 | * @param cls The callback closure |
140 | * @param identity The identity authoritative over the attributes | 153 | * @param identity The identity authoritative over the attributes |
141 | * @param attestation The attestation | 154 | * @param credential The credential |
142 | * @param attributes the parsed attributes | 155 | * @param attributes the parsed attributes |
143 | */ | 156 | */ |
144 | typedef void (*GNUNET_RECLAIM_AttestationResult) ( | 157 | typedef void (*GNUNET_RECLAIM_CredentialResult) ( |
145 | void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 158 | void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
146 | const struct GNUNET_RECLAIM_Attestation *attestation); | 159 | const struct GNUNET_RECLAIM_Credential *credential); |
147 | 160 | ||
148 | 161 | ||
149 | /** | 162 | /** |
@@ -178,22 +191,22 @@ GNUNET_RECLAIM_attribute_store ( | |||
178 | 191 | ||
179 | 192 | ||
180 | /** | 193 | /** |
181 | * Store an attestation. If the attestation is already present, | 194 | * Store a credential. If the credential is already present, |
182 | * it is replaced with the new attestation. | 195 | * it is replaced with the new credential. |
183 | * | 196 | * |
184 | * @param h handle to the re:claimID service | 197 | * @param h handle to the re:claimID service |
185 | * @param pkey private key of the identity | 198 | * @param pkey private key of the identity |
186 | * @param attr the attestation value | 199 | * @param attr the credential value |
187 | * @param exp_interval the relative expiration interval for the attestation | 200 | * @param exp_interval the relative expiration interval for the credential |
188 | * @param cont continuation to call when done | 201 | * @param cont continuation to call when done |
189 | * @param cont_cls closure for @a cont | 202 | * @param cont_cls closure for @a cont |
190 | * @return handle to abort the request | 203 | * @return handle to abort the request |
191 | */ | 204 | */ |
192 | struct GNUNET_RECLAIM_Operation * | 205 | struct GNUNET_RECLAIM_Operation * |
193 | GNUNET_RECLAIM_attestation_store ( | 206 | GNUNET_RECLAIM_credential_store ( |
194 | struct GNUNET_RECLAIM_Handle *h, | 207 | struct GNUNET_RECLAIM_Handle *h, |
195 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 208 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
196 | const struct GNUNET_RECLAIM_Attestation *attestation, | 209 | const struct GNUNET_RECLAIM_Credential *credential, |
197 | const struct GNUNET_TIME_Relative *exp_interval, | 210 | const struct GNUNET_TIME_Relative *exp_interval, |
198 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 211 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
199 | void *cont_cls); | 212 | void *cont_cls); |
@@ -218,21 +231,21 @@ GNUNET_RECLAIM_attribute_delete ( | |||
218 | GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); | 231 | GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); |
219 | 232 | ||
220 | /** | 233 | /** |
221 | * Delete an attestation. Tickets used to share this attestation are updated | 234 | * Delete a credential. Tickets used to share use a presentation of this |
222 | * accordingly. | 235 | * credential are updated accordingly. |
223 | * | 236 | * |
224 | * @param h handle to the re:claimID service | 237 | * @param h handle to the re:claimID service |
225 | * @param pkey Private key of the identity to add an attribute to | 238 | * @param pkey Private key of the identity to add an attribute to |
226 | * @param attr The attestation | 239 | * @param cred The credential |
227 | * @param cont Continuation to call when done | 240 | * @param cont Continuation to call when done |
228 | * @param cont_cls Closure for @a cont | 241 | * @param cont_cls Closure for @a cont |
229 | * @return handle Used to to abort the request | 242 | * @return handle Used to to abort the request |
230 | */ | 243 | */ |
231 | struct GNUNET_RECLAIM_Operation * | 244 | struct GNUNET_RECLAIM_Operation * |
232 | GNUNET_RECLAIM_attestation_delete ( | 245 | GNUNET_RECLAIM_credential_delete ( |
233 | struct GNUNET_RECLAIM_Handle *h, | 246 | struct GNUNET_RECLAIM_Handle *h, |
234 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 247 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
235 | const struct GNUNET_RECLAIM_Attestation *attr, | 248 | const struct GNUNET_RECLAIM_Credential *cred, |
236 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 249 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
237 | void *cont_cls); | 250 | void *cont_cls); |
238 | 251 | ||
@@ -293,12 +306,12 @@ GNUNET_RECLAIM_get_attributes_stop ( | |||
293 | 306 | ||
294 | 307 | ||
295 | /** | 308 | /** |
296 | * List all attestations for a local identity. | 309 | * List all credentials for a local identity. |
297 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` | 310 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` |
298 | * for any other calls than #GNUNET_RECLAIM_get_attestations_next() and | 311 | * for any other calls than #GNUNET_RECLAIM_get_credentials_next() and |
299 | * #GNUNET_RECLAIM_get_attestations_stop. @a proc will be called once | 312 | * #GNUNET_RECLAIM_get_credentials_stop. @a proc will be called once |
300 | * immediately, and then again after | 313 | * immediately, and then again after |
301 | * #GNUNET_RECLAIM_get_attestations_next() is invoked. | 314 | * #GNUNET_RECLAIM_get_credentials_next() is invoked. |
302 | * | 315 | * |
303 | * On error (disconnect), @a error_cb will be invoked. | 316 | * On error (disconnect), @a error_cb will be invoked. |
304 | * On normal completion, @a finish_cb proc will be | 317 | * On normal completion, @a finish_cb proc will be |
@@ -309,34 +322,34 @@ GNUNET_RECLAIM_get_attributes_stop ( | |||
309 | * @param error_cb Function to call on error (i.e. disconnect), | 322 | * @param error_cb Function to call on error (i.e. disconnect), |
310 | * the handle is afterwards invalid | 323 | * the handle is afterwards invalid |
311 | * @param error_cb_cls Closure for @a error_cb | 324 | * @param error_cb_cls Closure for @a error_cb |
312 | * @param proc Function to call on each attestation | 325 | * @param proc Function to call on each credential |
313 | * @param proc_cls Closure for @a proc | 326 | * @param proc_cls Closure for @a proc |
314 | * @param finish_cb Function to call on completion | 327 | * @param finish_cb Function to call on completion |
315 | * the handle is afterwards invalid | 328 | * the handle is afterwards invalid |
316 | * @param finish_cb_cls Closure for @a finish_cb | 329 | * @param finish_cb_cls Closure for @a finish_cb |
317 | * @return an iterator Handle to use for iteration | 330 | * @return an iterator Handle to use for iteration |
318 | */ | 331 | */ |
319 | struct GNUNET_RECLAIM_AttestationIterator * | 332 | struct GNUNET_RECLAIM_CredentialIterator * |
320 | GNUNET_RECLAIM_get_attestations_start ( | 333 | GNUNET_RECLAIM_get_credentials_start ( |
321 | struct GNUNET_RECLAIM_Handle *h, | 334 | struct GNUNET_RECLAIM_Handle *h, |
322 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 335 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
323 | GNUNET_SCHEDULER_TaskCallback error_cb, | 336 | GNUNET_SCHEDULER_TaskCallback error_cb, |
324 | void *error_cb_cls, | 337 | void *error_cb_cls, |
325 | GNUNET_RECLAIM_AttestationResult proc, | 338 | GNUNET_RECLAIM_CredentialResult proc, |
326 | void *proc_cls, | 339 | void *proc_cls, |
327 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 340 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
328 | void *finish_cb_cls); | 341 | void *finish_cb_cls); |
329 | 342 | ||
330 | 343 | ||
331 | /** | 344 | /** |
332 | * Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start | 345 | * Calls the record processor specified in #GNUNET_RECLAIM_get_credentials_start |
333 | * for the next record. | 346 | * for the next record. |
334 | * | 347 | * |
335 | * @param it the iterator | 348 | * @param it the iterator |
336 | */ | 349 | */ |
337 | void | 350 | void |
338 | GNUNET_RECLAIM_get_attestations_next (struct | 351 | GNUNET_RECLAIM_get_credentials_next ( |
339 | GNUNET_RECLAIM_AttestationIterator *ait); | 352 | struct GNUNET_RECLAIM_CredentialIterator *ait); |
340 | 353 | ||
341 | 354 | ||
342 | /** | 355 | /** |
@@ -347,8 +360,8 @@ GNUNET_RECLAIM_get_attestations_next (struct | |||
347 | * @param it the iterator | 360 | * @param it the iterator |
348 | */ | 361 | */ |
349 | void | 362 | void |
350 | GNUNET_RECLAIM_get_attestations_stop (struct | 363 | GNUNET_RECLAIM_get_credentials_stop ( |
351 | GNUNET_RECLAIM_AttestationIterator *ait); | 364 | struct GNUNET_RECLAIM_CredentialIterator *ait); |
352 | 365 | ||
353 | 366 | ||
354 | /** | 367 | /** |
@@ -370,7 +383,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
370 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, | 383 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, |
371 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, | 384 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, |
372 | const struct GNUNET_RECLAIM_AttributeList *attrs, | 385 | const struct GNUNET_RECLAIM_AttributeList *attrs, |
373 | GNUNET_RECLAIM_TicketCallback cb, void *cb_cls); | 386 | GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls); |
374 | 387 | ||
375 | 388 | ||
376 | /** | 389 | /** |
diff --git a/src/include/gnunet_seti_service.h b/src/include/gnunet_seti_service.h new file mode 100644 index 000000000..c0b6f41a5 --- /dev/null +++ b/src/include/gnunet_seti_service.h | |||
@@ -0,0 +1,369 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2013, 2014, 2020 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Florian Dold | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * Two-peer set intersection operations | ||
26 | * | ||
27 | * @defgroup set Set intersection service | ||
28 | * Two-peer set operations | ||
29 | * | ||
30 | * @{ | ||
31 | */ | ||
32 | |||
33 | #ifndef GNUNET_SETI_SERVICE_H | ||
34 | #define GNUNET_SETI_SERVICE_H | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" | ||
38 | { | ||
39 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
40 | } | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | #include "gnunet_common.h" | ||
45 | #include "gnunet_time_lib.h" | ||
46 | #include "gnunet_configuration_lib.h" | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Maximum size of a context message for set operation requests. | ||
51 | */ | ||
52 | #define GNUNET_SETI_CONTEXT_MESSAGE_MAX_SIZE ((1 << 16) - 1024) | ||
53 | |||
54 | /** | ||
55 | * Opaque handle to a set. | ||
56 | */ | ||
57 | struct GNUNET_SETI_Handle; | ||
58 | |||
59 | /** | ||
60 | * Opaque handle to a set operation request from another peer. | ||
61 | */ | ||
62 | struct GNUNET_SETI_Request; | ||
63 | |||
64 | /** | ||
65 | * Opaque handle to a listen operation. | ||
66 | */ | ||
67 | struct GNUNET_SETI_ListenHandle; | ||
68 | |||
69 | /** | ||
70 | * Opaque handle to a set operation. | ||
71 | */ | ||
72 | struct GNUNET_SETI_OperationHandle; | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Status for the result callback | ||
77 | */ | ||
78 | enum GNUNET_SETI_Status | ||
79 | { | ||
80 | |||
81 | /** | ||
82 | * Element should be added to the result set of the local peer, i.e. the | ||
83 | * element is in the intersection. | ||
84 | */ | ||
85 | GNUNET_SETI_STATUS_ADD_LOCAL, | ||
86 | |||
87 | /** | ||
88 | * Element should be delete from the result set of the local peer, i.e. the | ||
89 | * local peer is having an element that is not in the intersection. | ||
90 | */ | ||
91 | GNUNET_SETI_STATUS_DEL_LOCAL, | ||
92 | |||
93 | /** | ||
94 | * The other peer refused to do the operation with us, or something went | ||
95 | * wrong. | ||
96 | */ | ||
97 | GNUNET_SETI_STATUS_FAILURE, | ||
98 | |||
99 | /** | ||
100 | * Success, all elements have been sent (and received). | ||
101 | */ | ||
102 | GNUNET_SETI_STATUS_DONE | ||
103 | }; | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Element stored in a set. | ||
108 | */ | ||
109 | struct GNUNET_SETI_Element | ||
110 | { | ||
111 | /** | ||
112 | * Number of bytes in the buffer pointed to by data. | ||
113 | */ | ||
114 | uint16_t size; | ||
115 | |||
116 | /** | ||
117 | * Application-specific element type. | ||
118 | */ | ||
119 | uint16_t element_type; | ||
120 | |||
121 | /** | ||
122 | * Actual data of the element | ||
123 | */ | ||
124 | const void *data; | ||
125 | }; | ||
126 | |||
127 | |||
128 | /** | ||
129 | * Possible options to pass to a set operation. | ||
130 | * | ||
131 | * Used as tag for struct #GNUNET_SETI_Option. | ||
132 | */ | ||
133 | enum GNUNET_SETI_OptionType | ||
134 | { | ||
135 | /** | ||
136 | * List terminator. | ||
137 | */ | ||
138 | GNUNET_SETI_OPTION_END = 0, | ||
139 | |||
140 | /** | ||
141 | * Return the elements remaining in the intersection | ||
142 | * (#GNUNET_SETI_STATUS_ADD_LOCAL). If not given, the default is to return a | ||
143 | * list of the elements to be removed (#GNUNET_SETI_STATUS_DEL_LOCAL). | ||
144 | */ | ||
145 | GNUNET_SETI_OPTION_RETURN_INTERSECTION = 1, | ||
146 | }; | ||
147 | |||
148 | |||
149 | /** | ||
150 | * Option for set operations. | ||
151 | */ | ||
152 | struct GNUNET_SETI_Option | ||
153 | { | ||
154 | /** | ||
155 | * Type of the option. | ||
156 | */ | ||
157 | enum GNUNET_SETI_OptionType type; | ||
158 | |||
159 | /** | ||
160 | * Value for the option, only used with some options. | ||
161 | */ | ||
162 | union | ||
163 | { | ||
164 | uint64_t num; | ||
165 | } v; | ||
166 | }; | ||
167 | |||
168 | |||
169 | /** | ||
170 | * Callback for set union operation results. Called for each element | ||
171 | * in the result set. | ||
172 | * | ||
173 | * @param cls closure | ||
174 | * @param element a result element, only valid if status is #GNUNET_SETI_STATUS_OK | ||
175 | * @param current_size current set size | ||
176 | * @param status see `enum GNUNET_SETI_Status` | ||
177 | */ | ||
178 | typedef void | ||
179 | (*GNUNET_SETI_ResultIterator) (void *cls, | ||
180 | const struct GNUNET_SETI_Element *element, | ||
181 | uint64_t current_size, | ||
182 | enum GNUNET_SETI_Status status); | ||
183 | |||
184 | |||
185 | /** | ||
186 | * Called when another peer wants to do a set operation with the | ||
187 | * local peer. If a listen error occurs, the @a request is NULL. | ||
188 | * | ||
189 | * @param cls closure | ||
190 | * @param other_peer the other peer | ||
191 | * @param context_msg message with application specific information from | ||
192 | * the other peer | ||
193 | * @param request request from the other peer (never NULL), use GNUNET_SETI_accept() | ||
194 | * to accept it, otherwise the request will be refused | ||
195 | * Note that we can't just return value from the listen callback, | ||
196 | * as it is also necessary to specify the set we want to do the | ||
197 | * operation with, whith sometimes can be derived from the context | ||
198 | * message. It's necessary to specify the timeout. | ||
199 | */ | ||
200 | typedef void | ||
201 | (*GNUNET_SETI_ListenCallback) (void *cls, | ||
202 | const struct GNUNET_PeerIdentity *other_peer, | ||
203 | const struct GNUNET_MessageHeader *context_msg, | ||
204 | struct GNUNET_SETI_Request *request); | ||
205 | |||
206 | |||
207 | /** | ||
208 | * Create an empty set, supporting the specified operation. | ||
209 | * | ||
210 | * @param cfg configuration to use for connecting to the | ||
211 | * set service | ||
212 | * @return a handle to the set | ||
213 | */ | ||
214 | struct GNUNET_SETI_Handle * | ||
215 | GNUNET_SETI_create (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
216 | |||
217 | |||
218 | /** | ||
219 | * Add an element to the given set. | ||
220 | * | ||
221 | * @param set set to add element to | ||
222 | * @param element element to add to the set | ||
223 | * @param cb function to call when finished, can be NULL | ||
224 | * @param cb_cls closure for @a cb | ||
225 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the | ||
226 | * set is invalid (e.g. the set service crashed) | ||
227 | */ | ||
228 | int | ||
229 | GNUNET_SETI_add_element (struct GNUNET_SETI_Handle *set, | ||
230 | const struct GNUNET_SETI_Element *element, | ||
231 | GNUNET_SCHEDULER_TaskCallback cb, | ||
232 | void *cb_cls); | ||
233 | |||
234 | |||
235 | /** | ||
236 | * Destroy the set handle, and free all associated resources. Operations may | ||
237 | * still be pending when a set is destroyed (and will be allowed to complete). | ||
238 | * | ||
239 | * @param set set to destroy | ||
240 | */ | ||
241 | void | ||
242 | GNUNET_SETI_destroy (struct GNUNET_SETI_Handle *set); | ||
243 | |||
244 | |||
245 | /** | ||
246 | * Prepare a set operation to be evaluated with another peer. The evaluation | ||
247 | * will not start until the client provides a local set with | ||
248 | * GNUNET_SETI_commit(). | ||
249 | * | ||
250 | * @param other_peer peer with the other set | ||
251 | * @param app_id hash for the application using the set | ||
252 | * @param context_msg additional information for the request | ||
253 | * @param options options to use when processing the request | ||
254 | * @param result_cb called on error or success | ||
255 | * @param result_cls closure for @a result_cb | ||
256 | * @return a handle to cancel the operation | ||
257 | */ | ||
258 | struct GNUNET_SETI_OperationHandle * | ||
259 | GNUNET_SETI_prepare (const struct GNUNET_PeerIdentity *other_peer, | ||
260 | const struct GNUNET_HashCode *app_id, | ||
261 | const struct GNUNET_MessageHeader *context_msg, | ||
262 | const struct GNUNET_SETI_Option options[], | ||
263 | GNUNET_SETI_ResultIterator result_cb, | ||
264 | void *result_cls); | ||
265 | |||
266 | |||
267 | /** | ||
268 | * Wait for set operation requests for the given application ID. | ||
269 | * If the connection to the set service is lost, the listener is | ||
270 | * re-created transparently with exponential backoff. | ||
271 | * | ||
272 | * @param cfg configuration to use for connecting to | ||
273 | * the set service | ||
274 | * @param app_id id of the application that handles set operation requests | ||
275 | * @param listen_cb called for each incoming request matching the operation | ||
276 | * and application id | ||
277 | * @param listen_cls handle for @a listen_cb | ||
278 | * @return a handle that can be used to cancel the listen operation | ||
279 | */ | ||
280 | struct GNUNET_SETI_ListenHandle * | ||
281 | GNUNET_SETI_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
282 | const struct GNUNET_HashCode *app_id, | ||
283 | GNUNET_SETI_ListenCallback listen_cb, | ||
284 | void *listen_cls); | ||
285 | |||
286 | |||
287 | /** | ||
288 | * Cancel the given listen operation. After calling cancel, the | ||
289 | * listen callback for this listen handle will not be called again. | ||
290 | * Note that cancelling a listen operation will automatically reject | ||
291 | * all operations that have not yet been accepted. | ||
292 | * | ||
293 | * @param lh handle for the listen operation | ||
294 | */ | ||
295 | void | ||
296 | GNUNET_SETI_listen_cancel (struct GNUNET_SETI_ListenHandle *lh); | ||
297 | |||
298 | |||
299 | /** | ||
300 | * Accept a request we got via GNUNET_SETI_listen(). Must be called during | ||
301 | * GNUNET_SETI_listen(), as the `struct GNUNET_SETI_Request` becomes invalid | ||
302 | * afterwards. | ||
303 | * Call GNUNET_SETI_commit() to provide the local set to use for the operation, | ||
304 | * and to begin the exchange with the remote peer. | ||
305 | * | ||
306 | * @param request request to accept | ||
307 | * @param options options to use when processing the request | ||
308 | * @param result_cb callback for the results | ||
309 | * @param result_cls closure for @a result_cb | ||
310 | * @return a handle to cancel the operation | ||
311 | */ | ||
312 | struct GNUNET_SETI_OperationHandle * | ||
313 | GNUNET_SETI_accept (struct GNUNET_SETI_Request *request, | ||
314 | const struct GNUNET_SETI_Option options[], | ||
315 | GNUNET_SETI_ResultIterator result_cb, | ||
316 | void *result_cls); | ||
317 | |||
318 | |||
319 | /** | ||
320 | * Commit a set to be used with a set operation. | ||
321 | * This function is called once we have fully constructed | ||
322 | * the set that we want to use for the operation. At this | ||
323 | * time, the P2P protocol can then begin to exchange the | ||
324 | * set information and call the result callback with the | ||
325 | * result information. | ||
326 | * | ||
327 | * @param oh handle to the set operation | ||
328 | * @param set the set to use for the operation | ||
329 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the | ||
330 | * set is invalid (e.g. the set service crashed) | ||
331 | */ | ||
332 | int | ||
333 | GNUNET_SETI_commit (struct GNUNET_SETI_OperationHandle *oh, | ||
334 | struct GNUNET_SETI_Handle *set); | ||
335 | |||
336 | |||
337 | /** | ||
338 | * Cancel the given set operation. May not be called after the operation's | ||
339 | * `GNUNET_SETI_ResultIterator` has been called with a status of | ||
340 | * #GNUNET_SETI_STATUS_FAILURE or #GNUNET_SETI_STATUS_DONE. | ||
341 | * | ||
342 | * @param oh set operation to cancel | ||
343 | */ | ||
344 | void | ||
345 | GNUNET_SETI_operation_cancel (struct GNUNET_SETI_OperationHandle *oh); | ||
346 | |||
347 | |||
348 | /** | ||
349 | * Hash a set element. | ||
350 | * | ||
351 | * @param element the element that should be hashed | ||
352 | * @param[out] ret_hash a pointer to where the hash of @a element | ||
353 | * should be stored | ||
354 | */ | ||
355 | void | ||
356 | GNUNET_SETI_element_hash (const struct GNUNET_SETI_Element *element, | ||
357 | struct GNUNET_HashCode *ret_hash); | ||
358 | |||
359 | |||
360 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
361 | { | ||
362 | #endif | ||
363 | #ifdef __cplusplus | ||
364 | } | ||
365 | #endif | ||
366 | |||
367 | #endif | ||
368 | |||
369 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_setu_service.h b/src/include/gnunet_setu_service.h new file mode 100644 index 000000000..634c5c40b --- /dev/null +++ b/src/include/gnunet_setu_service.h | |||
@@ -0,0 +1,390 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2013, 2014, 2020 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Florian Dold | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * Two-peer set union operations | ||
26 | * | ||
27 | * @defgroup set Set union service | ||
28 | * Two-peer set operations | ||
29 | * | ||
30 | * @{ | ||
31 | */ | ||
32 | |||
33 | #ifndef GNUNET_SETU_SERVICE_H | ||
34 | #define GNUNET_SETU_SERVICE_H | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" | ||
38 | { | ||
39 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
40 | } | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | #include "gnunet_common.h" | ||
45 | #include "gnunet_time_lib.h" | ||
46 | #include "gnunet_configuration_lib.h" | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Maximum size of a context message for set operation requests. | ||
51 | */ | ||
52 | #define GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE ((1 << 16) - 1024) | ||
53 | |||
54 | /** | ||
55 | * Opaque handle to a set. | ||
56 | */ | ||
57 | struct GNUNET_SETU_Handle; | ||
58 | |||
59 | /** | ||
60 | * Opaque handle to a set operation request from another peer. | ||
61 | */ | ||
62 | struct GNUNET_SETU_Request; | ||
63 | |||
64 | /** | ||
65 | * Opaque handle to a listen operation. | ||
66 | */ | ||
67 | struct GNUNET_SETU_ListenHandle; | ||
68 | |||
69 | /** | ||
70 | * Opaque handle to a set operation. | ||
71 | */ | ||
72 | struct GNUNET_SETU_OperationHandle; | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Status for the result callback | ||
77 | */ | ||
78 | enum GNUNET_SETU_Status | ||
79 | { | ||
80 | |||
81 | /** | ||
82 | * Element should be added to the result set of the local peer, i.e. the | ||
83 | * local peer is missing an element. | ||
84 | */ | ||
85 | GNUNET_SETU_STATUS_ADD_LOCAL, | ||
86 | |||
87 | /** | ||
88 | * Element should be added to the result set of the remote peer, i.e. the | ||
89 | * remote peer is missing an element. Only used if | ||
90 | * #GNUNET_SETU_OPTION_SYMMETRIC is set. | ||
91 | */ | ||
92 | GNUNET_SETU_STATUS_ADD_REMOTE, | ||
93 | |||
94 | /** | ||
95 | * The other peer refused to do the operation with us, or something went | ||
96 | * wrong. | ||
97 | */ | ||
98 | GNUNET_SETU_STATUS_FAILURE, | ||
99 | |||
100 | /** | ||
101 | * Success, all elements have been sent (and received). | ||
102 | */ | ||
103 | GNUNET_SETU_STATUS_DONE | ||
104 | }; | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Element stored in a set. | ||
109 | */ | ||
110 | struct GNUNET_SETU_Element | ||
111 | { | ||
112 | /** | ||
113 | * Number of bytes in the buffer pointed to by data. | ||
114 | */ | ||
115 | uint16_t size; | ||
116 | |||
117 | /** | ||
118 | * Application-specific element type. | ||
119 | */ | ||
120 | uint16_t element_type; | ||
121 | |||
122 | /** | ||
123 | * Actual data of the element | ||
124 | */ | ||
125 | const void *data; | ||
126 | }; | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Possible options to pass to a set operation. | ||
131 | * | ||
132 | * Used as tag for struct #GNUNET_SETU_Option. | ||
133 | */ | ||
134 | enum GNUNET_SETU_OptionType | ||
135 | { | ||
136 | /** | ||
137 | * List terminator. | ||
138 | */ | ||
139 | GNUNET_SETU_OPTION_END=0, | ||
140 | |||
141 | /** | ||
142 | * Fail set operations when the other peer shows weird behavior | ||
143 | * that might by a Byzantine fault. | ||
144 | * | ||
145 | * For set union, 'v.num' is a lower bound on elements that the other peer | ||
146 | * must have in common with us. | ||
147 | */ | ||
148 | GNUNET_SETU_OPTION_BYZANTINE=1, | ||
149 | |||
150 | /** | ||
151 | * Do not use the optimized set operation, but send full sets. Might | ||
152 | * trigger Byzantine fault detection. | ||
153 | */ | ||
154 | GNUNET_SETU_OPTION_FORCE_FULL=2, | ||
155 | |||
156 | /** | ||
157 | * Only use optimized set operations, even though for this particular set | ||
158 | * operation they might be much slower. Might trigger Byzantine fault | ||
159 | * detection. | ||
160 | */ | ||
161 | GNUNET_SETU_OPTION_FORCE_DELTA=4, | ||
162 | |||
163 | /** | ||
164 | * Notify client also if we are sending a value to the other peer. | ||
165 | */ | ||
166 | GNUNET_SETU_OPTION_SYMMETRIC = 8 | ||
167 | }; | ||
168 | |||
169 | |||
170 | /** | ||
171 | * Option for set operations. | ||
172 | */ | ||
173 | struct GNUNET_SETU_Option | ||
174 | { | ||
175 | /** | ||
176 | * Type of the option. | ||
177 | */ | ||
178 | enum GNUNET_SETU_OptionType type; | ||
179 | |||
180 | /** | ||
181 | * Value for the option, only used with some options. | ||
182 | */ | ||
183 | union | ||
184 | { | ||
185 | uint64_t num; | ||
186 | } v; | ||
187 | }; | ||
188 | |||
189 | |||
190 | /** | ||
191 | * Callback for set union operation results. Called for each element | ||
192 | * in the result set. | ||
193 | * | ||
194 | * @param cls closure | ||
195 | * @param element a result element, only valid if status is #GNUNET_SETU_STATUS_OK | ||
196 | * @param current_size current set size | ||
197 | * @param status see `enum GNUNET_SETU_Status` | ||
198 | */ | ||
199 | typedef void | ||
200 | (*GNUNET_SETU_ResultIterator) (void *cls, | ||
201 | const struct GNUNET_SETU_Element *element, | ||
202 | uint64_t current_size, | ||
203 | enum GNUNET_SETU_Status status); | ||
204 | |||
205 | |||
206 | /** | ||
207 | * Called when another peer wants to do a set operation with the | ||
208 | * local peer. If a listen error occurs, the @a request is NULL. | ||
209 | * | ||
210 | * @param cls closure | ||
211 | * @param other_peer the other peer | ||
212 | * @param context_msg message with application specific information from | ||
213 | * the other peer | ||
214 | * @param request request from the other peer (never NULL), use GNUNET_SETU_accept() | ||
215 | * to accept it, otherwise the request will be refused | ||
216 | * Note that we can't just return value from the listen callback, | ||
217 | * as it is also necessary to specify the set we want to do the | ||
218 | * operation with, whith sometimes can be derived from the context | ||
219 | * message. It's necessary to specify the timeout. | ||
220 | */ | ||
221 | typedef void | ||
222 | (*GNUNET_SETU_ListenCallback) (void *cls, | ||
223 | const struct GNUNET_PeerIdentity *other_peer, | ||
224 | const struct GNUNET_MessageHeader *context_msg, | ||
225 | struct GNUNET_SETU_Request *request); | ||
226 | |||
227 | |||
228 | /** | ||
229 | * Create an empty set, supporting the specified operation. | ||
230 | * | ||
231 | * @param cfg configuration to use for connecting to the | ||
232 | * set service | ||
233 | * @return a handle to the set | ||
234 | */ | ||
235 | struct GNUNET_SETU_Handle * | ||
236 | GNUNET_SETU_create (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
237 | |||
238 | |||
239 | /** | ||
240 | * Add an element to the given set. | ||
241 | * | ||
242 | * @param set set to add element to | ||
243 | * @param element element to add to the set | ||
244 | * @param cb function to call when finished, can be NULL | ||
245 | * @param cb_cls closure for @a cb | ||
246 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the | ||
247 | * set is invalid (e.g. the set service crashed) | ||
248 | */ | ||
249 | int | ||
250 | GNUNET_SETU_add_element (struct GNUNET_SETU_Handle *set, | ||
251 | const struct GNUNET_SETU_Element *element, | ||
252 | GNUNET_SCHEDULER_TaskCallback cb, | ||
253 | void *cb_cls); | ||
254 | |||
255 | |||
256 | /** | ||
257 | * Destroy the set handle, and free all associated resources. Operations may | ||
258 | * still be pending when a set is destroyed (and will be allowed to complete). | ||
259 | * | ||
260 | * @param set set to destroy | ||
261 | */ | ||
262 | void | ||
263 | GNUNET_SETU_destroy (struct GNUNET_SETU_Handle *set); | ||
264 | |||
265 | |||
266 | /** | ||
267 | * Prepare a set operation to be evaluated with another peer. The evaluation | ||
268 | * will not start until the client provides a local set with | ||
269 | * GNUNET_SETU_commit(). | ||
270 | * | ||
271 | * @param other_peer peer with the other set | ||
272 | * @param app_id hash for the application using the set | ||
273 | * @param context_msg additional information for the request | ||
274 | * @param options options to use when processing the request | ||
275 | * @param result_cb called on error or success | ||
276 | * @param result_cls closure for @a result_cb | ||
277 | * @return a handle to cancel the operation | ||
278 | */ | ||
279 | struct GNUNET_SETU_OperationHandle * | ||
280 | GNUNET_SETU_prepare (const struct GNUNET_PeerIdentity *other_peer, | ||
281 | const struct GNUNET_HashCode *app_id, | ||
282 | const struct GNUNET_MessageHeader *context_msg, | ||
283 | const struct GNUNET_SETU_Option options[], | ||
284 | GNUNET_SETU_ResultIterator result_cb, | ||
285 | void *result_cls); | ||
286 | |||
287 | |||
288 | /** | ||
289 | * Wait for set operation requests for the given application ID. | ||
290 | * If the connection to the set service is lost, the listener is | ||
291 | * re-created transparently with exponential backoff. | ||
292 | * | ||
293 | * @param cfg configuration to use for connecting to | ||
294 | * the set service | ||
295 | * @param app_id id of the application that handles set operation requests | ||
296 | * @param listen_cb called for each incoming request matching the operation | ||
297 | * and application id | ||
298 | * @param listen_cls handle for @a listen_cb | ||
299 | * @return a handle that can be used to cancel the listen operation | ||
300 | */ | ||
301 | struct GNUNET_SETU_ListenHandle * | ||
302 | GNUNET_SETU_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
303 | const struct GNUNET_HashCode *app_id, | ||
304 | GNUNET_SETU_ListenCallback listen_cb, | ||
305 | void *listen_cls); | ||
306 | |||
307 | |||
308 | /** | ||
309 | * Cancel the given listen operation. After calling cancel, the | ||
310 | * listen callback for this listen handle will not be called again. | ||
311 | * Note that cancelling a listen operation will automatically reject | ||
312 | * all operations that have not yet been accepted. | ||
313 | * | ||
314 | * @param lh handle for the listen operation | ||
315 | */ | ||
316 | void | ||
317 | GNUNET_SETU_listen_cancel (struct GNUNET_SETU_ListenHandle *lh); | ||
318 | |||
319 | |||
320 | /** | ||
321 | * Accept a request we got via GNUNET_SETU_listen(). Must be called during | ||
322 | * GNUNET_SETU_listen(), as the `struct GNUNET_SETU_Request` becomes invalid | ||
323 | * afterwards. | ||
324 | * Call GNUNET_SETU_commit() to provide the local set to use for the operation, | ||
325 | * and to begin the exchange with the remote peer. | ||
326 | * | ||
327 | * @param request request to accept | ||
328 | * @param options options to use when processing the request | ||
329 | * @param result_cb callback for the results | ||
330 | * @param result_cls closure for @a result_cb | ||
331 | * @return a handle to cancel the operation | ||
332 | */ | ||
333 | struct GNUNET_SETU_OperationHandle * | ||
334 | GNUNET_SETU_accept (struct GNUNET_SETU_Request *request, | ||
335 | const struct GNUNET_SETU_Option options[], | ||
336 | GNUNET_SETU_ResultIterator result_cb, | ||
337 | void *result_cls); | ||
338 | |||
339 | |||
340 | /** | ||
341 | * Commit a set to be used with a set operation. | ||
342 | * This function is called once we have fully constructed | ||
343 | * the set that we want to use for the operation. At this | ||
344 | * time, the P2P protocol can then begin to exchange the | ||
345 | * set information and call the result callback with the | ||
346 | * result information. | ||
347 | * | ||
348 | * @param oh handle to the set operation | ||
349 | * @param set the set to use for the operation | ||
350 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the | ||
351 | * set is invalid (e.g. the set service crashed) | ||
352 | */ | ||
353 | int | ||
354 | GNUNET_SETU_commit (struct GNUNET_SETU_OperationHandle *oh, | ||
355 | struct GNUNET_SETU_Handle *set); | ||
356 | |||
357 | |||
358 | /** | ||
359 | * Cancel the given set operation. May not be called after the operation's | ||
360 | * `GNUNET_SETU_ResultIterator` has been called with a status of | ||
361 | * #GNUNET_SETU_STATUS_FAILURE or #GNUNET_SETU_STATUS_DONE. | ||
362 | * | ||
363 | * @param oh set operation to cancel | ||
364 | */ | ||
365 | void | ||
366 | GNUNET_SETU_operation_cancel (struct GNUNET_SETU_OperationHandle *oh); | ||
367 | |||
368 | |||
369 | /** | ||
370 | * Hash a set element. | ||
371 | * | ||
372 | * @param element the element that should be hashed | ||
373 | * @param[out] ret_hash a pointer to where the hash of @a element | ||
374 | * should be stored | ||
375 | */ | ||
376 | void | ||
377 | GNUNET_SETU_element_hash (const struct GNUNET_SETU_Element *element, | ||
378 | struct GNUNET_HashCode *ret_hash); | ||
379 | |||
380 | |||
381 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
382 | { | ||
383 | #endif | ||
384 | #ifdef __cplusplus | ||
385 | } | ||
386 | #endif | ||
387 | |||
388 | #endif | ||
389 | |||
390 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_uri_lib.h b/src/include/gnunet_uri_lib.h new file mode 100644 index 000000000..d428bdd9a --- /dev/null +++ b/src/include/gnunet_uri_lib.h | |||
@@ -0,0 +1,122 @@ | |||
1 | /** | ||
2 | * Copyright (C) 2016 Jack Engqvist Johansson | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
5 | * of this software and associated documentation files (the "Software"), to deal | ||
6 | * in the Software without restriction, including without limitation the rights | ||
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
8 | * copies of the Software, and to permit persons to whom the Software is | ||
9 | * furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in all | ||
12 | * copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
20 | * SOFTWARE. | ||
21 | */ | ||
22 | #ifndef GNUNET_URI_LIB_H | ||
23 | #define GNUNET_URI_LIB_H | ||
24 | |||
25 | |||
26 | /** | ||
27 | * The struct where the parsed values will be stored: | ||
28 | * | ||
29 | * scheme ":" [ "//" ] [ username ":" password "@" ] host [ ":" port ] [ "/" ] [ path ] [ "?" query ] | ||
30 | * | ||
31 | * Note: to make sure that no strings are copied, the first slash "/" in the | ||
32 | * path will be used to null terminate the hostname if no port is supplied. | ||
33 | */ | ||
34 | struct GNUNET_Uri { | ||
35 | char *scheme; /* scheme, without ":" and "//" */ | ||
36 | char *username; /* username, default: NULL */ | ||
37 | char *password; /* password, default: NULL */ | ||
38 | char *host; /* hostname or IP address */ | ||
39 | int port; /* port, default: 0 */ | ||
40 | char *path; /* path, without leading "/", default: NULL */ | ||
41 | char *query; /* query, default: NULL */ | ||
42 | char *fragment; /* fragment, default: NULL */ | ||
43 | }; | ||
44 | |||
45 | |||
46 | /* A struct to hold the query string parameter values. */ | ||
47 | struct GNUNET_UriParam { | ||
48 | char *key; | ||
49 | char *val; | ||
50 | }; | ||
51 | |||
52 | |||
53 | /** | ||
54 | * Parse a URL to a struct. | ||
55 | * | ||
56 | * The URL string should be in one of the following formats: | ||
57 | * | ||
58 | * Absolute URL: | ||
59 | * scheme ":" [ "//" ] [ username ":" password "@" ] host [ ":" port ] [ "/" ] [ path ] [ "?" query ] [ "#" fragment ] | ||
60 | * | ||
61 | * Relative URL: | ||
62 | * path [ "?" query ] [ "#" fragment ] | ||
63 | * | ||
64 | * The following parts will be parsed to the corresponding struct member. | ||
65 | * | ||
66 | * *url: a pointer to the struct where to store the parsed values. | ||
67 | * *url_str: a pointer to the url to be parsed (null terminated). The string | ||
68 | * will be modified. | ||
69 | * | ||
70 | * Returns 0 on success, otherwise -1. | ||
71 | */ | ||
72 | int | ||
73 | GNUNET_uri_parse (struct GNUNET_Uri *url, | ||
74 | char *url_str); | ||
75 | |||
76 | |||
77 | /** | ||
78 | * Split a path into several strings. | ||
79 | * | ||
80 | * No data is copied, the slashed are used as null terminators and then | ||
81 | * pointers to each path part will be stored in **parts. Double slashes will be | ||
82 | * treated as one. | ||
83 | * | ||
84 | * *path: the path to split. The string will be modified. | ||
85 | * **parts: a pointer to an array of (char *) where to store the result. | ||
86 | * max_parts: max number of parts to parse. | ||
87 | * | ||
88 | * Returns the number of parsed items. -1 on error. | ||
89 | */ | ||
90 | int | ||
91 | GNUNET_uri_split_path (char *path, | ||
92 | char **parts, | ||
93 | int max_parts); | ||
94 | |||
95 | |||
96 | /** | ||
97 | * Parse a query string into a key/value struct. | ||
98 | * | ||
99 | * The query string should be a null terminated string of parameters separated by | ||
100 | * a delimiter. Each parameter are checked for the equal sign character. If it | ||
101 | * appears in the parameter, it will be used as a null terminator and the part | ||
102 | * that comes after it will be the value of the parameter. | ||
103 | * | ||
104 | * No data are copied, the equal sign and delimiters are used as null | ||
105 | * terminators and then pointers to each parameter key and value will be stored | ||
106 | * in the yuarel_param struct. | ||
107 | * | ||
108 | * *query: the query string to parse. The string will be modified. | ||
109 | * delimiter: the character that separates the key/value pairs from eachother. | ||
110 | * *params: an array of (struct yuarel_param) where to store the result. | ||
111 | * max_values: max number of parameters to parse. | ||
112 | * | ||
113 | * Returns the number of parsed items. -1 on error. | ||
114 | */ | ||
115 | int | ||
116 | GNUNET_uri_parse_query (char *query, | ||
117 | char delimiter, | ||
118 | struct GNUNET_UriParam *params, | ||
119 | int max_params); | ||
120 | |||
121 | |||
122 | #endif /* GNUNET_URI_LIB_H */ | ||