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 229 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 242 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 252 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  //Subject had credentials before, but have been revoked now
64 
65  //Subject flag indicates that the subject is a holder of this credential and may present it as such
67 
68  //Issuer flag is used to signify that the subject is allowed to issue this credential and delegate issuance
70 };

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 302 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().

303 {
305 
306  handle = GNUNET_new(struct GNUNET_CREDENTIAL_Handle);
307  handle->cfg = cfg;
308  reconnect(handle);
309  if (NULL == handle->mq)
310  {
311  GNUNET_free(handle);
312  return NULL;
313  }
314  return handle;
315 }
#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 324 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().

325 {
326  if (NULL != handle->mq)
327  {
328  GNUNET_MQ_destroy(handle->mq);
329  handle->mq = NULL;
330  }
331  if (NULL != handle->reconnect_task)
332  {
334  handle->reconnect_task = NULL;
335  }
336  GNUNET_assert(NULL == handle->request_head);
337  GNUNET_free(handle);
338 }
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:821
#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:956
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 443 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().

451 {
452  /* IPC to shorten credential names, return shorten_handle */
453  struct VerifyMessage *v_msg;
454  struct GNUNET_CREDENTIAL_Request *vr;
455  size_t nlen;
456  size_t clen;
457 
458  if (NULL == issuer_attribute || NULL == credentials)
459  {
460  GNUNET_break(0);
461  return NULL;
462  }
463 
464  clen = GNUNET_CREDENTIAL_credentials_get_size(credential_count,
465  credentials);
466 
467  //DEBUG LOG
469  "Trying to verify `%s' in CREDENTIAL\n",
470  issuer_attribute);
471  nlen = strlen(issuer_attribute) + 1 + clen;
472  if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(*vr))
473  {
474  GNUNET_break(0);
475  return NULL;
476  }
479  vr->verify_proc = proc;
480  vr->proc_cls = proc_cls;
481  vr->r_id = handle->r_id_gen++;
482  vr->env = GNUNET_MQ_msg_extra(v_msg,
483  nlen,
485  v_msg->id = htonl(vr->r_id);
486  v_msg->subject_key = *subject_key;
487  v_msg->c_count = htonl(credential_count);
488  v_msg->issuer_key = *issuer_key;
489  v_msg->issuer_attribute_len = htons(strlen(issuer_attribute));
490  GNUNET_memcpy(&v_msg[1],
491  issuer_attribute,
492  strlen(issuer_attribute));
494  credentials,
495  clen,
496  ((char*)&v_msg[1])
497  + strlen(issuer_attribute) + 1);
499  handle->request_tail,
500  vr);
501  if (NULL != handle->mq)
502  GNUNET_MQ_send_copy(handle->mq,
503  vr->env);
504  return vr;
505 }
Message from client to Credential service to verify attributes.
Definition: credential.h:68
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:92
uint32_t id
Unique identifier for this request (for key collisions).
Definition: credential.h:97
static char * subject_key
Subject pubkey string.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Subject public key.
Definition: credential.h:77
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
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:87
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:430
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:82
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 373 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().

379 {
380  /* IPC to shorten credential names, return shorten_handle */
381  struct CollectMessage *c_msg;
382  struct GNUNET_CREDENTIAL_Request *vr;
383  size_t nlen;
384 
385  if (NULL == issuer_attribute)
386  {
387  GNUNET_break(0);
388  return NULL;
389  }
390 
391  //DEBUG LOG
393  "Trying to collect `%s' in CREDENTIAL\n",
394  issuer_attribute);
395  nlen = strlen(issuer_attribute) + 1;
396  if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(*vr))
397  {
398  GNUNET_break(0);
399  return NULL;
400  }
403  vr->verify_proc = proc;
404  vr->proc_cls = proc_cls;
405  vr->r_id = handle->r_id_gen++;
406  vr->env = GNUNET_MQ_msg_extra(c_msg,
407  nlen,
409  c_msg->id = htonl(vr->r_id);
410  c_msg->subject_key = *subject_key;
411  c_msg->issuer_key = *issuer_key;
412  c_msg->issuer_attribute_len = htons(strlen(issuer_attribute));
413  GNUNET_memcpy(&c_msg[1],
414  issuer_attribute,
415  strlen(issuer_attribute));
417  handle->request_tail,
418  vr);
419  if (NULL != handle->mq)
420  GNUNET_MQ_send_copy(handle->mq,
421  vr->env);
422  return vr;
423 }
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:49
#define GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT
Message from client to Credential service to collect credentials.
Definition: credential.h:35
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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
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:59
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:44
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:430
GNUNET_CREDENTIAL_CredentialResultProcessor verify_proc
processor to call on verify result
uint16_t issuer_attribute_len
Length of the issuer attribute.
Definition: credential.h:54
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 123 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().

127 {
128  struct CredentialEntry *crd;
129  struct GNUNET_CREDENTIAL_Credential *cred;
130  size_t size;
131 
132  size = sizeof(struct CredentialEntry) + strlen(attribute) + 1;
133  crd = GNUNET_malloc(size);
134  cred = GNUNET_malloc(sizeof(struct GNUNET_CREDENTIAL_Credential) + strlen(attribute) + 1);
135  crd->purpose.size = htonl(size - sizeof(struct GNUNET_CRYPTO_EcdsaSignature));
136 
137  crd->purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
139  &crd->issuer_key);
140  crd->subject_key = *subject;
141  crd->expiration = GNUNET_htonll(expiration->abs_value_us);
142  crd->issuer_attribute_len = htonl(strlen(attribute) + 1);
143  GNUNET_memcpy((char*)&crd[1],
144  attribute,
145  strlen(attribute) + 1);
146  if (GNUNET_OK !=
148  &crd->purpose,
149  &crd->signature))
150  {
151  GNUNET_break(0);
152  GNUNET_free(crd);
153  GNUNET_free(cred);
154  return NULL;
155  }
156  cred->signature = crd->signature;
157  cred->expiration = *expiration;
159  &cred->issuer_key);
160 
161  cred->subject_key = *subject;
162  GNUNET_memcpy(&cred[1],
163  attribute,
164  strlen(attribute) + 1);
165  cred->issuer_attribute = (char*)&cred[1];
166  GNUNET_free(crd);
167  return cred;
168 }
static char * expiration
Credential TTL.
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key
Public key of the subject this credential was issued to.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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_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:66
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 347 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().

348 {
350 
352  handle->request_tail,
353  lr);
354  GNUNET_MQ_discard(lr->env);
355  GNUNET_free(lr);
356 }
#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:319
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: