GNUnet  0.11.x
identity_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2013, 2016 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_protocols.h"
31 #include "identity.h"
32 
33 #define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
34 
35 
40 {
45 
50 
55 
60  const struct GNUNET_MessageHeader *msg;
61 
67 
73 
78 
84 
88  void *cls;
89 };
90 
91 
96 {
101 
106 
112 
117 
121  void *cb_cls;
122 
127 
132 
137 
141  struct GNUNET_TIME_Relative reconnect_delay;
142 
147 };
148 
149 
155 struct GNUNET_IDENTITY_Ego *
157 {
158  static struct GNUNET_IDENTITY_Ego anon;
159  static int setup;
160 
161  if (setup)
162  return &anon;
163  anon.pk.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
164  anon.pub.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
166  GNUNET_CRYPTO_hash (&anon.pk,
167  sizeof(anon.pk),
168  &anon.id);
169  setup = 1;
170  return &anon;
171 }
172 
173 
178 {
179  key->type = privkey->type;
180  switch (ntohl (privkey->type))
181  {
184  &key->ecdsa_key);
185  break;
188  &key->eddsa_key);
189  break;
190  default:
191  GNUNET_break (0);
192  return GNUNET_SYSERR;
193  }
194  return GNUNET_OK;
195 }
196 
197 
198 static int
201 {
202  key->type = htonl (ktype);
203  switch (ktype)
204  {
207  break;
210  break;
211  default:
212  GNUNET_break (0);
213  return GNUNET_SYSERR;
214  }
215  return GNUNET_OK;
216 }
217 
218 
224 static void
225 reconnect (void *cls);
226 
227 
236 static int
237 free_ego (void *cls,
238  const struct GNUNET_HashCode *key,
239  void *value)
240 {
241  struct GNUNET_IDENTITY_Handle *h = cls;
242  struct GNUNET_IDENTITY_Ego *ego = value;
243 
244  if (NULL != h->cb)
245  h->cb (h->cb_cls, ego,
246  &ego->ctx,
247  NULL);
248  GNUNET_free (ego->name);
251  key,
252  value));
253  GNUNET_free (ego);
254  return GNUNET_OK;
255 }
256 
257 
263 static void
265 {
267 
268  GNUNET_assert (NULL == h->reconnect_task);
269 
270  if (NULL != h->mq)
271  {
272  GNUNET_MQ_destroy (h->mq);
273  h->mq = NULL;
274  }
275  while (NULL != (op = h->op_head))
276  {
278  h->op_tail,
279  op);
280  if (NULL != op->cont)
281  op->cont (op->cls,
282  "Error in communication with the identity service");
283  else if (NULL != op->cb)
284  op->cb (op->cls, NULL, NULL, NULL);
285  else if (NULL != op->create_cont)
286  op->create_cont (op->cls,
287  NULL,
288  "Failed to communicate with the identity service");
289  GNUNET_free (op);
290  }
292  &free_ego,
293  h);
295  "Scheduling task to reconnect to identity service in %s.\n",
297  GNUNET_YES));
298  h->reconnect_task =
300  &reconnect,
301  h);
303 }
304 
305 
314 static void
316  enum GNUNET_MQ_Error error)
317 {
318  struct GNUNET_IDENTITY_Handle *h = cls;
319 
320  reschedule_connect (h);
321 }
322 
323 
332 static int
334  const struct ResultCodeMessage *rcm)
335 {
336  if (sizeof(*rcm) != htons (rcm->header.size))
338  return GNUNET_OK;
339 }
340 
341 
348 static void
350  const struct ResultCodeMessage *rcm)
351 {
352  struct GNUNET_IDENTITY_Handle *h = cls;
354  uint16_t size = ntohs (rcm->header.size) - sizeof(*rcm);
355  const char *str = (0 == size) ? NULL : (const char *) &rcm[1];
356 
357  op = h->op_head;
358  if (NULL == op)
359  {
360  GNUNET_break (0);
361  reschedule_connect (h);
362  return;
363  }
365  if (NULL != op->cont)
366  op->cont (op->cls, str);
367  else if (NULL != op->cb)
368  op->cb (op->cls, NULL, NULL, NULL);
369  else if (NULL != op->create_cont)
370  op->create_cont (op->cls, (NULL == str) ? &op->pk : NULL, str);
371  GNUNET_free (op);
372 }
373 
374 
382 static int
384  const struct UpdateMessage *um)
385 {
386  uint16_t size = ntohs (um->header.size);
387  uint16_t name_len = ntohs (um->name_len);
388  const char *str = (const char *) &um[1];
389 
390  if ((size != name_len + sizeof(struct UpdateMessage)) ||
391  ((0 != name_len) && ('\0' != str[name_len - 1])))
392  {
393  GNUNET_break (0);
394  return GNUNET_SYSERR;
395  }
396  return GNUNET_OK;
397 }
398 
399 
406 static void
408  const struct UpdateMessage *um)
409 {
410  struct GNUNET_IDENTITY_Handle *h = cls;
411  uint16_t name_len = ntohs (um->name_len);
412  const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
413  struct GNUNET_HashCode id;
414  struct GNUNET_IDENTITY_Ego *ego;
415 
416  if (GNUNET_YES == ntohs (um->end_of_list))
417  {
418  /* end of initial list of data */
419  if (NULL != h->cb)
420  h->cb (h->cb_cls, NULL, NULL, NULL);
421  return;
422  }
424  sizeof (um->private_key),
425  &id);
427  &id);
428  if (NULL == ego)
429  {
430  /* ego was created */
431  if (NULL == str)
432  {
433  /* deletion of unknown ego? not allowed */
434  GNUNET_break (0);
435  reschedule_connect (h);
436  return;
437  }
438  ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
439  ego->pub_initialized = GNUNET_NO;
440  ego->pk = um->private_key;
441  ego->name = GNUNET_strdup (str);
442  ego->id = id;
445  h->egos,
446  &ego->id,
447  ego,
449  }
450  if (NULL == str)
451  {
452  /* ego was deleted */
455  &ego->id,
456  ego));
457  }
458  else
459  {
460  /* ego changed name */
461  GNUNET_free (ego->name);
462  ego->name = GNUNET_strdup (str);
463  }
464  /* inform application about change */
465  if (NULL != h->cb)
466  h->cb (h->cb_cls,
467  ego,
468  &ego->ctx,
469  str);
470  /* complete deletion */
471  if (NULL == str)
472  {
473  GNUNET_free (ego->name);
474  GNUNET_free (ego);
475  }
476 }
477 
478 
487 static int
489  const struct SetDefaultMessage *sdm)
490 {
491  uint16_t size = ntohs (sdm->header.size) - sizeof(*sdm);
492  uint16_t name_len = ntohs (sdm->name_len);
493  const char *str = (const char *) &sdm[1];
494 
495  if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1])))
496  {
497  GNUNET_break (0);
498  return GNUNET_SYSERR;
499  }
500  GNUNET_break (0 == ntohs (sdm->reserved));
501  return GNUNET_OK;
502 }
503 
504 
512 static void
514  const struct SetDefaultMessage *sdm)
515 {
516  struct GNUNET_IDENTITY_Handle *h = cls;
518  struct GNUNET_HashCode id;
519  struct GNUNET_IDENTITY_Ego *ego;
520 
522  sizeof(sdm->private_key),
523  &id);
525  &id);
526  if (NULL == ego)
527  {
528  GNUNET_break (0);
529  reschedule_connect (h);
530  return;
531  }
532  op = h->op_head;
533  if (NULL == op)
534  {
535  GNUNET_break (0);
536  reschedule_connect (h);
537  return;
538  }
540  "Received SET_DEFAULT message from identity service\n");
542  h->op_tail,
543  op);
544  if (NULL != op->cb)
545  op->cb (op->cls,
546  ego,
547  &ego->ctx,
548  ego->name);
549  GNUNET_free (op);
550 }
551 
552 
558 static void
559 reconnect (void *cls)
560 {
561  struct GNUNET_IDENTITY_Handle *h = cls;
562  struct GNUNET_MQ_MessageHandler handlers[] = {
563  GNUNET_MQ_hd_var_size (identity_result_code,
565  struct ResultCodeMessage,
566  h),
567  GNUNET_MQ_hd_var_size (identity_update,
569  struct UpdateMessage,
570  h),
571  GNUNET_MQ_hd_var_size (identity_set_default,
573  struct SetDefaultMessage,
574  h),
576  };
577  struct GNUNET_MQ_Envelope *env;
578  struct GNUNET_MessageHeader *msg;
579 
580  h->reconnect_task = NULL;
582  "Connecting to identity service.\n");
583  GNUNET_assert (NULL == h->mq);
584  h->mq = GNUNET_CLIENT_connect (h->cfg,
585  "identity",
586  handlers,
588  h);
589  if (NULL == h->mq)
590  return;
591  if (NULL != h->cb)
592  {
593  env = GNUNET_MQ_msg (msg,
595  GNUNET_MQ_send (h->mq,
596  env);
597  }
598 }
599 
600 
609 struct GNUNET_IDENTITY_Handle *
612  void *cb_cls)
613 {
614  struct GNUNET_IDENTITY_Handle *h;
615 
616  h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
617  h->cfg = cfg;
618  h->cb = cb;
619  h->cb_cls = cb_cls;
621  GNUNET_YES);
622  reconnect (h);
623  if (NULL == h->mq)
624  {
625  GNUNET_free (h);
626  return NULL;
627  }
628  return h;
629 }
630 
631 
638 const struct GNUNET_IDENTITY_PrivateKey *
640 {
641  return &ego->pk;
642 }
643 
644 
651 void
654 {
655  if (GNUNET_NO == ego->pub_initialized)
656  {
657  GNUNET_IDENTITY_key_get_public (&ego->pk, &ego->pub);
659  }
660  *pk = ego->pub;
661 }
662 
663 
676  const char *service_name,
678  void *cb_cls)
679 {
681  struct GNUNET_MQ_Envelope *env;
682  struct GetDefaultMessage *gdm;
683  size_t slen;
684 
685  if (NULL == h->mq)
686  return NULL;
687  GNUNET_assert (NULL != h->cb);
688  slen = strlen (service_name) + 1;
689  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage))
690  {
691  GNUNET_break (0);
692  return NULL;
693  }
695  op->h = h;
696  op->cb = cb;
697  op->cls = cb_cls;
699  env =
701  gdm->name_len = htons (slen);
702  gdm->reserved = htons (0);
703  GNUNET_memcpy (&gdm[1], service_name, slen);
704  GNUNET_MQ_send (h->mq, env);
705  return op;
706 }
707 
708 
721  const char *service_name,
722  struct GNUNET_IDENTITY_Ego *ego,
724  void *cont_cls)
725 {
727  struct GNUNET_MQ_Envelope *env;
728  struct SetDefaultMessage *sdm;
729  size_t slen;
730 
731  if (NULL == h->mq)
732  return NULL;
733  GNUNET_assert (NULL != h->cb);
734  slen = strlen (service_name) + 1;
735  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage))
736  {
737  GNUNET_break (0);
738  return NULL;
739  }
741  op->h = h;
742  op->cont = cont;
743  op->cls = cont_cls;
745  env =
747  sdm->name_len = htons (slen);
748  sdm->reserved = htons (0);
749  sdm->private_key = ego->pk;
750  GNUNET_memcpy (&sdm[1], service_name, slen);
751  GNUNET_MQ_send (h->mq, env);
752  return op;
753 }
754 
755 
758  const char *name,
759  const struct GNUNET_IDENTITY_PrivateKey *privkey,
760  enum GNUNET_IDENTITY_KeyType ktype,
762  void *cont_cls)
763 {
765  struct GNUNET_MQ_Envelope *env;
766  struct CreateRequestMessage *crm;
767  size_t slen;
768 
769  if (NULL == h->mq)
770  return NULL;
771  slen = strlen (name) + 1;
772  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
773  {
774  GNUNET_break (0);
775  return NULL;
776  }
778  op->h = h;
779  op->create_cont = cont;
780  op->cls = cont_cls;
783  crm->name_len = htons (slen);
784  crm->reserved = htons (0);
785  if (NULL == privkey)
786  {
788  private_key_create (ktype, &crm->private_key));
789  }
790  else
791  crm->private_key = *privkey;
792  op->pk = crm->private_key;
793  GNUNET_memcpy (&crm[1], name, slen);
794  GNUNET_MQ_send (h->mq, env);
795  return op;
796 }
797 
798 
811  const char *old_name,
812  const char *new_name,
814  void *cb_cls)
815 {
817  struct GNUNET_MQ_Envelope *env;
818  struct RenameMessage *grm;
819  size_t slen_old;
820  size_t slen_new;
821  char *dst;
822 
823  if (NULL == h->mq)
824  return NULL;
825  slen_old = strlen (old_name) + 1;
826  slen_new = strlen (new_name) + 1;
827  if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
828  (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
829  (slen_old + slen_new >=
830  GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
831  {
832  GNUNET_break (0);
833  return NULL;
834  }
836  op->h = h;
837  op->cont = cb;
838  op->cls = cb_cls;
840  env = GNUNET_MQ_msg_extra (grm,
841  slen_old + slen_new,
843  grm->old_name_len = htons (slen_old);
844  grm->new_name_len = htons (slen_new);
845  dst = (char *) &grm[1];
846  GNUNET_memcpy (dst, old_name, slen_old);
847  GNUNET_memcpy (&dst[slen_old], new_name, slen_new);
848  GNUNET_MQ_send (h->mq, env);
849  return op;
850 }
851 
852 
864  const char *name,
866  void *cb_cls)
867 {
869  struct GNUNET_MQ_Envelope *env;
870  struct DeleteMessage *gdm;
871  size_t slen;
872 
873  if (NULL == h->mq)
874  return NULL;
875  slen = strlen (name) + 1;
876  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
877  {
878  GNUNET_break (0);
879  return NULL;
880  }
882  op->h = h;
883  op->cont = cb;
884  op->cls = cb_cls;
887  gdm->name_len = htons (slen);
888  gdm->reserved = htons (0);
889  GNUNET_memcpy (&gdm[1], name, slen);
890  GNUNET_MQ_send (h->mq, env);
891  return op;
892 }
893 
894 
903 void
905 {
906  op->cont = NULL;
907  op->cb = NULL;
908  op->create_cont = NULL;
909  memset (&op->pk,
910  0,
911  sizeof (op->pk));
912 }
913 
914 
920 void
922 {
924 
925  GNUNET_assert (NULL != h);
926  if (h->reconnect_task != NULL)
927  {
929  h->reconnect_task = NULL;
930  }
931  if (NULL != h->egos)
932  {
934  &free_ego,
935  h);
937  h->egos = NULL;
938  }
939  while (NULL != (op = h->op_head))
940  {
941  GNUNET_break (NULL == op->cont);
943  memset (&op->pk,
944  0,
945  sizeof (op->pk));
946  GNUNET_free (op);
947  }
948  if (NULL != h->mq)
949  {
950  GNUNET_MQ_destroy (h->mq);
951  h->mq = NULL;
952  }
953  GNUNET_free (h);
954 }
955 
956 
957 ssize_t
959 {
960  switch (ntohl (key->type))
961  {
963  return sizeof (key->type) + sizeof (key->ecdsa_key);
964  break;
966  return sizeof (key->type) + sizeof (key->eddsa_key);
967  break;
968  default:
969  GNUNET_break (0);
970  }
971  return -1;
972 }
973 
974 
975 ssize_t
977 {
978  switch (ntohl (key->type))
979  {
981  return sizeof (key->type) + sizeof (key->ecdsa_key);
982  break;
984  return sizeof (key->type) + sizeof (key->eddsa_key);
985  break;
986  default:
987  GNUNET_break (0);
988  }
989  return -1;
990 }
991 
992 
993 ssize_t
995  const void*buffer,
996  size_t len)
997 {
998  if (len < sizeof (key->type))
999  return -1;
1000  GNUNET_memcpy (&(key->type), buffer, sizeof (key->type));
1001  const ssize_t length = GNUNET_IDENTITY_key_get_length (key);
1002  if (len < length)
1003  return -1;
1004  if (length < 0)
1005  return -2;
1006  GNUNET_memcpy (&(key->ecdsa_key), buffer + sizeof (key->type), length
1007  - sizeof (key->type));
1008  return length;
1009 }
1010 
1011 
1012 ssize_t
1015  void*buffer,
1016  size_t len)
1017 {
1018  const ssize_t length = GNUNET_IDENTITY_key_get_length (key);
1019  if (len < length)
1020  return -1;
1021  if (length < 0)
1022  return -2;
1023  GNUNET_memcpy (buffer, key, length);
1024  return length;
1025 }
1026 
1027 
1028 ssize_t
1031 {
1032  switch (ntohl (sig->type))
1033  {
1035  return sizeof (sig->type) + sizeof (sig->ecdsa_signature);
1036  break;
1038  return sizeof (sig->type) + sizeof (sig->eddsa_signature);
1039  break;
1040  default:
1041  GNUNET_break (0);
1042  }
1043  return -1;
1044 }
1045 
1046 
1047 ssize_t
1050  const void*buffer,
1051  size_t len)
1052 {
1053  if (len < sizeof (sig->type))
1054  return -1;
1055  GNUNET_memcpy (&(sig->type), buffer, sizeof (sig->type));
1056  const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig);
1057  if (len < length)
1058  return -1;
1059  if (length < 0)
1060  return -2;
1061  GNUNET_memcpy (&(sig->ecdsa_signature), buffer + sizeof (sig->type), length
1062  - sizeof (sig->type));
1063  return length;
1064 }
1065 
1066 
1067 ssize_t
1070  void*buffer,
1071  size_t len)
1072 {
1073  const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig);
1074  if (len < length)
1075  return -1;
1076  if (length < 0)
1077  return -2;
1078  GNUNET_memcpy (buffer, &(sig->type), sizeof (sig->type));
1079  GNUNET_memcpy (buffer + sizeof (sig->type), &(sig->ecdsa_signature), length
1080  - sizeof (sig->type));
1081  return length;
1082 }
1083 
1084 
1085 int
1088  const struct
1090  struct GNUNET_IDENTITY_Signature *sig)
1091 {
1092  sig->type = priv->type;
1093  switch (ntohl (priv->type))
1094  {
1096  return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose,
1097  &(sig->ecdsa_signature));
1098  break;
1100  return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose,
1101  &(sig->eddsa_signature));
1102  break;
1103  default:
1104  GNUNET_break (0);
1105  }
1106 
1107  return GNUNET_SYSERR;
1108 }
1109 
1110 
1111 int
1113  const struct
1115  const struct GNUNET_IDENTITY_Signature *sig,
1116  const struct GNUNET_IDENTITY_PublicKey *pub)
1117 {
1118  /* check type matching of 'sig' and 'pub' */
1119  GNUNET_assert (ntohl (pub->type) == ntohl (sig->type));
1120  switch (ntohl (pub->type))
1121  {
1123  return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate,
1124  &(sig->ecdsa_signature),
1125  &(pub->ecdsa_key));
1126  break;
1128  return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate,
1129  &(sig->eddsa_signature),
1130  &(pub->eddsa_key));
1131  break;
1132  default:
1133  GNUNET_break (0);
1134  }
1135 
1136  return GNUNET_SYSERR;
1137 }
1138 
1139 
1140 ssize_t
1141 GNUNET_IDENTITY_encrypt (const void *block,
1142  size_t size,
1143  const struct GNUNET_IDENTITY_PublicKey *pub,
1144  struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
1145  void *result)
1146 {
1149  struct GNUNET_HashCode hash;
1150  switch (ntohl (pub->type))
1151  {
1153  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_ecdsa (&pk, &(pub->ecdsa_key),
1154  &hash))
1155  return -1;
1156  break;
1158  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_eddsa (&pk, &(pub->eddsa_key),
1159  &hash))
1160  return -1;
1161  break;
1162  default:
1163  return -1;
1164  }
1169  GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv);
1170  GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash));
1171  const ssize_t encrypted = GNUNET_CRYPTO_symmetric_encrypt (block, size, &key,
1172  &iv, result);
1173  GNUNET_CRYPTO_zero_keys (&key, sizeof(key));
1174  GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv));
1175  return encrypted;
1176 }
1177 
1178 
1179 ssize_t
1180 GNUNET_IDENTITY_decrypt (const void *block,
1181  size_t size,
1182  const struct GNUNET_IDENTITY_PrivateKey *priv,
1183  const struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
1184  void *result)
1185 {
1186  struct GNUNET_HashCode hash;
1187  switch (ntohl (priv->type))
1188  {
1190  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_ecdh (&(priv->ecdsa_key), ecc,
1191  &hash))
1192  return -1;
1193  break;
1195  if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_ecdh (&(priv->eddsa_key), ecc,
1196  &hash))
1197  return -1;
1198  break;
1199  default:
1200  return -1;
1201  }
1204  GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv);
1205  GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash));
1206  const ssize_t decrypted = GNUNET_CRYPTO_symmetric_decrypt (block, size, &key,
1207  &iv, result);
1208  GNUNET_CRYPTO_zero_keys (&key, sizeof(key));
1209  GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv));
1210  return decrypted;
1211 }
1212 
1213 
1214 char *
1217 {
1218  size_t size = GNUNET_IDENTITY_key_get_length (key);
1220  size);
1221 }
1222 
1223 
1224 char *
1227 {
1228  size_t size = private_key_get_length (key);
1230  size);
1231 }
1232 
1233 
1237 {
1239  enum GNUNET_IDENTITY_KeyType ktype;
1240  ret = GNUNET_STRINGS_string_to_data (str,
1241  strlen (str),
1242  key,
1243  sizeof (*key));
1244  if (GNUNET_OK != ret)
1245  return GNUNET_SYSERR;
1246  ktype = ntohl (key->type);
1247  return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; // FIXME other keys, cleaner way?
1248 
1249 }
1250 
1251 
1255 {
1257  enum GNUNET_IDENTITY_KeyType ktype;
1258  ret = GNUNET_STRINGS_string_to_data (str,
1259  strlen (str),
1260  key,
1261  sizeof (*key));
1262  if (GNUNET_OK != ret)
1263  return GNUNET_SYSERR;
1264  ktype = ntohl (key->type);
1265  return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; // FIXME other keys, cleaner way?
1266 }
1267 
1268 
1269 /* end of identity_api.c */
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:610
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
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:111
static void handle_identity_update(void *cls, const struct UpdateMessage *um)
Handle identity update message.
Definition: identity_api.c:407
int GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private ECDSA key.
Definition: crypto_ecc.c:1056
uint16_t reserved
Always zero.
Definition: identity.h:217
#define GNUNET_MESSAGE_TYPE_IDENTITY_START
First message send from identity client to service (to subscribe to updates).
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:569
int GNUNET_IDENTITY_signature_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_IDENTITY_Signature *sig, const struct GNUNET_IDENTITY_PublicKey *pub)
Verify a given signature.
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:904
#define GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
Client sets default identity; or service informs about default identity.
const struct GNUNET_MessageHeader * msg
Message to send to the identity service.
Definition: identity_api.c:60
Used from service to client as a result to the GET_DEFAULT message, used from client to service to SE...
Definition: identity.h:172
struct GNUNET_TIME_Relative reconnect_delay
Time for next connect retry.
Definition: identity_api.c:141
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
ssize_t GNUNET_IDENTITY_encrypt(const void *block, size_t size, const struct GNUNET_IDENTITY_PublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *ecc, void *result)
Encrypt a block with GNUNET_IDENTITY_PublicKey and derives a GNUNET_CRYPTO_EcdhePublicKey which is re...
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
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.
int GNUNET_CRYPTO_ecdh_ecdsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EcDSA public key and a private ECDH key.
Definition: crypto_ecc.c:1111
Common type definitions for the identity service and API.
uint32_t type
Type of public key.
static void handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
We received a result code from the service.
Definition: identity_api.c:349
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:1063
void GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c:470
uint16_t reserved
Always zero.
Definition: identity.h:161
ssize_t private_key_get_length(const struct GNUNET_IDENTITY_PrivateKey *key)
Definition: identity_api.c:958
GNUNET_IDENTITY_KeyType
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.
Definition: identity.h:120
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:863
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:315
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:182
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE.
Definition: identity.h:85
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
ssize_t GNUNET_IDENTITY_read_key_from_buffer(struct GNUNET_IDENTITY_PublicKey *key, const void *buffer, size_t len)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
Definition: identity_api.c:994
int GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Verify EdDSA signature.
Definition: crypto_ecc.c:819
ssize_t GNUNET_IDENTITY_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:976
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:156
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *h, const char *service_name, struct GNUNET_IDENTITY_Ego *ego, GNUNET_IDENTITY_Continuation cont, void *cont_cls)
Set the preferred/default identity for a service.
Definition: identity_api.c:720
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:242
Client requests renaming of an identity.
Definition: identity.h:232
struct GNUNET_IDENTITY_PublicKey pub
The identity key pair.
Definition: identity.h:46
A private key for an identity as per LSD0001.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t reserved
Always zero.
Definition: identity.h:273
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h, const char *service_name, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Obtain the identity that is currently preferred/default for a service.
Definition: identity_api.c:675
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:83
ssize_t GNUNET_IDENTITY_write_key_to_buffer(const struct GNUNET_IDENTITY_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PublicKey to a compact buffer.
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static int check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
We received a result code from the service.
Definition: identity_api.c:333
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_IDENTITY_PublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:652
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:212
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
char * name
Current name associated with this ego.
Definition: identity.h:56
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
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.
static void reconnect(void *cls)
Try again to connect to the identity service.
Definition: identity_api.c:559
char * GNUNET_IDENTITY_private_key_to_string(const struct GNUNET_IDENTITY_PrivateKey *key)
Creates a (Base32) string representation of the private key.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint16_t reserved
Always zero.
Definition: identity.h:187
#define LOG(kind,...)
Definition: identity_api.c:33
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
struct GNUNET_IDENTITY_PrivateKey pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:508
#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:52
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:1269
Handle for an ego.
Definition: identity.h:36
ssize_t GNUNET_IDENTITY_write_signature_to_buffer(const struct GNUNET_IDENTITY_Signature *sig, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_Signature to a compact buffer.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h, const char *name, const struct GNUNET_IDENTITY_PrivateKey *privkey, enum GNUNET_IDENTITY_KeyType ktype, GNUNET_IDENTITY_CreateContinuation cont, void *cont_cls)
Create a new ego with the given name.
Definition: identity_api.c:757
int GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private EdDSA key.
Definition: crypto_ecc.c:1024
static char * value
Value of the record to add/remove.
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:72
ssize_t GNUNET_IDENTITY_decrypt(const void *block, size_t size, const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, void *result)
Decrypt a given block with GNUNET_IDENTITY_PrivateKey and a given GNUNET_CRYPTO_EcdhePublicKey using ...
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
Handle for the service.
Definition: identity_api.c:95
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: identity_api.c:136
Client requests creation of an identity.
Definition: identity.h:202
struct GNUNET_IDENTITY_PrivateKey private_key
The private key.
Definition: identity.h:222
An identity signature as per LSD0001.
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:702
struct GNUNET_IDENTITY_PrivateKey pk
The identity key pair.
Definition: identity.h:51
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
static int check_identity_update(void *cls, const struct UpdateMessage *um)
Check validity of identity update message.
Definition: identity_api.c:383
int 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.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: identity_api.c:100
static int result
Global testing status.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:921
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
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:66
uint32_t type
Type of signature.
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
static void reschedule_connect(struct GNUNET_IDENTITY_Handle *h)
Reschedule a connect attempt to the service.
Definition: identity_api.c:264
A 512-bit hashcode.
int GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EdDSA public key and a private ECDH key.
Definition: crypto_ecc.c:1084
Message handler for a specific message type.
void GNUNET_CRYPTO_hash_to_aes_key(const struct GNUNET_HashCode *hc, struct GNUNET_CRYPTO_SymmetricSessionKey *skey, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv)
Convert a hashcode into a key.
Definition: crypto_hash.c:222
struct GNUNET_HashCode id
Hash of the private key of this ego.
Definition: identity.h:41
Client requests deletion of an identity.
Definition: identity.h:258
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_public_key_from_string(const char *str, struct GNUNET_IDENTITY_PublicKey *key)
Parses a (Base32) string representation of the public key.
Private ECC key encoded for transmission.
void(* GNUNET_IDENTITY_CreateContinuation)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, const char *emsg)
Function called once the requested operation has been completed.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
void * ctx
Client context associated with this ego.
Definition: identity.h:61
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
Create new identity (client->service).
struct GNUNET_HashCode key
The key used in the DHT.
ssize_t GNUNET_IDENTITY_read_signature_from_buffer(struct GNUNET_IDENTITY_Signature *sig, const void *buffer, size_t len)
Reads a GNUNET_IDENTITY_Signature from a compact buffer.
static unsigned int size
Size of the "table".
Definition: peer.c:67
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:176
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:215
struct GNUNET_IDENTITY_Operation * next
We keep operations in a DLL.
Definition: identity_api.c:49
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:544
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_private_key_from_string(const char *str, struct GNUNET_IDENTITY_PrivateKey *key)
Parses a (Base32) string representation of the private key.
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
uint32_t type
Type of public key.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
int 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.
int GNUNET_CRYPTO_ecdsa_sign_(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
ECDSA Sign a given block.
Definition: crypto_ecc.c:645
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: identity.h:177
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:193
struct GNUNET_IDENTITY_Ego * GNUNET_IDENTITY_ego_get_anonymous()
Obtain the ego representing &#39;anonymous&#39; users.
Definition: identity_api.c:156
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:126
Handle to a message queue.
Definition: mq.c:85
int GNUNET_CRYPTO_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:745
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:247
static void handle_identity_set_default(void *cls, const struct SetDefaultMessage *sdm)
Type of a function to call when we receive a message from the service.
Definition: identity_api.c:513
An identity key as per LSD0001.
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:237
configuration data
Definition: configuration.c:84
const char * name
struct GNUNET_IDENTITY_Operation * prev
We keep operations in a DLL.
Definition: identity_api.c:54
const struct GNUNET_IDENTITY_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:639
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:524
int GNUNET_IDENTITY_sign_(const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_IDENTITY_Signature *sig)
Sign a given block.
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition: identity.h:131
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
int GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:707
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
#define GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
Client requests to know default identity for a subsystem.
static int private_key_create(enum GNUNET_IDENTITY_KeyType ktype, struct GNUNET_IDENTITY_PrivateKey *key)
Definition: identity_api.c:199
bool pub_initialized
Set to true once pub was initialized.
Definition: identity.h:66
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
struct GNUNET_IDENTITY_PrivateKey private_key
The private key.
Definition: identity.h:136
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:268
Header for all communications.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
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:810
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
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:355
void * cb_cls
Closure for cb.
Definition: identity_api.c:121
Client requests knowledge about default identity for a subsystem from identity service.
Definition: identity.h:146
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:937
struct GNUNET_IDENTITY_PrivateKey private_key
The private key.
Definition: identity.h:192
static int check_identity_set_default(void *cls, const struct SetDefaultMessage *sdm)
Function called when we receive a set default message from the service.
Definition: identity_api.c:488
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
ssize_t GNUNET_CRYPTO_symmetric_decrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Decrypt a given block using a symmetric sessionkey.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
void(* GNUNET_IDENTITY_Continuation)(void *cls, const char *emsg)
Function called once the requested operation has been completed.
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for &#39;get&#39; operations (cont and create_cont...
Definition: identity_api.c:83
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:972
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:80
Service informs client about status of a pseudonym.
Definition: identity.h:115
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
int in_receive
Are we polling for incoming messages right now?
Definition: identity_api.c:146
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972