GNUnet  0.18.1
Identity service

Identity management. More...

Collaboration diagram for Identity service:

Data Structures

struct  GNUNET_IDENTITY_PrivateKey
 A private key for an identity as per LSD0001. More...
 
struct  GNUNET_IDENTITY_PublicKey
 An identity key as per LSD0001. More...
 
struct  GNUNET_IDENTITY_Signature
 An identity signature as per LSD0001. More...
 

Macros

#define GNUNET_IDENTITY_VERSION   0x00000100
 Version number of GNUnet Identity API. More...
 
#define GNUNET_IDENTITY_sign(priv, ps, sig)
 Sign a given block with GNUNET_IDENTITY_PrivateKey. More...
 
#define GNUNET_IDENTITY_signature_verify(purp, ps, sig, pub)
 Verify a given signature with GNUNET_IDENTITY_PublicKey. More...
 

Typedefs

typedef 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. More...
 
typedef void(* GNUNET_IDENTITY_Continuation) (void *cls, enum GNUNET_ErrorCode ec)
 Function called once the requested operation has been completed. More...
 
typedef 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. More...
 
typedef void(* GNUNET_IDENTITY_EgoCallback) (void *cls, struct GNUNET_IDENTITY_Ego *ego)
 Function called with the result. More...
 
typedef void(* GNUNET_IDENTITY_EgoSuffixCallback) (void *cls, const struct GNUNET_IDENTITY_PrivateKey *priv, const char *ego_name)
 Function called with the result. More...
 

Enumerations

enum  GNUNET_IDENTITY_KeyType { GNUNET_IDENTITY_TYPE_ECDSA = 65536 , GNUNET_IDENTITY_TYPE_EDDSA = 65556 }
 

Functions

const struct GNUNET_IDENTITY_PrivateKeyGNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
 Obtain the ECC key associated with a ego. More...
 
struct GNUNET_IDENTITY_EgoGNUNET_IDENTITY_ego_get_anonymous (void)
 Obtain the ego representing 'anonymous' users. More...
 
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. More...
 
struct GNUNET_IDENTITY_HandleGNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
 Connect to the identity service. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_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. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_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. More...
 
void GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
 Disconnect from identity service. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_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. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_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. More...
 
struct GNUNET_IDENTITY_OperationGNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id, const char *name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
 Delete an existing ego. More...
 
void GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
 Cancel an identity operation. More...
 
ssize_t GNUNET_IDENTITY_public_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key)
 Get the compacted length of a GNUNET_IDENTITY_PublicKey. More...
 
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. More...
 
ssize_t GNUNET_IDENTITY_private_key_get_length (const struct GNUNET_IDENTITY_PrivateKey *key)
 Get the compacted length of a GNUNET_IDENTITY_PrivateKey. More...
 
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. More...
 
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. More...
 
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. More...
 
ssize_t GNUNET_IDENTITY_signature_get_length (const struct GNUNET_IDENTITY_Signature *sig)
 Get the compacted length of a GNUNET_IDENTITY_Signature. More...
 
ssize_t GNUNET_IDENTITY_signature_get_raw_length_by_type (const uint32_t type)
 Get the compacted length of a signature by type. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 required for decryption using ecdh to derive a symmetric key. More...
 
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 ecdh to derive a symmetric key. More...
 
char * GNUNET_IDENTITY_public_key_to_string (const struct GNUNET_IDENTITY_PublicKey *key)
 Creates a (Base32) string representation of the public key. More...
 
char * GNUNET_IDENTITY_private_key_to_string (const struct GNUNET_IDENTITY_PrivateKey *key)
 Creates a (Base32) string representation of the private key. More...
 
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. More...
 
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. More...
 
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. More...
 
struct GNUNET_IDENTITY_EgoLookupGNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_IDENTITY_EgoCallback cb, void *cb_cls)
 Lookup an ego by name. More...
 
void GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el)
 Abort ego lookup attempt. More...
 
struct GNUNET_IDENTITY_EgoSuffixLookupGNUNET_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. More...
 
void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel (struct GNUNET_IDENTITY_EgoSuffixLookup *el)
 Abort ego suffix lookup attempt. More...
 

Detailed Description

Identity management.

Egos in GNUnet are ECDSA keys. You assume an ego by using (signing with) a particular private key. As GNUnet users are expected to have many egos, we need an identity service to allow users to manage their egos. The identity service manages the egos (private keys) of the local user; it does NOT manage egos of other users (public keys). For giving names to other users and manage their public keys securely, we use GNS.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_IDENTITY_VERSION

#define GNUNET_IDENTITY_VERSION   0x00000100

Version number of GNUnet Identity API.

Definition at line 61 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_sign

#define GNUNET_IDENTITY_sign (   priv,
  ps,
  sig 
)
Value:
do { \
/* check size is set correctly */ \
GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
/* check 'ps' begins with the purpose */ \
GNUNET_static_assert (((void*) (ps)) == \
((void*) &(ps)->purpose)); \
GNUNET_assert (GNUNET_OK == \
&(ps)->purpose, \
sig)); \
} while (0)
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.
@ GNUNET_OK
Definition: gnunet_common.h:99

Sign a given block with GNUNET_IDENTITY_PrivateKey.

The ps data must be a fixed-size struct for which the signature is to be created. The size field in ps->purpose must correctly indicate the number of bytes of the data structure, including its header.

Parameters
privprivate key to use for the signing
pspacked struct with what to sign, MUST begin with a purpose
[out]sigwhere to write the signature

Definition at line 623 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_signature_verify

#define GNUNET_IDENTITY_signature_verify (   purp,
  ps,
  sig,
  pub 
)
Value:
({ \
/* check size is set correctly */ \
GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
/* check 'ps' begins with the purpose */ \
GNUNET_static_assert (((void*) (ps)) == \
((void*) &(ps)->purpose)); \
GNUNET_IDENTITY_signature_verify_ (purp, \
&(ps)->purpose, \
sig, \
pub); \
})
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46

Verify a given signature with GNUNET_IDENTITY_PublicKey.

The ps data must be a fixed-size struct for which the signature is to be created. The size field in ps->purpose must correctly indicate the number of bytes of the data structure, including its header.

Parameters
purppurpose of the signature, must match 'ps->purpose.purpose' (except in host byte order)
pspacked struct with what to sign, MUST begin with a purpose
sigwhere to read the signature from
pubpublic key to use for the verifying

Definition at line 699 of file gnunet_identity_service.h.

Typedef Documentation

◆ GNUNET_IDENTITY_Callback

typedef 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.

When used with GNUNET_IDENTITY_connect, this function is initially called for all egos and then again whenever a ego's name changes or if it is deleted. At the end of the initial pass over all egos, the function is once called with 'NULL' for ego. That does NOT mean that the callback won't be invoked in the future or that there was an error.

When used with GNUNET_IDENTITY_create or GNUNET_IDENTITY_get, this function is only called ONCE, and 'NULL' being passed in ego does indicate an error (for example because name is taken or no default value is known). If ego is non-NULL and if '*ctx' is set in those callbacks, the value WILL be passed to a subsequent call to the identity callback of GNUNET_IDENTITY_connect (if that one was not NULL).

When an identity is renamed, this function is called with the (known) ego but the NEW name.

When an identity is deleted, this function is called with the (known) ego and "NULL" for the name. In this case, the ego is henceforth invalid (and the ctx should also be cleaned up).

Parameters
clsclosure
egoego handle
ctxcontext for application to store data for this ego (during the lifetime of this process, initially NULL)
namename assigned by the user for this ego, NULL if the user just deleted the ego and it must thus no longer be used

Definition at line 240 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_Continuation

typedef void(* GNUNET_IDENTITY_Continuation) (void *cls, enum GNUNET_ErrorCode ec)

Function called once the requested operation has been completed.

Parameters
clsclosure
ecthe GNUNET_ErrorCode

Definition at line 284 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_CreateContinuation

typedef 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.

Parameters
clsclosure
pkprivate key, NULL on error
ecthe GNUNET_ErrorCode

Definition at line 324 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_EgoCallback

typedef void(* GNUNET_IDENTITY_EgoCallback) (void *cls, struct GNUNET_IDENTITY_Ego *ego)

Function called with the result.

Parameters
clsclosure
egoNULL on error / ego not found

Definition at line 832 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_EgoSuffixCallback

typedef void(* GNUNET_IDENTITY_EgoSuffixCallback) (void *cls, const struct GNUNET_IDENTITY_PrivateKey *priv, const char *ego_name)

Function called with the result.

Parameters
clsclosure
egoNULL on error / ego not found
ego_nameNULL on error, name of the ego otherwise

Definition at line 873 of file gnunet_identity_service.h.

Enumeration Type Documentation

◆ GNUNET_IDENTITY_KeyType

Enumerator
GNUNET_IDENTITY_TYPE_ECDSA 

The identity type.

The value is the same as the PKEY record type.

GNUNET_IDENTITY_TYPE_EDDSA 

EDDSA identity.

The value is the same as the EDKEY record type.

Definition at line 63 of file gnunet_identity_service.h.

64 {
70 
76 };
@ GNUNET_IDENTITY_TYPE_ECDSA
The identity type.
@ GNUNET_IDENTITY_TYPE_EDDSA
EDDSA identity.

Function Documentation

◆ GNUNET_IDENTITY_ego_get_private_key()

const struct GNUNET_IDENTITY_PrivateKey* GNUNET_IDENTITY_ego_get_private_key ( const struct GNUNET_IDENTITY_Ego ego)

◆ GNUNET_IDENTITY_ego_get_anonymous()

struct GNUNET_IDENTITY_Ego* GNUNET_IDENTITY_ego_get_anonymous ( void  )

Obtain the ego representing 'anonymous' users.

Returns
handle for the anonymous user, MUST NOT be freed

Definition at line 157 of file identity_api.c.

158 {
159  static struct GNUNET_IDENTITY_Ego anon;
160  static int setup;
161  ssize_t key_len;
162 
163  if (setup)
164  return &anon;
165  anon.pk.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
166  anon.pub.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
167  anon.pk.ecdsa_key = *GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
168  key_len = GNUNET_IDENTITY_private_key_get_length (&anon.pk);
169  GNUNET_assert (0 < key_len);
170  GNUNET_CRYPTO_hash (&anon.pk,
171  key_len,
172  &anon.id);
173  setup = 1;
174  return &anon;
175 }
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:481
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
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
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Handle for an ego.
Definition: identity.h:37

References GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_assert, GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_hash(), GNUNET_IDENTITY_private_key_get_length(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_Ego::id, GNUNET_IDENTITY_Ego::pk, GNUNET_IDENTITY_Ego::pub, httpdomain.autohttp.bottle::setup(), GNUNET_IDENTITY_PrivateKey::type, and GNUNET_IDENTITY_PublicKey::type.

Referenced by get_anonymous_public_key(), and get_srv_handle_ego().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_get_public_key()

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.

Parameters
egoidentity handle with the private key
pkset to ego's public key

Definition at line 573 of file identity_api.c.

575 {
576  if (GNUNET_NO == ego->pub_initialized)
577  {
578  GNUNET_IDENTITY_key_get_public (&ego->pk, &ego->pub);
580  }
581  *pk = ego->pub;
582 }
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
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
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
bool pub_initialized
Set to true once pub was initialized.
Definition: identity.h:66
struct GNUNET_IDENTITY_PublicKey pub
The identity key pair.
Definition: identity.h:46

References GNUNET_IDENTITY_key_get_public(), GNUNET_NO, GNUNET_YES, pk, GNUNET_IDENTITY_Ego::pk, GNUNET_IDENTITY_Ego::pub, and GNUNET_IDENTITY_Ego::pub_initialized.

Referenced by code_redirect(), consume_ticket_cont(), DID_did_to_pkey(), DID_ego_to_did(), DID_identity_to_did_document(), ego_callback(), find_ego(), get_anonymous_public_key(), get_ego(), get_identity_for_string(), get_srv_handle_ego(), id_connect_cb(), list_ego(), print_ego(), revoke_ticket_cont(), and store_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_connect()

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.

Parameters
cfgConfiguration to contact the identity service.
cbfunction to call on all identity events, can be NULL
cb_clsclosure for cb
Returns
handle to communicate with identity service
Parameters
cfgthe configuration to use
cbfunction to call on all identity events, can be NULL
cb_clsclosure for cb
Returns
handle to use

Definition at line 531 of file identity_api.c.

534 {
535  struct GNUNET_IDENTITY_Handle *h;
536 
538  h->cfg = cfg;
539  h->cb = cb;
540  h->cb_cls = cb_cls;
542  GNUNET_YES);
543  reconnect (h);
544  if (NULL == h->mq)
545  {
546  GNUNET_free (h);
547  return NULL;
548  }
549  return h;
550 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static void reconnect(void *cls)
Try again to connect to the identity service.
Definition: identity_api.c:484
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
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

References GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Handle::cb_cls, cfg, GNUNET_ARM_Handle::cfg, GNUNET_CONTAINER_multihashmap_create(), GNUNET_free, GNUNET_new, GNUNET_YES, h, GNUNET_ARM_Handle::mq, and reconnect().

Referenced by init_ego_store(), libgnunet_plugin_rest_identity_init(), libgnunet_plugin_rest_namestore_init(), libgnunet_plugin_rest_openid_connect_init(), libgnunet_plugin_rest_reclaim_init(), run(), and run_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_get()

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.

Parameters
ididentity service to query
service_namefor which service is an identity wanted
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

◆ GNUNET_IDENTITY_set()

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.

Parameters
ididentity service to inform
service_namefor which service is an identity set
egonew default identity to be set for this service
contfunction to call once the operation finished
cont_clsclosure for cont
Returns
handle to abort the operation

◆ GNUNET_IDENTITY_disconnect()

void GNUNET_IDENTITY_disconnect ( struct GNUNET_IDENTITY_Handle h)

Disconnect from identity service.

Parameters
hidentity service to disconnect
hhandle to destroy

Definition at line 757 of file identity_api.c.

758 {
760 
761  GNUNET_assert (NULL != h);
762  if (h->reconnect_task != NULL)
763  {
765  h->reconnect_task = NULL;
766  }
767  if (NULL != h->egos)
768  {
770  &free_ego,
771  h);
773  h->egos = NULL;
774  }
775  while (NULL != (op = h->op_head))
776  {
777  GNUNET_break (NULL == op->cont);
778  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
779  memset (&op->pk,
780  0,
781  sizeof (op->pk));
782  GNUNET_free (op);
783  }
784  if (NULL != h->mq)
785  {
787  h->mq = NULL;
788  }
789  GNUNET_free (h);
790 }
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:686
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:943
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:241
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
Handle for an operation with the identity service.
Definition: identity_api.c:41

Referenced by cleanup(), clear_ego_store(), do_cleanup(), do_shutdown(), do_stop_task(), libgnunet_plugin_rest_identity_done(), libgnunet_plugin_rest_namestore_done(), libgnunet_plugin_rest_openid_connect_done(), libgnunet_plugin_rest_reclaim_done(), process_stdin(), and shutdown_task().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_create()

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.

Parameters
ididentity service to use
namedesired name
privkeydesired private key or NULL to create one
ktypethe type of key to create. Ignored if privkey != NULL.
contfunction to call with the result (will only be called once)
cont_clsclosure for cont
Returns
handle to abort the operation

Definition at line 586 of file identity_api.c.

592 {
593  struct GNUNET_IDENTITY_PrivateKey private_key;
595  struct GNUNET_MQ_Envelope *env;
596  struct CreateRequestMessage *crm;
597  size_t slen;
598  size_t key_len;
599 
600  if (NULL == h->mq)
601  return NULL;
602  slen = strlen (name) + 1;
603  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
604  {
605  GNUNET_break (0);
606  return NULL;
607  }
609  op->h = h;
610  op->create_cont = cont;
611  op->cls = cont_cls;
612  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
613  if (NULL == privkey)
614  {
616  private_key_create (ktype, &private_key));
617  }
618  else
619  private_key = *privkey;
621  env = GNUNET_MQ_msg_extra (crm, slen + key_len,
623  crm->name_len = htons (slen);
625  &crm[1],
626  key_len);
627  crm->key_len = htons (key_len);
628  op->pk = private_key;
629  GNUNET_memcpy ((char*) &crm[1] + key_len, name, slen);
630  GNUNET_MQ_send (h->mq, env);
631  return op;
632 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:303
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:56
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
Create new identity (client->service).
static enum GNUNET_GenericReturnValue private_key_create(enum GNUNET_IDENTITY_KeyType ktype, struct GNUNET_IDENTITY_PrivateKey *key)
Definition: identity_api.c:203
const char * name
Client requests creation of an identity.
Definition: identity.h:151
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:160
uint16_t key_len
Key length.
Definition: identity.h:165
struct GNUNET_ARM_Handle * h
ARM handle.
Definition: arm_api.c:55
A private key for an identity as per LSD0001.

References env, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_IDENTITY_private_key_get_length(), GNUNET_IDENTITY_write_private_key_to_buffer(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_ARM_Operation::h, h, CreateRequestMessage::key_len, GNUNET_ARM_Handle::mq, name, CreateRequestMessage::name_len, op, and private_key_create().

Referenced by create_did_ego_lockup_cb(), create_store_ego(), ego_create(), origin_lookup_cb(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_rename()

struct GNUNET_IDENTITY_Operation* GNUNET_IDENTITY_rename ( struct GNUNET_IDENTITY_Handle h,
const char *  old_name,
const char *  new_name,
GNUNET_IDENTITY_Continuation  cb,
void *  cb_cls 
)

Renames an existing ego.

Parameters
ididentity service to use
old_nameold name
new_namedesired new name
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Renames an existing ego.

Parameters
hidentity service to use
old_nameold name
new_namedesired new name
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Definition at line 646 of file identity_api.c.

651 {
653  struct GNUNET_MQ_Envelope *env;
654  struct RenameMessage *grm;
655  size_t slen_old;
656  size_t slen_new;
657  char *dst;
658 
659  if (NULL == h->mq)
660  return NULL;
661  slen_old = strlen (old_name) + 1;
662  slen_new = strlen (new_name) + 1;
663  if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
664  (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
665  (slen_old + slen_new >=
666  GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
667  {
668  GNUNET_break (0);
669  return NULL;
670  }
672  op->h = h;
673  op->cont = cb;
674  op->cls = cb_cls;
675  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
676  env = GNUNET_MQ_msg_extra (grm,
677  slen_old + slen_new,
679  grm->old_name_len = htons (slen_old);
680  grm->new_name_len = htons (slen_new);
681  dst = (char *) &grm[1];
682  GNUNET_memcpy (dst, old_name, slen_old);
683  GNUNET_memcpy (&dst[slen_old], new_name, slen_new);
684  GNUNET_MQ_send (h->mq, env);
685  return op;
686 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
Client requests renaming of an identity.
Definition: identity.h:178
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:187
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:192

References env, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_ARM_Operation::h, h, GNUNET_ARM_Handle::mq, RenameMessage::new_name_len, RenameMessage::old_name_len, and op.

Referenced by ego_edit(), and rename_store_ego().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_delete()

struct GNUNET_IDENTITY_Operation* GNUNET_IDENTITY_delete ( struct GNUNET_IDENTITY_Handle h,
const char *  name,
GNUNET_IDENTITY_Continuation  cb,
void *  cb_cls 
)

Delete an existing ego.

Parameters
ididentity service to use
namename of the identity to delete
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Delete an existing ego.

Parameters
hidentity service to use
namename of the identity to delete
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Definition at line 699 of file identity_api.c.

703 {
705  struct GNUNET_MQ_Envelope *env;
706  struct DeleteMessage *gdm;
707  size_t slen;
708 
709  if (NULL == h->mq)
710  return NULL;
711  slen = strlen (name) + 1;
712  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
713  {
714  GNUNET_break (0);
715  return NULL;
716  }
718  op->h = h;
719  op->cont = cb;
720  op->cls = cb_cls;
721  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
723  gdm->name_len = htons (slen);
724  gdm->reserved = htons (0);
725  GNUNET_memcpy (&gdm[1], name, slen);
726  GNUNET_MQ_send (h->mq, env);
727  return op;
728 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
Client requests deletion of an identity.
Definition: identity.h:204
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:213
uint16_t reserved
Always zero.
Definition: identity.h:218

References env, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_ARM_Operation::h, h, GNUNET_ARM_Handle::mq, name, DeleteMessage::name_len, op, and DeleteMessage::reserved.

Referenced by ego_delete_name(), ego_delete_pubkey(), renew_store_ego(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_cancel()

void GNUNET_IDENTITY_cancel ( struct GNUNET_IDENTITY_Operation op)

Cancel an identity operation.

Note that the operation MAY still be executed; this merely cancels the continuation; if the request was already transmitted, the service may still choose to complete the operation.

Parameters
opoperation to cancel

Definition at line 740 of file identity_api.c.

741 {
742  op->cont = NULL;
743  op->cb = NULL;
744  op->create_cont = NULL;
745  memset (&op->pk,
746  0,
747  sizeof (op->pk));
748 }

References op.

Referenced by clear_ego_store(), do_shutdown(), and shutdown_task().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_public_key_get_length()

ssize_t GNUNET_IDENTITY_public_key_get_length ( const struct GNUNET_IDENTITY_PublicKey key)

Get the compacted length of a GNUNET_IDENTITY_PublicKey.

Compacted means that it returns the minimum number of bytes this key is long, as opposed to the union structure inside GNUNET_IDENTITY_PublicKey. Useful for compact serializations.

Parameters
keythe key.
Returns
-1 on error, else the compacted length of the key.

Definition at line 830 of file identity_api.c.

832 {
833  switch (ntohl (key->type))
834  {
836  return sizeof (key->type) + sizeof (key->ecdsa_key);
838  return sizeof (key->type) + sizeof (key->eddsa_key);
839  default:
840  GNUNET_break (0);
841  }
842  return -1;
843 }
struct GNUNET_HashCode key
The key used in the DHT.

References GNUNET_break, GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, and key.

Referenced by attr_iter_cb(), change_handle_ego(), check_credential_iteration_start(), check_signature(), consume_result_cb(), ego_callback(), get_message_body_size(), gns_string_to_value(), GNUNET_GNS_lookup_limited(), GNUNET_IDENTITY_public_key_to_string(), GNUNET_IDENTITY_read_private_key_from_buffer(), GNUNET_MESSENGER_send_message(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_RECLAIM_read_ticket_from_buffer(), GNUNET_RECLAIM_ticket_issue(), GNUNET_REVOCATION_proof_get_size(), GNUNET_REVOCATION_query(), handle_client_call_message(), run(), run_edkey(), run_pkey(), and run_with_zone_pkey().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_read_public_key_from_buffer()

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.

The buffer has to contain at least the compacted length of a GNUNET_IDENTITY_PublicKey in bytes. If the buffer is too small, the function returns -1 as error. If the buffer does not contain a valid key, it returns -2 as error.

Parameters
bufferthe buffer
lenthe length of buffer
keythe key
theamount of bytes read from the buffer
Returns
GNUNET_SYSERR on error

Definition at line 847 of file identity_api.c.

870 {
871  if (len < sizeof (key->type))
872  return GNUNET_SYSERR;
873  GNUNET_memcpy (&key->type,
874  buffer,
875  sizeof (key->type));
876  ssize_t length = GNUNET_IDENTITY_public_key_get_length (key);
877  if (len < length)
878  return GNUNET_SYSERR;
879  if (length < 0)
880  return GNUNET_SYSERR;
881  GNUNET_memcpy (&key->ecdsa_key,
882  buffer + sizeof (key->type),
883  length - sizeof (key->type));
884  *kb_read = length;
885  return GNUNET_OK;
886 }
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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
@ GNUNET_SYSERR
Definition: gnunet_common.h:97

Referenced by check_get_key(), check_send_message(), do_flood(), handle_attribute_result(), handle_cadet_ring_message(), handle_consume_ticket_result(), handle_credential_result(), handle_get_key(), handle_issue_ticket_message(), handle_lookup(), handle_phone_ring(), handle_send_message(), and handle_zone_to_name().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_private_key_get_length()

ssize_t GNUNET_IDENTITY_private_key_get_length ( const struct GNUNET_IDENTITY_PrivateKey key)

Get the compacted length of a GNUNET_IDENTITY_PrivateKey.

Compacted means that it returns the minimum number of bytes this key is long, as opposed to the union structure inside GNUNET_IDENTITY_PrivateKey. Useful for compact serializations.

Parameters
keythe key.
Returns
-1 on error, else the compacted length of the key.

Definition at line 809 of file identity_api.c.

811 {
812  switch (ntohl (key->type))
813  {
815  return sizeof (key->type) + sizeof (key->ecdsa_key);
816  break;
818  return sizeof (key->type) + sizeof (key->eddsa_key);
819  break;
820  default:
822  "Got key type %u\n", ntohl (key->type));
823  GNUNET_break (0);
824  }
825  return -1;
826 }
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, GNUNET_log, and key.

Referenced by check_zone_to_name(), create_update_message(), GNUNET_IDENTITY_create(), GNUNET_IDENTITY_ego_get_anonymous(), GNUNET_IDENTITY_private_key_from_string(), GNUNET_IDENTITY_write_private_key_to_buffer(), GNUNET_NAMESTORE_records_store2(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_iteration_start2(), GNUNET_NAMESTORE_zone_monitor_start(), GNUNET_NAMESTORE_zone_monitor_start2(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_credential_delete(), GNUNET_RECLAIM_credential_store(), GNUNET_RECLAIM_get_attributes_start(), GNUNET_RECLAIM_get_credentials_start(), GNUNET_RECLAIM_ticket_consume(), GNUNET_RECLAIM_ticket_issue(), GNUNET_RECLAIM_ticket_iteration_start(), GNUNET_RECLAIM_ticket_revoke(), handle_gns_response(), handle_identity_update(), notify_listeners(), records_lookup(), and send_lookup_response_with_filter().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_write_public_key_to_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.

The buffer requires space for at least the compacted length of a GNUNET_IDENTITY_PublicKey in bytes. If the buffer is too small, the function returns -1 as error. If the key is not valid, it returns -2 as error.

Parameters
keythe key
bufferthe buffer
lenthe length of buffer
Returns
-1 or -2 on error, else the amount of bytes written to the buffer

Definition at line 890 of file identity_api.c.

894 {
895  const ssize_t length = GNUNET_IDENTITY_public_key_get_length (key);
896  if (len < length)
897  return -1;
898  if (length < 0)
899  return -2;
900  GNUNET_memcpy (buffer, &(key->type), sizeof (key->type));
901  GNUNET_memcpy (buffer + sizeof (key->type), &(key->ecdsa_key), length
902  - sizeof (key->type));
903  return length;
904 }

Referenced by attr_iter_cb(), change_handle_ego(), check_credential_iteration_start(), check_signature(), consume_result_cb(), GNUNET_GNS_lookup_limited(), GNUNET_MESSENGER_send_message(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_RECLAIM_ticket_issue(), GNUNET_RECLAIM_write_ticket_to_buffer(), GNUNET_REVOCATION_query(), and handle_client_call_message().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_read_private_key_from_buffer()

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.

The buffer has to contain at least the compacted length of a GNUNET_IDENTITY_PrivateKey in bytes. If the buffer is too small, the function returns GNUNET_SYSERR as error.

Parameters
bufferthe buffer
lenthe length of buffer
keythe key
theamount of bytes read from the buffer
Returns
GNUNET_SYSERR on error

Definition at line 890 of file identity_api.c.

913 {
914  if (len < sizeof (key->type))
915  return GNUNET_SYSERR;
916  GNUNET_memcpy (&key->type,
917  buffer,
918  sizeof (key->type));
919  ssize_t length = GNUNET_IDENTITY_private_key_get_length (key);
920  if (len < length)
921  return GNUNET_SYSERR;
922  if (length < 0)
923  return GNUNET_SYSERR;
924  GNUNET_memcpy (&key->ecdsa_key,
925  buffer + sizeof (key->type),
926  length - sizeof (key->type));
927  *kb_read = length;
928  return GNUNET_OK;
929 }

References GNUNET_IDENTITY_public_key_get_length(), GNUNET_memcpy, key, and len.

Referenced by handle_attribute_delete_message(), handle_attribute_store_message(), handle_client_call_message(), handle_consume_ticket_message(), handle_create_message(), handle_credential_delete_message(), handle_credential_iteration_start(), handle_credential_store_message(), handle_identity_update(), handle_issue_ticket_message(), handle_iteration_start(), handle_lookup_result(), handle_monitor_start(), handle_record_lookup(), handle_record_result(), handle_record_store(), handle_result(), handle_revoke_ticket_message(), handle_ticket_iteration_start(), handle_zone_to_name(), and handle_zone_to_name_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_write_private_key_to_buffer()

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.

The buffer requires space for at least the compacted length of a GNUNET_IDENTITY_PrivateKey in bytes. If the buffer is too small, the function returns -1 as error. If the key is not valid, it returns -2 as error.

Parameters
keythe key
bufferthe buffer
lenthe length of buffer
Returns
-1 or -2 on error, else the amount of bytes written to the buffer

Definition at line 933 of file identity_api.c.

937 {
938  const ssize_t length = GNUNET_IDENTITY_private_key_get_length (key);
939  if (len < length)
940  return -1;
941  if (length < 0)
942  return -2;
943  GNUNET_memcpy (buffer, &(key->type), sizeof (key->type));
944  GNUNET_memcpy (buffer + sizeof (key->type), &(key->ecdsa_key), length
945  - sizeof (key->type));
946  return length;
947 }

References GNUNET_IDENTITY_private_key_get_length(), GNUNET_memcpy, key, and len.

Referenced by check_zone_to_name(), create_update_message(), GNUNET_IDENTITY_create(), GNUNET_NAMESTORE_records_store2(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_iteration_start2(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_credential_delete(), GNUNET_RECLAIM_credential_store(), GNUNET_RECLAIM_get_attributes_start(), GNUNET_RECLAIM_get_credentials_start(), GNUNET_RECLAIM_ticket_consume(), GNUNET_RECLAIM_ticket_issue(), GNUNET_RECLAIM_ticket_iteration_start(), GNUNET_RECLAIM_ticket_revoke(), handle_gns_response(), notify_listeners(), reconnect(), records_lookup(), and send_lookup_response_with_filter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_signature_get_length()

ssize_t GNUNET_IDENTITY_signature_get_length ( const struct GNUNET_IDENTITY_Signature sig)

Get the compacted length of a GNUNET_IDENTITY_Signature.

Compacted means that it returns the minimum number of bytes this signature is long, as opposed to the union structure inside GNUNET_IDENTITY_Signature. Useful for compact serializations.

Parameters
sigthe signature.
Returns
-1 on error, else the compacted length of the signature.

Definition at line 951 of file identity_api.c.

953 {
954  switch (ntohl (sig->type))
955  {
957  return sizeof (sig->type) + sizeof (sig->ecdsa_signature);
958  break;
960  return sizeof (sig->type) + sizeof (sig->eddsa_signature);
961  break;
962  default:
963  GNUNET_break (0);
964  }
965  return -1;
966 }
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
uint32_t type
Type of signature.

References GNUNET_IDENTITY_Signature::ecdsa_signature, GNUNET_IDENTITY_Signature::eddsa_signature, GNUNET_break, GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, and GNUNET_IDENTITY_Signature::type.

Referenced by get_message_size(), GNUNET_IDENTITY_read_signature_from_buffer(), GNUNET_IDENTITY_sign_(), handle_client_call_message(), and hash_message().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_signature_get_raw_length_by_type()

ssize_t GNUNET_IDENTITY_signature_get_raw_length_by_type ( const uint32_t  type)

Get the compacted length of a signature by type.

Compacted means that it returns the minimum number of bytes this signature is long, as opposed to the union structure inside GNUNET_IDENTITY_Signature. Useful for compact serializations.

Parameters
sigthe signature.
Returns
-1 on error, else the compacted length of the signature.

Definition at line 970 of file identity_api.c.

971 {
972  switch (ntohl (type))
973  {
975  return sizeof (struct GNUNET_CRYPTO_EcdsaSignature);
976  break;
978  return sizeof (struct GNUNET_CRYPTO_EddsaSignature);
979  break;
980  default:
981  GNUNET_break (0);
982  }
983  return -1;
984 }
an ECC signature using ECDSA
an ECC signature using EdDSA.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

References GNUNET_break, GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, and type.

Referenced by GNUNET_REVOCATION_proof_get_size().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_read_signature_from_buffer()

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.

The buffer has to contain at least the compacted length of a GNUNET_IDENTITY_Signature in bytes. If the buffer is too small, the function returns -1 as error. If the buffer does not contain a valid key, it returns -2 as error.

Parameters
sigthe signature
bufferthe buffer
lenthe length of buffer
Returns
-1 or -2 on error, else the amount of bytes read from the buffer

Definition at line 988 of file identity_api.c.

992 {
993  if (len < sizeof (sig->type))
994  return -1;
995  GNUNET_memcpy (&(sig->type), buffer, sizeof (sig->type));
996  const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig);
997  if (len < length)
998  return -1;
999  if (length < 0)
1000  return -2;
1001  GNUNET_memcpy (&(sig->ecdsa_signature), buffer + sizeof (sig->type), length
1002  - sizeof (sig->type));
1003  return length;
1004 }
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

References GNUNET_IDENTITY_Signature::ecdsa_signature, GNUNET_IDENTITY_signature_get_length(), GNUNET_memcpy, len, and GNUNET_IDENTITY_Signature::type.

Referenced by decode_message(), and handle_cadet_ring_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_write_signature_to_buffer()

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.

The buffer requires space for at least the compacted length of a GNUNET_IDENTITY_Signature in bytes. If the buffer is too small, the function returns -1 as error. If the key is not valid, it returns -2 as error.

Parameters
sigthe signature
bufferthe buffer
lenthe length of buffer
Returns
-1 or -2 on error, else the amount of bytes written to the buffer

Definition at line 1008 of file identity_api.c.

1012 {
1013  const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig);
1014  if (len < length)
1015  return -1;
1016  if (length < 0)
1017  return -2;
1018  GNUNET_memcpy (buffer, &(sig->type), sizeof (sig->type));
1019  GNUNET_memcpy (buffer + sizeof (sig->type), &(sig->ecdsa_signature), length
1020  - sizeof (sig->type));
1021  return length;
1022 }

Referenced by handle_client_call_message().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_sign_()

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.

The purpose data is the beginning of the data of which the signature is to be created. The size field in purpose must correctly indicate the number of bytes of the data structure, including its header. If possible, use GNUNET_IDENTITY_sign() instead of this function.

Parameters
privprivate key to use for the signing
purposewhat to sign (size, purpose)
[out]sigwhere to write the signature
Returns
GNUNET_SYSERR on error, GNUNET_OK on success

Definition at line 1008 of file identity_api.c.

1058 {
1059  sig->type = priv->type;
1060  switch (ntohl (priv->type))
1061  {
1063  return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose,
1064  &(sig->ecdsa_signature));
1065  break;
1067  return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose,
1068  &(sig->eddsa_signature));
1069  break;
1070  default:
1071  GNUNET_break (0);
1072  }
1073 
1074  return GNUNET_SYSERR;
1075 }
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
ECDSA Sign a given block.
Definition: crypto_ecc.c:549
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:619
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.

References GNUNET_IDENTITY_Signature::ecdsa_signature, GNUNET_IDENTITY_signature_get_length(), GNUNET_memcpy, len, and GNUNET_IDENTITY_Signature::type.

Referenced by check_code_challenge(), and GNUNET_ABD_delegate_issue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_sign_raw_()

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.

The purpose data is the beginning of the data of which the signature is to be created. The size field in purpose must correctly indicate the number of bytes of the data structure, including its header. The signature payload and length depends on the key type.

Parameters
privprivate key to use for the signing
purposewhat to sign (size, purpose)
[out]sigwhere to write the signature
Returns
GNUNET_SYSERR on error, GNUNET_OK on success

Definition at line 1008 of file identity_api.c.

1031 {
1032  switch (ntohl (priv->type))
1033  {
1035  return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose,
1036  (struct
1038  break;
1040  return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose,
1041  (struct
1043  break;
1044  default:
1045  GNUNET_break (0);
1046  }
1047 
1048  return GNUNET_SYSERR;
1049 }

◆ GNUNET_IDENTITY_signature_verify_()

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.

The validate data is the beginning of the data of which the signature is to be verified. The size field in validate must correctly indicate the number of bytes of the data structure, including its header. If purpose does not match the purpose given in validate (the latter must be in big endian), signature verification fails. If possible, use GNUNET_IDENTITY_signature_verify() instead of this function (only if validate is not fixed-size, you must use this function directly).

Parameters
purposewhat is the purpose that the signature should have?
validateblock to validate (size, purpose, data)
sigsignature that is being validated
pubpublic key of the signer
Returns
GNUNET_OK if ok, GNUNET_SYSERR if invalid

Definition at line 1008 of file identity_api.c.

1084 {
1085  /* check type matching of 'sig' and 'pub' */
1086  GNUNET_assert (ntohl (pub->type) == ntohl (sig->type));
1087  switch (ntohl (pub->type))
1088  {
1090  return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate,
1091  &(sig->ecdsa_signature),
1092  &(pub->ecdsa_key));
1093  break;
1095  return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate,
1096  &(sig->eddsa_signature),
1097  &(pub->eddsa_key));
1098  break;
1099  default:
1100  GNUNET_break (0);
1101  }
1102 
1103  return GNUNET_SYSERR;
1104 }
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:643
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Verify EdDSA signature.
Definition: crypto_ecc.c:702

Referenced by GNUNET_ABD_delegate_deserialize(), GNUNET_ABD_delegate_serialize(), and OIDC_parse_authz_code().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_signature_verify_raw_()

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.

The validate data is the beginning of the data of which the signature is to be verified. The size field in validate must correctly indicate the number of bytes of the data structure, including its header. If purpose does not match the purpose given in validate (the latter must be in big endian), signature verification fails.

Parameters
purposewhat is the purpose that the signature should have?
validateblock to validate (size, purpose, data)
sigsignature that is being validated
pubpublic key of the signer
Returns
GNUNET_OK if ok, GNUNET_SYSERR if invalid

Definition at line 1008 of file identity_api.c.

1115 {
1116  switch (ntohl (pub->type))
1117  {
1119  return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate,
1120  (struct
1122  &(pub->ecdsa_key));
1123  break;
1125  return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate,
1126  (struct
1128  &(pub->eddsa_key));
1129  break;
1130  default:
1131  GNUNET_break (0);
1132  }
1133 
1134  return GNUNET_SYSERR;
1135 }

◆ GNUNET_IDENTITY_encrypt()

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 required for decryption using ecdh to derive a symmetric key.

Parameters
blockthe block to encrypt
sizethe size of the block
pubpublic key to use for ecdh
eccwhere to write the ecc public key
resultthe output parameter in which to store the encrypted result can be the same or overlap with block
Returns
the size of the encrypted block, -1 for errors. Due to the use of CFB and therefore an effective stream cipher, this size should be the same as len.

Definition at line 1139 of file identity_api.c.

1144 {
1147  struct GNUNET_HashCode hash;
1148  switch (ntohl (pub->type))
1149  {
1151  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_ecdsa (&pk, &(pub->ecdsa_key),
1152  &hash))
1153  return -1;
1154  break;
1156  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_eddsa (&pk, &(pub->eddsa_key),
1157  &hash))
1158  return -1;
1159  break;
1160  default:
1161  return -1;
1162  }
1167  GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv);
1168  GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash));
1169  const ssize_t encrypted = GNUNET_CRYPTO_symmetric_encrypt (block, size, &key,
1170  &iv, result);
1171  GNUNET_CRYPTO_zero_keys (&key, sizeof(key));
1172  GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv));
1173  return encrypted;
1174 }
static int result
Global testing status.
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:435
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_ecdsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EcDSA public key and a private ECDH key.
Definition: crypto_ecc.c:796
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EdDSA public key and a private ECDH key.
Definition: crypto_ecc.c:779
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
void GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c:414
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:213
void GNUNET_CRYPTO_hash_to_aes_key(const struct GNUNET_HashCode *hc, struct GNUNET_CRYPTO_SymmetricSessionKey *skey, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv)
Convert a hashcode into a key.
Definition: crypto_hash.c:151
static unsigned int size
Size of the "table".
Definition: peer.c:67
Private ECC key encoded for transmission.
A 512-bit hashcode.

References GNUNET_CRYPTO_ecdh_ecdsa(), GNUNET_CRYPTO_ecdh_eddsa(), GNUNET_CRYPTO_ecdhe_key_clear(), GNUNET_CRYPTO_ecdhe_key_create(), GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_CRYPTO_hash_to_aes_key(), GNUNET_CRYPTO_symmetric_encrypt(), GNUNET_CRYPTO_zero_keys(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, GNUNET_SYSERR, key, pk, pub, result, and size.

Referenced by encrypt_message(), and write_encrypted_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_decrypt()

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 ecdh to derive a symmetric key.

Parameters
blockthe data to decrypt, encoded as returned by encrypt
sizethe size of the block to decrypt
privprivate key to use for ecdh
eccthe ecc public key
resultaddress to store the result at can be the same or overlap with block
Returns
-1 on failure, size of decrypted block on success. Due to the use of CFB and therefore an effective stream cipher, this size should be the same as size.

Definition at line 1178 of file identity_api.c.

1183 {
1184  struct GNUNET_HashCode hash;
1185  switch (ntohl (priv->type))
1186  {
1188  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_ecdh (&(priv->ecdsa_key), ecc,
1189  &hash))
1190  return -1;
1191  break;
1193  if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_ecdh (&(priv->eddsa_key), ecc,
1194  &hash))
1195  return -1;
1196  break;
1197  default:
1198  return -1;
1199  }
1202  GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv);
1203  GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash));
1204  const ssize_t decrypted = GNUNET_CRYPTO_symmetric_decrypt (block, size, &key,
1205  &iv, result);
1206  GNUNET_CRYPTO_zero_keys (&key, sizeof(key));
1207  GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv));
1208  return decrypted;
1209 }
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private ECDSA key.
Definition: crypto_ecc.c:761
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private EdDSA key.
Definition: crypto_ecc.c:739
ssize_t GNUNET_CRYPTO_symmetric_decrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Decrypt a given block using a symmetric sessionkey.

References GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_IDENTITY_PrivateKey::eddsa_key, GNUNET_CRYPTO_ecdsa_ecdh(), GNUNET_CRYPTO_eddsa_ecdh(), GNUNET_CRYPTO_hash_to_aes_key(), GNUNET_CRYPTO_symmetric_decrypt(), GNUNET_CRYPTO_zero_keys(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, GNUNET_SYSERR, key, result, size, and GNUNET_IDENTITY_PrivateKey::type.

Referenced by decrypt_message(), and read_encrypted_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_public_key_to_string()

char* GNUNET_IDENTITY_public_key_to_string ( const struct GNUNET_IDENTITY_PublicKey key)

Creates a (Base32) string representation of the public key.

The resulting string encodes a compacted representation of the key. See also #GNUNET_IDENTITY_key_get_length.

Parameters
keythe key.
Returns
the string representation of the key, or NULL on error.

Definition at line 1213 of file identity_api.c.

1215 {
1218  size);
1219 }
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764

References GNUNET_IDENTITY_public_key_get_length(), GNUNET_STRINGS_data_to_string_alloc(), key, and size.

Referenced by abd_value_to_string(), create_finished(), delegation_chain_fw_resolution_start(), DID_ego_to_did(), DID_pkey_to_did(), forward_resolution(), get_store_contact(), gns_value_to_string(), GNUNET_ABD_delegate_to_string(), GNUNET_GNSRECORD_pkey_to_zkey(), handle_get_key(), handle_intermediate_result(), handle_verify_result(), issue_ticket(), list_ego(), print_deleset(), print_ego(), RECLAIM_TICKETS_consume(), and store_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_private_key_to_string()

char* GNUNET_IDENTITY_private_key_to_string ( const struct GNUNET_IDENTITY_PrivateKey key)

Creates a (Base32) string representation of the private key.

The resulting string encodes a compacted representation of the key. See also #GNUNET_IDENTITY_key_get_length.

Parameters
keythe key.
Returns
the string representation of the key, or NULL on error.

Definition at line 1223 of file identity_api.c.

1225 {
1228  size);
1229 }

Referenced by create_finished(), display_record(), ego_get_all(), ego_get_response(), and print_ego().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_public_key_from_string()

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.

See also GNUNET_IDENTITY_public_key_to_string.

Parameters
strthe encoded key.
keywhere to write the key.
Returns
GNUNET_SYSERR on error.

Definition at line 1223 of file identity_api.c.

1235 {
1238  strlen (str),
1239  key,
1240  sizeof (*key));
1241  if (GNUNET_OK != ret)
1242  return GNUNET_SYSERR;
1243  return check_key_type (ntohl (key->type));
1244 
1245 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:789
static enum GNUNET_GenericReturnValue check_key_type(uint32_t type)
Definition: identity_api.c:794

Referenced by abd_string_to_value(), authorize_endpoint(), code_redirect(), create_response(), get_identity_for_string(), gns_string_to_value(), GNUNET_ABD_delegate_from_string(), GNUNET_GNS_lookup_with_tld(), GNUNET_GNSRECORD_data_from_identity(), identity_cb(), load_member_session(), load_member_session_next(), run(), run_with_zone_pkey(), sign_cb(), start_process(), tld_iter(), and write_encrypted_message().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_private_key_from_string()

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.

See also GNUNET_IDENTITY_private_key_to_string.

Parameters
strthe encoded key.
keywhere to write the key.
Returns
GNUNET_SYSERR on error.

Definition at line 1223 of file identity_api.c.

1251 {
1254  strlen (str),
1255  key,
1256  sizeof (*key));
1257  if (GNUNET_OK != ret)
1258  return GNUNET_SYSERR;
1259  return check_key_type (ntohl (key->type));
1260 }

References GNUNET_IDENTITY_private_key_get_length(), GNUNET_STRINGS_data_to_string_alloc(), key, and size.

Here is the call graph for this function:

◆ GNUNET_IDENTITY_key_get_public()

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.

Parameters
privkeythe private key.
keythe public key result.
Returns
GNUNET_SYSERR on error.

Definition at line 157 of file identity_api.c.

182 {
183  key->type = privkey->type;
184  switch (ntohl (privkey->type))
185  {
188  &key->ecdsa_key);
189  break;
192  &key->eddsa_key);
193  break;
194  default:
195  GNUNET_break (0);
196  return GNUNET_SYSERR;
197  }
198  return GNUNET_OK;
199 }
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:197
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:186

Referenced by attr_iter_cb(), authorize_endpoint(), block_create2(), check_credential_iteration_start(), create_finished(), create_message_key(), DID_create(), filter_tickets_finished_cb(), get_nick_record(), GNUNET_ABD_delegate_issue(), GNUNET_GNSRECORD_query_from_private_key(), GNUNET_IDENTITY_ego_get_public_key(), handle_attribute_store_message(), handle_client_call_message(), handle_collect(), handle_credential_store_message(), identity_zone_cb(), issue_ticket(), RECLAIM_TICKETS_consume(), RECLAIM_TICKETS_revoke(), run(), run_edkey(), run_pkey(), and update_store_ego().

Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup()

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.

Parameters
cfgconfiguration to use
namename to look up
cbcallback to invoke with the result
cb_clsclosure for cb
Returns
NULL on error

Definition at line 186 of file identity_api_lookup.c.

190 {
192  struct GNUNET_MQ_Envelope *env;
193  struct GNUNET_MessageHeader *req;
194  size_t nlen;
195 
196  GNUNET_assert (NULL != cb);
198  el->cb = cb;
199  el->cb_cls = cb_cls;
200  {
202  { GNUNET_MQ_hd_var_size (identity_result_code,
204  struct ResultCodeMessage,
205  el),
206  GNUNET_MQ_hd_var_size (identity_update,
208  struct UpdateMessage,
209  el),
211 
212  el->mq =
214  }
215  if (NULL == el->mq)
216  {
217  GNUNET_break (0);
218  GNUNET_free (el);
219  return NULL;
220  }
221  el->name = GNUNET_strdup (name);
222  nlen = strlen (name) + 1;
224  memcpy (&req[1], name, nlen);
225  GNUNET_MQ_send (el->mq, env);
226  return el;
227 }
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1056
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP
First message send from identity client to service to lookup a single ego.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Handle for ego lookup.
struct GNUNET_MQ_Handle * mq
Connection to service.
void * cb_cls
Closure for cb.
char * name
Name of the ego we are looking up.
GNUNET_IDENTITY_EgoCallback cb
Function to call with the result.
Message handler for a specific message type.
Header for all communications.
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:81
Service informs client about status of a pseudonym.
Definition: identity.h:114

References GNUNET_IDENTITY_EgoLookup::cb, GNUNET_IDENTITY_EgoLookup::cb_cls, cfg, el, env, GNUNET_assert, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_free, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, handlers, GNUNET_IDENTITY_EgoLookup::mq, mq_error_handler(), name, and GNUNET_IDENTITY_EgoLookup::name.

Referenced by add_continuation(), create_did(), create_did_ego_create_cb(), ego_sign_data(), lookup_store_ego(), parse(), remove_did_document(), replace_did_document_remove_cb(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_cancel()

void GNUNET_IDENTITY_ego_lookup_cancel ( struct GNUNET_IDENTITY_EgoLookup el)

Abort ego lookup attempt.

Parameters
elhandle for lookup to abort

Definition at line 236 of file identity_api_lookup.c.

237 {
239  GNUNET_free (el->name);
240  GNUNET_free (el);
241 }

References el, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_IDENTITY_EgoLookup::mq, and GNUNET_IDENTITY_EgoLookup::name.

Referenced by clear_ego_store(), do_shutdown(), handle_identity_result_code(), and handle_identity_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_by_suffix()

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.

For example, given a suffix "a.b.c" and egos with names "d.a.b.c", "b.c" and "c", we return the ego for "b.c".

Parameters
cfgconfiguration to use
suffixfor which domain name suffix is an identity wanted
cbfunction to call with the result (will only be called once)
cb_clsclosure for cb
Returns
handle to abort the operation

Obtain the ego with the maximum suffix match between the ego's name and the given domain name suffix.

Parameters
cfgconfiguration to use
namename to look up
cbcallback to invoke with the result
cb_clsclosure for cb
Returns
NULL on error

Definition at line 185 of file identity_api_suffix_lookup.c.

190 {
192  struct GNUNET_MQ_Envelope *env;
193  struct GNUNET_MessageHeader *req;
194  size_t nlen;
195 
196  GNUNET_assert (NULL != cb);
198  el->cb = cb;
199  el->cb_cls = cb_cls;
200  {
202  { GNUNET_MQ_hd_var_size (identity_result_code,
204  struct ResultCodeMessage,
205  el),
206  GNUNET_MQ_hd_var_size (identity_update,
208  struct UpdateMessage,
209  el),
211 
212  el->mq =
214  }
215  if (NULL == el->mq)
216  {
217  GNUNET_break (0);
218  GNUNET_free (el);
219  return NULL;
220  }
221  el->suffix = GNUNET_strdup (suffix);
222  nlen = strlen (suffix) + 1;
223  env = GNUNET_MQ_msg_extra (req, nlen,
225  memcpy (&req[1], suffix, nlen);
226  GNUNET_MQ_send (el->mq, env);
227  return el;
228 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX
First message send from identity client to service to lookup a single ego matching the given suffix (...
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...

References GNUNET_IDENTITY_EgoLookup::cb, GNUNET_IDENTITY_EgoLookup::cb_cls, cfg, el, env, GNUNET_assert, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_free, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, handlers, GNUNET_IDENTITY_EgoLookup::mq, and mq_error_handler().

Referenced by GNUNET_GNS_lookup_with_tld().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_ego_lookup_by_suffix_cancel()

void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel ( struct GNUNET_IDENTITY_EgoSuffixLookup el)

Abort ego suffix lookup attempt.

Parameters
elhandle for lookup to abort

Abort ego suffix lookup attempt.

Parameters
elhandle for lookup to abort

Definition at line 237 of file identity_api_suffix_lookup.c.

239 {
241  GNUNET_free (el->suffix);
242  GNUNET_free (el);
243 }

References el, GNUNET_free, GNUNET_MQ_destroy(), and GNUNET_IDENTITY_EgoLookup::mq.

Referenced by GNUNET_GNS_lookup_with_tld_cancel(), handle_identity_result_code(), handle_identity_update(), and mq_error_handler().

Here is the call graph for this function:
Here is the caller graph for this function: