GNUnet  0.16.x
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 
42 #ifndef GNUNET_IDENTITY_SERVICE_H
43 #define GNUNET_IDENTITY_SERVICE_H
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #if 0 /* keep Emacsens' auto-indent happy */
48 }
49 #endif
50 #endif
51 
52 #include "gnunet_util_lib.h"
53 
54 
58 #define GNUNET_IDENTITY_VERSION 0x00000100
59 
61 {
67 
73 };
74 
79 
83 struct GNUNET_IDENTITY_Ego;
84 
85 // FIXME: these types are NOT packed,
86 // NOT 64-bit aligned, but used in messages!!??
87 
92 {
98  uint32_t type;
99 
100  union
101  {
106 
111  };
112 };
113 
114 
119 {
125  uint32_t type;
126 
127  union
128  {
133 
138  };
139 };
140 
141 
146 {
152  uint32_t type;
153 
154  union
155  {
160 
165  };
166 };
167 
168 
173 
174 
181 const struct GNUNET_IDENTITY_PrivateKey *
183 
184 
190 struct GNUNET_IDENTITY_Ego *
192 
193 
200 void
202  struct GNUNET_IDENTITY_PublicKey *pk);
203 
204 
238 typedef void
239 (*GNUNET_IDENTITY_Callback) (void *cls,
240  struct GNUNET_IDENTITY_Ego *ego,
241  void **ctx,
242  const char *name);
243 
244 
253 struct GNUNET_IDENTITY_Handle *
256  void *cb_cls);
257 
258 
270  const char *service_name,
272  void *cb_cls);
273 
274 
282 typedef void
284  const char *emsg);
285 
286 
299  const char *service_name,
300  struct GNUNET_IDENTITY_Ego *ego,
302  void *cont_cls);
303 
304 
310 void
312 
313 
322 typedef void
324  void *cls,
325  const struct GNUNET_IDENTITY_PrivateKey *pk,
326  const char *emsg);
327 
328 
342  const char *name,
343  const struct GNUNET_IDENTITY_PrivateKey *privkey,
344  enum GNUNET_IDENTITY_KeyType ktype,
346  void *cont_cls);
347 
348 
361  const char *old_name,
362  const char *new_name,
364  void *cb_cls);
365 
366 
378  const char *name,
380  void *cb_cls);
381 
382 
391 void
393 
394 
405 ssize_t
407 
408 
421 ssize_t
423  const void*buffer,
424  size_t len);
425 
426 
439 ssize_t
442  void*buffer,
443  size_t len);
444 
445 
456 ssize_t
459 
460 
471 ssize_t
473 
474 
475 
488 ssize_t
491  const void*buffer,
492  size_t len);
493 
494 
507 ssize_t
510  void*buffer,
511  size_t len);
512 
513 
528 GNUNET_IDENTITY_sign_ (const struct
530  const struct
532  struct GNUNET_IDENTITY_Signature *sig);
533 
548 GNUNET_IDENTITY_sign_raw_ (const struct
550  const struct
552  unsigned char *sig);
553 
554 
566 #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \
567  /* check size is set correctly */ \
568  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
569  /* check 'ps' begins with the purpose */ \
570  GNUNET_static_assert (((void*) (ps)) == \
571  ((void*) &(ps)->purpose)); \
572  GNUNET_assert (GNUNET_OK == \
573  GNUNET_IDENTITY_sign_ (priv, \
574  &(ps)->purpose, \
575  sig)); \
576 } while (0)
577 
578 
597 GNUNET_IDENTITY_signature_verify_ (uint32_t purpose,
598  const struct
600  const struct GNUNET_IDENTITY_Signature *sig,
601  const struct
603 
620 GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose,
621  const struct
623  validate,
624  const unsigned char *sig,
625  const struct
627 
628 
642 #define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \
643  /* check size is set correctly */ \
644  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
645  /* check 'ps' begins with the purpose */ \
646  GNUNET_static_assert (((void*) (ps)) == \
647  ((void*) &(ps)->purpose)); \
648  GNUNET_IDENTITY_signature_verify_ (purp, \
649  &(ps)->purpose, \
650  sig, \
651  pub); \
652  })
653 
654 
670 ssize_t
671 GNUNET_IDENTITY_encrypt (const void *block,
672  size_t size,
673  const struct GNUNET_IDENTITY_PublicKey *pub,
674  struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
675  void *result);
676 
677 
692 ssize_t
693 GNUNET_IDENTITY_decrypt (const void *block,
694  size_t size,
695  const struct
697  const struct
699  void *result);
700 
701 
710 char *
713 
714 
723 char *
726 
727 
739 
740 
752 
753 
762 GNUNET_IDENTITY_key_get_public (const struct
765 
766 
767 /* ************* convenience API to lookup an ego ***************** */
768 
775 typedef void
777  struct GNUNET_IDENTITY_Ego *ego);
778 
783 
784 
796  const char *name,
798  void *cb_cls);
799 
800 
806 void
808 
816 typedef void
818  void *cls,
819  const struct GNUNET_IDENTITY_PrivateKey *priv,
820  const char *ego_name);
821 
822 
827 
828 
844  const char *suffix,
846  void *cb_cls);
847 
848 
854 void
857 
858 
859 #if 0 /* keep Emacsens' auto-indent happy */
860 {
861 #endif
862 #ifdef __cplusplus
863 }
864 #endif
865 
866 /* ifndef GNUNET_IDENTITY_SERVICE_H */
867 #endif
868  /* end of group identity */
870 
871 /* 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.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
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.
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