GNUnet  0.10.x
Data Structures | Typedefs | Enumerations | Functions
Credential service

Credentials. More...

Data Structures

struct  GNUNET_CREDENTIAL_DelegationRecord
 The attribute delegation record. More...
 
struct  GNUNET_CREDENTIAL_DelegationRecordSet
 The attribute delegation record. More...
 
struct  GNUNET_CREDENTIAL_DelegationSet
 The attribute delegation record. More...
 
struct  GNUNET_CREDENTIAL_Delegation
 A delegation. More...
 
struct  GNUNET_CREDENTIAL_Credential
 A credential. More...
 

Typedefs

typedef void(* GNUNET_CREDENTIAL_CredentialResultProcessor) (void *cls, unsigned int d_count, struct GNUNET_CREDENTIAL_Delegation *delegation_chain, unsigned int c_count, struct GNUNET_CREDENTIAL_Credential *credential)
 Iterator called on obtained result for an attribute verification. More...
 
typedef void(* GNUNET_CREDENTIAL_DelegateResultProcessor) (void *cls, uint32_t success)
 Iterator called on obtained result for an attribute delegation. More...
 
typedef void(* GNUNET_CREDENTIAL_RemoveDelegateResultProcessor) (void *cls, uint32_t success)
 Iterator called on obtained result for an attribute delegation removal. More...
 

Enumerations

enum  GNUNET_CREDENTIAL_CredentialFlags { GNUNET_CREDENTIAL_FLAG_REVOKED =0, GNUNET_CREDENTIAL_FLAG_SUBJECT =1, GNUNET_CREDENTIAL_FLAG_ISSUER =2 }
 

Functions

struct GNUNET_CREDENTIAL_HandleGNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize the connection with the Credential service. More...
 
void GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle)
 Shutdown connection with the Credentail service. More...
 
struct GNUNET_CREDENTIAL_RequestGNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key, uint32_t credential_count, const struct GNUNET_CREDENTIAL_Credential *credentials, GNUNET_CREDENTIAL_CredentialResultProcessor proc, void *proc_cls)
 Performs attribute verification. More...
 
struct GNUNET_CREDENTIAL_RequestGNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle, const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key, GNUNET_CREDENTIAL_CredentialResultProcessor proc, void *proc_cls)
 Performs attribute collection. More...
 
struct GNUNET_CREDENTIAL_RequestGNUNET_CREDENTIAL_add_delegation (struct GNUNET_CREDENTIAL_Handle *handle, struct GNUNET_IDENTITY_Ego *issuer, const char *attribute, struct GNUNET_CRYPTO_EcdsaPublicKey *subject, const char *delegated_attribute, GNUNET_CREDENTIAL_DelegateResultProcessor proc, void *proc_cls)
 Delegate an attribute. More...
 
struct GNUNET_CREDENTIAL_RequestGNUNET_CREDENTIAL_remove_delegation (struct GNUNET_CREDENTIAL_Handle *handle, struct GNUNET_IDENTITY_Ego *issuer, const char *attribute, GNUNET_CREDENTIAL_RemoveDelegateResultProcessor proc, void *proc_cls)
 Remove a delegation. More...
 
struct GNUNET_CREDENTIAL_CredentialGNUNET_CREDENTIAL_credential_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, struct GNUNET_CRYPTO_EcdsaPublicKey *subject, const char *attribute, struct GNUNET_TIME_Absolute *expiration)
 Issue an attribute to a subject. More...
 
void GNUNET_CREDENTIAL_request_cancel (struct GNUNET_CREDENTIAL_Request *lr)
 Cancel pending lookup request. More...
 

Detailed Description

Credentials.

Typedef Documentation

◆ GNUNET_CREDENTIAL_CredentialResultProcessor

typedef void(* GNUNET_CREDENTIAL_CredentialResultProcessor) (void *cls, unsigned int d_count, struct GNUNET_CREDENTIAL_Delegation *delegation_chain, unsigned int c_count, struct GNUNET_CREDENTIAL_Credential *credential)

Iterator called on obtained result for an attribute verification.

Parameters
clsclosure
d_countthe number of delegations processed
delegation_chainthe delegations processed
c_countthe number of credentials found
credentialthe credentials

Definition at line 237 of file gnunet_credential_service.h.

◆ GNUNET_CREDENTIAL_DelegateResultProcessor

typedef void(* GNUNET_CREDENTIAL_DelegateResultProcessor) (void *cls, uint32_t success)

Iterator called on obtained result for an attribute delegation.

Parameters
clsclosure
successGNUNET_YES if successful
resultthe record data that can be handed to the subject

Definition at line 250 of file gnunet_credential_service.h.

◆ GNUNET_CREDENTIAL_RemoveDelegateResultProcessor

typedef void(* GNUNET_CREDENTIAL_RemoveDelegateResultProcessor) (void *cls, uint32_t success)

Iterator called on obtained result for an attribute delegation removal.

Parameters
clsclosure
successGNUNET_YES if successful
resultthe record data that can be handed to the subject

Definition at line 260 of file gnunet_credential_service.h.

Enumeration Type Documentation

◆ GNUNET_CREDENTIAL_CredentialFlags

Enumerator
GNUNET_CREDENTIAL_FLAG_REVOKED 
GNUNET_CREDENTIAL_FLAG_SUBJECT 
GNUNET_CREDENTIAL_FLAG_ISSUER 

Definition at line 61 of file gnunet_credential_service.h.

61  {
62 
63  //Subject had credentials before, but have been revoked now
65 
66  //Subject flag indicates that the subject is a holder of this credential and may present it as such
68 
69  //Issuer flag is used to signify that the subject is allowed to issue this credential and delegate issuance
71 
72 };

Function Documentation

◆ GNUNET_CREDENTIAL_connect()

struct GNUNET_CREDENTIAL_Handle* GNUNET_CREDENTIAL_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize the connection with the Credential service.

Parameters
cfgconfiguration to use
Returns
handle to the Credential service, or NULL on error

Initialize the connection with the Credential service.

Parameters
cfgconfiguration to use
Returns
handle to the CREDENTIAL service, or NULL on error

Definition at line 306 of file credential_api.c.

References GNUNET_CREDENTIAL_Handle::cfg, cfg, GNUNET_free, GNUNET_new, handle, GNUNET_CREDENTIAL_Handle::mq, and reconnect().

Referenced by collect_cred_cont(), get_cred_issuer_cb(), run(), and verify_cred_cont().

307 {
309 
310  handle = GNUNET_new (struct GNUNET_CREDENTIAL_Handle);
311  handle->cfg = cfg;
312  reconnect (handle);
313  if (NULL == handle->mq)
314  {
315  GNUNET_free (handle);
316  return NULL;
317  }
318  return handle;
319 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Connection to the CREDENTIAL service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static void reconnect(struct GNUNET_CREDENTIAL_Handle *handle)
Reconnect to CREDENTIAL service.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CREDENTIAL_disconnect()

void GNUNET_CREDENTIAL_disconnect ( struct GNUNET_CREDENTIAL_Handle handle)

Shutdown connection with the Credentail service.

Parameters
handleconnection to shut down

Shutdown connection with the Credentail service.

Parameters
handlehandle of the CREDENTIAL connection to stop

Definition at line 328 of file credential_api.c.

References GNUNET_assert, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_CREDENTIAL_Handle::mq, GNUNET_CREDENTIAL_Handle::reconnect_task, and GNUNET_CREDENTIAL_Handle::request_head.

Referenced by cleanup_handle(), and do_shutdown().

329 {
330  if (NULL != handle->mq)
331  {
332  GNUNET_MQ_destroy (handle->mq);
333  handle->mq = NULL;
334  }
335  if (NULL != handle->reconnect_task)
336  {
338  handle->reconnect_task = NULL;
339  }
340  GNUNET_assert (NULL == handle->request_head);
341  GNUNET_free (handle);
342 }
struct GNUNET_CREDENTIAL_Request * request_head
Head of linked list of active verify requests.
struct GNUNET_SCHEDULER_Task * reconnect_task
Reconnect task.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#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:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CREDENTIAL_verify()

struct GNUNET_CREDENTIAL_Request* GNUNET_CREDENTIAL_verify ( struct GNUNET_CREDENTIAL_Handle handle,
const struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key,
const char *  issuer_attribute,
const struct GNUNET_CRYPTO_EcdsaPublicKey subject_key,
uint32_t  credential_count,
const struct GNUNET_CREDENTIAL_Credential credentials,
GNUNET_CREDENTIAL_CredentialResultProcessor  proc,
void *  proc_cls 
)

Performs attribute verification.

Checks if there is a delegation chain from attribute issuer_attribute'' issued by the issuer with public keyissuer_key'' maps to the attribute subject_attribute'' claimed by the subject with key subject_key''

Parameters
handlehandle to the Credential service
issuer_keythe issuer public key
issuer_attributethe issuer attribute
subject_keythe subject public key
credential_countnumber of credentials
credentialsthe subject credentials
procfunction to call on result
proc_clsclosure for processor
Returns
handle to the queued request

Checks if there is a delegation chain from attribute issuer_attribute'' issued by the issuer with public keyissuer_key'' maps to the attribute subject_attribute'' claimed by the subject with key subject_key''

Parameters
handlehandle to the Credential service
issuer_keythe issuer public key
issuer_attributethe issuer attribute
subject_keythe subject public key
credential_countnumber of credentials provided
credentialssubject credentials
procfunction to call on result
proc_clsclosure for processor
Returns
handle to the queued request

Definition at line 447 of file credential_api.c.

References VerifyMessage::c_count, GNUNET_CREDENTIAL_Request::credential_handle, GNUNET_CREDENTIAL_Request::env, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CREDENTIAL_credentials_get_size(), GNUNET_CREDENTIAL_credentials_serialize(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY, GNUNET_MQ_msg_extra, GNUNET_MQ_send_copy(), GNUNET_new, handle, VerifyMessage::id, VerifyMessage::issuer_attribute_len, VerifyMessage::issuer_key, issuer_key, LOG, GNUNET_CREDENTIAL_Handle::mq, GNUNET_CREDENTIAL_Request::proc_cls, GNUNET_CREDENTIAL_Request::r_id, GNUNET_CREDENTIAL_Handle::r_id_gen, GNUNET_CREDENTIAL_Handle::request_head, GNUNET_CREDENTIAL_Handle::request_tail, VerifyMessage::subject_key, subject_key, and GNUNET_CREDENTIAL_Request::verify_proc.

Referenced by run(), and verify_cred_cont().

455 {
456  /* IPC to shorten credential names, return shorten_handle */
457  struct VerifyMessage *v_msg;
458  struct GNUNET_CREDENTIAL_Request *vr;
459  size_t nlen;
460  size_t clen;
461 
462  if (NULL == issuer_attribute || NULL == credentials)
463  {
464  GNUNET_break (0);
465  return NULL;
466  }
467 
468  clen = GNUNET_CREDENTIAL_credentials_get_size (credential_count,
469  credentials);
470 
471  //DEBUG LOG
473  "Trying to verify `%s' in CREDENTIAL\n",
474  issuer_attribute);
475  nlen = strlen (issuer_attribute) + 1 + clen;
476  if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*vr))
477  {
478  GNUNET_break (0);
479  return NULL;
480  }
483  vr->verify_proc = proc;
484  vr->proc_cls = proc_cls;
485  vr->r_id = handle->r_id_gen++;
486  vr->env = GNUNET_MQ_msg_extra (v_msg,
487  nlen,
489  v_msg->id = htonl (vr->r_id);
490  v_msg->subject_key = *subject_key;
491  v_msg->c_count = htonl(credential_count);
492  v_msg->issuer_key = *issuer_key;
493  v_msg->issuer_attribute_len = htons(strlen(issuer_attribute));
494  GNUNET_memcpy (&v_msg[1],
495  issuer_attribute,
496  strlen (issuer_attribute));
497  GNUNET_CREDENTIAL_credentials_serialize (credential_count,
498  credentials,
499  clen,
500  ((char*)&v_msg[1])
501  + strlen (issuer_attribute) + 1);
503  handle->request_tail,
504  vr);
505  if (NULL != handle->mq)
506  GNUNET_MQ_send_copy (handle->mq,
507  vr->env);
508  return vr;
509 }
Message from client to Credential service to verify attributes.
Definition: credential.h:70
struct GNUNET_CREDENTIAL_Request * request_head
Head of linked list of active verify requests.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
uint16_t issuer_attribute_len
Length of the issuer attribute.
Definition: credential.h:95
uint32_t id
Unique identifier for this request (for key collisions).
Definition: credential.h:100
static char * subject_key
Subject pubkey string.
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Subject public key.
Definition: credential.h:80
uint32_t r_id
request id
#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...
#define LOG(kind,...)
ssize_t GNUNET_CREDENTIAL_credentials_serialize(unsigned int c_count, const struct GNUNET_CREDENTIAL_Credential *cd, size_t dest_size, char *dest)
Serizalize the given credentials.
#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_memcpy(dst, src, n)
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
uint32_t r_id_gen
Request Id generator.
Handle to a verify request.
static char * issuer_key
Issuer pubkey string.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint32_t c_count
Number of credentials.
Definition: credential.h:90
size_t GNUNET_CREDENTIAL_credentials_get_size(unsigned int c_count, const struct GNUNET_CREDENTIAL_Credential *cd)
Calculate how many bytes we will need to serialize the credentials.
#define GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY
void GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
Send a copy of a message with the given message queue.
Definition: mq.c:432
GNUNET_CREDENTIAL_CredentialResultProcessor verify_proc
processor to call on verify result
void * proc_cls
verify_proc closure
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
struct GNUNET_CREDENTIAL_Request * request_tail
Tail of linked list of active verify requests.
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
Trust anchor.
Definition: credential.h:85
struct GNUNET_CREDENTIAL_Handle * credential_handle
handle to credential service
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CREDENTIAL_collect()

struct GNUNET_CREDENTIAL_Request* GNUNET_CREDENTIAL_collect ( struct GNUNET_CREDENTIAL_Handle handle,
const struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key,
const char *  issuer_attribute,
const struct GNUNET_CRYPTO_EcdsaPrivateKey subject_key,
GNUNET_CREDENTIAL_CredentialResultProcessor  proc,
void *  proc_cls 
)

Performs attribute collection.

Collects all credentials of subject to fulfill the attribute, if possible

Parameters
handlehandle to the Credential service
issuer_keythe issuer public key
issuer_attributethe issuer attribute
subject_keythe subject public key
procfunction to call on result
proc_clsclosure for processor
Returns
handle to the queued request

Definition at line 377 of file credential_api.c.

References GNUNET_CREDENTIAL_Request::credential_handle, GNUNET_CREDENTIAL_Request::env, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT, GNUNET_MQ_msg_extra, GNUNET_MQ_send_copy(), GNUNET_new, handle, CollectMessage::id, CollectMessage::issuer_attribute_len, issuer_key, CollectMessage::issuer_key, LOG, GNUNET_CREDENTIAL_Handle::mq, GNUNET_CREDENTIAL_Request::proc_cls, GNUNET_CREDENTIAL_Request::r_id, GNUNET_CREDENTIAL_Handle::r_id_gen, GNUNET_CREDENTIAL_Handle::request_head, GNUNET_CREDENTIAL_Handle::request_tail, subject_key, CollectMessage::subject_key, and GNUNET_CREDENTIAL_Request::verify_proc.

Referenced by identity_cb(), and subject_ego_lookup().

383 {
384  /* IPC to shorten credential names, return shorten_handle */
385  struct CollectMessage *c_msg;
386  struct GNUNET_CREDENTIAL_Request *vr;
387  size_t nlen;
388 
389  if (NULL == issuer_attribute)
390  {
391  GNUNET_break (0);
392  return NULL;
393  }
394 
395  //DEBUG LOG
397  "Trying to collect `%s' in CREDENTIAL\n",
398  issuer_attribute);
399  nlen = strlen (issuer_attribute) + 1;
400  if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*vr))
401  {
402  GNUNET_break (0);
403  return NULL;
404  }
407  vr->verify_proc = proc;
408  vr->proc_cls = proc_cls;
409  vr->r_id = handle->r_id_gen++;
410  vr->env = GNUNET_MQ_msg_extra (c_msg,
411  nlen,
413  c_msg->id = htonl (vr->r_id);
414  c_msg->subject_key = *subject_key;
415  c_msg->issuer_key = *issuer_key;
416  c_msg->issuer_attribute_len = htons(strlen(issuer_attribute));
417  GNUNET_memcpy (&c_msg[1],
418  issuer_attribute,
419  strlen (issuer_attribute));
421  handle->request_tail,
422  vr);
423  if (NULL != handle->mq)
424  GNUNET_MQ_send_copy (handle->mq,
425  vr->env);
426  return vr;
427 }
struct GNUNET_CREDENTIAL_Request * request_head
Head of linked list of active verify requests.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static char * subject_key
Subject pubkey string.
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
Trust anchor.
Definition: credential.h:50
#define GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT
Message from client to Credential service to collect credentials.
Definition: credential.h:35
uint32_t r_id
request id
#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...
#define LOG(kind,...)
#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_memcpy(dst, src, n)
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
uint32_t r_id_gen
Request Id generator.
Handle to a verify request.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: credential.h:60
static char * issuer_key
Issuer pubkey string.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
struct GNUNET_CRYPTO_EcdsaPrivateKey subject_key
Subject public key.
Definition: credential.h:45
void GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
Send a copy of a message with the given message queue.
Definition: mq.c:432
GNUNET_CREDENTIAL_CredentialResultProcessor verify_proc
processor to call on verify result
uint16_t issuer_attribute_len
Length of the issuer attribute.
Definition: credential.h:55
void * proc_cls
verify_proc closure
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
struct GNUNET_CREDENTIAL_Request * request_tail
Tail of linked list of active verify requests.
struct GNUNET_CREDENTIAL_Handle * credential_handle
handle to credential service
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CREDENTIAL_add_delegation()

struct GNUNET_CREDENTIAL_Request* GNUNET_CREDENTIAL_add_delegation ( struct GNUNET_CREDENTIAL_Handle handle,
struct GNUNET_IDENTITY_Ego issuer,
const char *  attribute,
struct GNUNET_CRYPTO_EcdsaPublicKey subject,
const char *  delegated_attribute,
GNUNET_CREDENTIAL_DelegateResultProcessor  proc,
void *  proc_cls 
)

Delegate an attribute.

Parameters
handlehandle to the Credential service
issuerthe ego that should be used to delegate the attribute
attributethe name of the attribute to delegate
subjectthe subject of the delegation
delegated_attributethe name of the attribute that is delegated to
procthe result callback
proc_clsthe result closure context
Returns
handle to the queued request

◆ GNUNET_CREDENTIAL_remove_delegation()

struct GNUNET_CREDENTIAL_Request* GNUNET_CREDENTIAL_remove_delegation ( struct GNUNET_CREDENTIAL_Handle handle,
struct GNUNET_IDENTITY_Ego issuer,
const char *  attribute,
GNUNET_CREDENTIAL_RemoveDelegateResultProcessor  proc,
void *  proc_cls 
)

Remove a delegation.

Parameters
handlehandle to the Credential service
issuerthe ego that was used to delegate the attribute
attributethe name of the attribute that is delegated
procthe callback
proc_clscallback closure
Returns
handle to the queued request

◆ GNUNET_CREDENTIAL_credential_issue()

struct GNUNET_CREDENTIAL_Credential* GNUNET_CREDENTIAL_credential_issue ( const struct GNUNET_CRYPTO_EcdsaPrivateKey issuer,
struct GNUNET_CRYPTO_EcdsaPublicKey subject,
const char *  attribute,
struct GNUNET_TIME_Absolute expiration 
)

Issue an attribute to a subject.

Parameters
issuerthe ego that should be used to issue the attribute
subjectthe subject of the attribute
attributethe name of the attribute
expirationthe TTL of the credential
Returns
handle to the queued request
Parameters
issuerthe ego that should be used to issue the attribute
subjectthe subject of the attribute
attributethe name of the attribute
Returns
handle to the queued request

Definition at line 122 of file credential_misc.c.

References GNUNET_TIME_Absolute::abs_value_us, expiration, GNUNET_CREDENTIAL_Credential::expiration, GNUNET_break, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_ecdsa_sign(), GNUNET_free, GNUNET_htonll(), GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_CREDENTIAL, GNUNET_CREDENTIAL_Credential::issuer_attribute, GNUNET_CREDENTIAL_Credential::issuer_key, GNUNET_CREDENTIAL_Credential::signature, size, and GNUNET_CREDENTIAL_Credential::subject_key.

Referenced by get_cred_issuer_cb(), and identity_cb().

126 {
127  struct CredentialEntry *crd;
128  struct GNUNET_CREDENTIAL_Credential *cred;
129  size_t size;
130 
131  size = sizeof (struct CredentialEntry) + strlen (attribute) + 1;
132  crd = GNUNET_malloc (size);
133  cred = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_Credential) + strlen (attribute) + 1);
134  crd->purpose.size = htonl (size - sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
135 
136  crd->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
138  &crd->issuer_key);
139  crd->subject_key = *subject;
140  crd->expiration = GNUNET_htonll (expiration->abs_value_us);
141  crd->issuer_attribute_len = htonl (strlen (attribute)+1);
142  GNUNET_memcpy ((char*)&crd[1],
143  attribute,
144  strlen (attribute)+1);
145  if (GNUNET_OK !=
146  GNUNET_CRYPTO_ecdsa_sign (issuer,
147  &crd->purpose,
148  &crd->signature))
149  {
150  GNUNET_break (0);
151  GNUNET_free (crd);
152  GNUNET_free (cred);
153  return NULL;
154  }
155  cred->signature = crd->signature;
156  cred->expiration = *expiration;
158  &cred->issuer_key);
159 
160  cred->subject_key = *subject;
161  GNUNET_memcpy (&cred[1],
162  attribute,
163  strlen (attribute)+1);
164  cred->issuer_attribute = (char*)&cred[1];
165  GNUNET_free (crd);
166  return cred;
167 }
static char * expiration
Credential TTL.
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Public key of the subject this credential was issued to.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key
The issuer of the credential.
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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:931
#define GNUNET_memcpy(dst, src, n)
#define GNUNET_SIGNATURE_PURPOSE_CREDENTIAL
Signature for a GNUnet credential.
an ECC signature using ECDSA
struct GNUNET_CRYPTO_EcdsaSignature signature
Signature of this credential.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:241
struct GNUNET_TIME_Absolute expiration
Expiration of this credential.
const char * issuer_attribute
The attribute.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CREDENTIAL_request_cancel()

void GNUNET_CREDENTIAL_request_cancel ( struct GNUNET_CREDENTIAL_Request lr)

Cancel pending lookup request.

Parameters
lrthe lookup request to cancel

Cancel pending lookup request.

Parameters
lrthe verify request to cancel

Definition at line 351 of file credential_api.c.

References GNUNET_CREDENTIAL_Request::credential_handle, GNUNET_CREDENTIAL_Request::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_discard(), handle, GNUNET_CREDENTIAL_Handle::request_head, and GNUNET_CREDENTIAL_Handle::request_tail.

Referenced by cleanup_handle(), and do_shutdown().

352 {
354 
356  handle->request_tail,
357  lr);
358  GNUNET_MQ_discard (lr->env);
359  GNUNET_free (lr);
360 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_CREDENTIAL_Request * request_head
Head of linked list of active verify requests.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
Connection to the CREDENTIAL service.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
struct GNUNET_CREDENTIAL_Request * request_tail
Tail of linked list of active verify requests.
struct GNUNET_CREDENTIAL_Handle * credential_handle
handle to credential service
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: