GNUnet  0.20.0
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 #include "gnunet_common.h"
49 #ifdef __cplusplus
50 extern "C" {
51 #if 0 /* keep Emacsens' auto-indent happy */
52 }
53 #endif
54 #endif
55 
56 
57 #include "gnunet_util_lib.h"
58 
59 
63 #define GNUNET_IDENTITY_VERSION 0x00000100
64 
66 {
72 
78 };
79 
84 
88 struct GNUNET_IDENTITY_Ego;
89 
96 {
102  uint32_t type;
103 
104  union
105  {
110 
115  };
116 };
117 
118 
123 {
129  uint32_t type;
130 
131  union
132  {
137 
142  };
143 };
144 
145 
150 {
156  uint32_t type;
157 
158  union
159  {
164 
169  };
170 };
171 
172 
177 
178 
185 const struct GNUNET_IDENTITY_PrivateKey *
187 
188 
194 struct GNUNET_IDENTITY_Ego *
196 
197 
204 void
206  struct GNUNET_IDENTITY_PublicKey *pk);
207 
208 
242 typedef void
243 (*GNUNET_IDENTITY_Callback) (void *cls,
244  struct GNUNET_IDENTITY_Ego *ego,
245  void **ctx,
246  const char *name);
247 
248 
257 struct GNUNET_IDENTITY_Handle *
260  void *cb_cls);
261 
262 
274  const char *service_name,
276  void *cb_cls);
277 
278 
286 typedef void
288  enum GNUNET_ErrorCode ec);
289 
290 
303  const char *service_name,
304  struct GNUNET_IDENTITY_Ego *ego,
306  void *cont_cls);
307 
308 
314 void
316 
317 
326 typedef void
328  void *cls,
329  const struct GNUNET_IDENTITY_PrivateKey *pk,
330  enum GNUNET_ErrorCode ec);
331 
332 
346  const char *name,
347  const struct GNUNET_IDENTITY_PrivateKey *privkey,
348  enum GNUNET_IDENTITY_KeyType ktype,
350  void *cont_cls);
351 
352 
365  const char *old_name,
366  const char *new_name,
368  void *cb_cls);
369 
370 
382  const char *name,
384  void *cb_cls);
385 
386 
395 void
397 
398 
409 ssize_t
412 
428  const void *buffer,
429  size_t len,
431  size_t *read);
432 
443 ssize_t
445  const struct GNUNET_IDENTITY_PrivateKey *key);
446 
447 
460 ssize_t
463  void*buffer,
464  size_t len);
465 
466 
481  const void*buffer,
482  size_t len,
484  size_t *read);
485 
486 
499 ssize_t
501  const struct GNUNET_IDENTITY_PrivateKey *key,
502  void*buffer,
503  size_t len);
504 
505 
516 ssize_t
518  const struct GNUNET_IDENTITY_Signature *sig);
519 
520 
531 ssize_t
533 
534 
547 ssize_t
549  struct GNUNET_IDENTITY_Signature *sig,
550  const void*buffer,
551  size_t len);
552 
553 
566 ssize_t
568  const struct GNUNET_IDENTITY_Signature *sig,
569  void*buffer,
570  size_t len);
571 
572 
588  const struct GNUNET_IDENTITY_PrivateKey *priv,
589  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
590  struct GNUNET_IDENTITY_Signature *sig);
591 
607  const struct GNUNET_IDENTITY_PrivateKey *priv,
608  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
609  unsigned char *sig);
610 
611 
623 #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \
624  /* check size is set correctly */ \
625  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
626  /* check 'ps' begins with the purpose */ \
627  GNUNET_static_assert (((void*) (ps)) == \
628  ((void*) &(ps)->purpose)); \
629  GNUNET_assert (GNUNET_OK == \
630  GNUNET_IDENTITY_sign_ (priv, \
631  &(ps)->purpose, \
632  sig)); \
633 } while (0)
634 
635 
655  uint32_t purpose,
656  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
657  const struct GNUNET_IDENTITY_Signature *sig,
658  const struct GNUNET_IDENTITY_PublicKey *pub);
659 
677  uint32_t purpose,
678  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
679  const unsigned char *sig,
680  const struct GNUNET_IDENTITY_PublicKey *pub);
681 
682 
696 #define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \
697  /* check size is set correctly */ \
698  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
699  /* check 'ps' begins with the purpose */ \
700  GNUNET_static_assert (((void*) (ps)) == \
701  ((void*) &(ps)->purpose)); \
702  GNUNET_IDENTITY_signature_verify_ (purp, \
703  &(ps)->purpose, \
704  sig, \
705  pub); \
706  })
707 
708 
724 ssize_t
725 GNUNET_IDENTITY_encrypt_old (const void *block,
726  size_t size,
727  const struct GNUNET_IDENTITY_PublicKey *pub,
728  struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
729  void *result);
730 
731 
746 ssize_t
748  const void *block,
749  size_t size,
750  const struct GNUNET_IDENTITY_PrivateKey *priv,
751  const struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
752  void *result);
753 
754 #define GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES (crypto_secretbox_MACBYTES \
755  + sizeof (struct \
756  GNUNET_CRYPTO_FoKemC))
757 
774 GNUNET_IDENTITY_encrypt (const void *block,
775  size_t size,
776  const struct GNUNET_IDENTITY_PublicKey *pub,
777  void *result,
778  size_t result_size);
779 
780 
793 GNUNET_IDENTITY_decrypt (const void *block,
794  size_t size,
795  const struct GNUNET_IDENTITY_PrivateKey *priv,
796  void *result,
797  size_t result_size);
798 
799 
808 char *
810  const struct GNUNET_IDENTITY_PublicKey *key);
811 
812 
821 char *
823  const struct GNUNET_IDENTITY_PrivateKey *key);
824 
825 
837 
838 
850 
851 
860 GNUNET_IDENTITY_key_get_public (const struct
863 
864 
865 /* ************* convenience API to lookup an ego ***************** */
866 
873 typedef void
875  struct GNUNET_IDENTITY_Ego *ego);
876 
881 
882 
894  const char *name,
896  void *cb_cls);
897 
898 
904 void
906 
914 typedef void
916  void *cls,
917  const struct GNUNET_IDENTITY_PrivateKey *priv,
918  const char *ego_name);
919 
920 
925 
926 
941  const struct GNUNET_CONFIGURATION_Handle *cfg,
942  const char *suffix,
944  void *cb_cls);
945 
946 
952 void
955 
956 
957 #if 0 /* keep Emacsens' auto-indent happy */
958 {
959 #endif
960 #ifdef __cplusplus
961 }
962 #endif
963 
964 /* ifndef GNUNET_IDENTITY_SERVICE_H */
965 #endif
966  /* end of group identity */
968  /* end of group addition */
970 
971 /* 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.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
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
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_decrypt_old(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 ...
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.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_decrypt(const void *block, size_t size, const struct GNUNET_IDENTITY_PrivateKey *priv, void *result, size_t result_size)
Decrypt a given block with GNUNET_IDENTITY_PrivateKey and a given GNUNET_CRYPTO_EcdhePublicKey using ...
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_encrypt(const void *block, size_t size, const struct GNUNET_IDENTITY_PublicKey *pub, void *result, size_t result_size)
Encrypt a block with GNUNET_IDENTITY_PublicKey and derives a GNUNET_CRYPTO_EcdhePublicKey which is re...
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
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
ssize_t GNUNET_IDENTITY_encrypt_old(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...
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.
ssize_t GNUNET_IDENTITY_signature_get_raw_length_by_type(uint32_t type)
Get the compacted length of a signature by type.
Definition: identity_api.c:970
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