aboutsummaryrefslogtreecommitdiff
path: root/src/abe
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-01-04 15:28:02 +0100
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-01-04 15:29:45 +0100
commit78705d5a49d7066a01b832546d2507456a3c5d2c (patch)
treeb0e5f72bdde4574f20c0b89ee56295f83b954800 /src/abe
parent272921672ec094644a1ddbbfacb96581e72ed443 (diff)
downloadgnunet-78705d5a49d7066a01b832546d2507456a3c5d2c.tar.gz
gnunet-78705d5a49d7066a01b832546d2507456a3c5d2c.zip
-cleanup doc; fixes
Diffstat (limited to 'src/abe')
-rw-r--r--src/abe/abe.c94
1 files changed, 88 insertions, 6 deletions
diff --git a/src/abe/abe.c b/src/abe/abe.c
index d008cc522..3f1f6dc5b 100644
--- a/src/abe/abe.c
+++ b/src/abe/abe.c
@@ -1,5 +1,5 @@
1/* 1/*
2 This file is part of GNUnet. Copyright (C) 2001-2014 Christian Grothoff 2 This file is part of GNUnet. Copyright (C) 2001-2018 Christian Grothoff
3 (and other contributing authors) 3 (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
@@ -20,9 +20,9 @@
20*/ 20*/
21 21
22/** 22/**
23 * @file util/crypto_random.c 23 * @file abe/abe.c
24 * @brief functions to gather random numbers 24 * @brief functions for Attribute-Based Encryption
25 * @author Christian Grothoff 25 * @author Martin Schanzenbach
26 */ 26 */
27 27
28 28
@@ -146,6 +146,12 @@ aes_128_cbc_decrypt( char* ct,
146 return len; 146 return len;
147} 147}
148 148
149/**
150 * @ingroup abe
151 * Create a new CP-ABE master key. Caller must free return value.
152 *
153 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key
154 */
149struct GNUNET_ABE_AbeMasterKey* 155struct GNUNET_ABE_AbeMasterKey*
150GNUNET_ABE_cpabe_create_master_key (void) 156GNUNET_ABE_cpabe_create_master_key (void)
151{ 157{
@@ -157,6 +163,13 @@ GNUNET_ABE_cpabe_create_master_key (void)
157 return key; 163 return key;
158} 164}
159 165
166/**
167 * @ingroup abe
168 * Delete a CP-ABE master key.
169 *
170 * @param key the master key
171 * @return fresh private key; free using #GNUNET_free
172 */
160void 173void
161GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key) 174GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key)
162{ 175{
@@ -167,6 +180,14 @@ GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key)
167 GNUNET_free (key); 180 GNUNET_free (key);
168} 181}
169 182
183/**
184 * @ingroup abe
185 * Create a new CP-ABE key. Caller must free return value.
186 *
187 * @param key the master key
188 * @param attrs the attributes to append to the key
189 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_key
190 */
170struct GNUNET_ABE_AbeKey* 191struct GNUNET_ABE_AbeKey*
171GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key, 192GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
172 char **attrs) 193 char **attrs)
@@ -184,6 +205,14 @@ GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
184 return prv_key; 205 return prv_key;
185} 206}
186 207
208/**
209 * @ingroup abe
210 * Delete a CP-ABE key.
211 *
212 * @param key the key to delete
213 * @param delete_pub GNUNE_YES if the public key should also be freed (bug in gabe)
214 * @return fresh private key; free using #GNUNET_free
215 */
187void 216void
188GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key, 217GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
189 int delete_pub) 218 int delete_pub)
@@ -195,7 +224,7 @@ GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
195 GNUNET_free (key); 224 GNUNET_free (key);
196} 225}
197 226
198ssize_t 227static ssize_t
199write_cpabe (void **result, 228write_cpabe (void **result,
200 uint32_t file_len, 229 uint32_t file_len,
201 char* cph_buf, 230 char* cph_buf,
@@ -223,7 +252,7 @@ write_cpabe (void **result,
223 return 12 + cph_buf_len + aes_buf_len; 252 return 12 + cph_buf_len + aes_buf_len;
224} 253}
225 254
226ssize_t 255static ssize_t
227read_cpabe (const void *data, 256read_cpabe (const void *data,
228 char** cph_buf, 257 char** cph_buf,
229 int *cph_buf_len, 258 int *cph_buf_len,
@@ -253,6 +282,17 @@ read_cpabe (const void *data,
253 return buf_len; 282 return buf_len;
254} 283}
255 284
285/**
286 * @ingroup abe
287 * Encrypt a block using sessionkey.
288 *
289 * @param block the block to encrypt
290 * @param size the size of the @a block
291 * @param policy the ABE policy
292 * @param key the key used to encrypt
293 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
294 * @return the size of the encrypted block, -1 for errors
295 */
256ssize_t 296ssize_t
257GNUNET_ABE_cpabe_encrypt (const void *block, 297GNUNET_ABE_cpabe_encrypt (const void *block,
258 size_t size, 298 size_t size,
@@ -285,6 +325,16 @@ GNUNET_ABE_cpabe_encrypt (const void *block,
285 return result_len; 325 return result_len;
286} 326}
287 327
328/**
329 * @ingroup abe
330 * Decrypt a block using the ABE key.
331 *
332 * @param block the block to encrypt
333 * @param size the size of the @a block
334 * @param key the key used to decrypt
335 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
336 * @return the size of the encrypted block, -1 for errors
337 */
288ssize_t 338ssize_t
289GNUNET_ABE_cpabe_decrypt (const void *block, 339GNUNET_ABE_cpabe_decrypt (const void *block,
290 size_t size, 340 size_t size,
@@ -323,6 +373,14 @@ GNUNET_ABE_cpabe_decrypt (const void *block,
323 return plt_len; 373 return plt_len;
324} 374}
325 375
376/**
377 * @ingroup abe
378 * Serialize an ABE key.
379 *
380 * @param key the key to serialize
381 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
382 * @return the size of the encrypted block, -1 for errors
383 */
326ssize_t 384ssize_t
327GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key, 385GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
328 void **result) 386 void **result)
@@ -345,6 +403,14 @@ GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
345 return len; 403 return len;
346} 404}
347 405
406/**
407 * @ingroup abe
408 * Deserialize a serialized ABE key.
409 *
410 * @param data the data to deserialize
411 * @param len the length of the data.
412 * @return the ABE key. NULL of unsuccessful
413 */
348struct GNUNET_ABE_AbeKey* 414struct GNUNET_ABE_AbeKey*
349GNUNET_ABE_cpabe_deserialize_key (const void *data, 415GNUNET_ABE_cpabe_deserialize_key (const void *data,
350 size_t len) 416 size_t len)
@@ -369,6 +435,14 @@ GNUNET_ABE_cpabe_deserialize_key (const void *data,
369 return key; 435 return key;
370} 436}
371 437
438/**
439 * @ingroup abe
440 * Serialize an ABE master key.
441 *
442 * @param key the key to serialize
443 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
444 * @return the size of the encrypted block, -1 for errors
445 */
372ssize_t 446ssize_t
373GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key, 447GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key,
374 void **result) 448 void **result)
@@ -391,6 +465,14 @@ GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key
391 return len; 465 return len;
392} 466}
393 467
468/**
469 * @ingroup abe
470 * Deserialize an ABE master key.
471 *
472 * @param data the data to deserialize
473 * @param len the length of the data.
474 * @return the ABE key. NULL of unsuccessful
475 */
394struct GNUNET_ABE_AbeMasterKey* 476struct GNUNET_ABE_AbeMasterKey*
395GNUNET_ABE_cpabe_deserialize_master_key (const void *data, 477GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
396 size_t len) 478 size_t len)