41#define LOG(kind, ...) GNUNET_log_from (kind, "pils", __VA_ARGS__)
78static unsigned char ikm[256 / 8];
163 "Failed to setup peer's private key\n");
206 "Got new address list to derive PID:\n");
209 &new_addresses_hash);
227 "Successfully generated a new peer id %s - inform clients\n",
254 msg->block_len = htonl (block_bytes);
262 while (NULL != client)
265 client = client->
next;
283 uint32_t block_bytes;
286 msg_size = ntohs (
msg->header.
size);
287 block_bytes = ntohl (
msg->block_len);
288 if (msg_size !=
sizeof (*
msg) + block_bytes)
291 "The msg_size (%lu) is not %lu (header) + %u (block)\n",
316 uint32_t block_bytes;
319 "PILS received FEED_ADDRESSES message from client\n");
323 block_bytes = ntohl (message->
block_len);
350 "PILS received KEM_DECAPS message from client\n");
357 "PILS failed to decapsulate encapsulation received from client\n");
358 memset (&rmsg->
key, 0, sizeof (rmsg->
key));
381 msg_size = ntohs (
msg->header.
size);
382 if (msg_size <=
sizeof (*
msg) +
sizeof (
struct
386 "The msg_size (%lu) is not big enough for msg (%lu) + purpose struct (%lu)\n",
393 if (msg_size <=
sizeof (*
msg) + ntohs (purp->
size))
396 "The msg_size (%lu) is not big enough for msg (%lu) + purpose (%u)\n",
423 "PILS received SIGN message from client\n");
431 "PILS failed to sign message received from client\n");
432 memset (&rmsg->
sig, 0, sizeof (rmsg->
sig));
435 "PILS sent SIGN_RESULT message to client %p\n",
456 "PILS shutting down\n");
553 while (NULL != client_iter)
557 if (client_iter->
client == c)
564 client_iter = client_next;
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_MQ_Envelope * signed_hello
Current signed HELLO.
static void handle_decaps(void *cls, const struct DecapsMessage *message)
Handler for decaps request message from client.
struct GNUNET_CRYPTO_EddsaPrivateKey my_private_key
The current private key.
static struct GNUNET_SCHEDULER_Task * generate_pid_task
Task to schedule the generation of the peer id.
static unsigned char ikm[256/8]
The initial key material for the peer.
struct GNUNET_HashCode addresses_hash
Hash of the canonicalized addresses.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
static int check_feed_addresses(void *cls, const struct FeedAddressesMessage *msg)
Checker for feed messages.
static void print_uri(void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
static void handle_feed_addresses(void *cls, const struct FeedAddressesMessage *message)
Handler for feed addresses message from client.
static struct P_Client * clients_tail
Tail of the liked list of clients.
static void shutdown_task(void *cls)
Task run during shutdown.
struct GNUNET_CRYPTO_EddsaPublicKey my_public_key
The current public key.
static struct P_Client * clients_head
Head of the liked list of clients.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Set up the service.
static void load_ikm()
Get the initial secret key for generating the peer id.
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 int have_id
Peer ID was calculated already at least once.
static void handle_sign(void *cls, const struct SignRequestMessage *message)
Handler for sign request message from client.
static void do_generate_pid(const struct GNUNET_HELLO_Parser *parser)
Generate the peer id from the addresses hash and the initial secret key.
static int check_sign(void *cls, const struct SignRequestMessage *msg)
Handler for sign request message from client.
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.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls)
Callback called when a client disconnected from the service.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
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.
Constants for network protocols.
#define GNUNET_SIGNATURE_PURPOSE_HELLO
Signature by which a peer affirms its address.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_decaps(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Decapsulate a key for a private EdDSA key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EddsaPrivateKey *pkey)
Create a new private key by reading it from a file.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
void GNUNET_CRYPTO_eddsa_key_clear(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Clear memory that was used to store a private key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_HELLO_parser_free(struct GNUNET_HELLO_Parser *parser)
Release resources of a builder.
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.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new()
Allocate builder.
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block_(const void *block, size_t block_size, int noverify)
Parse block.
void GNUNET_HELLO_builder_iterate(const struct GNUNET_HELLO_Builder *builder, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a builder.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_parser(const struct GNUNET_HELLO_Parser *parser, struct GNUNET_PeerIdentity *pid)
Allocate builder from parser.
size_t GNUNET_HELLO_get_builder_to_block_size(const struct GNUNET_HELLO_Builder *builder)
Get projected block size for builder.
#define GNUNET_HELLO_ADDRESS_EXPIRATION
For how long are HELLO signatures valid?
void GNUNET_HELLO_builder_hash_addresses(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
Compute hash over addresses in builder.
#define GNUNET_log(kind,...)
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
const char * GNUNET_p2s(const struct GNUNET_CRYPTO_EddsaPublicKey *p)
Convert a public key value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
Send a copy of a message with the given message queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define GNUNET_MESSAGE_TYPE_PILS_SIGN_REQUEST
The client requests data to be signed with the peer identity.
#define GNUNET_MESSAGE_TYPE_PILS_KEM_DECAPS
Decaps request.
#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.
#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.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Common type definitions for the peer identity lifecycle service and API.
Message to request a decapsulation from PILS.
struct GNUNET_CRYPTO_HpkeEncapsulation c
Encapsulation to decapsulate.
Message containing the decapsulated key.
struct GNUNET_ShortHashCode key
The decapsulated key.
Message requesting a signature on data with the current peer id.
uint32_t block_len
For alignment.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
Private ECC key encoded for transmission.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
an ECC signature using EdDSA.
Context for building (or parsing) HELLO URIs.
Context for parsing HELLOs.
Handle to a message queue.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Handle to a client that is connected to a service.
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Time for absolute times used by GNUnet, in microseconds.
Data structure for each client connected to the CORE service.
struct GNUNET_MQ_Handle * mq
Message queue to talk to client.
struct P_Client * next
Clients are kept in a linked list.
struct P_Client * prev
Clients are kept in a linked list.
struct GNUNET_SERVICE_Client * client
Handle for the client with the server API.
Message containing the current peer id and the hash from which it was generated.
Message signed as part of a HELLO block/URL.
struct GNUNET_HashCode h_addrs
Hash over all addresses.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_HELLO.
Message to request a signature from PILS.
Message containing the signature.
struct GNUNET_PeerIdentity peer_id
The peer identity that produces the signature.
struct GNUNET_CRYPTO_EddsaSignature sig
The signature.