diff options
author | ch3 <buenger@mytum.de> | 2024-03-13 17:44:48 +0100 |
---|---|---|
committer | ch3 <buenger@mytum.de> | 2024-04-26 19:05:01 +0200 |
commit | 16e16781dbc0f3d3d90ff485c1b2b4f3d47b8e4f (patch) | |
tree | fa6a8e45bb0002e09286da137e05a27048201206 | |
parent | 6e35f454000bb82686790322957d8d83070a6793 (diff) | |
download | gnunet-16e16781dbc0f3d3d90ff485c1b2b4f3d47b8e4f.tar.gz gnunet-16e16781dbc0f3d3d90ff485c1b2b4f3d47b8e4f.zip |
pils: add api for new pils service
-rw-r--r-- | src/include/gnunet_pils_service.h | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/src/include/gnunet_pils_service.h b/src/include/gnunet_pils_service.h new file mode 100644 index 000000000..08941ddf1 --- /dev/null +++ b/src/include/gnunet_pils_service.h | |||
@@ -0,0 +1,147 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2024 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 | /** | ||
22 | * @author ch3 | ||
23 | * | ||
24 | * @file include/gnunet_pils_service.h | ||
25 | * Peer Identity Lifecycle Service; the API for managing Peer Identities | ||
26 | * | ||
27 | * Peer Identity management | ||
28 | * | ||
29 | */ | ||
30 | #ifndef GNUNET_PILS_SERVICE_H | ||
31 | #define GNUNET_PILS_SERVICE_H | ||
32 | |||
33 | #ifdef __cplusplus | ||
34 | extern "C" { | ||
35 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
36 | } | ||
37 | #endif | ||
38 | #endif | ||
39 | |||
40 | |||
41 | #include "gnunet_util_lib.h" | ||
42 | |||
43 | |||
44 | // TODO do functions besides the subscriptions need connect/disconnect | ||
45 | // functionality? | ||
46 | |||
47 | /** | ||
48 | * @brief A handle for subscriptions for peer id changes | ||
49 | */ | ||
50 | struct GNUNET_PILS_SubscriptionHandle; | ||
51 | |||
52 | /** | ||
53 | * @brief Obtain the current GNUNET_PeerIdentity | ||
54 | * | ||
55 | * @return The current PeerIdentity | ||
56 | * | ||
57 | * TODO the functionality is duplicate to the subscription. We could | ||
58 | * simply leave this convenience method out. | ||
59 | * TODO rather return a pointer? | ||
60 | */ | ||
61 | struct GNUNET_PeerIdentity | ||
62 | GNUNET_PILS_obtain_pid (void); | ||
63 | |||
64 | |||
65 | |||
66 | /** | ||
67 | * @brief A handler to be called on the change of the peer id. | ||
68 | * | ||
69 | * @param peer_id The new peer id. | ||
70 | */ | ||
71 | typedef void (*GNUNET_PILS_PidChangeHandler) ( | ||
72 | const struct GNUNET_PeerIdentity *peer_id); | ||
73 | |||
74 | |||
75 | /** | ||
76 | * @brief Subscribe for changes of the peer id. | ||
77 | * | ||
78 | * @param handler The handler to be called on the change to a new peer id. | ||
79 | * | ||
80 | * @return A handle to cancle the subscription | ||
81 | */ | ||
82 | struct GNUNET_PILS_SubscriptionHandle * | ||
83 | GNUNET_PILS_pid_change_subscribe (GNUNET_PILS_PidChangeHandler handler); | ||
84 | |||
85 | /** | ||
86 | * @brief Cancle a subscription on peer id changes. | ||
87 | * | ||
88 | * @param h the handle to the subscription. | ||
89 | */ | ||
90 | GNUNET_PILS_pid_subscription_cancle (struct GNUNET_PILS_SubscriptionHandle *h); | ||
91 | |||
92 | |||
93 | /** | ||
94 | * @brief Sign data with the peer id. | ||
95 | * | ||
96 | * This should only be used on small amounts of data - hashes if a bigger | ||
97 | * amount of data is to be signed. | ||
98 | * TODO build convenience function for larger amounts of data that takes care | ||
99 | * about the hashing? | ||
100 | * | ||
101 | * @param data Pointer to the data | ||
102 | * @param size Size of the data to be signed in bytes | ||
103 | * | ||
104 | * @return The signature of the provided data | ||
105 | * TODO rather return a pointer to the hash? | ||
106 | * TODO what kind of signature to uses - is this the right kind? | ||
107 | * TODO should ther be the possibility to provide more specifics? (hash | ||
108 | * algorithm, parameters, seeds, salts, ...?) | ||
109 | */ | ||
110 | struct GNUNET_CRYPTO_Signature | ||
111 | GNUNET_PILS_pid_sign (const char *data, uint32_t size); | ||
112 | |||
113 | |||
114 | /** | ||
115 | * @brief Feed (an) address(es) to pils so that it will generate a new peer id | ||
116 | * based on the given address(es). | ||
117 | * | ||
118 | * THIS IS ONLY TO BE CALLED FROM CORE! | ||
119 | * | ||
120 | * The address(es) will be canonicalized/sorted before the new peer id is | ||
121 | * generated. | ||
122 | * | ||
123 | * @param num_addresses The number of addresses. | ||
124 | * @param address Array of string representation of addresses. | ||
125 | * TODO rather give a single array with a specified separator? | ||
126 | * | ||
127 | * @return #GNUNET_OK if a new peer id was generated, GNUNET_SYSERR otherwise | ||
128 | * TODO will we need a more specific return value? | ||
129 | */ | ||
130 | enum GNUNET_GenericReturnValue | ||
131 | GNUNET_PILS_feed_address (uint32_t num_addresses, | ||
132 | const char *address[static num_addresses]); | ||
133 | |||
134 | // TODO I don't remember did we also want to generate HELLOs here? I would | ||
135 | // weakly tend to do this in core | ||
136 | |||
137 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
138 | { | ||
139 | #endif | ||
140 | #ifdef __cplusplus | ||
141 | } | ||
142 | #endif | ||
143 | |||
144 | /* ifndef GNUNET_PILS_SERVICE_H */ | ||
145 | #endif | ||
146 | |||
147 | /* end of gnunet_pils_service.h */ | ||