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_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 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)
@ GNUNET_OK
Definition: gnunet_common.h:95
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.

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 566 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 642 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 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 775 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 816 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 };
@ 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)

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.

640 {
641  return &ego->pk;
642 }
struct GNUNET_IDENTITY_PrivateKey pk
The identity key pair.
Definition: identity.h:51

References GNUNET_IDENTITY_Ego::pk.

Referenced by add_attribute_cont(), add_credential_cont(), authorize_endpoint(), callback_ego_lookup(), callback_update_ego(), code_redirect(), consume_ticket_cont(), create_did_store(), 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(), read_encrypted_message(), remove_did_document_ego_lookup_cb(), revoke_ticket_cont(), sign_cb(), store_cb(), uri_ksk_continuation(), and userinfo_endpoint().

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.

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: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
Handle for an ego.
Definition: identity.h:37
uint32_t type
Type of public key.

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_anonymous_public_key(), and get_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 652 of file identity_api.c.

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_PrivateKey pk
Private key from command line option, or NULL.
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
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
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(), create_did_ego_lockup_cb(), DID_ego_to_did(), ego_callback(), ego_get_for_subsystem(), find_ego(), get_anonymous_public_key(), get_ego(), get_handle_ego(), 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 610 of file identity_api.c.

613 {
614  struct GNUNET_IDENTITY_Handle *h;
615 
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 }
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:559
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:96
GNUNET_IDENTITY_Callback cb
Function to call when we receive updates.
Definition: identity_api.c:116
void * cb_cls
Closure for cb.
Definition: identity_api.c:121

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

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;
698  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
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 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
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:302
#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
#define GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
Client requests to know default identity for a subsystem.
struct GNUNET_ARM_Handle * h
ARM handle.
Definition: arm_api.c:55
Handle for an operation with the identity service.
Definition: identity_api.c:40
Client requests knowledge about default identity for a subsystem from identity service.
Definition: identity.h:147
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:156
uint16_t reserved
Always zero.
Definition: identity.h:161

References 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_ARM_Operation::h, h, GNUNET_ARM_Handle::mq, GetDefaultMessage::name_len, op, GetDefaultMessage::reserved, and service_name.

Referenced by ego_get_subsystem(), and id_connect_cb().

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.

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;
744  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
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:173
uint16_t reserved
Always zero.
Definition: identity.h:187
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:182
struct GNUNET_IDENTITY_PrivateKey private_key
The private key.
Definition: identity.h:192

References 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_ARM_Operation::h, h, GNUNET_ARM_Handle::mq, SetDefaultMessage::name_len, op, GNUNET_IDENTITY_Ego::pk, SetDefaultMessage::private_key, SetDefaultMessage::reserved, and service_name.

Referenced by ego_edit_subsystem(), and print_ego().

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.

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);
942  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
943  memset (&op->pk,
944  0,
945  sizeof (op->pk));
946  GNUNET_free (op);
947  }
948  if (NULL != h->mq)
949  {
951  h->mq = NULL;
952  }
953  GNUNET_free (h);
954 }
#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.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:685
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
static int free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
Free ego from hash map.
Definition: identity_api.c:237
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147

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

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 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
Create new identity (client->service).
static int private_key_create(enum GNUNET_IDENTITY_KeyType ktype, struct GNUNET_IDENTITY_PrivateKey *key)
Definition: identity_api.c:199
const char * name
Client requests creation of an identity.
Definition: identity.h:203
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:212
struct GNUNET_IDENTITY_PrivateKey private_key
The private key.
Definition: identity.h:222
uint16_t reserved
Always zero.
Definition: identity.h:217

References 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_ARM_Operation::h, h, GNUNET_ARM_Handle::mq, name, CreateRequestMessage::name_len, op, CreateRequestMessage::private_key, private_key_create(), and CreateRequestMessage::reserved.

Referenced by create_did_document(), create_store_ego(), ego_create(), 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 810 of file identity_api.c.

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;
839  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
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 }
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
Client requests renaming of an identity.
Definition: identity.h:233
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:242
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:247

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

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;
885  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
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).
Client requests deletion of an identity.
Definition: identity.h:259
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:268
uint16_t reserved
Always zero.
Definition: identity.h:273

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

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 }

References op.

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

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

992 {
993  switch (ntohl (key->type))
994  {
996  return sizeof (key->type) + sizeof (key->ecdsa_key);
998  return sizeof (key->type) + sizeof (key->eddsa_key);
999  default:
1000  GNUNET_break (0);
1001  }
1002  return -1;
1003 }
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 change_handle_ego(), check_signature(), ego_callback(), get_message_body_size(), gns_string_to_value(), GNUNET_IDENTITY_public_key_to_string(), GNUNET_IDENTITY_read_key_from_buffer(), GNUNET_IDENTITY_write_key_to_buffer(), GNUNET_MESSENGER_send_message(), GNUNET_REVOCATION_proof_get_size(), run(), run_edkey(), run_pkey(), and run_with_zone_pkey().

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

1010 {
1011  if (len < sizeof (key->type))
1012  return -1;
1013  GNUNET_memcpy (&key->type,
1014  buffer,
1015  sizeof (key->type));
1016  ssize_t length = GNUNET_IDENTITY_key_get_length (key);
1017  if (len < length)
1018  return -1;
1019  if (length < 0)
1020  return -2;
1021  GNUNET_memcpy (&key->ecdsa_key,
1022  buffer + sizeof (key->type),
1023  length - sizeof (key->type));
1024  return length;
1025 }
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_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:991

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

Referenced by check_get_key(), check_send_message(), handle_get_key(), and handle_send_message().

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

1033 {
1034  const ssize_t length = GNUNET_IDENTITY_key_get_length (key);
1035  if (len < length)
1036  return -1;
1037  if (length < 0)
1038  return -2;
1039  GNUNET_memcpy (buffer, &(key->type), sizeof (key->type));
1040  GNUNET_memcpy (buffer + sizeof (key->type), &(key->ecdsa_key), length
1041  - sizeof (key->type));
1042  return length;
1043 }

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

Referenced by change_handle_ego(), check_signature(), and GNUNET_MESSENGER_send_message().

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

1049 {
1050  switch (ntohl (sig->type))
1051  {
1053  return sizeof (sig->type) + sizeof (sig->ecdsa_signature);
1054  break;
1056  return sizeof (sig->type) + sizeof (sig->eddsa_signature);
1057  break;
1058  default:
1059  GNUNET_break (0);
1060  }
1061  return -1;
1062 }
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_(), 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 1066 of file identity_api.c.

1067 {
1068  switch (ntohl (type))
1069  {
1071  return sizeof (struct GNUNET_CRYPTO_EcdsaSignature);
1072  break;
1074  return sizeof (struct GNUNET_CRYPTO_EddsaSignature);
1075  break;
1076  default:
1077  GNUNET_break (0);
1078  }
1079  return -1;
1080 }
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 1085 of file identity_api.c.

1089 {
1090  if (len < sizeof (sig->type))
1091  return -1;
1092  GNUNET_memcpy (&(sig->type), buffer, sizeof (sig->type));
1093  const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig);
1094  if (len < length)
1095  return -1;
1096  if (length < 0)
1097  return -2;
1098  GNUNET_memcpy (&(sig->ecdsa_signature), buffer + sizeof (sig->type), length
1099  - sizeof (sig->type));
1100  return length;
1101 }
ssize_t GNUNET_IDENTITY_signature_get_length(const struct GNUNET_IDENTITY_Signature *sig)
Get the compacted length of a GNUNET_IDENTITY_Signature.

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

Referenced by decode_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 1105 of file identity_api.c.

1109 {
1110  const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig);
1111  if (len < length)
1112  return -1;
1113  if (length < 0)
1114  return -2;
1115  GNUNET_memcpy (buffer, &(sig->type), sizeof (sig->type));
1116  GNUNET_memcpy (buffer + sizeof (sig->type), &(sig->ecdsa_signature), length
1117  - sizeof (sig->type));
1118  return length;
1119 }

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

1153 {
1154  sig->type = priv->type;
1155  switch (ntohl (priv->type))
1156  {
1158  return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose,
1159  &(sig->ecdsa_signature));
1160  break;
1162  return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose,
1163  &(sig->eddsa_signature));
1164  break;
1165  default:
1166  GNUNET_break (0);
1167  }
1168 
1169  return GNUNET_SYSERR;
1170 }
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
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:599
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 1105 of file identity_api.c.

1127 {
1128  switch (ntohl (priv->type))
1129  {
1131  return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose,
1132  (struct GNUNET_CRYPTO_EcdsaSignature*)sig);
1133  break;
1135  return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose,
1136  (struct GNUNET_CRYPTO_EddsaSignature*)sig);
1137  break;
1138  default:
1139  GNUNET_break (0);
1140  }
1141 
1142  return GNUNET_SYSERR;
1143 }

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

1179 {
1180  /* check type matching of 'sig' and 'pub' */
1181  GNUNET_assert (ntohl (pub->type) == ntohl (sig->type));
1182  switch (ntohl (pub->type))
1183  {
1185  return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate,
1186  &(sig->ecdsa_signature),
1187  &(pub->ecdsa_key));
1188  break;
1190  return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate,
1191  &(sig->eddsa_signature),
1192  &(pub->eddsa_key));
1193  break;
1194  default:
1195  GNUNET_break (0);
1196  }
1197 
1198  return GNUNET_SYSERR;
1199 }
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:623
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:682

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

1210 {
1211  switch (ntohl (pub->type))
1212  {
1214  return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate,
1215  (struct GNUNET_CRYPTO_EcdsaSignature*)sig,
1216  &(pub->ecdsa_key));
1217  break;
1219  return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate,
1220  (struct GNUNET_CRYPTO_EddsaSignature*)sig,
1221  &(pub->eddsa_key));
1222  break;
1223  default:
1224  GNUNET_break (0);
1225  }
1226 
1227  return GNUNET_SYSERR;
1228 }

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

1239 {
1242  struct GNUNET_HashCode hash;
1243  switch (ntohl (pub->type))
1244  {
1246  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_ecdsa (&pk, &(pub->ecdsa_key),
1247  &hash))
1248  return -1;
1249  break;
1251  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_eddsa (&pk, &(pub->eddsa_key),
1252  &hash))
1253  return -1;
1254  break;
1255  default:
1256  return -1;
1257  }
1262  GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv);
1263  GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash));
1264  const ssize_t encrypted = GNUNET_CRYPTO_symmetric_encrypt (block, size, &key,
1265  &iv, result);
1266  GNUNET_CRYPTO_zero_keys (&key, sizeof(key));
1267  GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv));
1268  return encrypted;
1269 }
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:775
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:758
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 1273 of file identity_api.c.

1278 {
1279  struct GNUNET_HashCode hash;
1280  switch (ntohl (priv->type))
1281  {
1283  if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_ecdh (&(priv->ecdsa_key), ecc,
1284  &hash))
1285  return -1;
1286  break;
1288  if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_ecdh (&(priv->eddsa_key), ecc,
1289  &hash))
1290  return -1;
1291  break;
1292  default:
1293  return -1;
1294  }
1297  GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv);
1298  GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash));
1299  const ssize_t decrypted = GNUNET_CRYPTO_symmetric_decrypt (block, size, &key,
1300  &iv, result);
1301  GNUNET_CRYPTO_zero_keys (&key, sizeof(key));
1302  GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv));
1303  return decrypted;
1304 }
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:740
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:718
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 1308 of file identity_api.c.

1310 {
1313  size);
1314 }
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_key_get_length(), GNUNET_STRINGS_data_to_string_alloc(), key, and size.

Referenced by abd_value_to_string(), create_did_generate(), create_finished(), delegation_chain_fw_resolution_start(), DID_ego_to_did(), ego_get_for_subsystem(), 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(), list_ego(), print_deleset(), print_ego(), 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 1318 of file identity_api.c.

1320 {
1321  size_t size = private_key_get_length (key);
1323  size);
1324 }
static ssize_t private_key_get_length(const struct GNUNET_IDENTITY_PrivateKey *key)
Definition: identity_api.c:973

Referenced by create_finished(), 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 1318 of file identity_api.c.

1329 {
1332  strlen (str),
1333  key,
1334  sizeof (*key));
1335  if (GNUNET_OK != ret)
1336  return GNUNET_SYSERR;
1337  return check_key_type (ntohl (key->type));
1338 
1339 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
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:958

Referenced by abd_string_to_value(), authorize_endpoint(), code_redirect(), create_response(), 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 1318 of file identity_api.c.

1345 {
1348  strlen (str),
1349  key,
1350  sizeof (*key));
1351  if (GNUNET_OK != ret)
1352  return GNUNET_SYSERR;
1353  return check_key_type (ntohl (key->type));
1354 }

References GNUNET_STRINGS_data_to_string_alloc(), key, private_key_get_length(), 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 156 of file identity_api.c.

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 }
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_decrypt_ecdsa(), create_finished(), create_message_key(), cred_iter_cb(), 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(), RECLAIM_TICKETS_consume(), RECLAIM_TICKETS_revoke(), refresh_block(), 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 171 of file identity_api_lookup.c.

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 =
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 }
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:1066
#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:116

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 create_did_document_ego_create_cb(), get_did_for_ego(), lookup_store_ego(), 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 221 of file identity_api_lookup.c.

222 {
224  GNUNET_free (el->name);
225  GNUNET_free (el);
226 }

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

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 =
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 }
#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 220 of file identity_api_suffix_lookup.c.

222 {
224  GNUNET_free (el->suffix);
225  GNUNET_free (el);
226 }

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: