GNUnet 0.22.2
abd_serialization.c File Reference

API to serialize and deserialize delegation chains and abds. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_abd_service.h"
#include "gnunet_signatures.h"
#include "abd.h"
#include "abd_serialization.h"
Include dependency graph for abd_serialization.c:

Go to the source code of this file.

Functions

size_t GNUNET_ABD_delegation_set_get_size (unsigned int ds_count, const struct GNUNET_ABD_DelegationSet *dsr)
 Calculate how many bytes we will need to serialize the given delegation chain. More...
 
ssize_t GNUNET_ABD_delegation_set_serialize (unsigned int d_count, const struct GNUNET_ABD_DelegationSet *dsr, size_t dest_size, char *dest)
 Serizalize the given delegation chain entries and abd. More...
 
int GNUNET_ABD_delegation_set_deserialize (size_t len, const char *src, unsigned int d_count, struct GNUNET_ABD_DelegationSet *dsr)
 Deserialize the given destination. More...
 
size_t GNUNET_ABD_delegates_get_size (unsigned int c_count, const struct GNUNET_ABD_Delegate *cd)
 Calculate how many bytes we will need to serialize the abds. More...
 
ssize_t GNUNET_ABD_delegates_serialize (unsigned int c_count, const struct GNUNET_ABD_Delegate *cd, size_t dest_size, char *dest)
 Serizalize the given abds. More...
 
int GNUNET_ABD_delegates_deserialize (size_t len, const char *src, unsigned int c_count, struct GNUNET_ABD_Delegate *cd)
 Deserialize the given destination. More...
 
size_t GNUNET_ABD_delegation_chain_get_size (unsigned int d_count, const struct GNUNET_ABD_Delegation *dd, unsigned int c_count, const struct GNUNET_ABD_Delegate *cd)
 Calculate how many bytes we will need to serialize the given delegation chain and abd. More...
 
ssize_t GNUNET_ABD_delegation_chain_serialize (unsigned int d_count, const struct GNUNET_ABD_Delegation *dd, unsigned int c_count, const struct GNUNET_ABD_Delegate *cd, size_t dest_size, char *dest)
 Serizalize the given delegation chain entries and abd. More...
 
int GNUNET_ABD_delegation_chain_deserialize (size_t len, const char *src, unsigned int d_count, struct GNUNET_ABD_Delegation *dd, unsigned int c_count, struct GNUNET_ABD_Delegate *cd)
 Deserialize the given destination. More...
 
int GNUNET_ABD_delegate_serialize (struct GNUNET_ABD_Delegate *dele, char **data)
 
struct GNUNET_ABD_DelegateGNUNET_ABD_delegate_deserialize (const char *data, size_t data_size)
 

Detailed Description

API to serialize and deserialize delegation chains and abds.

Author
Martin Schanzenbach

Definition in file abd_serialization.c.

Function Documentation

◆ GNUNET_ABD_delegation_set_get_size()

size_t GNUNET_ABD_delegation_set_get_size ( unsigned int  ds_count,
const struct GNUNET_ABD_DelegationSet dsr 
)

Calculate how many bytes we will need to serialize the given delegation chain.

Calculate how many bytes we will need to serialize the given delegation record.

Parameters
ds_countnumber of delegation chain entries
dsrarray of GNUNET_ABD_DelegationSet
Returns
the required size to serialize

Definition at line 44 of file abd_serialization.c.

47{
48 unsigned int i;
49 size_t ret;
50
51 ret = sizeof (struct DelegationRecordData) * (ds_count);
52
53 for (i = 0; i < ds_count; i++)
54 {
56 ret += dsr[i].subject_attribute_len;
57 }
58 return ret;
59}
static int ret
Final status code.
Definition: gnunet-arm.c:93
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t subject_attribute_len
Subject attributes.
Definition: abd.h:178

References GNUNET_assert, ret, DelegationRecordData::subject_attribute_len, and GNUNET_ABD_DelegationSet::subject_attribute_len.

Referenced by abd_string_to_value().

Here is the caller graph for this function:

◆ GNUNET_ABD_delegation_set_serialize()

ssize_t GNUNET_ABD_delegation_set_serialize ( unsigned int  d_count,
const struct GNUNET_ABD_DelegationSet dsr,
size_t  dest_size,
char *  dest 
)

Serizalize the given delegation chain entries and abd.

Serizalize the given delegation record entries.

Parameters
d_countnumber of delegation chain entries
dsrarray of GNUNET_ABD_DelegationSet
dest_sizesize of the destination
destwhere to store the result
Returns
the size of the data, -1 on failure

Definition at line 72 of file abd_serialization.c.

77{
78 struct DelegationRecordData rec;
79 unsigned int i;
80 size_t off;
81
82 off = 0;
83 for (i = 0; i < d_count; i++)
84 {
85 rec.subject_attribute_len = htonl ((uint32_t) dsr[i].subject_attribute_len);
86 rec.subject_key = dsr[i].subject_key;
87 if (off + sizeof (rec) > dest_size)
88 return -1;
89 GNUNET_memcpy (&dest[off], &rec, sizeof (rec));
90 off += sizeof (rec);
91 if (0 == dsr[i].subject_attribute_len)
92 continue;
93 if (off + dsr[i].subject_attribute_len > dest_size)
94 return -1;
95 GNUNET_memcpy (&dest[off],
96 dsr[i].subject_attribute,
98 off += dsr[i].subject_attribute_len;
99 }
100 return off;
101}
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this attribute was delegated to.

References warningfilter::dest, GNUNET_memcpy, DelegationRecordData::subject_attribute_len, GNUNET_ABD_DelegationSet::subject_attribute_len, DelegationRecordData::subject_key, and GNUNET_ABD_DelegationSet::subject_key.

Referenced by abd_string_to_value().

Here is the caller graph for this function:

◆ GNUNET_ABD_delegation_set_deserialize()

int GNUNET_ABD_delegation_set_deserialize ( size_t  len,
const char *  src,
unsigned int  d_count,
struct GNUNET_ABD_DelegationSet dsr 
)

Deserialize the given destination.

Parameters
lensize of the serialized delegation chain and cred
srcthe serialized data
d_countthe number of delegation chain entries
dsrwhere to put the delegation chain entries
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 114 of file abd_serialization.c.

119{
120 struct DelegationRecordData rec;
121 unsigned int i;
122 size_t off;
123
124 off = 0;
125 for (i = 0; i < d_count; i++)
126 {
127 if (off + sizeof (rec) > len)
128 return GNUNET_SYSERR;
129 GNUNET_memcpy (&rec, &src[off], sizeof (rec));
130 dsr[i].subject_key = rec.subject_key;
131 off += sizeof (rec);
132 dsr[i].subject_attribute_len = ntohl ((uint32_t) rec.subject_attribute_len);
133 if (off + dsr[i].subject_attribute_len > len)
134 return GNUNET_SYSERR;
135 dsr[i].subject_attribute = (char *) &src[off];
136 off += dsr[i].subject_attribute_len;
137 }
138 return GNUNET_OK;
139}
@ GNUNET_OK
@ GNUNET_SYSERR
const char * subject_attribute
The subject attribute.

References GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_ABD_DelegationSet::subject_attribute, DelegationRecordData::subject_attribute_len, GNUNET_ABD_DelegationSet::subject_attribute_len, DelegationRecordData::subject_key, and GNUNET_ABD_DelegationSet::subject_key.

Referenced by abd_value_to_string(), and backward_resolution().

Here is the caller graph for this function:

◆ GNUNET_ABD_delegates_get_size()

size_t GNUNET_ABD_delegates_get_size ( unsigned int  c_count,
const struct GNUNET_ABD_Delegate cd 
)

Calculate how many bytes we will need to serialize the abds.

Parameters
c_countnumber of abd entries
cda #GNUNET_ABD_Credential
Returns
the required size to serialize

Definition at line 151 of file abd_serialization.c.

154{
155 unsigned int i;
156 size_t ret;
157
158 ret = sizeof (struct DelegateEntry) * (c_count);
159
160 for (i = 0; i < c_count; i++)
161 {
163 + cd[i].subject_attribute_len) >= ret);
164 // subject_attribute_len should be 0
166 }
167 return ret;
168}
uint32_t issuer_attribute_len
Issuer subject attribute length.
Definition: abd.h:236
uint32_t subject_attribute_len
Issuer attribute length.
Definition: abd.h:241
uint32_t issuer_attribute_len
Length of the issuer attribute.
uint32_t subject_attribute_len
Length of the subject attribute.

References GNUNET_assert, DelegateEntry::issuer_attribute_len, GNUNET_ABD_Delegate::issuer_attribute_len, ret, DelegateEntry::subject_attribute_len, and GNUNET_ABD_Delegate::subject_attribute_len.

Referenced by GNUNET_ABD_delegation_chain_get_size(), and GNUNET_ABD_verify().

Here is the caller graph for this function:

◆ GNUNET_ABD_delegates_serialize()

ssize_t GNUNET_ABD_delegates_serialize ( unsigned int  c_count,
const struct GNUNET_ABD_Delegate cd,
size_t  dest_size,
char *  dest 
)

Serizalize the given abds.

Parameters
c_countnumber of abd entries
cda #GNUNET_ABD_Credential
dest_sizesize of the destination
destwhere to store the result
Returns
the size of the data, -1 on failure

Definition at line 181 of file abd_serialization.c.

186{
187 struct DelegateEntry c_rec;
188 unsigned int i;
189 size_t off;
190
191 off = 0;
192 for (i = 0; i < c_count; i++)
193 {
194 c_rec.subject_attribute_len = htonl (cd[i].subject_attribute_len);
195 c_rec.issuer_attribute_len = htonl (cd[i].issuer_attribute_len);
196 c_rec.issuer_key = cd[i].issuer_key;
197 c_rec.subject_key = cd[i].subject_key;
198 c_rec.signature = cd[i].signature;
199 c_rec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DELEGATE);
200 c_rec.purpose.size =
201 htonl ((sizeof (struct DelegateEntry) + cd[i].issuer_attribute_len)
202 - sizeof (struct GNUNET_CRYPTO_Signature));
203 c_rec.expiration = GNUNET_htonll (cd[i].expiration.abs_value_us);
204 if (off + sizeof (c_rec) > dest_size)
205 return -1;
206 GNUNET_memcpy (&dest[off], &c_rec, sizeof (c_rec));
207 off += sizeof (c_rec);
208 if (off + cd[i].issuer_attribute_len > dest_size)
209 return -1;
210 GNUNET_memcpy (&dest[off],
211 cd[i].issuer_attribute,
213 off += cd[i].issuer_attribute_len;
214 }
215
216 return off;
217}
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_SIGNATURE_PURPOSE_DELEGATE
Signature for a GNUnet credential (Reclaim)
struct GNUNET_CRYPTO_Signature signature
Signature of this credential.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer of the credential.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this credential was issued to.
An identity signature as per LSD0001.

References warningfilter::dest, expiration, DelegateEntry::expiration, GNUNET_htonll(), GNUNET_memcpy, GNUNET_SIGNATURE_PURPOSE_DELEGATE, DelegateEntry::issuer_attribute_len, GNUNET_ABD_Delegate::issuer_attribute_len, DelegateEntry::issuer_key, GNUNET_ABD_Delegate::issuer_key, DelegateEntry::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, DelegateEntry::signature, GNUNET_ABD_Delegate::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, DelegateEntry::subject_attribute_len, DelegateEntry::subject_key, and GNUNET_ABD_Delegate::subject_key.

Referenced by GNUNET_ABD_delegation_chain_serialize(), and GNUNET_ABD_verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ABD_delegates_deserialize()

int GNUNET_ABD_delegates_deserialize ( size_t  len,
const char *  src,
unsigned int  c_count,
struct GNUNET_ABD_Delegate cd 
)

Deserialize the given destination.

Parameters
lensize of the serialized creds
srcthe serialized data
c_countthe number of abd entries
cdwhere to put the abd data
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 230 of file abd_serialization.c.

234{
235 struct DelegateEntry c_rec;
236 unsigned int i;
237 size_t off;
238
239 off = 0;
240 for (i = 0; i < c_count; i++)
241 {
242 if (off + sizeof (c_rec) > len)
243 return GNUNET_SYSERR;
244 GNUNET_memcpy (&c_rec, &src[off], sizeof (c_rec));
245 cd[i].issuer_attribute_len = ntohl ((uint32_t) c_rec.issuer_attribute_len);
246 cd[i].issuer_key = c_rec.issuer_key;
247 cd[i].subject_key = c_rec.subject_key;
248 cd[i].signature = c_rec.signature;
249 cd[i].expiration.abs_value_us = GNUNET_ntohll (c_rec.expiration);
250 off += sizeof (c_rec);
251 if (off + cd[i].issuer_attribute_len > len)
252 return GNUNET_SYSERR;
253 cd[i].issuer_attribute = &src[off];
254 off += cd[i].issuer_attribute_len;
255 cd[i].subject_attribute_len = 0;
256 }
257 return GNUNET_OK;
258}
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
const char * issuer_attribute
The issuer attribute.
struct GNUNET_TIME_Absolute expiration
Expiration of this credential.
uint64_t abs_value_us
The actual value.

References GNUNET_TIME_Absolute::abs_value_us, DelegateEntry::expiration, GNUNET_ABD_Delegate::expiration, GNUNET_memcpy, GNUNET_ntohll(), GNUNET_OK, GNUNET_SYSERR, GNUNET_ABD_Delegate::issuer_attribute, DelegateEntry::issuer_attribute_len, GNUNET_ABD_Delegate::issuer_attribute_len, DelegateEntry::issuer_key, GNUNET_ABD_Delegate::issuer_key, DelegateEntry::signature, GNUNET_ABD_Delegate::signature, GNUNET_ABD_Delegate::subject_attribute_len, DelegateEntry::subject_key, and GNUNET_ABD_Delegate::subject_key.

Referenced by GNUNET_ABD_delegation_chain_deserialize(), and handle_verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ABD_delegation_chain_get_size()

size_t GNUNET_ABD_delegation_chain_get_size ( unsigned int  d_count,
const struct GNUNET_ABD_Delegation dd,
unsigned int  c_count,
const struct GNUNET_ABD_Delegate cd 
)

Calculate how many bytes we will need to serialize the given delegation chain and abd.

Parameters
d_countnumber of delegation chain entries
ddarray of GNUNET_ABD_Delegation
c_countnumber of abd entries
cda #GNUNET_ABD_Credential
Returns
the required size to serialize

Definition at line 272 of file abd_serialization.c.

277{
278 unsigned int i;
279 size_t ret;
280
281 ret = sizeof (struct ChainEntry) * (d_count);
282
283 for (i = 0; i < d_count; i++)
284 {
288 }
289 return ret + GNUNET_ABD_delegates_get_size (c_count, cd);
290}
size_t GNUNET_ABD_delegates_get_size(unsigned int c_count, const struct GNUNET_ABD_Delegate *cd)
Calculate how many bytes we will need to serialize the abds.
uint32_t issuer_attribute_len
Issuer attributes.
Definition: abd.h:197
uint32_t subject_attribute_len
Subject attributes.
Definition: abd.h:202
uint32_t issuer_attribute_len
Length of the attribute.
uint32_t subject_attribute_len
Length of the attribute.

References GNUNET_ABD_delegates_get_size(), GNUNET_assert, ChainEntry::issuer_attribute_len, GNUNET_ABD_Delegation::issuer_attribute_len, ret, ChainEntry::subject_attribute_len, and GNUNET_ABD_Delegation::subject_attribute_len.

Referenced by send_intermediate_response(), and send_lookup_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ABD_delegation_chain_serialize()

ssize_t GNUNET_ABD_delegation_chain_serialize ( unsigned int  d_count,
const struct GNUNET_ABD_Delegation dd,
unsigned int  c_count,
const struct GNUNET_ABD_Delegate cd,
size_t  dest_size,
char *  dest 
)

Serizalize the given delegation chain entries and abd.

Parameters
d_countnumber of delegation chain entries
ddarray of GNUNET_ABD_Delegation
c_countnumber of abd entries
cda #GNUNET_ABD_Credential
dest_sizesize of the destination
destwhere to store the result
Returns
the size of the data, -1 on failure

Definition at line 305 of file abd_serialization.c.

312{
313 struct ChainEntry rec;
314 unsigned int i;
315 size_t off;
316
317 off = 0;
318 for (i = 0; i < d_count; i++)
319 {
320 rec.issuer_attribute_len = htonl ((uint32_t) dd[i].issuer_attribute_len);
321 rec.subject_attribute_len = htonl ((uint32_t) dd[i].subject_attribute_len);
322 rec.issuer_key = dd[i].issuer_key;
323 rec.subject_key = dd[i].subject_key;
324 if (off + sizeof (rec) > dest_size)
325 return -1;
326 GNUNET_memcpy (&dest[off], &rec, sizeof (rec));
327 off += sizeof (rec);
328 if (off + dd[i].issuer_attribute_len > dest_size)
329 return -1;
330 GNUNET_memcpy (&dest[off],
331 dd[i].issuer_attribute,
333 off += dd[i].issuer_attribute_len;
334 if (0 == dd[i].subject_attribute_len)
335 continue;
336 if (off + dd[i].subject_attribute_len > dest_size)
337 return -1;
338 GNUNET_memcpy (&dest[off],
339 dd[i].subject_attribute,
341 off += dd[i].subject_attribute_len;
342 }
343 return off + GNUNET_ABD_delegates_serialize (c_count,
344 cd,
345 dest_size - off,
346 &dest[off]);
347}
ssize_t GNUNET_ABD_delegates_serialize(unsigned int c_count, const struct GNUNET_ABD_Delegate *cd, size_t dest_size, char *dest)
Serizalize the given abds.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this attribute was delegated to.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer of the delegation.

References warningfilter::dest, GNUNET_ABD_delegates_serialize(), GNUNET_memcpy, ChainEntry::issuer_attribute_len, GNUNET_ABD_Delegation::issuer_attribute_len, ChainEntry::issuer_key, GNUNET_ABD_Delegation::issuer_key, ChainEntry::subject_attribute_len, GNUNET_ABD_Delegation::subject_attribute_len, ChainEntry::subject_key, and GNUNET_ABD_Delegation::subject_key.

Referenced by send_intermediate_response(), and send_lookup_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ABD_delegation_chain_deserialize()

int GNUNET_ABD_delegation_chain_deserialize ( size_t  len,
const char *  src,
unsigned int  d_count,
struct GNUNET_ABD_Delegation dd,
unsigned int  c_count,
struct GNUNET_ABD_Delegate cd 
)

Deserialize the given destination.

Parameters
lensize of the serialized delegation chain and cred
srcthe serialized data
d_countthe number of delegation chain entries
ddwhere to put the delegation chain entries
c_countthe number of abd entries
cdwhere to put the abd data
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 362 of file abd_serialization.c.

369{
370 struct ChainEntry rec;
371 unsigned int i;
372 size_t off;
373
374 off = 0;
375 for (i = 0; i < d_count; i++)
376 {
377 if (off + sizeof (rec) > len)
378 return GNUNET_SYSERR;
379 GNUNET_memcpy (&rec, &src[off], sizeof (rec));
380 dd[i].issuer_attribute_len = ntohl ((uint32_t) rec.issuer_attribute_len);
381 dd[i].issuer_key = rec.issuer_key;
382 dd[i].subject_key = rec.subject_key;
383 off += sizeof (rec);
384 if (off + dd[i].issuer_attribute_len > len)
385 return GNUNET_SYSERR;
386 dd[i].issuer_attribute = &src[off];
387 off += dd[i].issuer_attribute_len;
388 dd[i].subject_attribute_len = ntohl ((uint32_t) rec.subject_attribute_len);
389 if (off + dd[i].subject_attribute_len > len)
390 return GNUNET_SYSERR;
391 dd[i].subject_attribute = &src[off];
392 off += dd[i].subject_attribute_len;
393 }
394 return GNUNET_ABD_delegates_deserialize (len - off,
395 &src[off],
396 c_count,
397 cd);
398}
int GNUNET_ABD_delegates_deserialize(size_t len, const char *src, unsigned int c_count, struct GNUNET_ABD_Delegate *cd)
Deserialize the given destination.
const char * issuer_attribute
The attribute.
const char * subject_attribute
The attribute.

References GNUNET_ABD_delegates_deserialize(), GNUNET_memcpy, GNUNET_SYSERR, GNUNET_ABD_Delegation::issuer_attribute, ChainEntry::issuer_attribute_len, GNUNET_ABD_Delegation::issuer_attribute_len, ChainEntry::issuer_key, GNUNET_ABD_Delegation::issuer_key, GNUNET_ABD_Delegation::subject_attribute, ChainEntry::subject_attribute_len, GNUNET_ABD_Delegation::subject_attribute_len, ChainEntry::subject_key, and GNUNET_ABD_Delegation::subject_key.

Referenced by handle_intermediate(), and handle_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ABD_delegate_serialize()

int GNUNET_ABD_delegate_serialize ( struct GNUNET_ABD_Delegate dele,
char **  data 
)

Definition at line 402 of file abd_serialization.c.

404{
405 size_t size;
406 struct DelegateEntry *cdata;
407 int attr_len;
408
409 // +1 for \0
410 if (0 == dele->subject_attribute_len)
411 {
412 attr_len = dele->issuer_attribute_len + 1;
413 }
414 else
415 {
416 attr_len = dele->issuer_attribute_len + dele->subject_attribute_len + 2;
417 }
418 size = sizeof (struct DelegateEntry) + attr_len;
419
420 {
421 char tmp_str[attr_len];
423 if (0 != dele->subject_attribute_len)
424 {
425 tmp_str[dele->issuer_attribute_len] = '\0';
426 GNUNET_memcpy (tmp_str + dele->issuer_attribute_len + 1,
427 dele->subject_attribute,
429 }
430 tmp_str[attr_len - 1] = '\0';
431
433 cdata = (struct DelegateEntry *) *data;
434 cdata->subject_key = dele->subject_key;
435 cdata->issuer_key = dele->issuer_key;
437 cdata->signature = dele->signature;
438 cdata->issuer_attribute_len = htonl (dele->issuer_attribute_len + 1);
439 if (0 == dele->subject_attribute_len)
440 {
441 cdata->subject_attribute_len = htonl (0);
442 }
443 else
444 {
445 cdata->subject_attribute_len = htonl (dele->subject_attribute_len + 1);
446 }
448 cdata->purpose.size =
449 htonl (size - sizeof (struct GNUNET_CRYPTO_Signature));
450
451 GNUNET_memcpy (&cdata[1], tmp_str, attr_len);
452 }
453 if (GNUNET_OK !=
455 &cdata->purpose,
456 &cdata->signature,
457 &cdata->issuer_key))
458 {
459 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Serialize: Invalid delegate\n");
460 return 0;
461 }
462 return size;
463}
static char * data
The data to insert into the dht.
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_signature_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_Signature *sig, const struct GNUNET_CRYPTO_PublicKey *pub)
Verify a given signature.
Definition: crypto_pkey.c:319
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_malloc(size)
Wrapper around malloc.
static unsigned int size
Size of the "table".
Definition: peer.c:68
struct GNUNET_CRYPTO_Signature signature
The signature for this credential by the issuer.
Definition: abd.h:211
struct GNUNET_CRYPTO_PublicKey issuer_key
Public key of the issuer.
Definition: abd.h:221
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this credential was issued to.
Definition: abd.h:226
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Signature meta.
Definition: abd.h:216
uint64_t expiration
Expiration time of this credential.
Definition: abd.h:231
const char * subject_attribute
The subject attribute.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...

References GNUNET_TIME_Absolute::abs_value_us, data, DelegateEntry::expiration, GNUNET_ABD_Delegate::expiration, GNUNET_CRYPTO_signature_verify_(), GNUNET_ERROR_TYPE_WARNING, GNUNET_htonll(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_DELEGATE, GNUNET_ABD_Delegate::issuer_attribute, DelegateEntry::issuer_attribute_len, GNUNET_ABD_Delegate::issuer_attribute_len, DelegateEntry::issuer_key, GNUNET_ABD_Delegate::issuer_key, DelegateEntry::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, DelegateEntry::signature, GNUNET_ABD_Delegate::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, size, GNUNET_ABD_Delegate::subject_attribute, DelegateEntry::subject_attribute_len, GNUNET_ABD_Delegate::subject_attribute_len, DelegateEntry::subject_key, and GNUNET_ABD_Delegate::subject_key.

Referenced by abd_string_to_value(), and store_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ABD_delegate_deserialize()

struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_deserialize ( const char *  data,
size_t  data_size 
)

Definition at line 467 of file abd_serialization.c.

468{
469 struct GNUNET_ABD_Delegate *dele;
470 struct DelegateEntry *cdata;
471 char *attr_combo_str;
472
473 if (data_size < sizeof (struct DelegateEntry))
474 return NULL;
475 cdata = (struct DelegateEntry *) data;
476 if (GNUNET_OK !=
478 &cdata->purpose,
479 &cdata->signature,
480 &cdata->issuer_key))
481 {
482 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Deserialize: Invalid delegate\n");
483 return NULL;
484 }
485 attr_combo_str = (char *) &cdata[1];
486 {
487 int iss_len = ntohl (cdata->issuer_attribute_len);
488 int sub_len = ntohl (cdata->subject_attribute_len);
489 int attr_combo_len = iss_len + sub_len;
490
491 dele =
492 GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate) + attr_combo_len);
493
494 dele->issuer_key = cdata->issuer_key;
495 dele->subject_key = cdata->subject_key;
496 GNUNET_memcpy (&dele[1], attr_combo_str, attr_combo_len);
497 dele->signature = cdata->signature;
498
499 // Set the pointers for the attributes
500 dele->issuer_attribute = (char *) &dele[1];
501 dele->issuer_attribute_len = iss_len;
502 dele->subject_attribute_len = sub_len;
503 if (0 == sub_len)
504 {
505 dele->subject_attribute = NULL;
506 }
507 else
508 {
509 dele->subject_attribute = (char *) &dele[1] + iss_len;
510 }
511
513 }
514 return dele;
515}
static size_t data_size
Number of bytes in data.

References GNUNET_TIME_Absolute::abs_value_us, data, data_size, DelegateEntry::expiration, GNUNET_ABD_Delegate::expiration, GNUNET_CRYPTO_signature_verify_(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_ntohll(), GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_DELEGATE, GNUNET_ABD_Delegate::issuer_attribute, DelegateEntry::issuer_attribute_len, GNUNET_ABD_Delegate::issuer_attribute_len, DelegateEntry::issuer_key, GNUNET_ABD_Delegate::issuer_key, DelegateEntry::purpose, DelegateEntry::signature, GNUNET_ABD_Delegate::signature, GNUNET_ABD_Delegate::subject_attribute, DelegateEntry::subject_attribute_len, GNUNET_ABD_Delegate::subject_attribute_len, DelegateEntry::subject_key, and GNUNET_ABD_Delegate::subject_key.

Referenced by abd_value_to_string(), forward_resolution(), and handle_delegate_collection_cb().

Here is the call graph for this function:
Here is the caller graph for this function: