GNUnet  0.19.3
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 
56 #include "gnunet_util_lib.h"
57 
58 
62 #define GNUNET_IDENTITY_VERSION 0x00000100
63 
65 {
71 
77 };
78 
83 
87 struct GNUNET_IDENTITY_Ego;
88 
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  enum GNUNET_ErrorCode ec);
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  enum GNUNET_ErrorCode ec);
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 
426  size_t len,
427  struct
429  size_t *read);
430 
441 ssize_t
444 
445 
458 ssize_t
461  void*buffer,
462  size_t len);
463 
464 
479  size_t len,
480  struct
482  size_t *read);
483 
484 
497 ssize_t
500  void*buffer,
501  size_t len);
502 
503 
514 ssize_t
517 
518 
529 ssize_t
531 
532 
533 
546 ssize_t
549  const void*buffer,
550  size_t len);
551 
552 
565 ssize_t
568  void*buffer,
569  size_t len);
570 
571 
586 GNUNET_IDENTITY_sign_ (const struct
588  const struct
590  struct GNUNET_IDENTITY_Signature *sig);
591 
606 GNUNET_IDENTITY_sign_raw_ (const struct
608  const struct
610  unsigned char *sig);
611 
612 
624 #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \
625  /* check size is set correctly */ \
626  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
627  /* check 'ps' begins with the purpose */ \
628  GNUNET_static_assert (((void*) (ps)) == \
629  ((void*) &(ps)->purpose)); \
630  GNUNET_assert (GNUNET_OK == \
631  GNUNET_IDENTITY_sign_ (priv, \
632  &(ps)->purpose, \
633  sig)); \
634 } while (0)
635 
636 
655 GNUNET_IDENTITY_signature_verify_ (uint32_t purpose,
656  const struct
658  const struct GNUNET_IDENTITY_Signature *sig,
659  const struct
661 
678 GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose,
679  const struct
681  validate,
682  const unsigned char *sig,
683  const struct
685 
686 
700 #define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \
701  /* check size is set correctly */ \
702  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
703  /* check 'ps' begins with the purpose */ \
704  GNUNET_static_assert (((void*) (ps)) == \
705  ((void*) &(ps)->purpose)); \
706  GNUNET_IDENTITY_signature_verify_ (purp, \
707  &(ps)->purpose, \
708  sig, \
709  pub); \
710  })
711 
712 
728 ssize_t
729 GNUNET_IDENTITY_encrypt (const void *block,
730  size_t size,
731  const struct GNUNET_IDENTITY_PublicKey *pub,
732  struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
733  void *result);
734 
735 
750 ssize_t
751 GNUNET_IDENTITY_decrypt (const void *block,
752  size_t size,
753  const struct
755  const struct
757  void *result);
758 
759 
768 char *
771 
772 
781 char *
784 
785 
797 
798 
810 
811 
820 GNUNET_IDENTITY_key_get_public (const struct
823 
824 
825 /* ************* convenience API to lookup an ego ***************** */
826 
833 typedef void
835  struct GNUNET_IDENTITY_Ego *ego);
836 
841 
842 
854  const char *name,
856  void *cb_cls);
857 
858 
864 void
866 
874 typedef void
876  void *cls,
877  const struct GNUNET_IDENTITY_PrivateKey *priv,
878  const char *ego_name);
879 
880 
885 
886 
902  const char *suffix,
904  void *cb_cls);
905 
906 
912 void
915 
916 
917 #if 0 /* keep Emacsens' auto-indent happy */
918 {
919 #endif
920 #ifdef __cplusplus
921 }
922 #endif
923 
924 /* ifndef GNUNET_IDENTITY_SERVICE_H */
925 #endif
926  /* end of group identity */
928  /* end of group addition */
930 
931 /* end of gnunet_identity_service.h */
GNUNET_ErrorCode
Taler error codes.
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:47
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:50
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:560
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
void(* GNUNET_IDENTITY_CreateContinuation)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, enum GNUNET_ErrorCode ec)
Function called once the requested operation has been completed.
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:646
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:179
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.
ssize_t GNUNET_IDENTITY_write_public_key_to_buffer(const struct GNUNET_IDENTITY_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PublicKey to a compact buffer.
Definition: identity_api.c:890
ssize_t GNUNET_IDENTITY_public_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:830
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:586
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.
ssize_t GNUNET_IDENTITY_write_private_key_to_buffer(const struct GNUNET_IDENTITY_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PrivateKey to a compact buffer.
Definition: identity_api.c:933
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:573
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.
Definition: identity_api.c:988
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.
ssize_t GNUNET_IDENTITY_private_key_get_length(const struct GNUNET_IDENTITY_PrivateKey *key)
Get the compacted length of a GNUNET_IDENTITY_PrivateKey.
Definition: identity_api.c:809
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.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PublicKey *key, size_t *read)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
Definition: identity_api.c:865
ssize_t GNUNET_IDENTITY_signature_get_raw_length_by_type(const uint32_t type)
Get the compacted length of a signature by type.
Definition: identity_api.c:970
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PrivateKey *key, size_t *read)
Reads a GNUNET_IDENTITY_PrivateKey from a compact buffer.
Definition: identity_api.c:908
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:740
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.
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:531
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:757
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.
struct GNUNET_IDENTITY_Ego * GNUNET_IDENTITY_ego_get_anonymous(void)
Obtain the ego representing 'anonymous' users.
Definition: identity_api.c:157
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:699
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.
void(* GNUNET_IDENTITY_Continuation)(void *cls, enum GNUNET_ErrorCode ec)
Function called once the requested operation has been completed.
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.
Definition: identity_api.c:951
@ GNUNET_IDENTITY_TYPE_ECDSA
The identity type.
@ GNUNET_IDENTITY_TYPE_EDDSA
EDDSA identity.
GNUNET_GenericReturnValue
Named constants for return values.
static unsigned int size
Size of the "table".
Definition: peer.c:68
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:97
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:117
void * cb_cls
Closure for cb.
Definition: identity_api.c:122
Handle for an operation with the identity service.
Definition: identity_api.c:41
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
void * cls
Closure for cont or cb.
Definition: identity_api.c:89
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
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