GNUnet 0.27.0
 
Loading...
Searching...
No Matches
gnunet_pils_service.h File Reference
#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_uri_lib.h"
Include dependency graph for gnunet_pils_service.h:

Go to the source code of this file.

Typedefs

typedef 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.
 
typedef void(* GNUNET_PILS_SignAddrResultCallback) (void *cls, void *result, size_t result_size)
 A handler/callback to be called for signatures on addresses.
 
typedef void(* GNUNET_PILS_DecapsResultCallback) (void *cls, const struct GNUNET_ShortHashCode *key)
 A handler/callback to be called for decaps.
 
typedef void(* GNUNET_PILS_EcdhResultCallback) (void *cls, const struct GNUNET_HashCode *key)
 A handler/callback to be called for ecdh.
 
typedef 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.
 

Functions

struct GNUNET_PILS_HandleGNUNET_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_OperationGNUNET_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_OperationGNUNET_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_OperationGNUNET_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_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.
 
void GNUNET_HELLO_builder_hash_addresses (const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *address_hash)
 Hash address in builder.
 
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_OperationGNUNET_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.
 
const struct GNUNET_PeerIdentityGNUNET_PILS_get_identity (const struct GNUNET_PILS_Handle *handle)
 Return the current peer identity of a given handle.
 
const struct GNUNET_HashCodeGNUNET_PILS_get_identity_hash (const struct GNUNET_PILS_Handle *handle)
 Return the hash of the current peer identity from a given handle.
 
struct GNUNET_PILS_KeyRingGNUNET_PILS_create_key_ring (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_SCHEDULER_TaskCallback init_cb, void *cls)
 Create a key ring handle to use the current peer identity key.
 
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_EddsaPrivateKeyGNUNET_PILS_key_ring_get_private_key (const struct GNUNET_PILS_KeyRing *key_ring)
 Return the current private key of a given key ring handle.
 

Detailed Description

Author
ch3

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.

Note: Currently the signatures are actually made in the api. TODO is it fine this way?

Definition in file gnunet_pils_service.h.

Typedef Documentation

◆ GNUNET_PILS_SignResultCallback

typedef 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.

The peer identity may have been changed by PILS in the meantime, so the identity that was used to sign is returned here.

Parameters
clsThe closure given to #GNUNET_PILS_sign
pidthe peer identity that produced the signature
sigthe signature, NULL on error

Definition at line 63 of file gnunet_pils_service.h.

◆ GNUNET_PILS_SignAddrResultCallback

typedef void(* GNUNET_PILS_SignAddrResultCallback) (void *cls, void *result, size_t result_size)

A handler/callback to be called for signatures on addresses.

Parameters
clsThe closure given to #GNUNET_PILS_sign
resultallocated address record
result_sizesize of result

Definition at line 75 of file gnunet_pils_service.h.

◆ GNUNET_PILS_DecapsResultCallback

typedef void(* GNUNET_PILS_DecapsResultCallback) (void *cls, const struct GNUNET_ShortHashCode *key)

A handler/callback to be called for decaps.

Parameters
clsThe closure given to GNUNET_PILS_kem_decaps
keyThe decapsulated key

Definition at line 86 of file gnunet_pils_service.h.

◆ GNUNET_PILS_EcdhResultCallback

typedef void(* GNUNET_PILS_EcdhResultCallback) (void *cls, const struct GNUNET_HashCode *key)

A handler/callback to be called for ecdh.

Parameters
clsThe closure given to GNUNET_PILS_ecdh
keyThe derived key material

Definition at line 96 of file gnunet_pils_service.h.

◆ GNUNET_PILS_PidChangeCallback

typedef 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.

Parameters
clsThe closure given to GNUNET_PILS_connect
parsera parsed HELLO block that represents the new PID
hashThe hash of addresses the peer id is based on. This hash is also returned by #GNUNET_PILS_feed_address.

Definition at line 108 of file gnunet_pils_service.h.

Function Documentation

◆ GNUNET_PILS_connect()

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.

Parameters
cfgconfiguration to use
pid_change_cbhandler/callback called once the peer id changes
clsclosure for pid_change_cb
Returns
Handle to the PILS service

Definition at line 465 of file pils_api.c.

468{
469 struct GNUNET_PILS_Handle *h;
470
472 h->cfg = cfg;
473 h->pid_change_cb = pid_change_cb;
474 h->pid_change_cb_cls = cls;
475 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
476 reconnect (h);
477 return h;
478}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
void pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *addr_hash)
Definition pils_api.c:748
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition arm_api.c:112
A handle for the PILS service.
Definition pils_api.c:82

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(), GSC_KX_init(), main_init(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_disconnect()

void GNUNET_PILS_disconnect ( struct GNUNET_PILS_Handle handle)

Disconnect from the PILS service.

Parameters
handlehandle to the PILS service (was returned by GNUNET_PILS_connect)

Definition at line 488 of file pils_api.c.

489{
491
492 GNUNET_assert (NULL != handle);
494 "Disonnecting from peer identity lifecycle service.\n");
495 if (NULL != handle->reconnect_task)
496 {
497 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
498 handle->reconnect_task = NULL;
499 }
500 if (NULL != handle->mq)
501 {
503 handle->mq = NULL;
504 }
505 LOG (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
506 while (NULL != (op = handle->op_head))
507 {
508 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
509 GNUNET_free (op);
510 }
511 if (handle->peer_id)
512 GNUNET_free (handle->peer_id);
514}
static struct GNUNET_ARM_Operation * op
Current operation.
Definition gnunet-arm.c:143
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition mq.c:700
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
#define LOG(kind,...)
Definition pils_api.c:44
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition vpn_api.c:44

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(), 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(), GSC_KX_done(), run(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), shutdown_task(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_sign_by_peer_identity()

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.

TODO not sure whether this was the intended design from last meeting - this is currently following the design of GNUNET_CRYPTO_blinded_key_sign_by_peer_identity

In particular we currently transfer the secret key from the service to the api so we can sign in-place and have no ipc-overhead. Is this fine?

Parameters
handlehandle to the PILS service
purposewhat to sign (size, purpose and data) TODO improve wording - look at GNUNET_CRYPTO_eddsa_sign
cbsignature result callback
cb_clsclosure for the cb
Returns
handle to the operation, NULL on error
Parameters
handlehandle to the PILS service
purposewhat to sign (size, purpose and data)
cbcallback to call once the signature is ready
cb_clsclosure to cb
Returns
handle to the operation, NULL on error

Definition at line 528 of file pils_api.c.

534{
536 struct SignRequestMessage *msg;
537
539 op->env = GNUNET_MQ_msg_extra (msg,
540 ntohl (purpose->size),
542 op->h = handle;
543 op->sign_cb = cb;
544 op->cb_cls = cb_cls;
545 msg->rid = htonl (handle->op_id_counter++);
546 op->op_id = ntohl (msg->rid);
547 memcpy (&msg[1], purpose, ntohl (purpose->size));
549 handle->op_tail,
550 op);
551 // FIXME resend?
552 GNUNET_MQ_send (handle->mq, op->env);
553 op->env = NULL;
554 return op;
555}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition mq.c:305
#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_MESSAGE_TYPE_PILS_SIGN_REQUEST
The client requests data to be signed with the peer identity.
struct GNUNET_ARM_Handle * h
ARM handle.
Definition arm_api.c:55
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
Message to request a signature from PILS.
Definition pils.h:248

References GNUNET_CONTAINER_DLL_insert, GNUNET_MESSAGE_TYPE_PILS_SIGN_REQUEST, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_ARM_Operation::h, handle, GNUNET_VPN_Handle::mq, msg, op, and GNUNET_CRYPTO_SignaturePurpose::size.

Referenced by do_dht_put(), forward_dv_learn(), GDS_helper_sign_path(), GNUNET_PILS_sign_hello(), handle_validation_challenge(), pils_sign_address(), regex_iterator(), send_create(), sign_ephemeral(), sign_message_by_peer(), start_dv_learn(), and transmit_task_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_kem_decaps()

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.

TODO whether it's fine to use the private key in this way needs to be discussed. If not, another key (which has been signed with this id) needs to be used for en-/decapsulating.

Parameters
handlehandle to the PILS service
cthe encapsulated key
cbthe callback to call with the decapsulated key
cb_clscallback closure
Returns
handle to the operation, NULL on error
Parameters
handlehandle to the PILS service
cthe encapsulated key
prkwhere to write the key material HKDF-Extract(c||aX)=HKDF-Extract(c||x(aG))
Returns
handle to the operation, NULL on error

Definition at line 568 of file pils_api.c.

572{
574 struct DecapsMessage *msg;
575
578 msg->c = *c;
579 op->h = handle;
580 op->decaps_cb = cb;
581 op->cb_cls = cb_cls;
582 msg->rid = htonl (handle->op_id_counter++);
583 op->op_id = ntohl (msg->rid);
585 handle->op_tail,
586 op);
587 // FIXME resend?
588 GNUNET_MQ_send (handle->mq, op->env);
589 op->env = NULL;
590 return op;
591}
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MESSAGE_TYPE_PILS_KEM_DECAPS
Decaps request.
Message to request a decapsulation from PILS.
Definition pils.h:142
struct GNUNET_CRYPTO_HpkeEncapsulation c
Encapsulation to decapsulate.
Definition pils.h:151

References DecapsMessage::c, GNUNET_CONTAINER_DLL_insert, GNUNET_MESSAGE_TYPE_PILS_KEM_DECAPS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_ARM_Operation::h, handle, GNUNET_VPN_Handle::mq, msg, and op.

Referenced by handle_dv_box(), handle_initiator_hello(), and handle_responder_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_ecdh()

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.

Parameters
handlehandle to the PILS service
pubthe public key
cbthe callback to call with the derived key material
cb_clscallback closure
Returns
handle to the operation, NULL on error

Definition at line 595 of file pils_api.c.

599{
601 struct EcdhMessage *msg;
602
603 GNUNET_assert ((handle) && (pub));
604
607 msg->pub = *pub;
608 op->h = handle;
609 op->ecdh_cb = cb;
610 op->cb_cls = cb_cls;
611 msg->rid = htonl (handle->op_id_counter++);
612 op->op_id = ntohl (msg->rid);
614 handle->op_tail,
615 op);
616 GNUNET_MQ_send (handle->mq, op->env);
617 op->env = NULL;
618 return op;
619}
static struct GNUNET_CRYPTO_EddsaPublicKey pub
#define GNUNET_MESSAGE_TYPE_PILS_ECDH
Ecdh request.

References GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_MESSAGE_TYPE_PILS_ECDH, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_ARM_Operation::h, handle, GNUNET_VPN_Handle::mq, msg, op, and pub.

Referenced by GCT_handle_kx(), and GCT_handle_kx_auth().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_feed_addresses()

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.

Parameters
handlethe handle to the PILS service
addresses_builderaddresses to feed as builder

Definition at line 669 of file pils_api.c.

671{
673 struct GNUNET_MQ_Envelope *env;
674 size_t block_bytes;
675
677 // TODO check whether the new hash and the 'current' hash are the same -
678 // nothing to do in that case (directly return the peer id?)
680 block_bytes,
682 msg->block_len = htonl (block_bytes);
684 builder,
685 NULL,
686 NULL,
688 (char*) &msg[1]);
690}
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
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.
Definition hello-uri.c:1280
size_t GNUNET_HELLO_get_builder_to_block_size(const struct GNUNET_HELLO_Builder *builder)
Get projected block size for builder.
Definition hello-uri.c:1348
#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.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition time.c:316
Message requesting a signature on data with the current peer id.
Definition pils.h:122

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_derive_pid()

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.

Parameters
seed_key_byteslength of the seed key in bytes
seed_keythe initial secret key
addrs_hashthe address to use for derivation
[out]outkeythe (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 635 of file pils_api.c.

639{
640 struct GNUNET_ShortHashCode prk;
641
649 addrs_hash,
650 sizeof *addrs_hash,
651 seed_key,
652 seed_key_bytes));
661 outkey,
662 sizeof *outkey,
663 &prk,
664 GNUNET_CRYPTO_kdf_arg_string ("gnunet-pils-ephemeral-peer-key"));
665}
static uint8_t seed_key[256/8]
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.
#define GNUNET_CRYPTO_hkdf_expand(result, out_len, prk,...)
HKDF-Expand using SHA256.
#define GNUNET_CRYPTO_kdf_arg_string(d)
@ GNUNET_OK
A 256-bit hashcode.

References GNUNET_assert, GNUNET_CRYPTO_hkdf_expand, GNUNET_CRYPTO_hkdf_extract(), GNUNET_CRYPTO_kdf_arg_string, GNUNET_OK, and seed_key.

Referenced by do_generate_pid(), pid_change_cb(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_sign_hello()

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.

Parameters
handlehandle to the pils service
builderthe builder to use
etexpiration time to sign
cbcallback to call with the signature
cb_clsclosure to cb

Definition at line 703 of file pils_api.c.

708{
709 struct PilsHelloSignaturePurpose hsp = {
710 .purpose.size = htonl (sizeof (hsp)),
711 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_HELLO),
712 .expiration_time = GNUNET_TIME_absolute_hton (et)
713 };
715 &hsp.h_addrs);
717 "Address hash is %s\n",
718 GNUNET_h2s_full (&hsp.h_addrs));
720 &hsp.purpose,
721 cb,
722 cb_cls);
723}
#define GNUNET_SIGNATURE_PURPOSE_HELLO
Signature by which a peer affirms its address.
void GNUNET_HELLO_builder_hash_addresses(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
Compute hash over addresses in builder.
Definition hello-uri.c:1170
#define GNUNET_log(kind,...)
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:636
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.
Definition pils_api.c:528
Message signed as part of a HELLO block/URL.
Definition hello-uri.c:51
struct GNUNET_HashCode h_addrs
Hash over all addresses.
Definition hello-uri.c:65
struct GNUNET_CRYPTO_SignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_HELLO.
Definition hello-uri.c:55

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_cancel()

void GNUNET_PILS_cancel ( struct GNUNET_PILS_Operation op)

Cancel request.

Parameters
opcancel PILS operation

Definition at line 623 of file pils_api.c.

624{
625 struct GNUNET_PILS_Handle *h = op->h;
626
627 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
628 if (NULL != op->env)
629 GNUNET_MQ_discard (op->env);
630 GNUNET_free (op);
631}
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition mq.c:285

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), h, GNUNET_ARM_Operation::h, and op.

Referenced by 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(), GSC_KX_done(), iterate_cancel_signature(), regex_iterator(), send_create(), shutdown_task(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_get_identity()

const struct GNUNET_PeerIdentity * GNUNET_PILS_get_identity ( const struct GNUNET_PILS_Handle handle)

Return the current peer identity of a given handle.

Parameters
handlehandle to the pils service
Returns
Peer identity or NULL on failure

Definition at line 727 of file pils_api.c.

728{
730
731 return handle->peer_id;
732}

References GNUNET_assert, and handle.

Referenced by announce_id(), cb_path_signed(), check_dv_box(), check_dv_learn(), decaps_dv_box_cb(), 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_hello_get(), 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(), pils_id_change_cb(), pils_pid_change_cb(), 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(), sign_dv_init_cb(), 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().

◆ GNUNET_PILS_get_identity_hash()

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.

Parameters
handlehandle to the pils service
Returns
Peer identity hash or NULL on failure

Definition at line 736 of file pils_api.c.

737{
739
740 if (NULL == handle->peer_id)
741 return NULL;
742
743 return &handle->peer_hash;
744}

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().

Here is the caller graph for this function:

◆ 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 
)

Create a key ring handle to use the current peer identity key.

Parameters
cfgconfiguration to use
init_cbinitial callback or NULL
clsclosure of callback or NULL
Returns
Handle to the PILS key ring or NULL on failure

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 804 of file pils_api.c.

807{
808 char *keyfile;
810
812
813 LOG (GNUNET_ERROR_TYPE_DEBUG, "Create key ring!\n");
814
815 if (GNUNET_OK !=
817 "PEER",
818 "PRIVATE_KEY",
819 &keyfile))
820 {
822 "PEER",
823 "PRIVATE_KEY");
824 return NULL;
825 }
826
827 if (GNUNET_SYSERR ==
830 &key))
831 {
833 "Failed to setup peer's private key\n");
834 GNUNET_free (keyfile);
835 return NULL;
836 }
837
838 GNUNET_free (keyfile);
839
842 if (NULL == key_ring)
843 return NULL;
845 key_ring->cls = cls;
846
847 GNUNET_assert (sizeof (key_ring->initial_key_material) == sizeof key.d);
848
850 if (NULL == key_ring->pils)
851 {
853 return NULL;
854 }
855
858
859 return key_ring;
860}
static struct GNUNET_PILS_KeyRing * key_ring
For PILS.
struct GNUNET_HashCode key
The key used in the DHT.
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_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.
@ GNUNET_YES
@ GNUNET_SYSERR
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_ERROR
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.
Definition pils_api.c:465
Private ECC key encoded for transmission.
A simplified handle for using the peer identity key.
Definition pils_api.c:132
GNUNET_SCHEDULER_TaskCallback init_cb
Initial callback.
Definition pils_api.c:141
unsigned char initial_key_material[256/8]
Initial key material.
Definition pils_api.c:151
void * cls
Closure for initial callback.
Definition pils_api.c:146
struct GNUNET_PILS_Handle * pils
PILS handle.
Definition pils_api.c:136
static void init_cb(void *cls, const struct GNUNET_PeerIdentity *my_identity)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_destroy_key_ring()

void GNUNET_PILS_destroy_key_ring ( struct GNUNET_PILS_KeyRing key_ring)

Destroy a key ring handle and free its memory.

Parameters
key_ringkey ring handle

Definition at line 864 of file pils_api.c.

865{
867
868 LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroy key ring!\n");
869
870 if (key_ring->pils)
872
874 {
876 sizeof (*(key_ring->private_key)));
878 }
879
883}
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:488
struct GNUNET_CRYPTO_EddsaPrivateKey * private_key
Private key.
Definition pils_api.c:156

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PILS_key_ring_get_private_key()

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.

Parameters
key_ringkey ring handle
Returns
Private key or NULL on failure

Definition at line 887 of file pils_api.c.

889{
891
892 return key_ring->private_key;
893}

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().

Here is the caller graph for this function: