GNUnet  0.10.x
Data Structures | Functions
crypto_abe.c File Reference
#include "platform.h"
#include <pbc/pbc.h>
#include <gabe.h>
#include "gnunet_crypto_lib.h"
Include dependency graph for crypto_abe.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_CRYPTO_AbeMasterKey
 
struct  GNUNET_CRYPTO_AbeKey
 

Functions

static int init_aes (element_t k, int enc, gcry_cipher_hd_t *handle, struct GNUNET_CRYPTO_SymmetricSessionKey *key, unsigned char *iv)
 
static int aes_128_cbc_encrypt (char *pt, int size, element_t k, char **ct)
 
static int aes_128_cbc_decrypt (char *ct, int size, element_t k, char **pt)
 
struct GNUNET_CRYPTO_AbeMasterKeyGNUNET_CRYPTO_cpabe_create_master_key (void)
 
void GNUNET_CRYPTO_cpabe_delete_master_key (struct GNUNET_CRYPTO_AbeMasterKey *key)
 
struct GNUNET_CRYPTO_AbeKeyGNUNET_CRYPTO_cpabe_create_key (struct GNUNET_CRYPTO_AbeMasterKey *key, char **attrs)
 
void GNUNET_CRYPTO_cpabe_delete_key (struct GNUNET_CRYPTO_AbeKey *key, int delete_pub)
 
ssize_t write_cpabe (void **result, uint32_t file_len, char *cph_buf, int cph_buf_len, char *aes_buf, int aes_buf_len)
 
ssize_t read_cpabe (const void *data, char **cph_buf, int *cph_buf_len, char **aes_buf, int *aes_buf_len)
 
ssize_t GNUNET_CRYPTO_cpabe_encrypt (const void *block, size_t size, const char *policy, const struct GNUNET_CRYPTO_AbeMasterKey *key, void **result)
 
ssize_t GNUNET_CRYPTO_cpabe_decrypt (const void *block, size_t size, const struct GNUNET_CRYPTO_AbeKey *key, void **result)
 
ssize_t GNUNET_CRYPTO_cpabe_serialize_key (const struct GNUNET_CRYPTO_AbeKey *key, void **result)
 
struct GNUNET_CRYPTO_AbeKeyGNUNET_CRYPTO_cpabe_deserialize_key (const void *data, size_t len)
 
ssize_t GNUNET_CRYPTO_cpabe_serialize_master_key (const struct GNUNET_CRYPTO_AbeMasterKey *key, void **result)
 
struct GNUNET_CRYPTO_AbeMasterKeyGNUNET_CRYPTO_cpabe_deserialize_master_key (const void *data, size_t len)
 

Function Documentation

◆ init_aes()

static int init_aes ( element_t  k,
int  enc,
gcry_cipher_hd_t *  handle,
struct GNUNET_CRYPTO_SymmetricSessionKey key,
unsigned char *  iv 
)
static

Definition at line 46 of file crypto_abe.c.

References GNUNET_CRYPTO_SymmetricSessionKey::aes_key, GNUNET_assert, GNUNET_CRYPTO_AES_KEY_LENGTH, and GNUNET_memcpy.

Referenced by aes_128_cbc_decrypt(), and aes_128_cbc_encrypt().

50 {
51  int rc;
52  int key_len;
53  unsigned char* key_buf;
54 
55  key_len = element_length_in_bytes(k) < 33 ? 3 : element_length_in_bytes(k);
56  key_buf = (unsigned char*)malloc(key_len);
57  element_to_bytes(key_buf, k);
58 
60  key_buf,
62  GNUNET_assert(0 ==
63  gcry_cipher_open(handle, GCRY_CIPHER_AES256,
64  GCRY_CIPHER_MODE_CFB, 0));
65  rc = gcry_cipher_setkey(*handle,
66  key->aes_key,
67  sizeof(key->aes_key));
68  GNUNET_assert((0 == rc) || ((char)rc == GPG_ERR_WEAK_KEY));
69  memset(iv, 0, 16); //TODO make reasonable
70  rc = gcry_cipher_setiv(*handle,
71  iv,
72  16);
73  GNUNET_assert((0 == rc) || ((char)rc == GPG_ERR_WEAK_KEY));
74 
75  free(key_buf);
76  return rc;
77 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
unsigned char aes_key[(256/8)]
Actual key for AES.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
Here is the caller graph for this function:

◆ aes_128_cbc_encrypt()

static int aes_128_cbc_encrypt ( char *  pt,
int  size,
element_t  k,
char **  ct 
)
static

Definition at line 80 of file crypto_abe.c.

References buf, GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, handle, init_aes(), len, and size.

Referenced by GNUNET_CRYPTO_cpabe_encrypt().

84 {
85  gcry_cipher_hd_t handle;
87  unsigned char iv[16];
88  char* buf;
89  int padding;
90  int buf_size;
91  uint8_t len[4];
92 
93  init_aes(k, 1, &handle, &skey, iv);
94 
95  /* TODO make less crufty */
96 
97  /* stuff in real length (big endian) before padding */
98  len[0] = (size & 0xff000000) >> 24;
99  len[1] = (size & 0xff0000) >> 16;
100  len[2] = (size & 0xff00) >> 8;
101  len[3] = (size & 0xff) >> 0;
102  padding = 16 - ((4 + size) % 16);
103  buf_size = 4 + size + padding;
104  buf = GNUNET_malloc(buf_size);
105  GNUNET_memcpy(buf, len, 4);
106  GNUNET_memcpy(buf + 4, pt, size);
107  *ct = GNUNET_malloc(buf_size);
108 
109  GNUNET_assert(0 == gcry_cipher_encrypt(handle, *ct, buf_size, buf, buf_size));
110  gcry_cipher_close(handle);
111  //AES_cbc_encrypt(pt->data, ct->data, pt->len, &key, iv, AES_ENCRYPT);
112  GNUNET_free(buf);
113  return buf_size;
114 }
static int init_aes(element_t k, int enc, gcry_cipher_hd_t *handle, struct GNUNET_CRYPTO_SymmetricSessionKey *key, unsigned char *iv)
Definition: crypto_abe.c:46
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static char buf[2048]
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static unsigned int size
Size of the "table".
Definition: peer.c:66
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ aes_128_cbc_decrypt()

static int aes_128_cbc_decrypt ( char *  ct,
int  size,
element_t  k,
char **  pt 
)
static

Definition at line 117 of file crypto_abe.c.

References GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, handle, init_aes(), and len.

Referenced by GNUNET_CRYPTO_cpabe_decrypt().

121 {
123  gcry_cipher_hd_t handle;
124  unsigned char iv[16];
125  char* tmp;
126  uint32_t len;
127 
128  init_aes(k, 1, &handle, &skey, iv);
129 
130  tmp = GNUNET_malloc(size);
131 
132  //AES_cbc_encrypt(ct->data, pt->data, ct->len, &key, iv, AES_DECRYPT);
133  GNUNET_assert(0 == gcry_cipher_decrypt(handle, tmp, size, ct, size));
134  gcry_cipher_close(handle);
135  /* TODO make less crufty */
136 
137  /* get real length */
138  len = 0;
139  len = len
140  | ((tmp[0]) << 24) | ((tmp[1]) << 16)
141  | ((tmp[2]) << 8) | ((tmp[3]) << 0);
142  /* truncate any garbage from the padding */
143  *pt = GNUNET_malloc(len);
144  GNUNET_memcpy(*pt, tmp + 4, len);
145  GNUNET_free(tmp);
146  return len;
147 }
static int init_aes(element_t k, int enc, gcry_cipher_hd_t *handle, struct GNUNET_CRYPTO_SymmetricSessionKey *key, unsigned char *iv)
Definition: crypto_abe.c:46
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static unsigned int size
Size of the "table".
Definition: peer.c:66
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_cpabe_create_master_key()

struct GNUNET_CRYPTO_AbeMasterKey* GNUNET_CRYPTO_cpabe_create_master_key ( void  )

Definition at line 150 of file crypto_abe.c.

References GNUNET_assert, GNUNET_new, key, GNUNET_CRYPTO_AbeMasterKey::msk, and GNUNET_CRYPTO_AbeMasterKey::pub.

151 {
153 
155  gabe_setup(&key->pub, &key->msk);
156  GNUNET_assert(NULL != key->pub);
157  GNUNET_assert(NULL != key->msk);
158  return key;
159 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_HashCode key
The key used in the DHT.

◆ GNUNET_CRYPTO_cpabe_delete_master_key()

void GNUNET_CRYPTO_cpabe_delete_master_key ( struct GNUNET_CRYPTO_AbeMasterKey key)

Definition at line 162 of file crypto_abe.c.

References GNUNET_free, GNUNET_CRYPTO_AbeMasterKey::msk, and GNUNET_CRYPTO_AbeMasterKey::pub.

163 {
164  gabe_msk_free(key->msk);
165  gabe_pub_free(key->pub);
166  //GNUNET_free (key->msk);
167  //gabe_msk_free (key->msk); //For some reason free of pub implicit?
168  GNUNET_free(key);
169 }
#define GNUNET_free(ptr)
Wrapper around free.

◆ GNUNET_CRYPTO_cpabe_create_key()

struct GNUNET_CRYPTO_AbeKey* GNUNET_CRYPTO_cpabe_create_key ( struct GNUNET_CRYPTO_AbeMasterKey key,
char **  attrs 
)

Definition at line 172 of file crypto_abe.c.

References GNUNET_assert, GNUNET_free, GNUNET_new, GNUNET_CRYPTO_AbeMasterKey::msk, GNUNET_CRYPTO_AbeKey::prv, GNUNET_CRYPTO_AbeMasterKey::pub, GNUNET_CRYPTO_AbeKey::pub, and size.

174 {
175  struct GNUNET_CRYPTO_AbeKey *prv_key;
176  int size;
177  char *tmp;
178 
179  prv_key = GNUNET_new(struct GNUNET_CRYPTO_AbeKey);
180  prv_key->prv = gabe_keygen(key->pub, key->msk, attrs);
181  size = gabe_pub_serialize(key->pub, &tmp);
182  prv_key->pub = gabe_pub_unserialize(tmp, size);
183  GNUNET_free(tmp);
184  GNUNET_assert(NULL != prv_key->prv);
185  return prv_key;
186 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
gabe_pub_t * pub
Definition: crypto_abe.c:41
static unsigned int size
Size of the "table".
Definition: peer.c:66
gabe_prv_t * prv
Definition: crypto_abe.c:42
#define GNUNET_free(ptr)
Wrapper around free.

◆ GNUNET_CRYPTO_cpabe_delete_key()

void GNUNET_CRYPTO_cpabe_delete_key ( struct GNUNET_CRYPTO_AbeKey key,
int  delete_pub 
)

Definition at line 189 of file crypto_abe.c.

References GNUNET_free, GNUNET_YES, GNUNET_CRYPTO_AbeKey::prv, and GNUNET_CRYPTO_AbeKey::pub.

191 {
192  //Memory management in gabe is buggy
193  gabe_prv_free(key->prv);
194  if (GNUNET_YES == delete_pub)
195  gabe_pub_free(key->pub);
196  GNUNET_free(key);
197 }
gabe_pub_t * pub
Definition: crypto_abe.c:41
gabe_prv_t * prv
Definition: crypto_abe.c:42
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.

◆ write_cpabe()

ssize_t write_cpabe ( void **  result,
uint32_t  file_len,
char *  cph_buf,
int  cph_buf_len,
char *  aes_buf,
int  aes_buf_len 
)

Definition at line 200 of file crypto_abe.c.

References GNUNET_malloc, GNUNET_memcpy, len, and result.

Referenced by GNUNET_CRYPTO_cpabe_encrypt(), GNUNET_CRYPTO_cpabe_serialize_key(), and GNUNET_CRYPTO_cpabe_serialize_master_key().

206 {
207  char *ptr;
208  uint32_t *len;
209 
210  *result = GNUNET_malloc(12 + cph_buf_len + aes_buf_len);
211  ptr = *result;
212  len = (uint32_t*)ptr;
213  *len = htonl(file_len);
214  ptr += 4;
215  len = (uint32_t*)ptr;
216  *len = htonl(aes_buf_len);
217  ptr += 4;
218  GNUNET_memcpy(ptr, aes_buf, aes_buf_len);
219  ptr += aes_buf_len;
220  len = (uint32_t*)ptr;
221  *len = htonl(cph_buf_len);
222  ptr += 4;
223  GNUNET_memcpy(ptr, cph_buf, cph_buf_len);
224  return 12 + cph_buf_len + aes_buf_len;
225 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int result
Global testing status.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the caller graph for this function:

◆ read_cpabe()

ssize_t read_cpabe ( const void *  data,
char **  cph_buf,
int *  cph_buf_len,
char **  aes_buf,
int *  aes_buf_len 
)

Definition at line 228 of file crypto_abe.c.

References GNUNET_malloc, GNUNET_memcpy, and len.

Referenced by GNUNET_CRYPTO_cpabe_decrypt(), GNUNET_CRYPTO_cpabe_deserialize_key(), and GNUNET_CRYPTO_cpabe_deserialize_master_key().

233 {
234  int buf_len;
235  char *ptr;
236  uint32_t *len;
237 
238  ptr = (char*)data;
239  len = (uint32_t*)ptr;
240  buf_len = ntohl(*len);
241  ptr += 4;
242  len = (uint32_t*)ptr;
243  *aes_buf_len = ntohl(*len);
244  ptr += 4;
245  *aes_buf = GNUNET_malloc(*aes_buf_len);
246  GNUNET_memcpy(*aes_buf, ptr, *aes_buf_len);
247  ptr += *aes_buf_len;
248  len = (uint32_t*)ptr;
249  *cph_buf_len = ntohl(*len);
250  ptr += 4;
251  *cph_buf = GNUNET_malloc(*cph_buf_len);
252  GNUNET_memcpy(*cph_buf, ptr, *cph_buf_len);
253 
254  return buf_len;
255 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_cpabe_encrypt()

ssize_t GNUNET_CRYPTO_cpabe_encrypt ( const void *  block,
size_t  size,
const char *  policy,
const struct GNUNET_CRYPTO_AbeMasterKey key,
void **  result 
)

Definition at line 258 of file crypto_abe.c.

References aes_128_cbc_encrypt(), GNUNET_free, GNUNET_memdup, GNUNET_SYSERR, m, GNUNET_CRYPTO_AbeMasterKey::pub, and write_cpabe().

263 {
264  gabe_cph_t* cph;
265  char* plt;
266  char* cph_buf;
267  char* aes_buf;
268  element_t m;
269  int cph_buf_len;
270  int aes_buf_len;
271  ssize_t result_len;
272 
273  if (!(cph = gabe_enc(key->pub, m, (char*)policy)))
274  return GNUNET_SYSERR;
275  cph_buf_len = gabe_cph_serialize(cph,
276  &cph_buf);
277  gabe_cph_free(cph);
278  GNUNET_free(cph);
279  plt = GNUNET_memdup(block, size);
280  aes_buf_len = aes_128_cbc_encrypt(plt, size, m, &aes_buf);
281  GNUNET_free(plt);
282  element_clear(m);
283  result_len = write_cpabe(result, size, cph_buf, cph_buf_len, aes_buf, aes_buf_len);
284  GNUNET_free(cph_buf);
285  GNUNET_free(aes_buf);
286  return result_len;
287 }
static int aes_128_cbc_encrypt(char *pt, int size, element_t k, char **ct)
Definition: crypto_abe.c:80
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
ssize_t write_cpabe(void **result, uint32_t file_len, char *cph_buf, int cph_buf_len, char *aes_buf, int aes_buf_len)
Definition: crypto_abe.c:200
static int result
Global testing status.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_CRYPTO_cpabe_decrypt()

ssize_t GNUNET_CRYPTO_cpabe_decrypt ( const void *  block,
size_t  size,
const struct GNUNET_CRYPTO_AbeKey key,
void **  result 
)

Definition at line 290 of file crypto_abe.c.

References aes_128_cbc_decrypt(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SYSERR, m, GNUNET_CRYPTO_AbeKey::prv, GNUNET_CRYPTO_AbeKey::pub, and read_cpabe().

294 {
295  char* aes_buf;
296  char* cph_buf;
297  gabe_cph_t* cph;
298  element_t m;
299  int cph_buf_size;
300  int aes_buf_size;
301  int plt_len;
302 
303  read_cpabe(block, &cph_buf, &cph_buf_size, &aes_buf, &aes_buf_size);
304  cph = gabe_cph_unserialize(key->pub, cph_buf, cph_buf_size);
305  if (!gabe_dec(key->pub, key->prv, cph, m))
306  {
308  "%s\n", gabe_error());
309  GNUNET_free(aes_buf);
310  GNUNET_free(cph_buf);
311  gabe_cph_free(cph);
312  GNUNET_free(cph);
313  element_clear(m);
314  return GNUNET_SYSERR;
315  }
316  gabe_cph_free(cph);
317  GNUNET_free(cph);
318  plt_len = aes_128_cbc_decrypt(aes_buf, aes_buf_size, m, (char**)result);
319  GNUNET_free(cph_buf);
320  GNUNET_free(aes_buf);
321  element_clear(m);
322  //freeing is buggy in gabe
323  //gabe_prv_free (prv);
324  //gabe_pub_free (pub);
325  return plt_len;
326 }
ssize_t read_cpabe(const void *data, char **cph_buf, int *cph_buf_len, char **aes_buf, int *aes_buf_len)
Definition: crypto_abe.c:228
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
static int aes_128_cbc_decrypt(char *ct, int size, element_t k, char **pt)
Definition: crypto_abe.c:117
gabe_pub_t * pub
Definition: crypto_abe.c:41
static int result
Global testing status.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
gabe_prv_t * prv
Definition: crypto_abe.c:42
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_CRYPTO_cpabe_serialize_key()

ssize_t GNUNET_CRYPTO_cpabe_serialize_key ( const struct GNUNET_CRYPTO_AbeKey key,
void **  result 
)

Definition at line 329 of file crypto_abe.c.

References GNUNET_free, len, GNUNET_CRYPTO_AbeKey::prv, GNUNET_CRYPTO_AbeMasterKey::pub, GNUNET_CRYPTO_AbeKey::pub, and write_cpabe().

331 {
332  ssize_t len;
333  char *pub;
334  char *prv;
335  int pub_len;
336  int prv_len;
337 
338  pub_len = gabe_pub_serialize(key->pub, &pub);
339  prv_len = gabe_prv_serialize(key->prv, &prv);
340 
341  len = pub_len + prv_len + 12;
342  write_cpabe(result, len, pub, pub_len, prv, prv_len);
343 
344  GNUNET_free(pub);
345  GNUNET_free(prv);
346 
347  return len;
348 }
gabe_pub_t * pub
Definition: crypto_abe.c:41
ssize_t write_cpabe(void **result, uint32_t file_len, char *cph_buf, int cph_buf_len, char *aes_buf, int aes_buf_len)
Definition: crypto_abe.c:200
static int result
Global testing status.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:39
gabe_prv_t * prv
Definition: crypto_abe.c:42
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ GNUNET_CRYPTO_cpabe_deserialize_key()

struct GNUNET_CRYPTO_AbeKey* GNUNET_CRYPTO_cpabe_deserialize_key ( const void *  data,
size_t  len 
)

Definition at line 351 of file crypto_abe.c.

References GNUNET_free, GNUNET_new, key, GNUNET_CRYPTO_AbeKey::prv, GNUNET_CRYPTO_AbeMasterKey::pub, GNUNET_CRYPTO_AbeKey::pub, and read_cpabe().

353 {
354  struct GNUNET_CRYPTO_AbeKey *key;
355  char *pub;
356  char *prv;
357  int prv_len;
358  int pub_len;
359 
360  key = GNUNET_new(struct GNUNET_CRYPTO_AbeKey);
362  &pub,
363  &pub_len,
364  &prv,
365  &prv_len);
366  key->pub = gabe_pub_unserialize(pub, pub_len);
367  key->prv = gabe_prv_unserialize(key->pub, prv, prv_len);
368 
369  GNUNET_free(pub);
370  GNUNET_free(prv);
371  return key;
372 }
ssize_t read_cpabe(const void *data, char **cph_buf, int *cph_buf_len, char **aes_buf, int *aes_buf_len)
Definition: crypto_abe.c:228
#define GNUNET_new(type)
Allocate a struct or union of the given type.
gabe_pub_t * pub
Definition: crypto_abe.c:41
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:39
gabe_prv_t * prv
Definition: crypto_abe.c:42
uint32_t data
The data value.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_CRYPTO_cpabe_serialize_master_key()

ssize_t GNUNET_CRYPTO_cpabe_serialize_master_key ( const struct GNUNET_CRYPTO_AbeMasterKey key,
void **  result 
)

Definition at line 375 of file crypto_abe.c.

References GNUNET_free, len, GNUNET_CRYPTO_AbeMasterKey::msk, GNUNET_CRYPTO_AbeMasterKey::pub, and write_cpabe().

377 {
378  ssize_t len;
379  char *pub;
380  char *msk;
381  int pub_len;
382  int msk_len;
383 
384  pub_len = gabe_pub_serialize(key->pub, &pub);
385  msk_len = gabe_msk_serialize(key->msk, &msk);
386 
387  len = pub_len + msk_len + 12;
388  write_cpabe(result, len, pub, pub_len, msk, msk_len);
389 
390  GNUNET_free(pub);
391  GNUNET_free(msk);
392 
393  return len;
394 }
ssize_t write_cpabe(void **result, uint32_t file_len, char *cph_buf, int cph_buf_len, char *aes_buf, int aes_buf_len)
Definition: crypto_abe.c:200
static int result
Global testing status.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:39
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:

◆ GNUNET_CRYPTO_cpabe_deserialize_master_key()

struct GNUNET_CRYPTO_AbeMasterKey* GNUNET_CRYPTO_cpabe_deserialize_master_key ( const void *  data,
size_t  len 
)

Definition at line 397 of file crypto_abe.c.

References GNUNET_free, GNUNET_new, key, GNUNET_CRYPTO_AbeMasterKey::msk, GNUNET_CRYPTO_AbeMasterKey::pub, and read_cpabe().

399 {
401  char *msk;
402  char *pub;
403  int msk_len;
404  int pub_len;
405 
408  &pub,
409  &pub_len,
410  &msk,
411  &msk_len);
412  key->pub = gabe_pub_unserialize(pub, pub_len);
413  key->msk = gabe_msk_unserialize(key->pub, msk, msk_len);
414 
415  GNUNET_free(pub);
416  GNUNET_free(msk);
417 
418  return key;
419 }
ssize_t read_cpabe(const void *data, char **cph_buf, int *cph_buf_len, char **aes_buf, int *aes_buf_len)
Definition: crypto_abe.c:228
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:39
uint32_t data
The data value.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function: