44#define LOG(kind, ...) GNUNET_log_from (kind, "pils-api", __VA_ARGS__)
140 "Finding request with id %u was unsuccessful\n",
156 uint32_t block_bytes;
159 msg_size = ntohs (
msg->header.
size);
160 block_bytes = ntohl (
msg->block_len);
161 if (msg_size !=
sizeof (*
msg) + block_bytes)
164 "The msg_size (%lu) is not %lu (header) + %u (block)\n",
186 uint32_t block_bytes;
189 block_bytes = ntohl (pid_msg->
block_len);
195 "Error parsing Hello block from PILS!\n");
200 if (NULL !=
h->pid_change_cb)
202 h->pid_change_cb (
h->pid_change_cb_cls,
226 "Received SIGN_RESULT message from service\n");
231 "Didn't find the operation corresponding to id %u\n",
306 "(mq_error_handler) Connection to service failed!.\n");
342 "Connecting to peer identity lifecycle service.\n");
352 "Failed to connect.\n");
362 "Connection to service successful!.\n");
376 h->pid_change_cb_cls = cls;
396 "Disonnecting from peer identity lifecycle service.\n");
397 if (NULL !=
handle->reconnect_task)
400 handle->reconnect_task = NULL;
408 while (NULL != (
op =
handle->op_head))
440 ntohl (purpose->
size),
445 msg->rid = htonl (
handle->op_id_counter++);
447 memcpy (&
msg[1], purpose, ntohl (purpose->
size));
482 msg->rid = htonl (
handle->op_id_counter++);
508 const uint8_t
seed_key[seed_key_bytes],
535 "gnunet-pils-ephemeral-peer-key",
536 strlen (
"gnunet-pils-ephemeral-peer-key"),
555 msg->block_len = htonl (block_bytes);
590 "Address hash is %s\n",
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static char * peer_id
Option –peer.
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
struct GNUNET_PILS_Operation * op
PILS op.
static uint8_t seed_key[256/8]
void pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *hparser, const struct GNUNET_HashCode *addr_hash)
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Helper library for handling HELLO URIs.
void(* GNUNET_PILS_PidChangeCallback)(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
A handler/callback to be called on the change of the peer id.
void(* GNUNET_PILS_DecapsResultCallback)(void *cls, const struct GNUNET_ShortHashCode *key)
A handler/callback to be called for decaps.
void(* GNUNET_PILS_SignResultCallback)(void *cls, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig)
A handler/callback to be called for signatures.
Constants for network protocols.
#define GNUNET_SIGNATURE_PURPOSE_HELLO
Signature by which a peer affirms its address.
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.
#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.
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk,...)
HKDF-Expand using SHA256.
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.
size_t GNUNET_HELLO_get_builder_to_block_size(const struct GNUNET_HELLO_Builder *builder)
Get projected block size for builder.
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block(const void *block, size_t block_size)
Parse block.
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.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#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.
@ 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.
GNUNET_MQ_Error
Error codes for the 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.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
#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)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
#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_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
Common type definitions for the peer identity lifecycle service and API.
static void handle_peer_id(void *cls, const struct PeerIdUpdateMessage *pid_msg)
Handles peer ids sent from the service.
static struct GNUNET_PILS_Operation * find_op(struct GNUNET_PILS_Handle *h, uint32_t rid)
Find the op that matches the rid.
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.
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
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.
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.
void GNUNET_PILS_cancel(struct GNUNET_PILS_Operation *op)
Cancel request.
static void handle_sign_result(void *cls, const struct SignResultMessage *msg)
Handles sign result.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Handles errors with the mq.
static void reconnect(void *cls)
Try again to connect to peer identity lifecycle service.
static void handle_decaps_result(void *cls, const struct DecapsResultMessage *msg)
Handles decaps result.
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.
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.
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 addr...
static int check_peer_id(void *cls, const struct PeerIdUpdateMessage *msg)
Handles sign result.
Message to request a decapsulation from PILS.
struct GNUNET_CRYPTO_HpkeEncapsulation c
Encapsulation to decapsulate.
Message containing the decapsulated key.
Message requesting a signature on data with the current peer id.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
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.
HPKE DHKEM encapsulation (X25519) See RFC 9180.
Context for building (or parsing) HELLO URIs.
Context for parsing HELLOs.
Handle to a message queue.
Message handler for a specific message type.
A handle for the PILS service.
struct GNUNET_PILS_Operation * op_head
DLL.
const struct GNUNET_CONFIGURATION_Handle * cfg
struct GNUNET_PeerIdentity peer_id
uint32_t op_id_counter
Op ID counter.
struct GNUNET_SCHEDULER_Task * reconnect_task
struct GNUNET_TIME_Relative reconnect_delay
struct GNUNET_PILS_Operation * op_tail
DLL.
struct GNUNET_HashCode hash
GNUNET_PILS_PidChangeCallback pid_change_cb
struct GNUNET_MQ_Handle * mq
struct GNUNET_PILS_Operation * next
struct GNUNET_PILS_Handle * h
GNUNET_PILS_SignResultCallback sign_cb
GNUNET_PILS_DecapsResultCallback decaps_cb
struct GNUNET_PILS_Operation * prev
struct GNUNET_MQ_Envelope * env
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Message containing the current peer id and the hash from which it was generated.
struct GNUNET_HashCode hash
The hash from which the peer id was generated.
uint32_t block_len
Length of the HELLO block in bytes.
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.