peer identity lifecycle service More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_pils_service.h"
#include "pils.h"
Go to the source code of this file.
Data Structures | |
struct | P_Client |
Data structure for each client connected to the CORE service. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "pils", __VA_ARGS__) |
Functions | |
static void | load_ikm () |
Get the initial secret key for generating the peer id. More... | |
static void | print_uri (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri) |
static void | do_generate_pid (const struct GNUNET_HELLO_Parser *parser) |
Generate the peer id from the addresses hash and the initial secret key. More... | |
static int | check_feed_addresses (void *cls, const struct FeedAddressesMessage *msg) |
Checker for feed messages. More... | |
static void | handle_feed_addresses (void *cls, const struct FeedAddressesMessage *message) |
Handler for feed addresses message from client. More... | |
static void | handle_decaps (void *cls, const struct DecapsMessage *message) |
Handler for decaps request message from client. More... | |
static int | check_sign (void *cls, const struct SignRequestMessage *msg) |
Handler for sign request message from client. More... | |
static void | handle_sign (void *cls, const struct SignRequestMessage *message) |
Handler for sign request message from client. More... | |
static void | shutdown_task (void *cls) |
Task run during shutdown. More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) |
Set up the service. More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq) |
Callback called when a client connects to the service. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls) |
Callback called when a client disconnected from the service. More... | |
GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "pils", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(feed_addresses, GNUNET_MESSAGE_TYPE_PILS_FEED_ADDRESSES, struct FeedAddressesMessage, NULL), GNUNET_MQ_hd_fixed_size(decaps, GNUNET_MESSAGE_TYPE_PILS_KEM_DECAPS, struct DecapsMessage, NULL), GNUNET_MQ_hd_var_size(sign, GNUNET_MESSAGE_TYPE_PILS_SIGN_REQUEST, struct SignRequestMessage, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Handle to our current configuration. More... | |
static struct GNUNET_SCHEDULER_Task * | generate_pid_task |
Task to schedule the generation of the peer id. More... | |
struct GNUNET_HashCode | addresses_hash |
Hash of the canonicalized addresses. More... | |
struct GNUNET_CRYPTO_EddsaPrivateKey | my_private_key |
The current private key. More... | |
struct GNUNET_CRYPTO_EddsaPublicKey | my_public_key |
The current public key. More... | |
static unsigned char | ikm [256/8] |
The initial key material for the peer. More... | |
static struct P_Client * | clients_head |
Head of the liked list of clients. More... | |
static struct P_Client * | clients_tail |
Tail of the liked list of clients. More... | |
static int | have_id |
Peer ID was calculated already at least once. More... | |
static struct GNUNET_MQ_Envelope * | signed_hello |
Current signed HELLO. More... | |
peer identity lifecycle service
This 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 gnunet-service-pils.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "pils", __VA_ARGS__) |
Definition at line 41 of file gnunet-service-pils.c.
|
static |
Get the initial secret key for generating the peer id.
This is supposed to be generated at random once in the lifetime of a peer, so all generated peer ids use the same initial secret key to optain the same peer id per set of addresses.
First check whether there's already a initial secret key. If so: return it. If no initial secret key exists yet, generate at random and store it where it will be found.
initial | secret key the memory the initial secret key can be written to. |
Definition at line 140 of file gnunet-service-pils.c.
References cfg, GNUNET_assert, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CRYPTO_eddsa_key_from_file(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_YES, ikm, and key.
Referenced by run().
|
static |
Definition at line 174 of file gnunet-service-pils.c.
References GNUNET_ERROR_TYPE_DEBUG, LOG, and uri.
Referenced by do_generate_pid().
|
static |
Generate the peer id from the addresses hash and the initial secret key.
Notify all subscribed clients with the new peer id.
cls | Closure - unused. |
Definition at line 190 of file gnunet-service-pils.c.
References addresses_hash, builder, P_Client::client, clients_head, generate_pid_task, GNUNET_assert, GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_eddsa_sign_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_HELLO_ADDRESS_EXPIRATION, GNUNET_HELLO_builder_from_parser(), GNUNET_HELLO_builder_hash_addresses(), GNUNET_HELLO_builder_iterate(), GNUNET_HELLO_builder_new(), GNUNET_HELLO_builder_to_block(), GNUNET_HELLO_get_builder_to_block_size(), GNUNET_MESSAGE_TYPE_PILS_PEER_ID, GNUNET_MQ_msg_extra, GNUNET_MQ_send_copy(), GNUNET_OK, GNUNET_p2s(), GNUNET_PILS_derive_pid(), GNUNET_SIGNATURE_PURPOSE_HELLO, GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, PilsHelloSignaturePurpose::h_addrs, have_id, ikm, LOG, P_Client::mq, msg, my_private_key, my_public_key, P_Client::next, warningfilter::parser, print_uri(), PilsHelloSignaturePurpose::purpose, signed_hello, and GNUNET_CRYPTO_EccSignaturePurpose::size.
Referenced by handle_feed_addresses(), and run().
|
static |
Checker for feed messages.
cls | client who sent the message |
message | the message received |
Definition at line 279 of file gnunet-service-pils.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SYSERR, LOG, msg, and GNUNET_MessageHeader::size.
|
static |
Handler for feed addresses message from client.
A client (must be core) sent us the hash of the current set of addresses. This triggers the generation of the new peer id.
cls | client who sent the message |
message | the message received |
Definition at line 311 of file gnunet-service-pils.c.
References FeedAddressesMessage::block_len, P_Client::client, do_generate_pid(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_block_(), GNUNET_SERVICE_client_continue(), GNUNET_YES, LOG, and warningfilter::parser.
|
static |
Handler for decaps request message from client.
cls | client who sent the message |
message | the message received |
Definition at line 341 of file gnunet-service-pils.c.
References DecapsMessage::c, P_Client::client, env, GNUNET_CRYPTO_eddsa_kem_decaps(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_PILS_DECAPS_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SERVICE_client_continue(), DecapsResultMessage::key, LOG, P_Client::mq, my_private_key, DecapsMessage::rid, and DecapsResultMessage::rid.
|
static |
Handler for sign request message from client.
cls | client sending the message |
er_msg | message of type struct EditRecordSetMessage |
Definition at line 375 of file gnunet-service-pils.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SYSERR, LOG, msg, GNUNET_MessageHeader::size, and GNUNET_CRYPTO_EccSignaturePurpose::size.
|
static |
Handler for sign request message from client.
cls | client who sent the message |
message | the message received |
Definition at line 413 of file gnunet-service-pils.c.
References P_Client::client, env, GNUNET_CRYPTO_eddsa_sign_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_PILS_SIGN_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SERVICE_client_continue(), LOG, P_Client::mq, my_private_key, my_public_key, SignResultMessage::peer_id, GNUNET_PeerIdentity::public_key, SignResultMessage::rid, SignRequestMessage::rid, and SignResultMessage::sig.
|
static |
Task run during shutdown.
cls | unused |
Definition at line 450 of file gnunet-service-pils.c.
References cfg, P_Client::client, clients_head, generate_pid_task, GNUNET_CRYPTO_eddsa_key_clear(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_drop(), LOG, my_private_key, P_Client::next, and signed_hello.
Referenced by run().
|
static |
Set up the service.
cls | closure - unused |
c | configuration to use |
service | the initialized service - unused |
Definition at line 484 of file gnunet-service-pils.c.
References cfg, do_generate_pid(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_add_shutdown(), have_id, load_ikm(), LOG, and shutdown_task().
|
static |
Callback called when a client connects to the service.
This stores the client in a DLL. If we have a peer id, send it immediately to the api/client.
cls | closure for the service - unused |
c | the new client that connected to the service |
mq | the message queue used to send messages to the client |
Definition at line 512 of file gnunet-service-pils.c.
References P_Client::client, clients_head, clients_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_send_copy(), GNUNET_new, GNUNET_YES, have_id, LOG, mq, GNUNET_SERVICE_Client::mq, and signed_hello.
|
static |
Callback called when a client disconnected from the service.
Remove the client from the DLL
cls | closure for the service |
c | the client that disconnected |
internal_cls | should be equal to c |
Definition at line 545 of file gnunet-service-pils.c.
References P_Client::client, clients_head, clients_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and P_Client::next.
GNUNET_SERVICE_MAIN | ( | GNUNET_OS_project_data_gnunet() | , |
"pils" | , | ||
GNUNET_SERVICE_OPTION_NONE | , | ||
& | run, | ||
& | client_connect_cb, | ||
& | client_disconnect_cb, | ||
NULL | , | ||
GNUNET_MQ_hd_var_size(feed_addresses, GNUNET_MESSAGE_TYPE_PILS_FEED_ADDRESSES, struct FeedAddressesMessage, NULL) | , | ||
GNUNET_MQ_hd_fixed_size(decaps, GNUNET_MESSAGE_TYPE_PILS_KEM_DECAPS, struct DecapsMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(sign, GNUNET_MESSAGE_TYPE_PILS_SIGN_REQUEST, struct SignRequestMessage, NULL) | , | ||
GNUNET_MQ_handler_end() | |||
) |
Define "main" method using service macro.
|
static |
Handle to our current configuration.
Definition at line 46 of file gnunet-service-pils.c.
Referenced by load_ikm(), run(), and shutdown_task().
|
static |
Task to schedule the generation of the peer id.
Definition at line 52 of file gnunet-service-pils.c.
Referenced by do_generate_pid(), and shutdown_task().
struct GNUNET_HashCode addresses_hash |
Hash of the canonicalized addresses.
This is computed by the api, passed to the service as representation of the addresses. From it the service generates the peer id. It is also passed back to the api alongside the peer id to connect the peer id to the addresses it was based upon.
Definition at line 61 of file gnunet-service-pils.c.
Referenced by do_generate_pid().
struct GNUNET_CRYPTO_EddsaPrivateKey my_private_key |
The current private key.
Own private key.
Definition at line 67 of file gnunet-service-pils.c.
Referenced by do_generate_pid(), handle_decaps(), handle_sign(), and shutdown_task().
struct GNUNET_CRYPTO_EddsaPublicKey my_public_key |
The current public key.
Definition at line 73 of file gnunet-service-pils.c.
Referenced by do_generate_pid(), GNUNET_FS_uri_loc_create(), and handle_sign().
|
static |
The initial key material for the peer.
Definition at line 78 of file gnunet-service-pils.c.
Referenced by checkvec(), do_generate_pid(), labeled_extract(), load_ikm(), output_vectors(), and pid_change_cb().
|
static |
Head of the liked list of clients.
Definition at line 110 of file gnunet-service-pils.c.
Referenced by client_connect_cb(), client_disconnect_cb(), do_generate_pid(), and shutdown_task().
|
static |
Tail of the liked list of clients.
Definition at line 116 of file gnunet-service-pils.c.
Referenced by client_connect_cb(), and client_disconnect_cb().
|
static |
Peer ID was calculated already at least once.
Definition at line 122 of file gnunet-service-pils.c.
Referenced by client_connect_cb(), do_generate_pid(), and run().
|
static |
Current signed HELLO.
Definition at line 127 of file gnunet-service-pils.c.
Referenced by client_connect_cb(), do_generate_pid(), and shutdown_task().