#include <string.h>#include <stdint.h>#include "gnunet_common.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... | |
| struct | GNUNET_PILS_KeyRing |
| A simplified handle for using the peer identity key. More... | |
Macros | |
| #define | LOG(kind, ...) GNUNET_log_from (kind, "pils-api", __VA_ARGS__) |
Functions | |
| static void | transmit_op (struct GNUNET_PILS_Operation *op) |
| Send the request of op to the service, if we are connected. | |
| static void | flush_ops (struct GNUNET_PILS_Handle *h) |
| (Re-)transmit every outstanding request of h. | |
| static struct GNUNET_PILS_Operation * | op_start (struct GNUNET_PILS_Handle *h, struct GNUNET_MessageHeader *req) |
| Set up a new operation for h and start transmitting req. | |
| static void | op_destroy (struct GNUNET_PILS_Operation *op) |
| Remove op from its handle and free it. | |
| static struct GNUNET_PILS_Operation * | find_op (struct GNUNET_PILS_Handle *h, uint32_t rid) |
| Find the op that matches the rid. | |
| static int | check_peer_id (void *cls, const struct PeerIdUpdateMessage *msg) |
| Handles sign result. | |
| static void | derive_private_key (struct GNUNET_PILS_Handle *h) |
| Re-derive the private key of the current peer identity of h. | |
| static void | handle_peer_id (void *cls, const struct PeerIdUpdateMessage *pid_msg) |
| Handles peer ids sent from the service. | |
| static void | handle_sign_result (void *cls, const struct SignResultMessage *msg) |
| Handles sign result. | |
| static void | handle_decaps_result (void *cls, const struct DecapsResultMessage *msg) |
| Handles decaps result. | |
| static void | handle_ecdh_result (void *cls, const struct EcdhResultMessage *msg) |
| Handles ecdh result. | |
| static void | reconnect (void *cls) |
| Try again to connect to peer identity lifecycle service. | |
| static void | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
| Handles errors with the mq. | |
| 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. | |
| struct GNUNET_PILS_Operation * | GNUNET_PILS_sign_by_peer_identity (struct GNUNET_PILS_Handle *handle, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, GNUNET_PILS_SignResultCallback cb, void *cb_cls) |
| Sign data with the peer id. | |
| 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_ecdh (struct GNUNET_PILS_Handle *handle, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, GNUNET_PILS_EcdhResultCallback cb, void *cb_cls) |
| Derive key material from a ECDH public key and our private key. | |
| void | GNUNET_PILS_cancel (struct GNUNET_PILS_Operation *op) |
| Cancel request. | |
| 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. | |
| 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. | |
| 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. | |
| const struct GNUNET_PeerIdentity * | GNUNET_PILS_get_identity (const struct GNUNET_PILS_Handle *handle) |
| Return the current peer identity of a given handle. | |
| const struct GNUNET_HashCode * | GNUNET_PILS_get_identity_hash (const struct GNUNET_PILS_Handle *handle) |
| Return the hash of the current peer identity from a given handle. | |
| enum GNUNET_GenericReturnValue | GNUNET_PILS_enable_private_key (struct GNUNET_PILS_Handle *handle) |
| Enable local access to the private key of the current peer identity. | |
| const struct GNUNET_CRYPTO_EddsaPrivateKey * | GNUNET_PILS_get_private_key (const struct GNUNET_PILS_Handle *handle) |
| Return the private key of the current peer identity. | |
| void | pid_change_cb (void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *addr_hash) |
| struct GNUNET_PILS_KeyRing * | GNUNET_PILS_create_key_ring (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_SCHEDULER_TaskCallback init_cb, void *cls) |
| Get the initial secret key for generating the peer id. | |
| void | GNUNET_PILS_destroy_key_ring (struct GNUNET_PILS_KeyRing *key_ring) |
| Destroy a key ring handle and free its memory. | |
| const struct GNUNET_CRYPTO_EddsaPrivateKey * | GNUNET_PILS_key_ring_get_private_key (const struct GNUNET_PILS_KeyRing *key_ring) |
| Return the current private key of a given key ring handle. | |
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 |
Send the request of op to the service, if we are connected.
A request that cannot be sent right now stays in op_head and is transmitted by flush_ops() once the connection is (re-)established. Note that this must never call GNUNET_MQ_send() on a NULL mq: that asserts, which would take the caller's service down every time an operation is started while PILS happens to be reconnecting.
| op | operation whose request to transmit |
Definition at line 198 of file pils_api.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), h, GNUNET_ARM_Operation::h, LOG, GNUNET_ARM_Handle::mq, and op.
Referenced by flush_ops(), GNUNET_PILS_ecdh(), GNUNET_PILS_kem_decaps(), and GNUNET_PILS_sign_by_peer_identity().
|
static |
(Re-)transmit every outstanding request of h.
Called after a successful (re-)connect. The service is stateless with respect to these requests – it computes an answer and forgets them – so a request that was in flight when the connection broke is simply gone, and without this its callback would never run. Sending it again is safe: the operations are pure functions of the request, and a duplicate answer is dropped by find_op().
| h | handle whose operations to flush |
Definition at line 227 of file pils_api.c.
References h, GNUNET_ARM_Operation::next, op, and transmit_op().
Referenced by reconnect().
|
static |
Set up a new operation for h and start transmitting req.
Takes ownership of req.
| h | handle to the PILS service |
| req | the request message, with rid already filled in |
Definition at line 246 of file pils_api.c.
References GNUNET_CONTAINER_DLL_insert, GNUNET_new, h, GNUNET_ARM_Operation::h, op, and GNUNET_PILS_Operation::req.
Referenced by GNUNET_PILS_ecdh(), GNUNET_PILS_kem_decaps(), and GNUNET_PILS_sign_by_peer_identity().
|
static |
Remove op from its handle and free it.
| op | operation to destroy |
Definition at line 267 of file pils_api.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, h, GNUNET_ARM_Operation::h, and op.
Referenced by GNUNET_PILS_cancel(), GNUNET_PILS_disconnect(), handle_decaps_result(), handle_ecdh_result(), and handle_sign_result().
|
static |
Find the op that matches the rid.
| h | PILS handle |
| rid | id to look up |
Definition at line 287 of file pils_api.c.
References GNUNET_ERROR_TYPE_WARNING, h, LOG, GNUNET_ARM_Operation::next, and op.
Referenced by handle_decaps_result(), handle_ecdh_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 308 of file pils_api.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SYSERR, LOG, msg, and GNUNET_MessageHeader::size.
|
static |
Re-derive the private key of the current peer identity of h.
Does nothing unless local key access was enabled with GNUNET_PILS_enable_private_key(). Must be called after peer_id and hash were updated, and before the application's GNUNET_PILS_PidChangeCallback runs, so that a caller which sees an identity always sees the matching private key.
If the derived key does not belong to the peer identity the service announced, our [PEER]/PRIVATE_KEY does not match the one the service uses. Signing with it would produce signatures nobody can verify, so the key is discarded and callers fall back to asking the service.
| h | handle to update |
Definition at line 347 of file pils_api.c.
References GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_zero_keys(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s(), GNUNET_memcmp, GNUNET_new, GNUNET_PILS_derive_pid(), h, LOG, and GNUNET_PeerIdentity::public_key.
Referenced by GNUNET_PILS_enable_private_key(), and handle_peer_id().
|
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 387 of file pils_api.c.
References PeerIdUpdateMessage::block_len, derive_private_key(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_ERROR, GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_block(), GNUNET_HELLO_parser_get_id(), GNUNET_new, GNUNET_TIME_UNIT_ZERO, h, PeerIdUpdateMessage::hash, and LOG.
|
static |
Handles sign result.
| cls | closure - Handle to the PILS service |
| msg | the message containing the signature |
Definition at line 431 of file pils_api.c.
References find_op(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_TIME_UNIT_ZERO, h, LOG, msg, op, and op_destroy().
|
static |
Handles decaps result.
| cls | closure - Handle to the PILS service |
| msg | the message containing the decapsulation result |
Definition at line 468 of file pils_api.c.
References find_op(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_TIME_UNIT_ZERO, h, LOG, msg, op, and op_destroy().
|
static |
Handles ecdh result.
| cls | closure - Handle to the PILS service |
| msg | the message containing the ecdh result |
Definition at line 504 of file pils_api.c.
References find_op(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_TIME_UNIT_ZERO, h, LOG, msg, op, and op_destroy().
|
static |
Try again to connect to peer identity lifecycle service.
| cls | the struct GNUNET_PILS_Handle * |
Definition at line 574 of file pils_api.c.
References GNUNET_ARM_Handle::cfg, flush_ops(), GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_PILS_DECAPS_RESULT, GNUNET_MESSAGE_TYPE_PILS_ECDH_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.
|
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 546 of file pils_api.c.
References GNUNET_ERROR_TYPE_WARNING, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, h, LOG, 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 624 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 advertise_dns_exit(), create_service(), DHTU_gnunet_init(), GCH_init(), GNUNET_PILS_create_key_ring(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), GSC_KX_init(), main_init(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), 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 647 of file pils_api.c.
References GNUNET_assert, GNUNET_CRYPTO_zero_keys(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), handle, LOG, GNUNET_VPN_Handle::mq, op, and op_destroy().
Referenced by cleaning_task(), cleanup(), cleanup_task(), destroy_service(), DHTU_gnunet_done(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), GCH_shutdown(), GNUNET_PILS_destroy_key_ring(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop(), GSC_KX_done(), run(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), and shutdown_task().
| struct GNUNET_PILS_Operation * GNUNET_PILS_sign_by_peer_identity | ( | struct GNUNET_PILS_Handle * | handle, |
| const struct GNUNET_CRYPTO_SignaturePurpose * | 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 692 of file pils_api.c.
References GNUNET_assert, GNUNET_malloc, GNUNET_MESSAGE_TYPE_PILS_SIGN_REQUEST, handle, msg, op, op_start(), GNUNET_MessageHeader::size, GNUNET_CRYPTO_SignaturePurpose::size, transmit_op(), and GNUNET_MessageHeader::type.
Referenced by do_dht_put(), GDS_helper_sign_path(), GNUNET_PILS_sign_hello(), regex_iterator(), send_create(), sign_message_by_peer(), 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 728 of file pils_api.c.
References DecapsMessage::c, GNUNET_MESSAGE_TYPE_PILS_KEM_DECAPS, GNUNET_new, handle, msg, op, op_start(), GNUNET_MessageHeader::size, transmit_op(), and GNUNET_MessageHeader::type.
| struct GNUNET_PILS_Operation * GNUNET_PILS_ecdh | ( | struct GNUNET_PILS_Handle * | handle, |
| const struct GNUNET_CRYPTO_EcdhePublicKey * | pub, | ||
| GNUNET_PILS_EcdhResultCallback | cb, | ||
| void * | cb_cls | ||
| ) |
Derive key material from a ECDH public key and our private key.
| handle | handle to the PILS service |
| pub | the public key |
| cb | the callback to call with the derived key material |
| cb_cls | callback closure |
Definition at line 751 of file pils_api.c.
References GNUNET_assert, GNUNET_MESSAGE_TYPE_PILS_ECDH, GNUNET_new, handle, msg, op, op_start(), pub, GNUNET_MessageHeader::size, transmit_op(), and GNUNET_MessageHeader::type.
Referenced by GCT_handle_kx(), and GCT_handle_kx_auth().
| void GNUNET_PILS_cancel | ( | struct GNUNET_PILS_Operation * | op | ) |
Cancel request.
| op | cancel PILS operation |
Definition at line 776 of file pils_api.c.
References op, and op_destroy().
Referenced by cancel_address_store(), cleanup(), cleanup_helper_operation(), destroy_tunnel(), do_dht_put(), do_initial_dht_put(), do_shutdown(), GCC_destroy(), GCH_shutdown(), GCT_handle_kx(), GCT_handle_kx_auth(), iterate_cancel_signature(), regex_iterator(), send_create(), shutdown_task(), 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 counter to the initial secret key to the above PRF.
Definition at line 783 of file pils_api.c.
References GNUNET_assert, GNUNET_CRYPTO_hkdf_expand, GNUNET_CRYPTO_hkdf_extract(), GNUNET_CRYPTO_kdf_arg_string, GNUNET_OK, and seed_key.
Referenced by derive_private_key(), 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 817 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 | handle 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 851 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_SignaturePurpose::size.
Referenced by peerstore_store_own_cb(), and pid_changed_cb().
| const struct GNUNET_PeerIdentity * GNUNET_PILS_get_identity | ( | const struct GNUNET_PILS_Handle * | handle | ) |
Return the current peer identity of a given handle.
| handle | handle to the pils service |
Definition at line 875 of file pils_api.c.
References GNUNET_assert, and handle.
Referenced by announce_id(), cb_path_signed(), check_dv_box(), check_dv_learn(), decaps_dv_box_cont(), decrypt_and_check_tc(), dir_ready_cb(), do_initial_dht_put(), do_rekey(), encapsulate_for_dv(), find_proof(), forward_dv_learn(), forward_reply(), GCCH_bind(), GCCH_channel_local_new(), GCPP_try_path_from_dht(), GCT_alice_or_betty(), GDS_CLIENTS_handle_reply(), GDS_NEIGHBOURS_get_id(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), GDS_NEIGHBOURS_handle_reply(), GDS_try_connect(), GDS_u_connect(), get_next_free_ctn(), got_hello(), GSC_CLIENTS_solicit_request(), GSC_complete_initialization_cb(), GSC_KX_start(), GSC_SESSIONS_dequeue_request(), GSF_peer_connect_handler(), handle_backchannel_encapsulation(), handle_client_init(), handle_client_send_request(), handle_communicator_available(), handle_connection_create(), handle_core_connect(), handle_core_disconnect(), handle_dht_local_get(), handle_dht_local_hello_get(), handle_dht_local_put(), handle_dht_p2p_get(), handle_dht_p2p_put(), handle_dht_p2p_result(), handle_dv_box(), handle_dv_learn(), handle_find_my_hello(), handle_hello_for_client(), handle_hello_for_incoming(), handle_p2p_estimate(), handle_port_open(), handle_suggest(), handle_transport_notify_connect(), handshake_monotime_cb(), iface_proc(), inject_rekey(), learn_dv_path(), mq_send(), peerinfo_cb(), pid_change_cb(), pid_change_cb(), pils_id_change_cb(), pils_pid_change_cb(), pils_sign_address(), recv_rx_key_cb(), regex_iterator(), route_message(), run(), send_broken_without_mqm(), send_challenge(), send_create(), send_initiator_hello(), send_msg_with_kx(), setup_flood_message(), setup_in_cipher(), setup_in_cipher_elligator(), sock_read(), sock_read(), start_dv_learn(), store_pi(), tokenized_cb(), transmit_kx(), try_connection_reversal(), try_handle_plaintext(), update_flood_message(), and verify_confirmation().
| const struct GNUNET_HashCode * GNUNET_PILS_get_identity_hash | ( | const struct GNUNET_PILS_Handle * | handle | ) |
Return the hash of the current peer identity from a given handle.
| handle | handle to the pils service |
Definition at line 884 of file pils_api.c.
References GNUNET_assert, and handle.
Referenced by find_bucket(), GDS_am_closest_peer(), GDS_DATACACHE_handle_put(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), handle_find_my_hello(), handle_initiator_hello(), handle_initiator_hello_cont(), restart_kx(), select_peer(), and send_find_peer_message().
| enum GNUNET_GenericReturnValue GNUNET_PILS_enable_private_key | ( | struct GNUNET_PILS_Handle * | handle | ) |
Enable local access to the private key of the current peer identity.
Loads the peer's master key from [PEER]/PRIVATE_KEY (the same file the PILS service itself uses) and derives the private key belonging to the current peer identity from it, re-deriving it whenever the peer identity changes. This lets a caller sign directly with GNUNET_CRYPTO_eddsa_sign() instead of round-tripping through the service with GNUNET_PILS_sign_by_peer_identity(), which is what you want when the signature is needed in the middle of a synchronous operation.
Only call this from components that may hold the peer's private key.
| handle | handle to the pils service |
Definition at line 896 of file pils_api.c.
References GNUNET_VPN_Handle::cfg, derive_private_key(), GNUNET_assert, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CRYPTO_eddsa_key_from_file(), GNUNET_CRYPTO_zero_keys(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, handle, key, and LOG.
Referenced by GSC_KX_start(), run(), and run().
| const struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_PILS_get_private_key | ( | const struct GNUNET_PILS_Handle * | handle | ) |
Return the private key of the current peer identity.
Requires a preceding successful call to GNUNET_PILS_enable_private_key(). The returned key belongs to the identity GNUNET_PILS_get_identity() reports and stays valid until the peer identity changes, so do not cache it across GNUNET_PILS_PidChangeCallback invocations.
| handle | handle to the pils service |
Definition at line 943 of file pils_api.c.
References GNUNET_assert, and handle.
Referenced by GDS_NEIGHBOURS_handle_put(), GDS_NEIGHBOURS_handle_reply(), handle_dv_box(), handle_initiator_hello(), handle_responder_hello(), and sign_by_my_identity().
| void pid_change_cb | ( | void * | cls, |
| const struct GNUNET_HELLO_Parser * | parser, | ||
| const struct GNUNET_HashCode * | addr_hash | ||
| ) |
Definition at line 952 of file pils_api.c.
References GNUNET_PILS_KeyRing::cls, GNUNET_assert, GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_new, GNUNET_NO, GNUNET_PILS_derive_pid(), GNUNET_PILS_get_identity(), GNUNET_YES, GNUNET_PILS_KeyRing::hash, GNUNET_PILS_KeyRing::identity, GNUNET_PILS_KeyRing::init_cb, GNUNET_PILS_KeyRing::initial_key_material, initialized, key_ring, GNUNET_PILS_KeyRing::pils, GNUNET_PILS_KeyRing::private_key, and GNUNET_PeerIdentity::public_key.
Referenced by GNUNET_PILS_connect(), and GNUNET_PILS_create_key_ring().
| struct GNUNET_PILS_KeyRing * GNUNET_PILS_create_key_ring | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
| GNUNET_SCHEDULER_TaskCallback | init_cb, | ||
| void * | cls | ||
| ) |
Get the initial secret key for generating the peer id.
Create a key ring handle to use the current peer identity key.
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 obtain 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.
Definition at line 1008 of file pils_api.c.
References cfg, GNUNET_PILS_KeyRing::cls, GNUNET_assert, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CRYPTO_eddsa_key_from_file(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_new, GNUNET_OK, GNUNET_PILS_connect(), GNUNET_SYSERR, GNUNET_YES, init_cb(), GNUNET_PILS_KeyRing::init_cb, GNUNET_PILS_KeyRing::initial_key_material, key, key_ring, LOG, pid_change_cb(), and GNUNET_PILS_KeyRing::pils.
Referenced by run(), and run().
| void GNUNET_PILS_destroy_key_ring | ( | struct GNUNET_PILS_KeyRing * | key_ring | ) |
Destroy a key ring handle and free its memory.
| key_ring | key ring handle |
Definition at line 1068 of file pils_api.c.
References GNUNET_assert, GNUNET_CRYPTO_zero_keys(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_PILS_disconnect(), GNUNET_PILS_KeyRing::initial_key_material, key_ring, LOG, GNUNET_PILS_KeyRing::pils, and GNUNET_PILS_KeyRing::private_key.
Referenced by do_shutdown(), and do_shutdown().
| const struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_PILS_key_ring_get_private_key | ( | const struct GNUNET_PILS_KeyRing * | key_ring | ) |
Return the current private key of a given key ring handle.
| key_ring | key ring handle |
Definition at line 1091 of file pils_api.c.
References GNUNET_assert, key_ring, and GNUNET_PILS_KeyRing::private_key.
Referenced by iface_proc(), inject_rekey(), send_challenge(), send_msg_with_kx(), setup_in_cipher(), setup_in_cipher_elligator(), setup_initial_shared_secret_dec(), setup_shared_secret_dec(), and transmit_kx().