![]() |
GNUnet
0.11.x
|
api to interact with the identity service More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_identity_service.h"
#include "identity.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_IDENTITY_Operation |
Handle for an operation with the identity service. More... | |
struct | GNUNET_IDENTITY_Handle |
Handle for the service. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__) |
Functions | |
struct GNUNET_IDENTITY_Ego * | GNUNET_IDENTITY_ego_get_anonymous () |
Obtain the ego representing 'anonymous' users. 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... | |
static int | private_key_create (enum GNUNET_IDENTITY_KeyType ktype, struct GNUNET_IDENTITY_PrivateKey *key) |
static void | reconnect (void *cls) |
Try again to connect to the identity service. More... | |
static int | free_ego (void *cls, const struct GNUNET_HashCode *key, void *value) |
Free ego from hash map. More... | |
static void | reschedule_connect (struct GNUNET_IDENTITY_Handle *h) |
Reschedule a connect attempt to the service. More... | |
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 creation of the message queue. More... | |
static int | check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) |
We received a result code from the service. More... | |
static void | handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) |
We received a result code from the service. More... | |
static int | check_identity_update (void *cls, const struct UpdateMessage *um) |
Check validity of identity update message. More... | |
static void | handle_identity_update (void *cls, const struct UpdateMessage *um) |
Handle identity update message. More... | |
static int | check_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) |
Function called when we receive a set default message from the service. More... | |
static void | handle_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) |
Type of a function to call when we receive a message from the service. More... | |
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. More... | |
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. 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_Operation * | GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, const char *service_name, GNUNET_IDENTITY_Callback cb, void *cb_cls) |
Obtain the identity that is currently preferred/default for a service. More... | |
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 identity for a service. More... | |
struct GNUNET_IDENTITY_Operation * | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, 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_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 identity. More... | |
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 identity. More... | |
void | GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) |
Cancel an identity operation. More... | |
void | GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) |
Disconnect from identity service. More... | |
ssize_t | private_key_get_length (const struct GNUNET_IDENTITY_PrivateKey *key) |
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... | |
api to interact with the identity service
Definition in file identity_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "identity-api", __VA_ARGS__) |
Definition at line 33 of file identity_api.c.
Referenced by reconnect(), and reschedule_connect().
|
static |
Definition at line 199 of file identity_api.c.
References GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_IDENTITY_PrivateKey::eddsa_key, GNUNET_break, GNUNET_CRYPTO_ecdsa_key_create(), GNUNET_CRYPTO_eddsa_key_create(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, GNUNET_OK, GNUNET_SYSERR, reconnect(), and GNUNET_IDENTITY_PrivateKey::type.
Referenced by GNUNET_IDENTITY_create().
|
static |
Try again to connect to the identity service.
cls | handle to the identity service. |
Definition at line 559 of file identity_api.c.
References GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Handle::cfg, GNUNET_IDENTITY_Operation::cls, env, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, GNUNET_MESSAGE_TYPE_IDENTITY_START, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_IDENTITY_Operation::h, LOG, GNUNET_IDENTITY_Handle::mq, mq_error_handler(), GNUNET_IDENTITY_Operation::msg, and GNUNET_IDENTITY_Handle::reconnect_task.
Referenced by GNUNET_IDENTITY_connect(), private_key_create(), and reschedule_connect().
|
static |
Free ego from hash map.
cls | identity service handle |
key | unused |
value | ego to free |
Definition at line 237 of file identity_api.c.
References GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Handle::cb_cls, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Ego::ctx, GNUNET_IDENTITY_Handle::egos, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_OK, GNUNET_YES, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Ego::name, and value.
Referenced by GNUNET_IDENTITY_disconnect(), and reschedule_connect().
|
static |
Reschedule a connect attempt to the service.
h | transport service to reconnect |
Definition at line 264 of file identity_api.c.
References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, GNUNET_IDENTITY_Operation::create_cont, GNUNET_IDENTITY_Handle::egos, free_ego(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_STD_BACKOFF, GNUNET_YES, LOG, GNUNET_IDENTITY_Handle::mq, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, reconnect(), GNUNET_IDENTITY_Handle::reconnect_delay, and GNUNET_IDENTITY_Handle::reconnect_task.
Referenced by handle_identity_result_code(), handle_identity_set_default(), handle_identity_update(), and mq_error_handler().
|
static |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.
Not every message queue implementation supports an error handler.
cls | closure with the struct GNUNET_IDENTITY_Handle * |
error | error code |
Definition at line 315 of file identity_api.c.
References GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::h, and reschedule_connect().
Referenced by reconnect().
|
static |
We received a result code from the service.
Check the message is well-formed.
cls | closure |
rcm | result message received |
Definition at line 333 of file identity_api.c.
References GNUNET_MQ_check_zero_termination, GNUNET_OK, ResultCodeMessage::header, and GNUNET_MessageHeader::size.
|
static |
We received a result code from the service.
cls | closure |
rcm | result message received |
Definition at line 349 of file identity_api.c.
References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Operation::cont, GNUNET_IDENTITY_Operation::create_cont, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_IDENTITY_Operation::h, ResultCodeMessage::header, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, GNUNET_IDENTITY_Operation::pk, reschedule_connect(), size, and GNUNET_MessageHeader::size.
|
static |
Check validity of identity update message.
cls | closure |
um | message received |
Definition at line 383 of file identity_api.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, UpdateMessage::header, UpdateMessage::name_len, size, and GNUNET_MessageHeader::size.
|
static |
Handle identity update message.
cls | closure |
um | message received |
Definition at line 407 of file identity_api.c.
References GNUNET_IDENTITY_Handle::cb, GNUNET_IDENTITY_Handle::cb_cls, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Ego::ctx, GNUNET_IDENTITY_Handle::egos, UpdateMessage::end_of_list, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_strdup, GNUNET_YES, GNUNET_IDENTITY_Operation::h, id, GNUNET_IDENTITY_Ego::id, GNUNET_IDENTITY_Ego::name, UpdateMessage::name_len, GNUNET_IDENTITY_Ego::pk, UpdateMessage::private_key, GNUNET_IDENTITY_Ego::pub_initialized, and reschedule_connect().
|
static |
Function called when we receive a set default message from the service.
cls | closure |
sdm | message received |
Definition at line 488 of file identity_api.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, SetDefaultMessage::header, SetDefaultMessage::name_len, SetDefaultMessage::reserved, size, and GNUNET_MessageHeader::size.
|
static |
Type of a function to call when we receive a message from the service.
cls | closure |
sdm | message received |
Definition at line 513 of file identity_api.c.
References GNUNET_IDENTITY_Operation::cb, GNUNET_IDENTITY_Operation::cls, GNUNET_IDENTITY_Ego::ctx, GNUNET_IDENTITY_Handle::egos, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_IDENTITY_Operation::h, GNUNET_IDENTITY_Ego::name, op, GNUNET_IDENTITY_Handle::op_head, GNUNET_IDENTITY_Handle::op_tail, SetDefaultMessage::private_key, and reschedule_connect().
ssize_t private_key_get_length | ( | const struct GNUNET_IDENTITY_PrivateKey * | key | ) |
Definition at line 958 of file identity_api.c.
References GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_IDENTITY_PrivateKey::eddsa_key, GNUNET_break, GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, and GNUNET_IDENTITY_PrivateKey::type.
Referenced by GNUNET_IDENTITY_private_key_to_string().