GNUnet debian-0.24.3-23-g589b01d60
pils_api.c File Reference
#include <string.h>
#include <stdint.h>
#include "platform.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet_pils_service.h"
#include "pils.h"
Include dependency graph for pils_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_PILS_Operation
 
struct  GNUNET_PILS_Handle
 A handle for the PILS service. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "pils-api", __VA_ARGS__)
 

Functions

static struct GNUNET_PILS_Operationfind_op (struct GNUNET_PILS_Handle *h, uint32_t rid)
 Find the op that matches the rid. More...
 
static int check_peer_id (void *cls, const struct PeerIdUpdateMessage *msg)
 Handles sign result. More...
 
static void handle_peer_id (void *cls, const struct PeerIdUpdateMessage *pid_msg)
 Handles peer ids sent from the service. More...
 
static void handle_sign_result (void *cls, const struct SignResultMessage *msg)
 Handles sign result. More...
 
static void handle_decaps_result (void *cls, const struct DecapsResultMessage *msg)
 Handles decaps result. More...
 
static void reconnect (void *cls)
 Try again to connect to peer identity lifecycle service. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Handles errors with the mq. More...
 
struct GNUNET_PILS_HandleGNUNET_PILS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
 Connect to the PILS service. More...
 
void GNUNET_PILS_disconnect (struct GNUNET_PILS_Handle *handle)
 Disconnect from the PILS service. More...
 
struct GNUNET_PILS_OperationGNUNET_PILS_sign_by_peer_identity (struct GNUNET_PILS_Handle *handle, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, GNUNET_PILS_SignResultCallback cb, void *cb_cls)
 Sign data with the peer id. More...
 
struct GNUNET_PILS_OperationGNUNET_PILS_kem_decaps (struct GNUNET_PILS_Handle *handle, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, GNUNET_PILS_DecapsResultCallback cb, void *cb_cls)
 Decaps an encapsulated key with our private key. More...
 
void GNUNET_PILS_cancel (struct GNUNET_PILS_Operation *op)
 Cancel request. More...
 
void GNUNET_PILS_derive_pid (size_t seed_key_bytes, const uint8_t seed_key[seed_key_bytes], const struct GNUNET_HashCode *addrs_hash, struct GNUNET_CRYPTO_EddsaPrivateKey *outkey)
 Generate the peer id from the addresses hash and the initial secret key. More...
 
void GNUNET_PILS_feed_addresses (struct GNUNET_PILS_Handle *handle, const struct GNUNET_HELLO_Builder *builder)
 Feed a set of addresses to pils so that it will generate a new peer id based on the given set of addresses. More...
 
struct GNUNET_PILS_OperationGNUNET_PILS_sign_hello (struct GNUNET_PILS_Handle *handle, const struct GNUNET_HELLO_Builder *builder, struct GNUNET_TIME_Absolute et, GNUNET_PILS_SignResultCallback cb, void *cb_cls)
 Create HELLO signature. More...
 

Detailed Description

Author
ch3

Peer Identity Lifecycle Service; the API for managing Peer Identities

This api gives access to the PILS service.

The service maintains the peer identity. On address change it generates a new identity and informs subscribed components. It also signs data with the identity on request.

Definition in file pils_api.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "pils-api", __VA_ARGS__)

Definition at line 44 of file pils_api.c.

Function Documentation

◆ find_op()

static struct GNUNET_PILS_Operation * find_op ( struct GNUNET_PILS_Handle h,
uint32_t  rid 
)
static

Find the op that matches the rid.

Parameters
hPILS handle
ridid to look up
Returns
NULL if rid was not found

Definition at line 132 of file pils_api.c.

133{
135
136 for (op = h->op_head; op != NULL; op = op->next)
137 if (op->op_id == rid)
138 return op;
140 "Finding request with id %u was unsuccessful\n",
141 rid);
142 return NULL;
143}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
struct GNUNET_PILS_Operation * op
PILS op.
Definition: gnunet-hello.c:94
@ GNUNET_ERROR_TYPE_WARNING
#define LOG(kind,...)
Definition: pils_api.c:44
struct GNUNET_PILS_Operation * next
Definition: pils_api.c:50

References GNUNET_ERROR_TYPE_WARNING, h, LOG, GNUNET_PILS_Operation::next, op, and GNUNET_PILS_Operation::op_id.

Referenced by handle_decaps_result(), and handle_sign_result().

Here is the caller graph for this function:

◆ check_peer_id()

static int check_peer_id ( void *  cls,
const struct PeerIdUpdateMessage msg 
)
static

Handles sign result.

Parameters
clsclosure - Handle to the PILS service
msgthe message containing the signature

Definition at line 153 of file pils_api.c.

154{
155 size_t msg_size;
156 uint32_t block_bytes;
157 (void) cls;
158
159 msg_size = ntohs (msg->header.size);
160 block_bytes = ntohl (msg->block_len);
161 if (msg_size != sizeof (*msg) + block_bytes)
162 {
164 "The msg_size (%lu) is not %lu (header) + %u (block)\n",
165 msg_size,
166 sizeof (*msg),
167 block_bytes);
168 return GNUNET_SYSERR;
169 }
170 return GNUNET_OK;
171
172}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SYSERR, LOG, msg, and GNUNET_MessageHeader::size.

◆ handle_peer_id()

static void handle_peer_id ( void *  cls,
const struct PeerIdUpdateMessage pid_msg 
)
static

Handles peer ids sent from the service.

Parameters
clsclosure - Handle to the PILS service
pid_msgthe message containing peer id and addresses hash

Definition at line 182 of file pils_api.c.

183{
184 struct GNUNET_PILS_Handle *h = cls;
186 uint32_t block_bytes;
187
188 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
189 block_bytes = ntohl (pid_msg->block_len);
191 block_bytes);
192 if (NULL == parser)
193 {
195 "Error parsing Hello block from PILS!\n");
196 return;
197 }
198 memcpy (&h->hash, &pid_msg->hash, sizeof (struct GNUNET_HashCode));
199
200 if (NULL != h->pid_change_cb)
201 {
202 h->pid_change_cb (h->pid_change_cb_cls,
203 parser,
204 &pid_msg->hash);
205 }
207}
void GNUNET_HELLO_parser_free(struct GNUNET_HELLO_Parser *parser)
Release resources of a builder.
Definition: hello-uri.c:379
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block(const void *block, size_t block_size)
Parse block.
Definition: hello-uri.c:523
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
Context for parsing HELLOs.
Definition: hello-uri.c:232
A 512-bit hashcode.
A handle for the PILS service.
Definition: pils_api.c:82
struct GNUNET_HashCode hash
The hash from which the peer id was generated.
Definition: pils.h:49
uint32_t block_len
Length of the HELLO block in bytes.
Definition: pils.h:54

References PeerIdUpdateMessage::block_len, GNUNET_ERROR_TYPE_ERROR, GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_block(), GNUNET_TIME_UNIT_ZERO, h, PeerIdUpdateMessage::hash, LOG, and warningfilter::parser.

Here is the call graph for this function:

◆ handle_sign_result()

static void handle_sign_result ( void *  cls,
const struct SignResultMessage msg 
)
static

Handles sign result.

Parameters
clsclosure - Handle to the PILS service
msgthe message containing the signature

Definition at line 217 of file pils_api.c.

218{
219 struct GNUNET_PILS_Handle *h = cls;
221
222 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
223 op = find_op (h, ntohl (msg->rid));
224
226 "Received SIGN_RESULT message from service\n");
227
228 if (NULL == op)
229 {
231 "Didn't find the operation corresponding to id %u\n",
232 ntohl(msg->rid));
233 return;
234 }
235 if (NULL != op->sign_cb)
236 {
237 // FIXME maybe return NULL of key is 0ed
238 // as this indicates an error
240 &msg->peer_id,
241 &msg->sig);
242 }
244 h->op_tail,
245 op);
246 GNUNET_free (op);
247}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_PILS_Operation * find_op(struct GNUNET_PILS_Handle *h, uint32_t rid)
Find the op that matches the rid.
Definition: pils_api.c:132
GNUNET_PILS_SignResultCallback sign_cb
Definition: pils_api.c:65

References find_op(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_TIME_UNIT_ZERO, h, LOG, msg, op, GNUNET_PILS_Operation::sign_cb, and GNUNET_PILS_Operation::sign_cb_cls.

Here is the call graph for this function:

◆ handle_decaps_result()

static void handle_decaps_result ( void *  cls,
const struct DecapsResultMessage msg 
)
static

Handles decaps result.

Parameters
clsclosure - Handle to the PILS service
msgthe message containing the decapsulation result

Definition at line 257 of file pils_api.c.

258{
259 struct GNUNET_PILS_Handle *h = cls;
261
262 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
263 op = find_op (h, ntohl (msg->rid));
264
265 if (NULL == op)
266 return;
267 if (NULL != op->decaps_cb)
268 {
269 // FIXME maybe return NULL of key is 0ed
270 // as this indicates an error
272 &msg->key);
273 }
275 h->op_tail,
276 op);
277 GNUNET_free (op);
278}
GNUNET_PILS_DecapsResultCallback decaps_cb
Definition: pils_api.c:59

References GNUNET_PILS_Operation::decaps_cb, GNUNET_PILS_Operation::decaps_cb_cls, find_op(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_TIME_UNIT_ZERO, h, msg, and op.

Here is the call graph for this function:

◆ reconnect()

static void reconnect ( void *  cls)
static

Try again to connect to peer identity lifecycle service.

Parameters
clsthe struct GNUNET_PILS_Handle *

Definition at line 321 of file pils_api.c.

322{
323 struct GNUNET_PILS_Handle *h = cls;
327 struct PeerIdUpdateMessage,
328 h),
329 GNUNET_MQ_hd_fixed_size (decaps_result,
331 struct DecapsResultMessage,
332 h),
333 GNUNET_MQ_hd_fixed_size (sign_result,
335 struct SignResultMessage,
336 h),
338 };
339
340 h->reconnect_task = NULL;
342 "Connecting to peer identity lifecycle service.\n");
343 GNUNET_assert (NULL == h->mq);
345 "pils",
346 handlers,
348 h);
349 if (NULL == h->mq)
350 {
352 "Failed to connect.\n");
353 {
355 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
356 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
357 }
358 return;
359 }
361 "pils-api",
362 "Connection to service successful!.\n");
363}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1060
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_log_from_nocheck(enum GNUNET_ErrorType kind, const char *comp, const char *message,...) __attribute__((format(printf
Log function that specifies an alternative component.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_PILS_DECAPS_RESULT
Decaps result.
#define GNUNET_MESSAGE_TYPE_PILS_PEER_ID
Message passing the new peer id from the service to the client.
#define GNUNET_MESSAGE_TYPE_PILS_SIGN_RESULT
The service sends the requested signature to the client.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1277
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Handles errors with the mq.
Definition: pils_api.c:298
static void reconnect(void *cls)
Try again to connect to peer identity lifecycle service.
Definition: pils_api.c:321
Message containing the decapsulated key.
Definition: pils.h:164
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
Message handler for a specific message type.
Message containing the current peer id and the hash from which it was generated.
Definition: pils.h:40
Message containing the signature.
Definition: pils.h:185

References GNUNET_ARM_Handle::cfg, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_from_nocheck(), GNUNET_MESSAGE_TYPE_PILS_DECAPS_RESULT, GNUNET_MESSAGE_TYPE_PILS_PEER_ID, GNUNET_MESSAGE_TYPE_PILS_SIGN_RESULT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, h, handlers, LOG, GNUNET_ARM_Handle::mq, mq_error_handler(), peer_id, reconnect(), and GNUNET_ARM_Handle::reconnect_task.

Referenced by GNUNET_PILS_connect(), mq_error_handler(), and reconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Handles errors with the mq.

Schedules the reconnect task and updates the reconnect delay.

Parameters
clsclosure - handle to PILS
errorerror type indicating the kind of problem with mq

Definition at line 298 of file pils_api.c.

299{
300 struct GNUNET_PILS_Handle *h = cls;
301 (void) error;
302
303 // TODO logging
305 "pils-api",
306 "(mq_error_handler) Connection to service failed!.\n");
308 h->mq = NULL;
310 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
311 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
312}
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700

References GNUNET_ERROR_TYPE_ERROR, GNUNET_log_from_nocheck(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, h, GNUNET_ARM_Handle::mq, reconnect(), and GNUNET_ARM_Handle::reconnect_task.

Referenced by reconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_connect()

struct GNUNET_PILS_Handle * GNUNET_PILS_connect ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_PILS_PidChangeCallback  pid_change_cb,
void *  cls 
)

Connect to the PILS service.

Parameters
cfgconfiguration to use
pid_change_cbhandler/callback called once the peer id changes
clsclosure for pid_change_cb
Returns
Handle to the PILS service

Definition at line 367 of file pils_api.c.

370{
371 struct GNUNET_PILS_Handle *h;
372
374 h->cfg = cfg;
375 h->pid_change_cb = pid_change_cb;
376 h->pid_change_cb_cls = cls;
377 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
378 reconnect (h);
379 return h;
380}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
void pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *hparser, const struct GNUNET_HashCode *addr_hash)
Definition: gnunet-pils.c:64
#define GNUNET_new(type)
Allocate a struct or union of the given type.

References cfg, GNUNET_ARM_Handle::cfg, GNUNET_new, GNUNET_TIME_UNIT_ZERO, h, pid_change_cb(), and reconnect().

Referenced by GCH_init(), GSC_KX_init(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_disconnect()

void GNUNET_PILS_disconnect ( struct GNUNET_PILS_Handle handle)

Disconnect from the PILS service.

Parameters
handlehandle to the PILS service (was returned by GNUNET_PILS_connect)

Definition at line 390 of file pils_api.c.

391{
393
394 GNUNET_assert (NULL != handle);
396 "Disonnecting from peer identity lifecycle service.\n");
397 if (NULL != handle->reconnect_task)
398 {
399 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
400 handle->reconnect_task = NULL;
401 }
402 if (NULL != handle->mq)
403 {
405 handle->mq = NULL;
406 }
407 LOG (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
408 while (NULL != (op = handle->op_head))
409 {
410 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
411 GNUNET_free (op);
412 }
414}
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:44

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), handle, LOG, GNUNET_VPN_Handle::mq, and op.

Referenced by cleaning_task(), do_shutdown(), GCH_shutdown(), GSC_KX_done(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_sign_by_peer_identity()

struct GNUNET_PILS_Operation * GNUNET_PILS_sign_by_peer_identity ( struct GNUNET_PILS_Handle handle,
const struct GNUNET_CRYPTO_EccSignaturePurpose purpose,
GNUNET_PILS_SignResultCallback  cb,
void *  cb_cls 
)

Sign data with the peer id.

Parameters
handlehandle to the PILS service
purposewhat to sign (size, purpose and data)
cbcallback to call once the signature is ready
cb_clsclosure to cb
Returns
handle to the operation, NULL on error

Definition at line 428 of file pils_api.c.

434{
436 struct SignRequestMessage *msg;
437
440 ntohl (purpose->size),
442 op->h = handle;
443 op->sign_cb = cb;
444 op->sign_cb_cls = cb_cls;
445 msg->rid = htonl (handle->op_id_counter++);
446 op->op_id = ntohl (msg->rid);
447 memcpy (&msg[1], purpose, ntohl (purpose->size));
449 handle->op_tail,
450 op);
451 // FIXME resend?
453 op->env = NULL;
454 return op;
455}
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:61
#define GNUNET_MESSAGE_TYPE_PILS_SIGN_REQUEST
The client requests data to be signed with the peer identity.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
struct GNUNET_PILS_Handle * h
Definition: pils_api.c:56
struct GNUNET_MQ_Envelope * env
Definition: pils_api.c:71
Message to request a signature from PILS.
Definition: pils.h:213

References GNUNET_PILS_Operation::env, GNUNET_CONTAINER_DLL_insert, GNUNET_MESSAGE_TYPE_PILS_SIGN_REQUEST, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_PILS_Operation::h, handle, GNUNET_VPN_Handle::mq, msg, op, GNUNET_PILS_Operation::op_id, GNUNET_PILS_Operation::sign_cb, GNUNET_PILS_Operation::sign_cb_cls, and GNUNET_CRYPTO_EccSignaturePurpose::size.

Referenced by forward_dv_learn(), GNUNET_PILS_sign_hello(), handle_validation_challenge(), pils_sign_address(), sign_ephemeral(), start_dv_learn(), and transmit_task_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_kem_decaps()

struct GNUNET_PILS_Operation * GNUNET_PILS_kem_decaps ( struct GNUNET_PILS_Handle handle,
const struct GNUNET_CRYPTO_HpkeEncapsulation c,
GNUNET_PILS_DecapsResultCallback  cb,
void *  cb_cls 
)

Decaps an encapsulated key with our private key.

Parameters
handlehandle to the PILS service
cthe encapsulated key
prkwhere to write the key material HKDF-Extract(c||aX)=HKDF-Extract(c||x(aG))
Returns
handle to the operation, NULL on error

Definition at line 468 of file pils_api.c.

472{
474 struct DecapsMessage *msg;
475
478 msg->c = *c;
479 op->h = handle;
480 op->decaps_cb = cb;
481 op->decaps_cb_cls = cb_cls;
482 msg->rid = htonl (handle->op_id_counter++);
483 op->op_id = ntohl (msg->rid);
485 handle->op_tail,
486 op);
487 // FIXME resend?
489 op->env = NULL;
490 return op;
491}
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MESSAGE_TYPE_PILS_KEM_DECAPS
Decaps request.
Message to request a decapsulation from PILS.
Definition: pils.h:143
struct GNUNET_CRYPTO_HpkeEncapsulation c
Encapsulation to decapsulate.
Definition: pils.h:152

References DecapsMessage::c, GNUNET_PILS_Operation::decaps_cb, GNUNET_PILS_Operation::decaps_cb_cls, GNUNET_PILS_Operation::env, GNUNET_CONTAINER_DLL_insert, GNUNET_MESSAGE_TYPE_PILS_KEM_DECAPS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_PILS_Operation::h, handle, GNUNET_VPN_Handle::mq, msg, op, and GNUNET_PILS_Operation::op_id.

Referenced by handle_dv_box(), handle_initiator_hello(), and handle_responder_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_cancel()

void GNUNET_PILS_cancel ( struct GNUNET_PILS_Operation op)

Cancel request.

Parameters
opcancel PILS operation

Definition at line 495 of file pils_api.c.

496{
497 struct GNUNET_PILS_Handle *h = op->h;
498
499 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
500 if (NULL != op->env)
502 GNUNET_free (op);
503}
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:285

References GNUNET_PILS_Operation::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), h, GNUNET_PILS_Operation::h, and op.

Referenced by do_shutdown(), GCH_shutdown(), GSC_KX_done(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_derive_pid()

void GNUNET_PILS_derive_pid ( size_t  seed_key_bytes,
const uint8_t  seed_key[seed_key_bytes],
const struct GNUNET_HashCode addrs_hash,
struct GNUNET_CRYPTO_EddsaPrivateKey outkey 
)

Generate the peer id from the addresses hash and the initial secret key.

Parameters
seed_key_byteslength of the seed key in bytes
seed_keythe initial secret key
addrs_hashthe address to use for derivation
[out]outkeythe (private) peer identity key

Since we should have initial keying material of good quality here, this is effectively a PRF called on the address hash with a uniform random key.

We now expand the PRK to the key size we actually require. FIXME: IF we want to use elligator, we need to find a private key that can actually be used as such. For that, we may want to add a coutner to the initial secret key to the above PRF.

Definition at line 507 of file pils_api.c.

511{
512 struct GNUNET_ShortHashCode prk;
513
521 addrs_hash,
522 sizeof *addrs_hash,
523 seed_key,
524 seed_key_bytes));
533 sizeof *outkey,
534 &prk,
535 "gnunet-pils-ephemeral-peer-key",
536 strlen ("gnunet-pils-ephemeral-peer-key"),
537 NULL, 0);
538}
static uint8_t seed_key[256/8]
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_extract(struct GNUNET_ShortHashCode *prk, const void *salt, size_t salt_len, const void *ikm, size_t ikm_len)
HKDF-Extract using SHA256.
Definition: crypto_hkdf.c:224
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk,...)
HKDF-Expand using SHA256.
Definition: crypto_hkdf.c:156
A 256-bit hashcode.

References GNUNET_assert, GNUNET_CRYPTO_hkdf_expand(), GNUNET_CRYPTO_hkdf_extract(), GNUNET_OK, and seed_key.

Referenced by do_generate_pid(), pid_change_cb(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_feed_addresses()

void GNUNET_PILS_feed_addresses ( struct GNUNET_PILS_Handle handle,
const struct GNUNET_HELLO_Builder addresses_builder 
)

Feed a set of addresses to pils so that it will generate a new peer id based on the given set of addresses.

THIS IS ONLY TO BE CALLED FROM CORE!

The address representation will be canonicalized/sorted by pils before the new peer id is generated.

Parameters
handlethe handle to the PILS service
addresses_builderaddresses to feed as builder

Definition at line 542 of file pils_api.c.

544{
546 struct GNUNET_MQ_Envelope *env;
547 size_t block_bytes;
548
550 // TODO check whether the new hash and the 'current' hash are the same -
551 // nothing to do in that case (directly return the peer id?)
553 block_bytes,
555 msg->block_len = htonl (block_bytes);
557 builder,
558 NULL,
559 NULL,
561 (char*) &msg[1]);
563}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
void GNUNET_HELLO_builder_to_block(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration_time, char *outbuf)
Generate DHT block from a builder.
Definition: hello-uri.c:1244
size_t GNUNET_HELLO_get_builder_to_block_size(const struct GNUNET_HELLO_Builder *builder)
Get projected block size for builder.
Definition: hello-uri.c:1312
#define GNUNET_MESSAGE_TYPE_PILS_FEED_ADDRESSES
The client (core) provides new addresses to the service, so the service can generate the new peer id.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:316
Message requesting a signature on data with the current peer id.
Definition: pils.h:123

References builder, env, GNUNET_HELLO_builder_to_block(), GNUNET_HELLO_get_builder_to_block_size(), GNUNET_MESSAGE_TYPE_PILS_FEED_ADDRESSES, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_ZERO, handle, GNUNET_VPN_Handle::mq, and msg.

Referenced by feed_addresses_to_pils().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_sign_hello()

struct GNUNET_PILS_Operation * GNUNET_PILS_sign_hello ( struct GNUNET_PILS_Handle handle,
const struct GNUNET_HELLO_Builder builder,
struct GNUNET_TIME_Absolute  et,
GNUNET_PILS_SignResultCallback  cb,
void *  cb_cls 
)

Create HELLO signature.

Parameters
handlehande to the pils service
builderthe builder to use
etexpiration time to sign
cbcallback to call with the signature
cb_clsclosure to cb

Definition at line 576 of file pils_api.c.

581{
582 struct PilsHelloSignaturePurpose hsp = {
583 .purpose.size = htonl (sizeof (hsp)),
584 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_HELLO),
585 .expiration_time = GNUNET_TIME_absolute_hton (et)
586 };
588 &hsp.h_addrs);
590 "Address hash is %s\n",
591 GNUNET_h2s_full (&hsp.h_addrs));
593 &hsp.purpose,
594 cb,
595 cb_cls);
596}
#define GNUNET_SIGNATURE_PURPOSE_HELLO
Signature by which a peer affirms its address.
void GNUNET_HELLO_builder_hash_addresses(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
Compute hash over addresses in builder.
Definition: hello-uri.c:1134
#define GNUNET_log(kind,...)
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
struct GNUNET_PILS_Operation * GNUNET_PILS_sign_by_peer_identity(struct GNUNET_PILS_Handle *handle, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, GNUNET_PILS_SignResultCallback cb, void *cb_cls)
Sign data with the peer id.
Definition: pils_api.c:428
Message signed as part of a HELLO block/URL.
Definition: hello-uri.c:50
struct GNUNET_HashCode h_addrs
Hash over all addresses.
Definition: hello-uri.c:64
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_HELLO.
Definition: hello-uri.c:54

References builder, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s_full(), GNUNET_HELLO_builder_hash_addresses(), GNUNET_log, GNUNET_PILS_sign_by_peer_identity(), GNUNET_SIGNATURE_PURPOSE_HELLO, GNUNET_TIME_absolute_hton(), PilsHelloSignaturePurpose::h_addrs, handle, PilsHelloSignaturePurpose::purpose, and GNUNET_CRYPTO_EccSignaturePurpose::size.

Referenced by peerstore_store_own_cb(), and pid_changed_cb().

Here is the call graph for this function:
Here is the caller graph for this function: