GNUnet 0.22.1
identity_api.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2013, 2016, 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_constants.h"
29#include "gnunet_error_codes.h"
30#include "gnunet_protocols.h"
32#include "identity.h"
33
34#define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
35
36
41{
46
51
56
62
68
74
79
85
89 void *cls;
90};
91
92
97{
102
107
113
118
122 void *cb_cls;
123
128
133
138
143
148};
149
150
156struct GNUNET_IDENTITY_Ego *
158{
159 static struct GNUNET_IDENTITY_Ego anon;
160 static int setup;
161 ssize_t key_len;
162
163 if (setup)
164 return &anon;
165 anon.pk.type = htonl (GNUNET_PUBLIC_KEY_TYPE_ECDSA);
169 GNUNET_assert (0 < key_len);
170 GNUNET_CRYPTO_hash (&anon.pk,
171 key_len,
172 &anon.id);
173 setup = 1;
174 return &anon;
175}
176
177
178
184static void
185reconnect (void *cls);
186
187
196static int
197free_ego (void *cls,
198 const struct GNUNET_HashCode *key,
199 void *value)
200{
201 struct GNUNET_IDENTITY_Handle *h = cls;
202 struct GNUNET_IDENTITY_Ego *ego = value;
203
204 if (NULL != h->cb)
205 h->cb (h->cb_cls, ego,
206 &ego->ctx,
207 NULL);
208 GNUNET_free (ego->name);
211 key,
212 value));
213 GNUNET_free (ego);
214 return GNUNET_OK;
215}
216
217
223static void
225{
227
228 GNUNET_assert (NULL == h->reconnect_task);
229
230 if (NULL != h->mq)
231 {
233 h->mq = NULL;
234 }
235 while (NULL != (op = h->op_head))
236 {
238 h->op_tail,
239 op);
240 if (NULL != op->cont)
241 op->cont (op->cls,
243 else if (NULL != op->cb)
244 op->cb (op->cls, NULL, NULL, NULL);
245 else if (NULL != op->create_cont)
246 op->create_cont (op->cls,
247 NULL,
249 GNUNET_free (op);
250 }
252 &free_ego,
253 h);
255 "Scheduling task to reconnect to identity service in %s.\n",
257 GNUNET_YES));
259 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay,
260 &reconnect,
261 h);
262 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
263}
264
265
274static void
276 enum GNUNET_MQ_Error error)
277{
278 struct GNUNET_IDENTITY_Handle *h = cls;
279
281}
282
283
290static void
292 const struct ResultCodeMessage *rcm)
293{
294 struct GNUNET_IDENTITY_Handle *h = cls;
296 enum GNUNET_ErrorCode ec = ntohl (rcm->result_code);
297
298 op = h->op_head;
299 if (NULL == op)
300 {
301 GNUNET_break (0);
303 return;
304 }
305 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
306 if (NULL != op->cont)
307 op->cont (op->cls, ec);
308 else if (NULL != op->cb)
309 op->cb (op->cls, NULL, NULL, NULL);
310 else if (NULL != op->create_cont)
311 op->create_cont (op->cls, (GNUNET_EC_NONE == ec) ? &op->pk : NULL, ec);
312 GNUNET_free (op);
313}
314
315
323static int
325 const struct UpdateMessage *um)
326{
327 uint16_t size = ntohs (um->header.size);
328 uint16_t name_len = ntohs (um->name_len);
329 const char *str = (const char *) &um[1];
330
331 if ((size < name_len + sizeof(struct UpdateMessage)) ||
332 ((0 != name_len) && ('\0' != str[name_len - 1])))
333 {
334 GNUNET_break (0);
335 return GNUNET_SYSERR;
336 }
337 return GNUNET_OK;
338}
339
340
347static void
349 const struct UpdateMessage *um)
350{
351 struct GNUNET_IDENTITY_Handle *h = cls;
352 uint16_t name_len = ntohs (um->name_len);
353 const char *str;
354 size_t key_len;
355 size_t kb_read;
356 struct GNUNET_HashCode id;
357 struct GNUNET_IDENTITY_Ego *ego;
358 struct GNUNET_CRYPTO_PrivateKey private_key;
359 const char *tmp;
360
361 if (GNUNET_YES == ntohs (um->end_of_list))
362 {
363 /* end of initial list of data */
364 if (NULL != h->cb)
365 h->cb (h->cb_cls, NULL, NULL, NULL);
366 return;
367 }
368 tmp = (const char*) &um[1];
369 str = (0 == name_len) ? NULL : tmp;
370 memset (&private_key, 0, sizeof (private_key));
371 key_len = ntohs (um->key_len);
374 key_len,
375 &private_key,
376 &kb_read));
378 GNUNET_CRYPTO_hash (&private_key,
380 &id);
382 &id);
383 if (NULL == ego)
384 {
385 /* ego was created */
386 if (NULL == str)
387 {
388 /* deletion of unknown ego? not allowed */
389 GNUNET_break (0);
391 return;
392 }
393 ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
395 ego->pk = private_key;
396 ego->name = GNUNET_strdup (str);
397 ego->id = id;
400 h->egos,
401 &ego->id,
402 ego,
404 }
405 if (NULL == str)
406 {
407 /* ego was deleted */
410 &ego->id,
411 ego));
412 }
413 else
414 {
415 /* ego changed name */
416 GNUNET_free (ego->name);
417 ego->name = GNUNET_strdup (str);
418 }
419 /* inform application about change */
420 if (NULL != h->cb)
421 h->cb (h->cb_cls,
422 ego,
423 &ego->ctx,
424 str);
425 /* complete deletion */
426 if (NULL == str)
427 {
428 GNUNET_free (ego->name);
429 GNUNET_free (ego);
430 }
431}
432
433
439static void
440reconnect (void *cls)
441{
442 struct GNUNET_IDENTITY_Handle *h = cls;
444 GNUNET_MQ_hd_fixed_size (identity_result_code,
446 struct ResultCodeMessage,
447 h),
448 GNUNET_MQ_hd_var_size (identity_update,
450 struct UpdateMessage,
451 h),
453 };
454 struct GNUNET_MQ_Envelope *env;
456
457 h->reconnect_task = NULL;
459 "Connecting to identity service.\n");
460 GNUNET_assert (NULL == h->mq);
462 "identity",
463 handlers,
465 h);
466 if (NULL == h->mq)
467 return;
468 if (NULL != h->cb)
469 {
473 env);
474 }
475}
476
477
489 void *cb_cls)
490{
492
494 h->cfg = cfg;
495 h->cb = cb;
496 h->cb_cls = cb_cls;
498 GNUNET_YES);
499 reconnect (h);
500 if (NULL == h->mq)
501 {
502 GNUNET_free (h);
503 return NULL;
504 }
505 return h;
506}
507
508
509
516const struct GNUNET_CRYPTO_PrivateKey *
518{
519 return &ego->pk;
520}
521
528void
531{
532 if (GNUNET_NO == ego->pub_initialized)
533 {
534 GNUNET_CRYPTO_key_get_public (&ego->pk, &ego->pub);
536 }
537 *pk = ego->pub;
538}
539
543{
544 key->type = htonl (ktype);
545 switch (ktype)
546 {
549 break;
552 break;
553 default:
554 GNUNET_break (0);
555 return GNUNET_SYSERR;
556 }
557 return GNUNET_OK;
558}
559
562 const char *name,
563 const struct GNUNET_CRYPTO_PrivateKey *privkey,
564 enum GNUNET_CRYPTO_KeyType ktype,
566 void *cont_cls)
567{
568 struct GNUNET_CRYPTO_PrivateKey private_key;
570 struct GNUNET_MQ_Envelope *env;
571 struct CreateRequestMessage *crm;
572 size_t slen;
573 size_t key_len;
574
575 if (NULL == h->mq)
576 return NULL;
577 slen = strlen (name) + 1;
578 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
579 {
580 GNUNET_break (0);
581 return NULL;
582 }
584 op->h = h;
585 op->create_cont = cont;
586 op->cls = cont_cls;
587 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
588 if (NULL == privkey)
589 {
591 private_key_create (ktype, &private_key));
592 }
593 else
594 private_key = *privkey;
596 env = GNUNET_MQ_msg_extra (crm, slen + key_len,
598 crm->name_len = htons (slen);
600 &crm[1],
601 key_len);
602 crm->key_len = htons (key_len);
603 op->pk = private_key;
604 GNUNET_memcpy ((char*) &crm[1] + key_len, name, slen);
606 return op;
607}
608
609
622 const char *old_name,
623 const char *new_name,
625 void *cb_cls)
626{
628 struct GNUNET_MQ_Envelope *env;
629 struct RenameMessage *grm;
630 size_t slen_old;
631 size_t slen_new;
632 char *dst;
633
634 if (NULL == h->mq)
635 return NULL;
636 slen_old = strlen (old_name) + 1;
637 slen_new = strlen (new_name) + 1;
638 if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
639 (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
640 (slen_old + slen_new >=
641 GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
642 {
643 GNUNET_break (0);
644 return NULL;
645 }
647 op->h = h;
648 op->cont = cb;
649 op->cls = cb_cls;
650 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
652 slen_old + slen_new,
654 grm->old_name_len = htons (slen_old);
655 grm->new_name_len = htons (slen_new);
656 dst = (char *) &grm[1];
657 GNUNET_memcpy (dst, old_name, slen_old);
658 GNUNET_memcpy (&dst[slen_old], new_name, slen_new);
660 return op;
661}
662
663
675 const char *name,
677 void *cb_cls)
678{
680 struct GNUNET_MQ_Envelope *env;
681 struct DeleteMessage *gdm;
682 size_t slen;
683
684 if (NULL == h->mq)
685 return NULL;
686 slen = strlen (name) + 1;
687 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
688 {
689 GNUNET_break (0);
690 return NULL;
691 }
693 op->h = h;
694 op->cont = cb;
695 op->cls = cb_cls;
696 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
698 gdm->name_len = htons (slen);
699 gdm->reserved = htons (0);
700 GNUNET_memcpy (&gdm[1], name, slen);
702 return op;
703}
704
705
714void
716{
717 op->cont = NULL;
718 op->cb = NULL;
719 op->create_cont = NULL;
720 memset (&op->pk,
721 0,
722 sizeof (op->pk));
723}
724
725
731void
733{
735
736 GNUNET_assert (NULL != h);
737 if (h->reconnect_task != NULL)
738 {
740 h->reconnect_task = NULL;
741 }
742 if (NULL != h->egos)
743 {
745 &free_ego,
746 h);
748 h->egos = NULL;
749 }
750 while (NULL != (op = h->op_head))
751 {
752 GNUNET_break (NULL == op->cont);
753 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
754 memset (&op->pk,
755 0,
756 sizeof (op->pk));
757 GNUNET_free (op);
758 }
759 if (NULL != h->mq)
760 {
762 h->mq = NULL;
763 }
764 GNUNET_free (h);
765}
766
767
768/* end of identity_api.c */
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:143
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
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static char * name
Name (label) of the records to list.
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
static char * value
Value of the record to add/remove.
Identity service; implements identity management for GNUnet.
Constants for network protocols.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
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.
Definition: client.c:1060
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:480
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:465
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:500
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h, const char *name, const struct GNUNET_CRYPTO_PrivateKey *privkey, enum GNUNET_CRYPTO_KeyType ktype, GNUNET_IDENTITY_CreateContinuation cont, void *cont_cls)
Create a new ego with the given name.
Definition: identity_api.c:561
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *h, const char *old_name, const char *new_name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Renames an existing identity.
Definition: identity_api.c:621
void(* GNUNET_IDENTITY_CreateContinuation)(void *cls, const struct GNUNET_CRYPTO_PrivateKey *pk, enum GNUNET_ErrorCode ec)
Function called once the requested operation has been completed.
const struct GNUNET_CRYPTO_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:517
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h, const char *name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Delete an existing identity.
Definition: identity_api.c:674
void(* GNUNET_IDENTITY_Callback)(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Method called to inform about the egos of this peer.
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:487
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:715
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:732
struct GNUNET_IDENTITY_Ego * GNUNET_IDENTITY_ego_get_anonymous()
Obtain the ego representing 'anonymous' users.
Definition: identity_api.c:157
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_PublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:529
void(* GNUNET_IDENTITY_Continuation)(void *cls, enum GNUNET_ErrorCode ec)
Function called once the requested operation has been completed.
GNUNET_CRYPTO_KeyType
Key type for the generic public key union.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: crypto_pkey.c:430
ssize_t GNUNET_CRYPTO_private_key_get_length(const struct GNUNET_CRYPTO_PrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_PrivateKey.
Definition: crypto_pkey.c:64
ssize_t GNUNET_CRYPTO_write_private_key_to_buffer(const struct GNUNET_CRYPTO_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PrivateKey to a compact buffer.
Definition: crypto_pkey.c:172
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PrivateKey from a compact buffer.
Definition: crypto_pkey.c:146
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#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.
Definition: mq.c:305
#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.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#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.
Definition: mq.c:700
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
627 and 628 unused
#define GNUNET_MESSAGE_TYPE_IDENTITY_START
First message send from identity client to service (to subscribe to updates).
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:979
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.
Definition: scheduler.c:1276
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:579
#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 identity service and API.
static void handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
We received a result code from the service.
Definition: identity_api.c:291
static int check_identity_update(void *cls, const struct UpdateMessage *um)
Check validity of identity update message.
Definition: identity_api.c:324
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: identity_api.c:275
static void reconnect(void *cls)
Try again to connect to the identity service.
Definition: identity_api.c:440
static enum GNUNET_GenericReturnValue private_key_create(enum GNUNET_CRYPTO_KeyType ktype, struct GNUNET_CRYPTO_PrivateKey *key)
Definition: identity_api.c:541
static void handle_identity_update(void *cls, const struct UpdateMessage *um)
Handle identity update message.
Definition: identity_api.c:348
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:197
#define LOG(kind,...)
Definition: identity_api.c:34
static void reschedule_connect(struct GNUNET_IDENTITY_Handle *h)
Reschedule a connect attempt to the service.
Definition: identity_api.c:224
static unsigned int size
Size of the "table".
Definition: peer.c:68
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_SERVICE_COMMUNICATION_FAILED
Communication with service failed.
@ GNUNET_EC_NONE
No error (success).
Client requests creation of an identity.
Definition: identity.h:151
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:160
uint16_t key_len
Key length.
Definition: identity.h:165
Client requests deletion of an identity.
Definition: identity.h:204
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:213
uint16_t reserved
Always zero.
Definition: identity.h:218
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
struct GNUNET_ARM_Handle * h
ARM handle.
Definition: arm_api.c:55
Internal representation of the hash map.
A private key for an identity as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
An identity key as per LSD0001.
uint32_t type
Type of public key.
A 512-bit hashcode.
Handle for an ego.
Definition: identity.h:37
void * ctx
Client context associated with this ego.
Definition: identity.h:61
bool pub_initialized
Set to true once pub was initialized.
Definition: identity.h:66
char * name
Current name associated with this ego.
Definition: identity.h:56
struct GNUNET_CRYPTO_PrivateKey pk
The identity key pair.
Definition: identity.h:51
struct GNUNET_CRYPTO_PublicKey pub
The identity key pair.
Definition: identity.h:46
struct GNUNET_HashCode id
Hash of the private key of this ego.
Definition: identity.h:41
Handle for the service.
Definition: identity_api.c:97
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:106
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:127
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:117
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:132
struct GNUNET_CONTAINER_MultiHashMap * egos
Hash map from the hash of the private key to the respective GNUNET_IDENTITY_Ego handle.
Definition: identity_api.c:112
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: identity_api.c:137
int in_receive
Are we polling for incoming messages right now?
Definition: identity_api.c:147
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: identity_api.c:101
void * cb_cls
Closure for cb.
Definition: identity_api.c:122
struct GNUNET_TIME_Relative reconnect_delay
Time for next connect retry.
Definition: identity_api.c:142
Handle for an operation with the identity service.
Definition: identity_api.c:41
GNUNET_IDENTITY_CreateContinuation create_cont
Continuation to invoke with the result of the transmission; cb and cb will be NULL in this case.
Definition: identity_api.c:73
GNUNET_IDENTITY_Continuation cont
Continuation to invoke with the result of the transmission; cb and create_cont will be NULL in this c...
Definition: identity_api.c:67
struct GNUNET_CRYPTO_PrivateKey pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:78
struct GNUNET_IDENTITY_Operation * prev
We keep operations in a DLL.
Definition: identity_api.c:55
struct GNUNET_IDENTITY_Operation * next
We keep operations in a DLL.
Definition: identity_api.c:50
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:45
void * cls
Closure for cont or cb.
Definition: identity_api.c:89
const struct GNUNET_MessageHeader * msg
Message to send to the identity service.
Definition: identity_api.c:61
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:84
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Header for all communications.
Entry in list of pending tasks.
Definition: scheduler.c:135
Time for relative time used by GNUnet, in microseconds.
Client requests renaming of an identity.
Definition: identity.h:178
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:187
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:192
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:81
uint32_t result_code
Status code for the last operation, in NBO.
Definition: identity.h:91
Service informs client about status of a pseudonym.
Definition: identity.h:114
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition: identity.h:129
uint16_t key_len
Key length.
Definition: identity.h:134
uint16_t name_len
Number of bytes in ego name string including 0-termination, in NBO; 0 if the ego was deleted.
Definition: identity.h:124
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.
Definition: identity.h:118