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 
236 typedef void
238  struct GNUNET_IDENTITY_Ego *ego,
239  void **ctx,
240  const char *name);
241 
242 
251 struct GNUNET_IDENTITY_Handle *
254  void *cb_cls);
255 
256 
268  const char *service_name,
270  void *cb_cls);
271 
272 
280 typedef void
282  const char *emsg);
283 
284 
297  const char *service_name,
298  struct GNUNET_IDENTITY_Ego *ego,
300  void *cont_cls);
301 
302 
308 void
310 
311 
320 typedef void
322  void *cls,
323  const struct GNUNET_IDENTITY_PrivateKey *pk,
324  const char *emsg);
325 
326 
340  const char *name,
341  const struct GNUNET_IDENTITY_PrivateKey *privkey,
342  enum GNUNET_IDENTITY_KeyType ktype,
344  void *cont_cls);
345 
346 
359  const char *old_name,
360  const char *new_name,
362  void *cb_cls);
363 
364 
376  const char *name,
378  void *cb_cls);
379 
380 
389 void
391 
392 
403 ssize_t
405 
406 
419 ssize_t
421  const void*buffer,
422  size_t len);
423 
424 
437 ssize_t
440  void*buffer,
441  size_t len);
442 
443 
454 ssize_t
457 
458 
471 ssize_t
474  const void*buffer,
475  size_t len);
476 
477 
490 ssize_t
493  void*buffer,
494  size_t len);
495 
496 
510 int
511 GNUNET_IDENTITY_sign_ (const struct
513  const struct
515  struct GNUNET_IDENTITY_Signature *sig);
516 
517 
529 #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \
530  /* check size is set correctly */ \
531  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
532  /* check 'ps' begins with the purpose */ \
533  GNUNET_static_assert (((void*) (ps)) == \
534  ((void*) &(ps)->purpose)); \
535  GNUNET_assert (GNUNET_OK == \
536  GNUNET_IDENTITY_sign_ (priv, \
537  &(ps)->purpose, \
538  sig)); \
539 } while (0)
540 
541 
559 int
560 GNUNET_IDENTITY_signature_verify_ (uint32_t purpose,
561  const struct
563  const struct GNUNET_IDENTITY_Signature *sig,
564  const struct
566 
567 
581 #define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \
582  /* check size is set correctly */ \
583  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
584  /* check 'ps' begins with the purpose */ \
585  GNUNET_static_assert (((void*) (ps)) == \
586  ((void*) &(ps)->purpose)); \
587  GNUNET_IDENTITY_signature_verify_ (purp, \
588  &(ps)->purpose, \
589  sig, \
590  pub); \
591  })
592 
593 
609 ssize_t
610 GNUNET_IDENTITY_encrypt (const void *block,
611  size_t size,
612  const struct GNUNET_IDENTITY_PublicKey *pub,
613  struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
614  void *result);
615 
616 
631 ssize_t
632 GNUNET_IDENTITY_decrypt (const void *block,
633  size_t size,
634  const struct
636  const struct
638  void *result);
639 
640 
649 char *
652 
653 
662 char *
665 
666 
678 
679 
691 
692 
701 GNUNET_IDENTITY_key_get_public (const struct
704 
705 
706 /* ************* convenience API to lookup an ego ***************** */
707 
714 typedef void
716  struct GNUNET_IDENTITY_Ego *ego);
717 
722 
723 
735  const char *name,
737  void *cb_cls);
738 
739 
745 void
747 
755 typedef void
757  void *cls,
758  const struct GNUNET_IDENTITY_PrivateKey *priv,
759  const char *ego_name);
760 
761 
766 
767 
783  const char *suffix,
785  void *cb_cls);
786 
787 
793 void
796 
797 
798 #if 0 /* keep Emacsens' auto-indent happy */
799 {
800 #endif
801 #ifdef __cplusplus
802 }
803 #endif
804 
805 /* ifndef GNUNET_IDENTITY_SERVICE_H */
806 #endif
807  /* end of group identity */
809 
810 /* 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
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...