GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
Identity service

Identity management. More...

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, const char *emsg)
 Function called once the requested operation has been completed. More...
 
typedef void(* GNUNET_IDENTITY_CreateContinuation) (void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, const char *emsg)
 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_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key)
 Get the compacted length of a GNUNET_IDENTITY_PublicKey. More...
 
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. More...
 
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. 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_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...
 
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. More...
 
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. 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 58 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)
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.

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 530 of file gnunet_identity_service.h.

Referenced by handle_client_call_message(), and sign_message().

◆ 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 582 of file gnunet_identity_service.h.

Referenced by handle_cadet_ring_message(), and verify_message().

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 (i.e. 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 238 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_Continuation

typedef void(* GNUNET_IDENTITY_Continuation) (void *cls, const char *emsg)

Function called once the requested operation has been completed.

Parameters
clsclosure
emsgNULL on success, otherwise an error message

Definition at line 282 of file gnunet_identity_service.h.

◆ GNUNET_IDENTITY_CreateContinuation

typedef void(* GNUNET_IDENTITY_CreateContinuation) (void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, const char *emsg)

Function called once the requested operation has been completed.

Parameters
clsclosure
pkprivate key, NULL on error
emsgerror message, NULL on success

Definition at line 322 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 716 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 757 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 60 of file gnunet_identity_service.h.

61 {
67 
73 };

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)

Obtain the ECC key associated with a ego.

Parameters
egothe ego
Returns
associated ECC key, valid as long as the ego is valid

Definition at line 639 of file identity_api.c.

References GNUNET_IDENTITY_Ego::pk.

Referenced by add_attribute_cont(), add_credential_cont(), authorize_endpoint(), callback_update_ego(), code_redirect(), consume_ticket_cont(), delete_attribute_cont(), delete_credential_cont(), directory_trim_complete(), ego_callback(), ego_cb(), ego_get_all(), ego_get_response(), get_ego(), get_handle_ego(), GNUNET_CONVERSATION_phone_create(), handle_gns_response(), identity_cb(), list_attribute_cont(), list_credential_cont(), list_tickets_cont(), namestore_add_or_update(), namestore_delete(), namestore_get(), print_ego(), revoke_ticket_cont(), sign_cb(), store_cb(), uri_ksk_continuation(), and userinfo_endpoint().

640 {
641  return &ego->pk;
642 }
struct GNUNET_IDENTITY_PrivateKey pk
The identity key pair.
Definition: identity.h:51
Here is the caller graph for this function:

◆ 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 156 of file identity_api.c.

References GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_hash(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_Ego::id, GNUNET_IDENTITY_Ego::pk, GNUNET_IDENTITY_Ego::pub, GNUNET_IDENTITY_PrivateKey::type, and GNUNET_IDENTITY_PublicKey::type.

Referenced by get_handle_ego(), and get_handle_key().

157 {
158  static struct GNUNET_IDENTITY_Ego anon;
159  static int setup;
160 
161  if (setup)
162  return &anon;
163  anon.pk.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
164  anon.pub.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
165  anon.pk.ecdsa_key = *GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
166  GNUNET_CRYPTO_hash (&anon.pk,
167  sizeof(anon.pk),
168  &anon.id);
169  setup = 1;
170  return &anon;
171 }
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:569
Handle for an ego.
Definition: identity.h:36
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
struct GNUNET_IDENTITY_PrivateKey pk
The identity key pair.
Definition: identity.h:51
uint32_t type
Type of public key.
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 652 of file identity_api.c.

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

Referenced by code_redirect(), consume_ticket_cont(), ego_callback(), ego_get_for_subsystem(), find_ego(), get_ego(), get_handle_ego(), get_handle_key(), list_ego(), print_ego(), revoke_ticket_cont(), and store_cb().

654 {
655  if (GNUNET_NO == ego->pub_initialized)
656  {
657  GNUNET_IDENTITY_key_get_public (&ego->pk, &ego->pub);
659  }
660  *pk = ego->pub;
661 }
struct GNUNET_IDENTITY_PublicKey pub
The identity key pair.
Definition: identity.h:46
struct GNUNET_IDENTITY_PrivateKey pk
The identity key pair.
Definition: identity.h:51
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
bool pub_initialized
Set to true once pub was initialized.
Definition: identity.h:66
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 610 of file identity_api.c.

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

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

613 {
614  struct GNUNET_IDENTITY_Handle *h;
615 
616  h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
617  h->cfg = cfg;
618  h->cb = cb;
619  h->cb_cls = cb_cls;
621  GNUNET_YES);
622  reconnect (h);
623  if (NULL == h->mq)
624  {
625  GNUNET_free (h);
626  return NULL;
627  }
628  return h;
629 }
struct GNUNET_CONTAINER_MultiHashMap * egos
Hash map from the hash of the private key to the respective GNUNET_IDENTITY_Ego handle.
Definition: identity_api.c:111
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void reconnect(void *cls)
Try again to connect to the identity service.
Definition: identity_api.c:559
Handle for the service.
Definition: identity_api.c:95
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: identity_api.c:100
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void * cb_cls
Closure for cb.
Definition: identity_api.c:121
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
#define GNUNET_free(ptr)
Wrapper around free.
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 h,
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

Obtain the ego that is currently preferred/default for a service.

Parameters
hidentity 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

Definition at line 675 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Operation::cls, env, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, GetDefaultMessage::name_len, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, and GetDefaultMessage::reserved.

Referenced by ego_get_subsystem(), and id_connect_cb().

679 {
681  struct GNUNET_MQ_Envelope *env;
682  struct GetDefaultMessage *gdm;
683  size_t slen;
684 
685  if (NULL == h->mq)
686  return NULL;
687  GNUNET_assert (NULL != h->cb);
688  slen = strlen (service_name) + 1;
689  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage))
690  {
691  GNUNET_break (0);
692  return NULL;
693  }
695  op->h = h;
696  op->cb = cb;
697  op->cls = cb_cls;
699  env =
701  gdm->name_len = htons (slen);
702  gdm->reserved = htons (0);
703  GNUNET_memcpy (&gdm[1], service_name, slen);
704  GNUNET_MQ_send (h->mq, env);
705  return op;
706 }
uint16_t reserved
Always zero.
Definition: identity.h:161
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:156
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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
#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:52
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
#define GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
Client requests to know default identity for a subsystem.
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:355
Client requests knowledge about default identity for a subsystem from identity service.
Definition: identity.h:146
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
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 'get' operations (cont and create_cont...
Definition: identity_api.c:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_set()

struct GNUNET_IDENTITY_Operation* GNUNET_IDENTITY_set ( struct GNUNET_IDENTITY_Handle h,
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

Set the preferred/default ego for a service.

Parameters
hidentity 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

Definition at line 720 of file identity_api.c.

References GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, env, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, SetDefaultMessage::name_len, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, GNUNET_IDENTITY_Ego::pk, SetDefaultMessage::private_key, and SetDefaultMessage::reserved.

Referenced by ego_edit_subsystem(), and print_ego().

725 {
727  struct GNUNET_MQ_Envelope *env;
728  struct SetDefaultMessage *sdm;
729  size_t slen;
730 
731  if (NULL == h->mq)
732  return NULL;
733  GNUNET_assert (NULL != h->cb);
734  slen = strlen (service_name) + 1;
735  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage))
736  {
737  GNUNET_break (0);
738  return NULL;
739  }
741  op->h = h;
742  op->cont = cont;
743  op->cls = cont_cls;
745  env =
747  sdm->name_len = htons (slen);
748  sdm->reserved = htons (0);
749  sdm->private_key = ego->pk;
750  GNUNET_memcpy (&sdm[1], service_name, slen);
751  GNUNET_MQ_send (h->mq, env);
752  return op;
753 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
Client sets default identity; or service informs about default identity.
Used from service to client as a result to the GET_DEFAULT message, used from client to service to SE...
Definition: identity.h:172
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:182
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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
uint16_t reserved
Always zero.
Definition: identity.h:187
#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:52
struct GNUNET_IDENTITY_PrivateKey pk
The identity key pair.
Definition: identity.h:51
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
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
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
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:355
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
struct GNUNET_IDENTITY_PrivateKey private_key
The private key.
Definition: identity.h:192
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 921 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cont, GNUNET_IDENTITY_Handle::egos, free_ego(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_IDENTITY_Handle::mq, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, GNUNET_IDENTITY_Operation::pk, and GNUNET_IDENTITY_Handle::reconnect_task.

Referenced by destroy_service(), 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().

922 {
924 
925  GNUNET_assert (NULL != h);
926  if (h->reconnect_task != NULL)
927  {
929  h->reconnect_task = NULL;
930  }
931  if (NULL != h->egos)
932  {
934  &free_ego,
935  h);
937  h->egos = NULL;
938  }
939  while (NULL != (op = h->op_head))
940  {
941  GNUNET_break (NULL == op->cont);
943  memset (&op->pk,
944  0,
945  sizeof (op->pk));
946  GNUNET_free (op);
947  }
948  if (NULL != h->mq)
949  {
950  GNUNET_MQ_destroy (h->mq);
951  h->mq = NULL;
952  }
953  GNUNET_free (h);
954 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_CONTAINER_MultiHashMap * egos
Hash map from the hash of the private key to the respective GNUNET_IDENTITY_Ego handle.
Definition: identity_api.c:111
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
struct GNUNET_IDENTITY_PrivateKey pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: identity_api.c:136
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
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:237
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
Here is the call graph for this function:
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 757 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, GNUNET_IDENTITY_Operation::create_cont, env, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, CreateRequestMessage::name_len, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, GNUNET_IDENTITY_Operation::pk, CreateRequestMessage::private_key, private_key_create(), and CreateRequestMessage::reserved.

Referenced by ego_create(), run(), and update_handle().

763 {
765  struct GNUNET_MQ_Envelope *env;
766  struct CreateRequestMessage *crm;
767  size_t slen;
768 
769  if (NULL == h->mq)
770  return NULL;
771  slen = strlen (name) + 1;
772  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
773  {
774  GNUNET_break (0);
775  return NULL;
776  }
778  op->h = h;
779  op->create_cont = cont;
780  op->cls = cont_cls;
781  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
783  crm->name_len = htons (slen);
784  crm->reserved = htons (0);
785  if (NULL == privkey)
786  {
788  private_key_create (ktype, &crm->private_key));
789  }
790  else
791  crm->private_key = *privkey;
792  op->pk = crm->private_key;
793  GNUNET_memcpy (&crm[1], name, slen);
794  GNUNET_MQ_send (h->mq, env);
795  return op;
796 }
uint16_t reserved
Always zero.
Definition: identity.h:217
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:212
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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
struct GNUNET_IDENTITY_PrivateKey pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
#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:52
GNUNET_IDENTITY_CreateContinuation create_cont
Continuation to invoke with the result of the transmission; cb and cb will be NULL in this case...
Definition: identity_api.c:72
Client requests creation of an identity.
Definition: identity.h:202
struct GNUNET_IDENTITY_PrivateKey private_key
The private key.
Definition: identity.h:222
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
Create new identity (client->service).
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
const char * name
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
static int private_key_create(enum GNUNET_IDENTITY_KeyType ktype, struct GNUNET_IDENTITY_PrivateKey *key)
Definition: identity_api.c:199
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:355
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
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 810 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, 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_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, RenameMessage::new_name_len, RenameMessage::old_name_len, op, GNUNET_IDENTITY_Handle::op_head, and GNUNET_IDENTITY_Handle::op_tail.

Referenced by ego_edit(), and set_handle_name().

815 {
817  struct GNUNET_MQ_Envelope *env;
818  struct RenameMessage *grm;
819  size_t slen_old;
820  size_t slen_new;
821  char *dst;
822 
823  if (NULL == h->mq)
824  return NULL;
825  slen_old = strlen (old_name) + 1;
826  slen_new = strlen (new_name) + 1;
827  if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
828  (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
829  (slen_old + slen_new >=
830  GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
831  {
832  GNUNET_break (0);
833  return NULL;
834  }
836  op->h = h;
837  op->cont = cb;
838  op->cls = cb_cls;
840  env = GNUNET_MQ_msg_extra (grm,
841  slen_old + slen_new,
843  grm->old_name_len = htons (slen_old);
844  grm->new_name_len = htons (slen_new);
845  dst = (char *) &grm[1];
846  GNUNET_memcpy (dst, old_name, slen_old);
847  GNUNET_memcpy (&dst[slen_old], new_name, slen_new);
848  GNUNET_MQ_send (h->mq, env);
849  return op;
850 }
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:242
Client requests renaming of an identity.
Definition: identity.h:232
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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
#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:52
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
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:247
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
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:355
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
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 863 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, 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_IDENTITY_Operation::h, GNUNET_IDENTITY_Handle::mq, DeleteMessage::name_len, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, and DeleteMessage::reserved.

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

867 {
869  struct GNUNET_MQ_Envelope *env;
870  struct DeleteMessage *gdm;
871  size_t slen;
872 
873  if (NULL == h->mq)
874  return NULL;
875  slen = strlen (name) + 1;
876  if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
877  {
878  GNUNET_break (0);
879  return NULL;
880  }
882  op->h = h;
883  op->cont = cb;
884  op->cls = cb_cls;
887  gdm->name_len = htons (slen);
888  gdm->reserved = htons (0);
889  GNUNET_memcpy (&gdm[1], name, slen);
890  GNUNET_MQ_send (h->mq, env);
891  return op;
892 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t reserved
Always zero.
Definition: identity.h:273
struct GNUNET_IDENTITY_Operation * op_tail
Tail of active operations.
Definition: identity_api.c:131
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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
#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:52
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
struct GNUNET_IDENTITY_Operation * op_head
Head of active operations.
Definition: identity_api.c:126
Client requests deletion of an identity.
Definition: identity.h:258
struct GNUNET_IDENTITY_Handle * h
Main identity handle.
Definition: identity_api.c:44
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
const char * name
void * cls
Closure for cont or cb.
Definition: identity_api.c:88
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:268
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:355
struct GNUNET_MQ_Handle * mq
Connection to service.
Definition: identity_api.c:105
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
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 904 of file identity_api.c.

References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cont, GNUNET_IDENTITY_Operation::create_cont, and GNUNET_IDENTITY_Operation::pk.

Referenced by destroy_handle(), do_shutdown(), set_handle_name(), and shutdown_task().

905 {
906  op->cont = NULL;
907  op->cb = NULL;
908  op->create_cont = NULL;
909  memset (&op->pk,
910  0,
911  sizeof (op->pk));
912 }
struct GNUNET_IDENTITY_PrivateKey pk
Private key to return to create_cont, or NULL.
Definition: identity_api.c:77
GNUNET_IDENTITY_CreateContinuation create_cont
Continuation to invoke with the result of the transmission; cb and cb will be NULL in this case...
Definition: identity_api.c:72
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
GNUNET_IDENTITY_Callback cb
Continuation to invoke with the result of the transmission for 'get' operations (cont and create_cont...
Definition: identity_api.c:83
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_key_get_length()

ssize_t GNUNET_IDENTITY_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 976 of file identity_api.c.

References GNUNET_IDENTITY_PublicKey::ecdsa_key, GNUNET_IDENTITY_PublicKey::eddsa_key, GNUNET_break, GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, and GNUNET_IDENTITY_PublicKey::type.

Referenced by block_plugin_revocation_evaluate(), block_plugin_revocation_get_key(), check_signature_identity(), ego_callback(), gns_string_to_value(), GNUNET_GNSRECORD_data_from_identity(), GNUNET_IDENTITY_public_key_to_string(), GNUNET_IDENTITY_read_key_from_buffer(), GNUNET_IDENTITY_write_key_to_buffer(), GNUNET_REVOCATION_check_pow(), GNUNET_REVOCATION_pow_round(), GNUNET_REVOCATION_proof_get_size(), publicize_rm(), run(), run_with_zone_pkey(), and sign_pow_identity().

977 {
978  switch (ntohl (key->type))
979  {
981  return sizeof (key->type) + sizeof (key->ecdsa_key);
982  break;
984  return sizeof (key->type) + sizeof (key->eddsa_key);
985  break;
986  default:
987  GNUNET_break (0);
988  }
989  return -1;
990 }
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_read_key_from_buffer()

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.

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
keythe key
bufferthe buffer
lenthe length of buffer
Returns
-1 or -2 on error, else the amount of bytes read from the buffer

Definition at line 994 of file identity_api.c.

References GNUNET_IDENTITY_PublicKey::ecdsa_key, GNUNET_IDENTITY_key_get_length(), GNUNET_memcpy, and GNUNET_IDENTITY_PublicKey::type.

Referenced by GNUNET_GNSRECORD_identity_from_data().

997 {
998  if (len < sizeof (key->type))
999  return -1;
1000  GNUNET_memcpy (&(key->type), buffer, sizeof (key->type));
1001  const ssize_t length = GNUNET_IDENTITY_key_get_length (key);
1002  if (len < length)
1003  return -1;
1004  if (length < 0)
1005  return -2;
1006  GNUNET_memcpy (&(key->ecdsa_key), buffer + sizeof (key->type), length
1007  - sizeof (key->type));
1008  return length;
1009 }
uint32_t type
Type of public key.
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
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_write_key_to_buffer()

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.

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 1013 of file identity_api.c.

References GNUNET_IDENTITY_key_get_length(), and GNUNET_memcpy.

Referenced by check_signature_identity(), GNUNET_GNSRECORD_data_from_identity(), and sign_pow_identity().

1017 {
1018  const ssize_t length = GNUNET_IDENTITY_key_get_length (key);
1019  if (len < length)
1020  return -1;
1021  if (length < 0)
1022  return -2;
1023  GNUNET_memcpy (buffer, key, length);
1024  return length;
1025 }
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
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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 1029 of file identity_api.c.

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 GNUNET_IDENTITY_read_signature_from_buffer(), GNUNET_IDENTITY_write_signature_to_buffer(), and GNUNET_REVOCATION_proof_get_size().

1031 {
1032  switch (ntohl (sig->type))
1033  {
1035  return sizeof (sig->type) + sizeof (sig->ecdsa_signature);
1036  break;
1038  return sizeof (sig->type) + sizeof (sig->eddsa_signature);
1039  break;
1040  default:
1041  GNUNET_break (0);
1042  }
1043  return -1;
1044 }
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint32_t type
Type of signature.
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 1048 of file identity_api.c.

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

1052 {
1053  if (len < sizeof (sig->type))
1054  return -1;
1055  GNUNET_memcpy (&(sig->type), buffer, sizeof (sig->type));
1056  const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig);
1057  if (len < length)
1058  return -1;
1059  if (length < 0)
1060  return -2;
1061  GNUNET_memcpy (&(sig->ecdsa_signature), buffer + sizeof (sig->type), length
1062  - sizeof (sig->type));
1063  return length;
1064 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
uint32_t type
Type of signature.
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call 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 1068 of file identity_api.c.

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

1072 {
1073  const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig);
1074  if (len < length)
1075  return -1;
1076  if (length < 0)
1077  return -2;
1078  GNUNET_memcpy (buffer, &(sig->type), sizeof (sig->type));
1079  GNUNET_memcpy (buffer + sizeof (sig->type), &(sig->ecdsa_signature), length
1080  - sizeof (sig->type));
1081  return length;
1082 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
uint32_t type
Type of signature.
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ GNUNET_IDENTITY_sign_()

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.

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 1086 of file identity_api.c.

References GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_IDENTITY_Signature::ecdsa_signature, GNUNET_IDENTITY_PrivateKey::eddsa_key, GNUNET_IDENTITY_Signature::eddsa_signature, GNUNET_break, GNUNET_CRYPTO_ecdsa_sign_(), GNUNET_CRYPTO_eddsa_sign_(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, GNUNET_SYSERR, GNUNET_IDENTITY_PrivateKey::type, and GNUNET_IDENTITY_Signature::type.

Referenced by OIDC_build_authz_code(), and sign_pow_identity().

1091 {
1092  sig->type = priv->type;
1093  switch (ntohl (priv->type))
1094  {
1096  return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose,
1097  &(sig->ecdsa_signature));
1098  break;
1100  return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose,
1101  &(sig->eddsa_signature));
1102  break;
1103  default:
1104  GNUNET_break (0);
1105  }
1106 
1107  return GNUNET_SYSERR;
1108 }
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
uint32_t type
Type of signature.
uint32_t type
Type of public key.
int 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:645
int 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:707
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_IDENTITY_signature_verify_()

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.

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 1112 of file identity_api.c.

References GNUNET_IDENTITY_PublicKey::ecdsa_key, GNUNET_IDENTITY_Signature::ecdsa_signature, GNUNET_IDENTITY_PublicKey::eddsa_key, GNUNET_IDENTITY_Signature::eddsa_signature, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_ecdsa_verify_(), GNUNET_CRYPTO_eddsa_verify_(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, GNUNET_SYSERR, GNUNET_IDENTITY_PublicKey::type, and GNUNET_IDENTITY_Signature::type.

Referenced by check_signature_identity(), and OIDC_parse_authz_code().

1117 {
1118  /* check type matching of 'sig' and 'pub' */
1119  GNUNET_assert (ntohl (pub->type) == ntohl (sig->type));
1120  switch (ntohl (pub->type))
1121  {
1123  return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate,
1124  &(sig->ecdsa_signature),
1125  &(pub->ecdsa_key));
1126  break;
1128  return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate,
1129  &(sig->eddsa_signature),
1130  &(pub->eddsa_key));
1131  break;
1132  default:
1133  GNUNET_break (0);
1134  }
1135 
1136  return GNUNET_SYSERR;
1137 }
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
uint32_t type
Type of public key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int 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:819
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
uint32_t type
Type of signature.
int 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:745
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 1141 of file identity_api.c.

References GNUNET_IDENTITY_PublicKey::ecdsa_key, GNUNET_IDENTITY_PublicKey::eddsa_key, 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, and GNUNET_IDENTITY_PublicKey::type.

Referenced by encrypt_message().

1146 {
1149  struct GNUNET_HashCode hash;
1150  switch (ntohl (pub->type))
1151  {
1154  &hash))
1155  return -1;
1156  break;
1159  &hash))
1160  return -1;
1161  break;
1162  default:
1163  return -1;
1164  }
1169  GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv);
1170  GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash));
1171  const ssize_t encrypted = GNUNET_CRYPTO_symmetric_encrypt (block, size, &key,
1172  &iv, result);
1173  GNUNET_CRYPTO_zero_keys (&key, sizeof(key));
1174  GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv));
1175  return encrypted;
1176 }
int 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:1111
uint32_t type
Type of public key.
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:470
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:508
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.
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
static int result
Global testing status.
A 512-bit hashcode.
int 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:1084
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:222
Private ECC key encoded for transmission.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:215
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
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 1180 of file identity_api.c.

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, and GNUNET_IDENTITY_PrivateKey::type.

Referenced by decrypt_message().

1185 {
1186  struct GNUNET_HashCode hash;
1187  switch (ntohl (priv->type))
1188  {
1190  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_ecdh (&(priv->ecdsa_key), ecc,
1191  &hash))
1192  return -1;
1193  break;
1195  if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_ecdh (&(priv->eddsa_key), ecc,
1196  &hash))
1197  return -1;
1198  break;
1199  default:
1200  return -1;
1201  }
1204  GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv);
1205  GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash));
1206  const ssize_t decrypted = GNUNET_CRYPTO_symmetric_decrypt (block, size, &key,
1207  &iv, result);
1208  GNUNET_CRYPTO_zero_keys (&key, sizeof(key));
1209  GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv));
1210  return decrypted;
1211 }
int 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:1056
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
int 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:1024
static int result
Global testing status.
A 512-bit hashcode.
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:222
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:67
uint32_t type
Type of public key.
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.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
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 1215 of file identity_api.c.

References GNUNET_IDENTITY_key_get_length(), GNUNET_STRINGS_data_to_string_alloc(), and size.

Referenced by create_finished(), ego_get_for_subsystem(), gns_value_to_string(), GNUNET_GNSRECORD_pkey_to_zkey(), handle_get_key(), list_ego(), and print_ego().

1217 {
1218  size_t size = GNUNET_IDENTITY_key_get_length (key);
1220  size);
1221 }
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
static unsigned int size
Size of the "table".
Definition: peer.c:67
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:937
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 1225 of file identity_api.c.

References GNUNET_STRINGS_data_to_string_alloc(), private_key_get_length(), and size.

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

1227 {
1228  size_t size = private_key_get_length (key);
1230  size);
1231 }
ssize_t private_key_get_length(const struct GNUNET_IDENTITY_PrivateKey *key)
Definition: identity_api.c:958
static unsigned int size
Size of the "table".
Definition: peer.c:67
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:937
Here is the call graph for this function:
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 1235 of file identity_api.c.

References GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, ret, and GNUNET_IDENTITY_PublicKey::type.

Referenced by authorize_endpoint(), code_redirect(), create_response(), gns_string_to_value(), GNUNET_GNS_lookup_with_tld(), GNUNET_GNSRECORD_zkey_to_pkey(), lookup_it_finished(), run(), run_with_zone_pkey(), start_process(), and tld_iter().

1237 {
1239  enum GNUNET_IDENTITY_KeyType ktype;
1240  ret = GNUNET_STRINGS_string_to_data (str,
1241  strlen (str),
1242  key,
1243  sizeof (*key));
1244  if (GNUNET_OK != ret)
1245  return GNUNET_SYSERR;
1246  ktype = ntohl (key->type);
1247  return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; // FIXME other keys, cleaner way?
1248 
1249 }
uint32_t type
Type of public key.
GNUNET_IDENTITY_KeyType
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:83
int 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:972
Here is the call graph for this function:
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 1253 of file identity_api.c.

References GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, ret, and GNUNET_IDENTITY_PrivateKey::type.

1255 {
1257  enum GNUNET_IDENTITY_KeyType ktype;
1258  ret = GNUNET_STRINGS_string_to_data (str,
1259  strlen (str),
1260  key,
1261  sizeof (*key));
1262  if (GNUNET_OK != ret)
1263  return GNUNET_SYSERR;
1264  ktype = ntohl (key->type);
1265  return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; // FIXME other keys, cleaner way?
1266 }
GNUNET_IDENTITY_KeyType
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:83
uint32_t type
Type of public key.
int 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:972
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 175 of file identity_api.c.

References GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_IDENTITY_PublicKey::ecdsa_key, GNUNET_IDENTITY_PrivateKey::eddsa_key, GNUNET_IDENTITY_PublicKey::eddsa_key, GNUNET_break, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, GNUNET_OK, GNUNET_SYSERR, GNUNET_IDENTITY_PrivateKey::type, and GNUNET_IDENTITY_PublicKey::type.

Referenced by attr_iter_cb(), authorize_endpoint(), create_finished(), create_message_key(), cred_iter_cb(), filter_tickets_finished_cb(), get_nick_record(), GNUNET_GNSRECORD_query_from_private_key(), GNUNET_IDENTITY_ego_get_public_key(), handle_attribute_store_message(), handle_client_call_message(), handle_credential_store_message(), identity_zone_cb(), RECLAIM_TICKETS_consume(), RECLAIM_TICKETS_revoke(), refresh_block(), run(), sign_pow(), and update_service_ego().

178 {
179  key->type = privkey->type;
180  switch (ntohl (privkey->type))
181  {
184  &key->ecdsa_key);
185  break;
188  &key->eddsa_key);
189  break;
190  default:
191  GNUNET_break (0);
192  return GNUNET_SYSERR;
193  }
194  return GNUNET_OK;
195 }
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
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:176
uint32_t type
Type of public key.
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:193
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
Here is the call graph for this function:
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 171 of file identity_api_lookup.c.

References GNUNET_IDENTITY_EgoLookup::cb, GNUNET_IDENTITY_EgoLookup::cb_cls, 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, GNUNET_IDENTITY_EgoLookup::mq, mq_error_handler(), and GNUNET_IDENTITY_EgoLookup::name.

Referenced by run().

175 {
177  struct GNUNET_MQ_Envelope *env;
178  struct GNUNET_MessageHeader *req;
179  size_t nlen;
180 
181  GNUNET_assert (NULL != cb);
183  el->cb = cb;
184  el->cb_cls = cb_cls;
185  {
187  { GNUNET_MQ_hd_var_size (identity_result_code,
189  struct ResultCodeMessage,
190  el),
191  GNUNET_MQ_hd_var_size (identity_update,
193  struct UpdateMessage,
194  el),
196 
197  el->mq =
198  GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
199  }
200  if (NULL == el->mq)
201  {
202  GNUNET_break (0);
203  GNUNET_free (el);
204  return NULL;
205  }
206  el->name = GNUNET_strdup (name);
207  nlen = strlen (name) + 1;
209  memcpy (&req[1], name, nlen);
210  GNUNET_MQ_send (el->mq, env);
211  return el;
212 }
Handle for ego lookup.
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:1063
struct GNUNET_MQ_Handle * mq
Connection to service.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#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:52
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#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.
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...
Message handler for a specific message type.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
char * name
Name of the ego we are looking up.
const char * name
GNUNET_IDENTITY_EgoCallback cb
Function to call with the result.
Header for all communications.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
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:355
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
void * cb_cls
Closure for cb.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:80
Service informs client about status of a pseudonym.
Definition: identity.h:115
#define GNUNET_free(ptr)
Wrapper around free.
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 221 of file identity_api_lookup.c.

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

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

222 {
223  GNUNET_MQ_destroy (el->mq);
224  GNUNET_free (el->name);
225  GNUNET_free (el);
226 }
struct GNUNET_MQ_Handle * mq
Connection to service.
char * name
Name of the ego we are looking up.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
#define GNUNET_free(ptr)
Wrapper around free.
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.

I.e., 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 168 of file identity_api_suffix_lookup.c.

References GNUNET_IDENTITY_EgoSuffixLookup::cb, GNUNET_IDENTITY_EgoSuffixLookup::cb_cls, 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, GNUNET_IDENTITY_EgoSuffixLookup::mq, mq_error_handler(), and GNUNET_IDENTITY_EgoSuffixLookup::suffix.

Referenced by GNUNET_GNS_lookup_with_tld().

173 {
175  struct GNUNET_MQ_Envelope *env;
176  struct GNUNET_MessageHeader *req;
177  size_t nlen;
178 
179  GNUNET_assert (NULL != cb);
181  el->cb = cb;
182  el->cb_cls = cb_cls;
183  {
185  { GNUNET_MQ_hd_var_size (identity_result_code,
187  struct ResultCodeMessage,
188  el),
189  GNUNET_MQ_hd_var_size (identity_update,
191  struct UpdateMessage,
192  el),
194 
195  el->mq =
196  GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
197  }
198  if (NULL == el->mq)
199  {
200  GNUNET_break (0);
201  GNUNET_free (el);
202  return NULL;
203  }
204  el->suffix = GNUNET_strdup (suffix);
205  nlen = strlen (suffix) + 1;
206  env = GNUNET_MQ_msg_extra (req, nlen,
208  memcpy (&req[1], suffix, nlen);
209  GNUNET_MQ_send (el->mq, env);
210  return el;
211 }
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:1063
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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...
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MQ_Handle * mq
Connection to service.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#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:52
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
Message handler for a specific message type.
#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 (...
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
GNUNET_IDENTITY_EgoSuffixCallback cb
Function to call with the result.
Header for all communications.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
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:355
char * suffix
Suffix we are looking up.
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:80
Service informs client about status of a pseudonym.
Definition: identity.h:115
#define GNUNET_free(ptr)
Wrapper around free.
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 220 of file identity_api_suffix_lookup.c.

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_IDENTITY_EgoSuffixLookup::mq, and GNUNET_IDENTITY_EgoSuffixLookup::suffix.

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

222 {
223  GNUNET_MQ_destroy (el->mq);
224  GNUNET_free (el->suffix);
225  GNUNET_free (el);
226 }
struct GNUNET_MQ_Handle * mq
Connection to service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
char * suffix
Suffix we are looking up.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: