#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"
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_Operation * | find_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_Handle * | GNUNET_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_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. More... | |
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. 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_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. More... | |
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.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "pils-api", __VA_ARGS__) |
Definition at line 44 of file pils_api.c.
|
static |
Find the op that matches the rid.
h | PILS handle |
rid | id to look up |
Definition at line 132 of file pils_api.c.
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().
|
static |
Handles sign result.
cls | closure - Handle to the PILS service |
msg | the message containing the signature |
Definition at line 153 of file pils_api.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SYSERR, LOG, msg, and GNUNET_MessageHeader::size.
|
static |
Handles peer ids sent from the service.
cls | closure - Handle to the PILS service |
pid_msg | the message containing peer id and addresses hash |
Definition at line 182 of file pils_api.c.
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.
|
static |
Handles sign result.
cls | closure - Handle to the PILS service |
msg | the message containing the signature |
Definition at line 217 of file pils_api.c.
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.
|
static |
Handles decaps result.
cls | closure - Handle to the PILS service |
msg | the message containing the decapsulation result |
Definition at line 257 of file pils_api.c.
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.
|
static |
Try again to connect to peer identity lifecycle service.
cls | the struct GNUNET_PILS_Handle * |
Definition at line 321 of file pils_api.c.
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().
|
static |
Handles errors with the mq.
Schedules the reconnect task and updates the reconnect delay.
cls | closure - handle to PILS |
error | error type indicating the kind of problem with mq |
Definition at line 298 of file pils_api.c.
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().
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.
cfg | configuration to use |
pid_change_cb | handler/callback called once the peer id changes |
cls | closure for pid_change_cb |
Definition at line 367 of file pils_api.c.
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().
void GNUNET_PILS_disconnect | ( | struct GNUNET_PILS_Handle * | handle | ) |
Disconnect from the PILS service.
handle | handle to the PILS service (was returned by GNUNET_PILS_connect) |
Definition at line 390 of file pils_api.c.
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().
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.
handle | handle to the PILS service |
purpose | what to sign (size, purpose and data) |
cb | callback to call once the signature is ready |
cb_cls | closure to cb |
Definition at line 428 of file pils_api.c.
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().
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.
handle | handle to the PILS service |
c | the encapsulated key |
prk | where to write the key material HKDF-Extract(c||aX)=HKDF-Extract(c||x(aG)) |
Definition at line 468 of file pils_api.c.
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().
void GNUNET_PILS_cancel | ( | struct GNUNET_PILS_Operation * | op | ) |
Cancel request.
op | cancel PILS operation |
Definition at line 495 of file pils_api.c.
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().
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.
seed_key_bytes | length of the seed key in bytes | |
seed_key | the initial secret key | |
addrs_hash | the address to use for derivation | |
[out] | outkey | the (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.
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().
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.
handle | the handle to the PILS service |
addresses_builder | addresses to feed as builder |
Definition at line 542 of file pils_api.c.
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().
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.
handle | hande to the pils service |
builder | the builder to use |
et | expiration time to sign |
cb | callback to call with the signature |
cb_cls | closure to cb |
Definition at line 576 of file pils_api.c.
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().