GNUnet  0.17.6
gnunet_identity_service.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2013 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 
45 #ifndef GNUNET_IDENTITY_SERVICE_H
46 #define GNUNET_IDENTITY_SERVICE_H
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #if 0 /* keep Emacsens' auto-indent happy */
51 }
52 #endif
53 #endif
54 
55 #include "gnunet_util_lib.h"
56 
57 
61 #define GNUNET_IDENTITY_VERSION 0x00000100
62 
64 {
70 
76 };
77 
82 
86 struct GNUNET_IDENTITY_Ego;
87 
88 // FIXME: these types are NOT packed,
89 // NOT 64-bit aligned, but used in messages!!??
90 
95 {
101  uint32_t type;
102 
103  union
104  {
109 
114  };
115 };
116 
117 
122 {
128  uint32_t type;
129 
130  union
131  {
136 
141  };
142 };
143 
144 
149 {
155  uint32_t type;
156 
157  union
158  {
163 
168  };
169 };
170 
171 
176 
177 
184 const struct GNUNET_IDENTITY_PrivateKey *
186 
187 
193 struct GNUNET_IDENTITY_Ego *
195 
196 
203 void
205  struct GNUNET_IDENTITY_PublicKey *pk);
206 
207 
241 typedef void
242 (*GNUNET_IDENTITY_Callback) (void *cls,
243  struct GNUNET_IDENTITY_Ego *ego,
244  void **ctx,
245  const char *name);
246 
247 
256 struct GNUNET_IDENTITY_Handle *
259  void *cb_cls);
260 
261 
273  const char *service_name,
275  void *cb_cls);
276 
277 
285 typedef void
287  const char *emsg);
288 
289 
302  const char *service_name,
303  struct GNUNET_IDENTITY_Ego *ego,
305  void *cont_cls);
306 
307 
313 void
315 
316 
325 typedef void
327  void *cls,
328  const struct GNUNET_IDENTITY_PrivateKey *pk,
329  const char *emsg);
330 
331 
345  const char *name,
346  const struct GNUNET_IDENTITY_PrivateKey *privkey,
347  enum GNUNET_IDENTITY_KeyType ktype,
349  void *cont_cls);
350 
351 
364  const char *old_name,
365  const char *new_name,
367  void *cb_cls);
368 
369 
381  const char *name,
383  void *cb_cls);
384 
385 
394 void
396 
397 
408 ssize_t
410 
411 
424 ssize_t
426  const void*buffer,
427  size_t len);
428 
429 
442 ssize_t
445  void*buffer,
446  size_t len);
447 
448 
459 ssize_t
462 
463 
474 ssize_t
476 
477 
478 
491 ssize_t
494  const void*buffer,
495  size_t len);
496 
497 
510 ssize_t
513  void*buffer,
514  size_t len);
515 
516 
531 GNUNET_IDENTITY_sign_ (const struct
533  const struct
535  struct GNUNET_IDENTITY_Signature *sig);
536 
551 GNUNET_IDENTITY_sign_raw_ (const struct
553  const struct
555  unsigned char *sig);
556 
557 
569 #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \
570  /* check size is set correctly */ \
571  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
572  /* check 'ps' begins with the purpose */ \
573  GNUNET_static_assert (((void*) (ps)) == \
574  ((void*) &(ps)->purpose)); \
575  GNUNET_assert (GNUNET_OK == \
576  GNUNET_IDENTITY_sign_ (priv, \
577  &(ps)->purpose, \
578  sig)); \
579 } while (0)
580 
581 
600 GNUNET_IDENTITY_signature_verify_ (uint32_t purpose,
601  const struct
603  const struct GNUNET_IDENTITY_Signature *sig,
604  const struct
606 
623 GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose,
624  const struct
626  validate,
627  const unsigned char *sig,
628  const struct
630 
631 
645 #define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \
646  /* check size is set correctly */ \
647  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
648  /* check 'ps' begins with the purpose */ \
649  GNUNET_static_assert (((void*) (ps)) == \
650  ((void*) &(ps)->purpose)); \
651  GNUNET_IDENTITY_signature_verify_ (purp, \
652  &(ps)->purpose, \
653  sig, \
654  pub); \
655  })
656 
657 
673 ssize_t
674 GNUNET_IDENTITY_encrypt (const void *block,
675  size_t size,
676  const struct GNUNET_IDENTITY_PublicKey *pub,
677  struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
678  void *result);
679 
680 
695 ssize_t
696 GNUNET_IDENTITY_decrypt (const void *block,
697  size_t size,
698  const struct
700  const struct
702  void *result);
703 
704 
713 char *
716 
717 
726 char *
729 
730 
742 
743 
755 
756 
765 GNUNET_IDENTITY_key_get_public (const struct
768 
769 
770 /* ************* convenience API to lookup an ego ***************** */
771 
778 typedef void
780  struct GNUNET_IDENTITY_Ego *ego);
781 
786 
787 
799  const char *name,
801  void *cb_cls);
802 
803 
809 void
811 
819 typedef void
821  void *cls,
822  const struct GNUNET_IDENTITY_PrivateKey *priv,
823  const char *ego_name);
824 
825 
830 
831 
847  const char *suffix,
849  void *cb_cls);
850 
851 
857 void
860 
861 
862 #if 0 /* keep Emacsens' auto-indent happy */
863 {
864 #endif
865 #ifdef __cplusplus
866 }
867 #endif
868 
869 /* ifndef GNUNET_IDENTITY_SERVICE_H */
870 #endif
871  /* end of group identity */
873  /* end of group addition */
875 
876 /* end of gnunet_identity_service.h */
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_HashCode key
The key used in the DHT.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
char * ego_name
static int result
Global testing status.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
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
void(* GNUNET_IDENTITY_CreateContinuation)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, const char *emsg)
Function called once the requested operation has been completed.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_sign_(const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_IDENTITY_Signature *sig)
Sign a given block.
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.
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.
GNUNET_IDENTITY_KeyType
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *id, const char *old_name, const char *new_name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Renames an existing ego.
Definition: identity_api.c:810
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 ...
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
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...
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.
void(* GNUNET_IDENTITY_Continuation)(void *cls, const char *emsg)
Function called once the requested operation has been completed.
char * GNUNET_IDENTITY_private_key_to_string(const struct GNUNET_IDENTITY_PrivateKey *key)
Creates a (Base32) string representation of the private key.
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *id, 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
enum GNUNET_GenericReturnValue 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_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
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.
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.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_sign_raw_(const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, unsigned char *sig)
Sign a given block.
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_signature_verify_raw_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const unsigned char *sig, const struct GNUNET_IDENTITY_PublicKey *pub)
Verify a given signature.
void(* GNUNET_IDENTITY_EgoSuffixCallback)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *priv, const char *ego_name)
Function called with the result.
ssize_t GNUNET_IDENTITY_signature_get_raw_length_by_type(const uint32_t type)
Get the compacted length of a signature by type.
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:904
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *id, const char *service_name, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Obtain the ego that is currently preferred/default for a service.
Definition: identity_api.c:675
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
void(* GNUNET_IDENTITY_EgoCallback)(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Function called with the result.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:921
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *id, const char *service_name, struct GNUNET_IDENTITY_Ego *ego, GNUNET_IDENTITY_Continuation cont, void *cont_cls)
Set the preferred/default ego for a service.
Definition: identity_api.c:720
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.
struct GNUNET_IDENTITY_Ego * GNUNET_IDENTITY_ego_get_anonymous(void)
Obtain the ego representing 'anonymous' users.
Definition: identity_api.c:156
struct GNUNET_IDENTITY_EgoLookup * GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_IDENTITY_EgoCallback cb, void *cb_cls)
Lookup an ego by name.
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *id, const char *name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Delete an existing ego.
Definition: identity_api.c:863
struct GNUNET_IDENTITY_EgoSuffixLookup * GNUNET_IDENTITY_ego_lookup_by_suffix(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *suffix, GNUNET_IDENTITY_EgoSuffixCallback cb, void *cb_cls)
Obtain the ego with the maximum suffix match between the ego's name and the given domain name suffix.
void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(struct GNUNET_IDENTITY_EgoSuffixLookup *el)
Abort ego suffix lookup attempt.
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.
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:991
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.
@ GNUNET_IDENTITY_TYPE_ECDSA
The identity type.
@ GNUNET_IDENTITY_TYPE_EDDSA
EDDSA identity.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
static unsigned int size
Size of the "table".
Definition: peer.c:67
const char * name
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
Private ECC key encoded for transmission.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
an ECC signature using ECDSA
Private ECC key encoded for transmission.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
an ECC signature using EdDSA.
Handle for ego lookup.
void * cb_cls
Closure for cb.
GNUNET_IDENTITY_EgoCallback cb
Function to call with the result.
GNUNET_IDENTITY_EgoSuffixCallback cb
Function to call with the result.
char * suffix
Suffix we are looking up.
Handle for an ego.
Definition: identity.h:37
Handle for the service.
Definition: identity_api.c:96
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
void * cb_cls
Closure for cb.
Definition: identity_api.c:121
Handle for an operation with the identity service.
Definition: identity_api.c:40
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
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:83
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.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
An identity key as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
An identity signature as per LSD0001.
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
uint32_t type
Type of signature.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model