GNUnet  0.11.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 
90 {
96  uint32_t type;
97 
98  union
99  {
104 
109  };
110 };
111 
112 
117 {
123  uint32_t type;
124 
125  union
126  {
131 
136  };
137 };
138 
139 
144 {
150  uint32_t type;
151 
152  union
153  {
157  struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature;
158 
162  struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
163  };
164 };
165 
166 
171 
172 
179 const struct GNUNET_IDENTITY_PrivateKey *
181 
182 
188 struct GNUNET_IDENTITY_Ego *
190 
191 
198 void
200  struct GNUNET_IDENTITY_PublicKey *pk);
201 
202 
237 typedef void
239  struct GNUNET_IDENTITY_Ego *ego,
240  void **ctx,
241  const char *name);
242 
243 
252 struct GNUNET_IDENTITY_Handle *
255  void *cb_cls);
256 
257 
269  const char *service_name,
271  void *cb_cls);
272 
273 
281 typedef void
283  const char *emsg);
284 
285 
298  const char *service_name,
299  struct GNUNET_IDENTITY_Ego *ego,
301  void *cont_cls);
302 
303 
309 void
311 
312 
321 typedef void
323  void *cls,
324  const struct GNUNET_IDENTITY_PrivateKey *pk,
325  const char *emsg);
326 
327 
341  const char *name,
342  const struct GNUNET_IDENTITY_PrivateKey *privkey,
343  enum GNUNET_IDENTITY_KeyType ktype,
345  void *cont_cls);
346 
347 
360  const char *old_name,
361  const char *new_name,
363  void *cb_cls);
364 
365 
377  const char *name,
379  void *cb_cls);
380 
381 
390 void
392 
393 
404 ssize_t
406 
407 
420 ssize_t
422  const void*buffer,
423  size_t len);
424 
425 
438 ssize_t
441  void*buffer,
442  size_t len);
443 
444 
455 ssize_t
458 
459 
472 ssize_t
475  const void*buffer,
476  size_t len);
477 
478 
491 ssize_t
494  void*buffer,
495  size_t len);
496 
497 
511 int
512 GNUNET_IDENTITY_sign_ (const struct
514  const struct
516  struct GNUNET_IDENTITY_Signature *sig);
517 
518 
530 #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \
531  /* check size is set correctly */ \
532  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
533  /* check 'ps' begins with the purpose */ \
534  GNUNET_static_assert (((void*) (ps)) == \
535  ((void*) &(ps)->purpose)); \
536  GNUNET_assert (GNUNET_OK == \
537  GNUNET_IDENTITY_sign_ (priv, \
538  &(ps)->purpose, \
539  sig)); \
540 } while (0)
541 
542 
560 int
561 GNUNET_IDENTITY_signature_verify_ (uint32_t purpose,
562  const struct
564  const struct GNUNET_IDENTITY_Signature *sig,
565  const struct
567 
568 
582 #define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \
583  /* check size is set correctly */ \
584  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
585  /* check 'ps' begins with the purpose */ \
586  GNUNET_static_assert (((void*) (ps)) == \
587  ((void*) &(ps)->purpose)); \
588  GNUNET_IDENTITY_signature_verify_ (purp, \
589  &(ps)->purpose, \
590  sig, \
591  pub); \
592  })
593 
594 
610 ssize_t
611 GNUNET_IDENTITY_encrypt (const void *block,
612  size_t size,
613  const struct GNUNET_IDENTITY_PublicKey *pub,
614  struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
615  void *result);
616 
617 
632 ssize_t
633 GNUNET_IDENTITY_decrypt (const void *block,
634  size_t size,
635  const struct
637  const struct
639  void *result);
640 
641 
650 char *
653 
654 
663 char *
666 
667 
679 
680 
692 
693 
702 GNUNET_IDENTITY_key_get_public (const struct
705 
706 
707 /* ************* convenience API to lookup an ego ***************** */
708 
715 typedef void
717  struct GNUNET_IDENTITY_Ego *ego);
718 
723 
724 
736  const char *name,
738  void *cb_cls);
739 
740 
746 void
748 
756 typedef void
758  void *cls,
759  const struct GNUNET_IDENTITY_PrivateKey *priv,
760  const char *ego_name);
761 
762 
767 
768 
784  const char *suffix,
786  void *cb_cls);
787 
788 
794 void
797 
798 
799 #if 0 /* keep Emacsens' auto-indent happy */
800 {
801 #endif
802 #ifdef __cplusplus
803 }
804 #endif
805 
806 /* ifndef GNUNET_IDENTITY_SERVICE_H */
807 #endif
808  /* end of group identity */
810 
811 /* end of gnunet_identity_service.h */
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
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
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...
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
Handle for ego lookup.
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.
uint32_t type
Type of public key.
GNUNET_IDENTITY_KeyType
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
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
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
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
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
A private key for an identity as per LSD0001.
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
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.
Private ECC key encoded for transmission.
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
Handle for an operation with the identity service.
Definition: identity_api.c:39
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
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 ...
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
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.
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
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 ...
Handle for the service.
Definition: identity_api.c:95
An identity signature as per LSD0001.
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&#39;s name and the given domain name suffix...
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(struct GNUNET_IDENTITY_EgoSuffixLookup *el)
Abort ego suffix lookup attempt.
an ECC signature using ECDSA
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.
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.
void(* GNUNET_IDENTITY_CreateContinuation)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, const char *emsg)
Function called once the requested operation has been completed.
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
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.
uint32_t type
Type of public key.
GNUNET_IDENTITY_EgoSuffixCallback cb
Function to call with the result.
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.
char * ego_name
an ECC signature using EdDSA.
struct GNUNET_IDENTITY_Ego * GNUNET_IDENTITY_ego_get_anonymous(void)
Obtain the ego representing &#39;anonymous&#39; users.
Definition: identity_api.c:156
Private ECC key encoded for transmission.
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.
An identity key as per LSD0001.
configuration data
Definition: configuration.c:84
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
void(* GNUNET_IDENTITY_EgoCallback)(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Function called with the result.
const char * name
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
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.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
GNUNET_IDENTITY_EgoCallback cb
Function to call with the result.
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...
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
void * cb_cls
Closure for cb.
Definition: identity_api.c:121
char * suffix
Suffix we are looking up.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
void(* GNUNET_IDENTITY_Continuation)(void *cls, const char *emsg)
Function called once the requested operation has been completed.
void(* GNUNET_IDENTITY_EgoSuffixCallback)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *priv, const char *ego_name)
Function called with the result.
void * cb_cls
Closure for cb.
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
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...