aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--contrib/Dockerfile (renamed from Dockerfile)0
-rw-r--r--contrib/docker-entrypoint.sh (renamed from docker-entrypoint.sh)0
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/Makefile.am7
-rw-r--r--src/abe/Makefile.am50
-rw-r--r--src/abe/abe.c417
-rw-r--r--src/abe/test_cpabe.c (renamed from src/util/test_crypto_abe.c)13
-rw-r--r--src/identity-provider/Makefile.am1
-rw-r--r--src/identity-provider/gnunet-service-identity-provider.c77
-rw-r--r--src/include/gnunet_abe_lib.h143
-rw-r--r--src/include/gnunet_crypto_lib.h82
-rw-r--r--src/util/Makefile.am23
13 files changed, 663 insertions, 152 deletions
diff --git a/configure.ac b/configure.ac
index ac00bd5d6..017b4836c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1658,6 +1658,7 @@ src/vpn/vpn.conf
1658src/zonemaster/Makefile 1658src/zonemaster/Makefile
1659src/zonemaster/zonemaster.conf 1659src/zonemaster/zonemaster.conf
1660src/rest/Makefile 1660src/rest/Makefile
1661src/abe/Makefile
1661src/identity-attribute/Makefile 1662src/identity-attribute/Makefile
1662src/identity-provider/Makefile 1663src/identity-provider/Makefile
1663pkgconfig/Makefile 1664pkgconfig/Makefile
diff --git a/Dockerfile b/contrib/Dockerfile
index 5a193a46d..5a193a46d 100644
--- a/Dockerfile
+++ b/contrib/Dockerfile
diff --git a/docker-entrypoint.sh b/contrib/docker-entrypoint.sh
index 807d86d6f..807d86d6f 100644
--- a/docker-entrypoint.sh
+++ b/contrib/docker-entrypoint.sh
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e0654d4b4..2fcb74c09 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,3 +1,4 @@
1src/abe/abe.c
1src/arm/arm_api.c 2src/arm/arm_api.c
2src/arm/arm_monitor_api.c 3src/arm/arm_monitor_api.c
3src/arm/gnunet-arm.c 4src/arm/gnunet-arm.c
diff --git a/src/Makefile.am b/src/Makefile.am
index fcdd44bfb..6d0284157 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,9 +14,10 @@ if HAVE_EXPERIMENTAL
14 rps 14 rps
15# dv (FTBFS) 15# dv (FTBFS)
16if HAVE_ABE 16if HAVE_ABE
17 EXP_DIR += identity-attribute \ 17 EXP_DIR += abe \
18 identity-provider \ 18 credential \
19 credential 19 identity-attribute \
20 identity-provider
20endif 21endif
21endif 22endif
22 23
diff --git a/src/abe/Makefile.am b/src/abe/Makefile.am
new file mode 100644
index 000000000..308e6c67c
--- /dev/null
+++ b/src/abe/Makefile.am
@@ -0,0 +1,50 @@
1# This Makefile.am is in the public domain
2AM_CPPFLAGS = -I$(top_srcdir)/src/include
3
4plugindir = $(libdir)/gnunet
5
6libexecdir= $(pkglibdir)/libexec/
7
8pkgcfgdir= $(pkgdatadir)/config.d/
9
10dist_pkgcfg_DATA = \
11 abe.conf
12
13if USE_COVERAGE
14 AM_CFLAGS = --coverage -O0
15 XLIB = -lgcov
16endif
17
18libgnunetabe_la_SOURCES = abe.c
19
20libgnunetabe_la_LIBADD = \
21 $(GCLIBADD)\
22 $(LIBGCRYPT_LIBS) \
23 $(LTLIBICONV) \
24 $(LTLIBINTL) \
25 $(ABE_LIBADD) \
26 -lgabe \
27 -lpbc \
28 -lglib-2.0 \
29 -lltdl $(Z_LIBS) -lunistring $(XLIB)
30
31libgnunetabe_la_LDFLAGS = \
32 $(GN_LIB_LDFLAGS) \
33 -version-info 1:0:0
34
35lib_LTLIBRARIES = libgnunetabe.la
36
37if ENABLE_TEST_RUN
38AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
39TESTS = $(check_PROGRAMS)
40endif
41
42check_PROGRAMS = test_cpabe
43
44test_cpabe_SOURCES = \
45 test_cpabe.c
46test_cpabe_LDADD = \
47 libgnunetabe.la \
48 $(top_builddir)/src/util/libgnunetutil.la
49check_PROGRAMS += \
50 test_cpabe
diff --git a/src/abe/abe.c b/src/abe/abe.c
new file mode 100644
index 000000000..d008cc522
--- /dev/null
+++ b/src/abe/abe.c
@@ -0,0 +1,417 @@
1/*
2 This file is part of GNUnet. Copyright (C) 2001-2014 Christian Grothoff
3 (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19
20*/
21
22/**
23 * @file util/crypto_random.c
24 * @brief functions to gather random numbers
25 * @author Christian Grothoff
26 */
27
28
29#include "platform.h"
30#include <pbc/pbc.h>
31#include <gabe.h>
32
33#include "gnunet_crypto_lib.h"
34#include "gnunet_abe_lib.h"
35
36struct GNUNET_ABE_AbeMasterKey
37{
38 gabe_pub_t* pub;
39 gabe_msk_t* msk;
40};
41
42struct GNUNET_ABE_AbeKey
43{
44 gabe_pub_t* pub;
45 gabe_prv_t* prv;
46};
47
48static int
49init_aes( element_t k, int enc,
50 gcry_cipher_hd_t* handle,
51 struct GNUNET_CRYPTO_SymmetricSessionKey *key,
52 unsigned char* iv)
53{
54 int rc;
55 int key_len;
56 unsigned char* key_buf;
57
58 key_len = element_length_in_bytes(k) < 33 ? 3 : element_length_in_bytes(k);
59 key_buf = (unsigned char*) malloc(key_len);
60 element_to_bytes(key_buf, k);
61
62 memcpy (key->aes_key, key_buf, GNUNET_CRYPTO_AES_KEY_LENGTH);
63 GNUNET_assert (0 ==
64 gcry_cipher_open (handle, GCRY_CIPHER_AES256,
65 GCRY_CIPHER_MODE_CFB, 0));
66 rc = gcry_cipher_setkey (*handle,
67 key->aes_key,
68 sizeof (key->aes_key));
69 GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
70 memset (iv, 0, 16); //TODO make reasonable
71 rc = gcry_cipher_setiv (*handle,
72 iv,
73 16);
74 GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
75
76 free(key_buf);
77 return rc;
78}
79
80static int
81aes_128_cbc_encrypt( char* pt,
82 int size,
83 element_t k,
84 char **ct )
85{
86 gcry_cipher_hd_t handle;
87 struct GNUNET_CRYPTO_SymmetricSessionKey skey;
88 unsigned char iv[16];
89 char* buf;
90 int padding;
91 int buf_size;
92 uint8_t len[4];
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}
115
116static int
117aes_128_cbc_decrypt( char* ct,
118 int size,
119 element_t k,
120 char **pt )
121{
122 struct GNUNET_CRYPTO_SymmetricSessionKey skey;
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}
148
149struct GNUNET_ABE_AbeMasterKey*
150GNUNET_ABE_cpabe_create_master_key (void)
151{
152 struct GNUNET_ABE_AbeMasterKey* key;
153 key = GNUNET_new (struct GNUNET_ABE_AbeMasterKey);
154 gabe_setup(&key->pub, &key->msk);
155 GNUNET_assert (NULL != key->pub);
156 GNUNET_assert (NULL != key->msk);
157 return key;
158}
159
160void
161GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key)
162{
163 gabe_msk_free (key->msk);
164 gabe_pub_free (key->pub);
165 //GNUNET_free (key->msk);
166 //gabe_msk_free (key->msk); //For some reason free of pub implicit?
167 GNUNET_free (key);
168}
169
170struct GNUNET_ABE_AbeKey*
171GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
172 char **attrs)
173{
174 struct GNUNET_ABE_AbeKey *prv_key;
175 int size;
176 char *tmp;
177
178 prv_key = GNUNET_new (struct GNUNET_ABE_AbeKey);
179 prv_key->prv = gabe_keygen(key->pub, key->msk, attrs);
180 size = gabe_pub_serialize(key->pub, &tmp);
181 prv_key->pub = gabe_pub_unserialize(tmp, size);
182 GNUNET_free (tmp);
183 GNUNET_assert (NULL != prv_key->prv);
184 return prv_key;
185}
186
187void
188GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
189 int delete_pub)
190{
191 //Memory management in gabe is buggy
192 gabe_prv_free (key->prv);
193 if (GNUNET_YES == delete_pub)
194 gabe_pub_free (key->pub);
195 GNUNET_free (key);
196}
197
198ssize_t
199write_cpabe (void **result,
200 uint32_t file_len,
201 char* cph_buf,
202 int cph_buf_len,
203 char* aes_buf,
204 int aes_buf_len)
205{
206 char *ptr;
207 uint32_t *len;
208
209 *result = GNUNET_malloc (12 + cph_buf_len + aes_buf_len);
210 ptr = *result;
211 len = (uint32_t*) ptr;
212 *len = htonl (file_len);
213 ptr += 4;
214 len = (uint32_t*) ptr;
215 *len = htonl (aes_buf_len);
216 ptr += 4;
217 memcpy (ptr, aes_buf, aes_buf_len);
218 ptr += aes_buf_len;
219 len = (uint32_t*) ptr;
220 *len = htonl (cph_buf_len);
221 ptr += 4;
222 memcpy (ptr, cph_buf, cph_buf_len);
223 return 12 + cph_buf_len + aes_buf_len;
224}
225
226ssize_t
227read_cpabe (const void *data,
228 char** cph_buf,
229 int *cph_buf_len,
230 char** aes_buf,
231 int *aes_buf_len)
232{
233 int buf_len;
234 char *ptr;
235 uint32_t *len;
236
237 ptr = (char*)data;
238 len = (uint32_t*)ptr;
239 buf_len = ntohl (*len);
240 ptr += 4;
241 len = (uint32_t*)ptr;
242 *aes_buf_len = ntohl (*len);
243 ptr += 4;
244 *aes_buf = GNUNET_malloc (*aes_buf_len);
245 memcpy(*aes_buf, ptr, *aes_buf_len);
246 ptr += *aes_buf_len;
247 len = (uint32_t*)ptr;
248 *cph_buf_len = ntohl (*len);
249 ptr += 4;
250 *cph_buf = GNUNET_malloc (*cph_buf_len);
251 memcpy(*cph_buf, ptr, *cph_buf_len);
252
253 return buf_len;
254}
255
256ssize_t
257GNUNET_ABE_cpabe_encrypt (const void *block,
258 size_t size,
259 const char *policy,
260 const struct GNUNET_ABE_AbeMasterKey *key,
261 void **result)
262{
263 gabe_cph_t* cph;
264 char* plt;
265 char* cph_buf;
266 char* aes_buf;
267 element_t m;
268 int cph_buf_len;
269 int aes_buf_len;
270 ssize_t result_len;
271
272 if( !(cph = gabe_enc(key->pub, m, (char*)policy)) )
273 return GNUNET_SYSERR;
274 cph_buf_len = gabe_cph_serialize(cph,
275 &cph_buf);
276 gabe_cph_free(cph);
277 GNUNET_free (cph);
278 plt = GNUNET_memdup (block, size);
279 aes_buf_len = aes_128_cbc_encrypt(plt, size, m, &aes_buf);
280 GNUNET_free (plt);
281 element_clear(m);
282 result_len = write_cpabe(result, size, cph_buf, cph_buf_len, aes_buf, aes_buf_len);
283 GNUNET_free(cph_buf);
284 GNUNET_free(aes_buf);
285 return result_len;
286}
287
288ssize_t
289GNUNET_ABE_cpabe_decrypt (const void *block,
290 size_t size,
291 const struct GNUNET_ABE_AbeKey *key,
292 void **result)
293{
294 char* aes_buf;
295 char* cph_buf;
296 gabe_cph_t* cph;
297 element_t m;
298 int cph_buf_size;
299 int aes_buf_size;
300 int plt_len;
301
302 read_cpabe(block, &cph_buf, &cph_buf_size, &aes_buf, &aes_buf_size);
303 cph = gabe_cph_unserialize(key->pub, cph_buf, cph_buf_size);
304 if( !gabe_dec(key->pub, key->prv, cph, m) ) {
305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
306 "%s\n", gabe_error());
307 GNUNET_free (aes_buf);
308 GNUNET_free (cph_buf);
309 gabe_cph_free(cph);
310 GNUNET_free (cph);
311 element_clear (m);
312 return GNUNET_SYSERR;
313 }
314 gabe_cph_free(cph);
315 GNUNET_free (cph);
316 plt_len = aes_128_cbc_decrypt(aes_buf, aes_buf_size, m, (char**)result);
317 GNUNET_free (cph_buf);
318 GNUNET_free (aes_buf);
319 element_clear (m);
320 //freeing is buggy in gabe
321 //gabe_prv_free (prv);
322 //gabe_pub_free (pub);
323 return plt_len;
324}
325
326ssize_t
327GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
328 void **result)
329{
330 ssize_t len;
331 char *pub;
332 char *prv;
333 int pub_len;
334 int prv_len;
335
336 pub_len = gabe_pub_serialize (key->pub, &pub);
337 prv_len = gabe_prv_serialize (key->prv, &prv);
338
339 len = pub_len + prv_len + 12;
340 write_cpabe (result, len, pub, pub_len, prv, prv_len);
341
342 GNUNET_free (pub);
343 GNUNET_free (prv);
344
345 return len;
346}
347
348struct GNUNET_ABE_AbeKey*
349GNUNET_ABE_cpabe_deserialize_key (const void *data,
350 size_t len)
351{
352 struct GNUNET_ABE_AbeKey *key;
353 char *pub;
354 char *prv;
355 int prv_len;
356 int pub_len;
357
358 key = GNUNET_new (struct GNUNET_ABE_AbeKey);
359 read_cpabe (data,
360 &pub,
361 &pub_len,
362 &prv,
363 &prv_len);
364 key->pub = gabe_pub_unserialize (pub, pub_len);
365 key->prv = gabe_prv_unserialize (key->pub, prv, prv_len);
366
367 GNUNET_free (pub);
368 GNUNET_free (prv);
369 return key;
370}
371
372ssize_t
373GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key,
374 void **result)
375{
376 ssize_t len;
377 char *pub;
378 char *msk;
379 int pub_len;
380 int msk_len;
381
382 pub_len = gabe_pub_serialize (key->pub, &pub);
383 msk_len = gabe_msk_serialize (key->msk, &msk);
384
385 len = pub_len + msk_len + 12;
386 write_cpabe (result, len, pub, pub_len, msk, msk_len);
387
388 GNUNET_free (pub);
389 GNUNET_free (msk);
390
391 return len;
392}
393
394struct GNUNET_ABE_AbeMasterKey*
395GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
396 size_t len)
397{
398 struct GNUNET_ABE_AbeMasterKey *key;
399 char *msk;
400 char *pub;
401 int msk_len;
402 int pub_len;
403
404 key = GNUNET_new (struct GNUNET_ABE_AbeMasterKey);
405 read_cpabe (data,
406 &pub,
407 &pub_len,
408 &msk,
409 &msk_len);
410 key->pub = gabe_pub_unserialize (pub, pub_len);
411 key->msk = gabe_msk_unserialize (key->pub, msk, msk_len);
412
413 GNUNET_free (pub);
414 GNUNET_free (msk);
415
416 return key;
417}
diff --git a/src/util/test_crypto_abe.c b/src/abe/test_cpabe.c
index cb36dccae..9b2062b23 100644
--- a/src/util/test_crypto_abe.c
+++ b/src/abe/test_cpabe.c
@@ -25,20 +25,21 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_abe_lib.h"
28 29
29#define TESTSTRING "Hello World!" 30#define TESTSTRING "Hello World!"
30 31
31static int 32static int
32testAbecipher () 33testAbecipher ()
33{ 34{
34 struct GNUNET_CRYPTO_AbeMasterKey *msk; 35 struct GNUNET_ABE_AbeMasterKey *msk;
35 struct GNUNET_CRYPTO_AbeKey *key; 36 struct GNUNET_ABE_AbeKey *key;
36 char *result; 37 char *result;
37 char **attrs; 38 char **attrs;
38 int size; 39 int size;
39 char *res; 40 char *res;
40 msk = GNUNET_CRYPTO_cpabe_create_master_key (); 41 msk = GNUNET_ABE_cpabe_create_master_key ();
41 size = GNUNET_CRYPTO_cpabe_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, 42 size = GNUNET_ABE_cpabe_encrypt (TESTSTRING, strlen (TESTSTRING) + 1,
42 "testattr", //Policy 43 "testattr", //Policy
43 msk, 44 msk,
44 (void*)&result); 45 (void*)&result);
@@ -46,10 +47,10 @@ testAbecipher ()
46 attrs = GNUNET_malloc (2 * sizeof (char*)); 47 attrs = GNUNET_malloc (2 * sizeof (char*));
47 attrs[0] = "testattr"; 48 attrs[0] = "testattr";
48 attrs[1] = NULL; 49 attrs[1] = NULL;
49 key = GNUNET_CRYPTO_cpabe_create_key (msk, 50 key = GNUNET_ABE_cpabe_create_key (msk,
50 attrs); 51 attrs);
51 52
52 size = GNUNET_CRYPTO_cpabe_decrypt (result, size, 53 size = GNUNET_ABE_cpabe_decrypt (result, size,
53 key, 54 key,
54 (void*)&res); 55 (void*)&res);
55 if (strlen (TESTSTRING) + 1 != size) 56 if (strlen (TESTSTRING) + 1 != size)
diff --git a/src/identity-provider/Makefile.am b/src/identity-provider/Makefile.am
index 5c5ddaa57..adf6af3b3 100644
--- a/src/identity-provider/Makefile.am
+++ b/src/identity-provider/Makefile.am
@@ -70,6 +70,7 @@ gnunet_service_identity_provider_LDADD = \
70 $(top_builddir)/src/namestore/libgnunetnamestore.la \ 70 $(top_builddir)/src/namestore/libgnunetnamestore.la \
71 $(top_builddir)/src/identity/libgnunetidentity.la \ 71 $(top_builddir)/src/identity/libgnunetidentity.la \
72 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 72 $(top_builddir)/src/statistics/libgnunetstatistics.la \
73 $(top_builddir)/src/abe/libgnunetabe.la \
73 $(top_builddir)/src/credential/libgnunetcredential.la \ 74 $(top_builddir)/src/credential/libgnunetcredential.la \
74 $(top_builddir)/src/identity-attribute/libgnunetidentityattribute.la \ 75 $(top_builddir)/src/identity-attribute/libgnunetidentityattribute.la \
75 libgnunetidentityprovider.la \ 76 libgnunetidentityprovider.la \
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c
index a5c178aa5..351308c3a 100644
--- a/src/identity-provider/gnunet-service-identity-provider.c
+++ b/src/identity-provider/gnunet-service-identity-provider.c
@@ -30,6 +30,7 @@
30#include "gnunet_identity_service.h" 30#include "gnunet_identity_service.h"
31#include "gnunet_gnsrecord_lib.h" 31#include "gnunet_gnsrecord_lib.h"
32#include "gnunet_namestore_service.h" 32#include "gnunet_namestore_service.h"
33#include "gnunet_abe_lib.h"
33#include "gnunet_credential_service.h" 34#include "gnunet_credential_service.h"
34#include "gnunet_statistics_service.h" 35#include "gnunet_statistics_service.h"
35#include "gnunet_gns_service.h" 36#include "gnunet_gns_service.h"
@@ -205,7 +206,7 @@ struct TicketIteration
205 */ 206 */
206typedef void 207typedef void
207(*AbeBootstrapResult) (void *cls, 208(*AbeBootstrapResult) (void *cls,
208 struct GNUNET_CRYPTO_AbeMasterKey *abe_key); 209 struct GNUNET_ABE_AbeMasterKey *abe_key);
209 210
210 211
211struct AbeBootstrapHandle 212struct AbeBootstrapHandle
@@ -233,7 +234,7 @@ struct AbeBootstrapHandle
233 /** 234 /**
234 * The issuer egos ABE master key 235 * The issuer egos ABE master key
235 */ 236 */
236 struct GNUNET_CRYPTO_AbeMasterKey *abe_key; 237 struct GNUNET_ABE_AbeMasterKey *abe_key;
237}; 238};
238 239
239/** 240/**
@@ -264,7 +265,7 @@ struct AttributeIterator
264 /** 265 /**
265 * The issuer egos ABE master key 266 * The issuer egos ABE master key
266 */ 267 */
267 struct GNUNET_CRYPTO_AbeMasterKey *abe_key; 268 struct GNUNET_ABE_AbeMasterKey *abe_key;
268 269
269 /** 270 /**
270 * Namestore iterator 271 * Namestore iterator
@@ -355,7 +356,7 @@ struct AttributeStoreHandle
355 /** 356 /**
356 * The issuer egos ABE master key 357 * The issuer egos ABE master key
357 */ 358 */
358 struct GNUNET_CRYPTO_AbeMasterKey *abe_key; 359 struct GNUNET_ABE_AbeMasterKey *abe_key;
359 360
360 /** 361 /**
361 * QueueEntry 362 * QueueEntry
@@ -423,7 +424,7 @@ struct ConsumeTicketHandle
423 /** 424 /**
424 * The ABE key 425 * The ABE key
425 */ 426 */
426 struct GNUNET_CRYPTO_AbeKey *key; 427 struct GNUNET_ABE_AbeKey *key;
427 428
428 /** 429 /**
429 * Attributes 430 * Attributes
@@ -520,7 +521,7 @@ struct TicketRevocationHandle
520 /** 521 /**
521 * The ABE master key 522 * The ABE master key
522 */ 523 */
523 struct GNUNET_CRYPTO_AbeMasterKey *abe_key; 524 struct GNUNET_ABE_AbeMasterKey *abe_key;
524 525
525 /** 526 /**
526 * Offset 527 * Offset
@@ -690,7 +691,7 @@ bootstrap_store_task (void *cls)
690 struct GNUNET_GNSRECORD_Data rd[1]; 691 struct GNUNET_GNSRECORD_Data rd[1];
691 char *key; 692 char *key;
692 693
693 rd[0].data_size = GNUNET_CRYPTO_cpabe_serialize_master_key (abh->abe_key, 694 rd[0].data_size = GNUNET_ABE_cpabe_serialize_master_key (abh->abe_key,
694 (void**)&key); 695 (void**)&key);
695 rd[0].data = key; 696 rd[0].data = key;
696 rd[0].record_type = GNUNET_GNSRECORD_TYPE_ABE_MASTER; 697 rd[0].record_type = GNUNET_GNSRECORD_TYPE_ABE_MASTER;
@@ -730,13 +731,13 @@ bootstrap_abe_result (void *cls,
730 const struct GNUNET_GNSRECORD_Data *rd) 731 const struct GNUNET_GNSRECORD_Data *rd)
731{ 732{
732 struct AbeBootstrapHandle *abh = cls; 733 struct AbeBootstrapHandle *abh = cls;
733 struct GNUNET_CRYPTO_AbeMasterKey *abe_key; 734 struct GNUNET_ABE_AbeMasterKey *abe_key;
734 int i; 735 int i;
735 736
736 for (i=0;i<rd_count;i++) { 737 for (i=0;i<rd_count;i++) {
737 if (GNUNET_GNSRECORD_TYPE_ABE_MASTER != rd[i].record_type) 738 if (GNUNET_GNSRECORD_TYPE_ABE_MASTER != rd[i].record_type)
738 continue; 739 continue;
739 abe_key = GNUNET_CRYPTO_cpabe_deserialize_master_key (rd[i].data, 740 abe_key = GNUNET_ABE_cpabe_deserialize_master_key (rd[i].data,
740 rd[i].data_size); 741 rd[i].data_size);
741 abh->proc (abh->proc_cls, abe_key); 742 abh->proc (abh->proc_cls, abe_key);
742 GNUNET_free (abh); 743 GNUNET_free (abh);
@@ -744,7 +745,7 @@ bootstrap_abe_result (void *cls,
744 } 745 }
745 746
746 //No ABE master found, bootstrapping... 747 //No ABE master found, bootstrapping...
747 abh->abe_key = GNUNET_CRYPTO_cpabe_create_master_key (); 748 abh->abe_key = GNUNET_ABE_cpabe_create_master_key ();
748 GNUNET_SCHEDULER_add_now (&bootstrap_store_task, abh); 749 GNUNET_SCHEDULER_add_now (&bootstrap_store_task, abh);
749} 750}
750 751
@@ -767,7 +768,7 @@ bootstrap_abe (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
767 abh->identity = *identity; 768 abh->identity = *identity;
768 if (GNUNET_YES == recreate) 769 if (GNUNET_YES == recreate)
769 { 770 {
770 abh->abe_key = GNUNET_CRYPTO_cpabe_create_master_key (); 771 abh->abe_key = GNUNET_ABE_cpabe_create_master_key ();
771 GNUNET_SCHEDULER_add_now (&bootstrap_store_task, abh); 772 GNUNET_SCHEDULER_add_now (&bootstrap_store_task, abh);
772 } else { 773 } else {
773 abh->ns_qe = GNUNET_NAMESTORE_records_lookup (ns_handle, 774 abh->ns_qe = GNUNET_NAMESTORE_records_lookup (ns_handle,
@@ -874,7 +875,7 @@ store_ticket_issue_cont (void *cls,
874int 875int
875serialize_abe_keyinfo2 (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, 876serialize_abe_keyinfo2 (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
876 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, 877 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
877 const struct GNUNET_CRYPTO_AbeKey *rp_key, 878 const struct GNUNET_ABE_AbeKey *rp_key,
878 struct GNUNET_CRYPTO_EcdhePrivateKey **ecdh_privkey, 879 struct GNUNET_CRYPTO_EcdhePrivateKey **ecdh_privkey,
879 char **result) 880 char **result)
880{ 881{
@@ -892,7 +893,7 @@ serialize_abe_keyinfo2 (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
892 struct GNUNET_HashCode new_key_hash; 893 struct GNUNET_HashCode new_key_hash;
893 ssize_t enc_size; 894 ssize_t enc_size;
894 895
895 size = GNUNET_CRYPTO_cpabe_serialize_key (rp_key, 896 size = GNUNET_ABE_cpabe_serialize_key (rp_key,
896 (void**)&serialized_key); 897 (void**)&serialized_key);
897 attrs_str_len = 0; 898 attrs_str_len = 0;
898 for (le = attrs->list_head; NULL != le; le = le->next) { 899 for (le = attrs->list_head; NULL != le; le = le->next) {
@@ -951,13 +952,13 @@ serialize_abe_keyinfo2 (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
951 952
952static void 953static void
953issue_ticket_after_abe_bootstrap (void *cls, 954issue_ticket_after_abe_bootstrap (void *cls,
954 struct GNUNET_CRYPTO_AbeMasterKey *abe_key) 955 struct GNUNET_ABE_AbeMasterKey *abe_key)
955{ 956{
956 struct TicketIssueHandle *ih = cls; 957 struct TicketIssueHandle *ih = cls;
957 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; 958 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le;
958 struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey; 959 struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey;
959 struct GNUNET_GNSRECORD_Data code_record[1]; 960 struct GNUNET_GNSRECORD_Data code_record[1];
960 struct GNUNET_CRYPTO_AbeKey *rp_key; 961 struct GNUNET_ABE_AbeKey *rp_key;
961 char *code_record_data; 962 char *code_record_data;
962 char **attrs; 963 char **attrs;
963 char *label; 964 char *label;
@@ -983,7 +984,7 @@ issue_ticket_after_abe_bootstrap (void *cls,
983 i++; 984 i++;
984 } 985 }
985 attrs[i] = NULL; 986 attrs[i] = NULL;
986 rp_key = GNUNET_CRYPTO_cpabe_create_key (abe_key, 987 rp_key = GNUNET_ABE_cpabe_create_key (abe_key,
987 attrs); 988 attrs);
988 989
989 //TODO review this wireformat 990 //TODO review this wireformat
@@ -1014,9 +1015,9 @@ issue_ticket_after_abe_bootstrap (void *cls,
1014 GNUNET_free (label); 1015 GNUNET_free (label);
1015 GNUNET_free (attrs); 1016 GNUNET_free (attrs);
1016 GNUNET_free (code_record_data); 1017 GNUNET_free (code_record_data);
1017 GNUNET_CRYPTO_cpabe_delete_key (rp_key, 1018 GNUNET_ABE_cpabe_delete_key (rp_key,
1018 GNUNET_YES); 1019 GNUNET_YES);
1019 GNUNET_CRYPTO_cpabe_delete_master_key (abe_key); 1020 GNUNET_ABE_cpabe_delete_master_key (abe_key);
1020} 1021}
1021 1022
1022 1023
@@ -1091,7 +1092,7 @@ cleanup_revoke_ticket_handle (struct TicketRevocationHandle *handle)
1091 if (NULL != handle->rvk_attrs) 1092 if (NULL != handle->rvk_attrs)
1092 GNUNET_IDENTITY_ATTRIBUTE_list_destroy (handle->rvk_attrs); 1093 GNUNET_IDENTITY_ATTRIBUTE_list_destroy (handle->rvk_attrs);
1093 if (NULL != handle->abe_key) 1094 if (NULL != handle->abe_key)
1094 GNUNET_CRYPTO_cpabe_delete_master_key (handle->abe_key); 1095 GNUNET_ABE_cpabe_delete_master_key (handle->abe_key);
1095 if (NULL != handle->ns_qe) 1096 if (NULL != handle->ns_qe)
1096 GNUNET_NAMESTORE_cancel (handle->ns_qe); 1097 GNUNET_NAMESTORE_cancel (handle->ns_qe);
1097 if (NULL != handle->ns_it) 1098 if (NULL != handle->ns_it)
@@ -1183,7 +1184,7 @@ ticket_reissue_proc (void *cls,
1183 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le_rollover; 1184 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le_rollover;
1184 struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey; 1185 struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey;
1185 struct GNUNET_GNSRECORD_Data code_record[1]; 1186 struct GNUNET_GNSRECORD_Data code_record[1];
1186 struct GNUNET_CRYPTO_AbeKey *rp_key; 1187 struct GNUNET_ABE_AbeKey *rp_key;
1187 char *code_record_data; 1188 char *code_record_data;
1188 char **attr_arr; 1189 char **attr_arr;
1189 char *label; 1190 char *label;
@@ -1263,7 +1264,7 @@ ticket_reissue_proc (void *cls,
1263 i++; 1264 i++;
1264 } 1265 }
1265 attr_arr[i] = NULL; 1266 attr_arr[i] = NULL;
1266 rp_key = GNUNET_CRYPTO_cpabe_create_key (rh->abe_key, 1267 rp_key = GNUNET_ABE_cpabe_create_key (rh->abe_key,
1267 attr_arr); 1268 attr_arr);
1268 1269
1269 //TODO review this wireformat 1270 //TODO review this wireformat
@@ -1294,7 +1295,7 @@ ticket_reissue_proc (void *cls,
1294 GNUNET_free (label); 1295 GNUNET_free (label);
1295 GNUNET_free (attr_arr); 1296 GNUNET_free (attr_arr);
1296 GNUNET_free (code_record_data); 1297 GNUNET_free (code_record_data);
1297 GNUNET_CRYPTO_cpabe_delete_key (rp_key, GNUNET_YES); 1298 GNUNET_ABE_cpabe_delete_key (rp_key, GNUNET_YES);
1298} 1299}
1299 1300
1300 1301
@@ -1362,7 +1363,7 @@ reenc_next_attribute (struct TicketRevocationHandle *rh)
1362 /** 1363 /**
1363 * Encrypt the attribute value and store in namestore 1364 * Encrypt the attribute value and store in namestore
1364 */ 1365 */
1365 enc_size = GNUNET_CRYPTO_cpabe_encrypt (buf, 1366 enc_size = GNUNET_ABE_cpabe_encrypt (buf,
1366 buf_size, 1367 buf_size,
1367 policy, //Policy 1368 policy, //Policy
1368 rh->abe_key, 1369 rh->abe_key,
@@ -1463,7 +1464,7 @@ process_attributes_to_update (void *cls,
1463 1464
1464static void 1465static void
1465get_ticket_after_abe_bootstrap (void *cls, 1466get_ticket_after_abe_bootstrap (void *cls,
1466 struct GNUNET_CRYPTO_AbeMasterKey *abe_key) 1467 struct GNUNET_ABE_AbeMasterKey *abe_key)
1467{ 1468{
1468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1469 "Finished ABE bootstrap\n"); 1470 "Finished ABE bootstrap\n");
@@ -1534,7 +1535,7 @@ static void
1534cleanup_consume_ticket_handle (struct ConsumeTicketHandle *handle) 1535cleanup_consume_ticket_handle (struct ConsumeTicketHandle *handle)
1535{ 1536{
1536 if (NULL != handle->key) 1537 if (NULL != handle->key)
1537 GNUNET_CRYPTO_cpabe_delete_key (handle->key, 1538 GNUNET_ABE_cpabe_delete_key (handle->key,
1538 GNUNET_YES); 1539 GNUNET_YES);
1539 if (NULL != handle->attrs) 1540 if (NULL != handle->attrs)
1540 GNUNET_IDENTITY_ATTRIBUTE_list_destroy (handle->attrs); 1541 GNUNET_IDENTITY_ATTRIBUTE_list_destroy (handle->attrs);
@@ -1603,7 +1604,7 @@ process_parallel_lookup2 (void *cls, uint32_t rd_count,
1603 if (rd->record_type == GNUNET_GNSRECORD_TYPE_ID_ATTR) 1604 if (rd->record_type == GNUNET_GNSRECORD_TYPE_ID_ATTR)
1604 { 1605 {
1605 decrypt_duration = GNUNET_TIME_absolute_get (); 1606 decrypt_duration = GNUNET_TIME_absolute_get ();
1606 attr_len = GNUNET_CRYPTO_cpabe_decrypt (rd->data + sizeof (uint32_t), 1607 attr_len = GNUNET_ABE_cpabe_decrypt (rd->data + sizeof (uint32_t),
1607 rd->data_size - sizeof (uint32_t), 1608 rd->data_size - sizeof (uint32_t),
1608 handle->key, 1609 handle->key,
1609 (void**)&data); 1610 (void**)&data);
@@ -1745,7 +1746,7 @@ process_consume_abe_key (void *cls, uint32_t rd_count,
1745 scopes = GNUNET_strdup (buf); 1746 scopes = GNUNET_strdup (buf);
1746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1747 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1747 "Scopes %s\n", scopes); 1748 "Scopes %s\n", scopes);
1748 handle->key = GNUNET_CRYPTO_cpabe_deserialize_key ((void*)(buf + strlen (scopes) + 1), 1749 handle->key = GNUNET_ABE_cpabe_deserialize_key ((void*)(buf + strlen (scopes) + 1),
1749 rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey) 1750 rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)
1750 - strlen (scopes) - 1); 1751 - strlen (scopes) - 1);
1751 1752
@@ -1833,7 +1834,7 @@ cleanup_as_handle (struct AttributeStoreHandle *handle)
1833 if (NULL != handle->claim) 1834 if (NULL != handle->claim)
1834 GNUNET_free (handle->claim); 1835 GNUNET_free (handle->claim);
1835 if (NULL != handle->abe_key) 1836 if (NULL != handle->abe_key)
1836 GNUNET_CRYPTO_cpabe_delete_master_key (handle->abe_key); 1837 GNUNET_ABE_cpabe_delete_master_key (handle->abe_key);
1837 GNUNET_free (handle); 1838 GNUNET_free (handle);
1838} 1839}
1839 1840
@@ -1897,7 +1898,7 @@ attr_store_task (void *cls)
1897 /** 1898 /**
1898 * Encrypt the attribute value and store in namestore 1899 * Encrypt the attribute value and store in namestore
1899 */ 1900 */
1900 enc_size = GNUNET_CRYPTO_cpabe_encrypt (buf, 1901 enc_size = GNUNET_ABE_cpabe_encrypt (buf,
1901 buf_size, 1902 buf_size,
1902 policy, //Policy 1903 policy, //Policy
1903 as_handle->abe_key, 1904 as_handle->abe_key,
@@ -1931,7 +1932,7 @@ attr_store_task (void *cls)
1931 1932
1932static void 1933static void
1933store_after_abe_bootstrap (void *cls, 1934store_after_abe_bootstrap (void *cls,
1934 struct GNUNET_CRYPTO_AbeMasterKey *abe_key) 1935 struct GNUNET_ABE_AbeMasterKey *abe_key)
1935{ 1936{
1936 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1937 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1937 "Finished ABE bootstrap\n"); 1938 "Finished ABE bootstrap\n");
@@ -2001,7 +2002,7 @@ static void
2001cleanup_iter_handle (struct AttributeIterator *ai) 2002cleanup_iter_handle (struct AttributeIterator *ai)
2002{ 2003{
2003 if (NULL != ai->abe_key) 2004 if (NULL != ai->abe_key)
2004 GNUNET_CRYPTO_cpabe_delete_master_key (ai->abe_key); 2005 GNUNET_ABE_cpabe_delete_master_key (ai->abe_key);
2005 GNUNET_CONTAINER_DLL_remove (ai->client->op_head, 2006 GNUNET_CONTAINER_DLL_remove (ai->client->op_head,
2006 ai->client->op_tail, 2007 ai->client->op_tail,
2007 ai); 2008 ai);
@@ -2043,7 +2044,7 @@ attr_iter_cb (void *cls,
2043{ 2044{
2044 struct AttributeIterator *ai = cls; 2045 struct AttributeIterator *ai = cls;
2045 struct AttributeResultMessage *arm; 2046 struct AttributeResultMessage *arm;
2046 struct GNUNET_CRYPTO_AbeKey *key; 2047 struct GNUNET_ABE_AbeKey *key;
2047 struct GNUNET_MQ_Envelope *env; 2048 struct GNUNET_MQ_Envelope *env;
2048 ssize_t msg_extra_len; 2049 ssize_t msg_extra_len;
2049 char* attr_ser; 2050 char* attr_ser;
@@ -2067,14 +2068,14 @@ attr_iter_cb (void *cls,
2067 label, attr_ver); 2068 label, attr_ver);
2068 attrs[0] = policy; 2069 attrs[0] = policy;
2069 attrs[1] = 0; 2070 attrs[1] = 0;
2070 key = GNUNET_CRYPTO_cpabe_create_key (ai->abe_key, 2071 key = GNUNET_ABE_cpabe_create_key (ai->abe_key,
2071 attrs); 2072 attrs);
2072 msg_extra_len = GNUNET_CRYPTO_cpabe_decrypt (rd->data+sizeof (uint32_t), 2073 msg_extra_len = GNUNET_ABE_cpabe_decrypt (rd->data+sizeof (uint32_t),
2073 rd->data_size-sizeof (uint32_t), 2074 rd->data_size-sizeof (uint32_t),
2074 key, 2075 key,
2075 (void**)&attr_ser); 2076 (void**)&attr_ser);
2076 2077
2077 GNUNET_CRYPTO_cpabe_delete_key (key, 2078 GNUNET_ABE_cpabe_delete_key (key,
2078 GNUNET_YES); 2079 GNUNET_YES);
2079 //GNUNET_free (policy); 2080 //GNUNET_free (policy);
2080 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2081 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2092,14 +2093,14 @@ attr_iter_cb (void *cls,
2092 msg_extra_len); 2093 msg_extra_len);
2093 GNUNET_MQ_send (ai->client->mq, env); 2094 GNUNET_MQ_send (ai->client->mq, env);
2094 GNUNET_free (attr_ser); 2095 GNUNET_free (attr_ser);
2095 GNUNET_CRYPTO_cpabe_delete_master_key (ai->abe_key); 2096 GNUNET_ABE_cpabe_delete_master_key (ai->abe_key);
2096 ai->abe_key = NULL; 2097 ai->abe_key = NULL;
2097} 2098}
2098 2099
2099 2100
2100void 2101void
2101iterate_after_abe_bootstrap (void *cls, 2102iterate_after_abe_bootstrap (void *cls,
2102 struct GNUNET_CRYPTO_AbeMasterKey *abe_key) 2103 struct GNUNET_ABE_AbeMasterKey *abe_key)
2103{ 2104{
2104 struct AttributeIterator *ai = cls; 2105 struct AttributeIterator *ai = cls;
2105 ai->abe_key = abe_key; 2106 ai->abe_key = abe_key;
@@ -2115,7 +2116,7 @@ iterate_after_abe_bootstrap (void *cls,
2115 2116
2116void 2117void
2117iterate_next_after_abe_bootstrap (void *cls, 2118iterate_next_after_abe_bootstrap (void *cls,
2118 struct GNUNET_CRYPTO_AbeMasterKey *abe_key) 2119 struct GNUNET_ABE_AbeMasterKey *abe_key)
2119{ 2120{
2120 struct AttributeIterator *ai = cls; 2121 struct AttributeIterator *ai = cls;
2121 ai->abe_key = abe_key; 2122 ai->abe_key = abe_key;
diff --git a/src/include/gnunet_abe_lib.h b/src/include/gnunet_abe_lib.h
new file mode 100644
index 000000000..77b0f9e99
--- /dev/null
+++ b/src/include/gnunet_abe_lib.h
@@ -0,0 +1,143 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001-2018 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @file include/gnunet_crypto_lib.h
23 * @brief cryptographic primitives for GNUnet
24 *
25 * @author Martin Schanzenbach
26 *
27 * @defgroup abe ABE Crypto library: Attribute-Based Encryption operations
28 *
29 */
30#ifndef GNUNET_ABE_LIB_H
31#define GNUNET_ABE_LIB_H
32
33#ifdef __cplusplus
34extern "C"
35{
36#if 0 /* keep Emacsens' auto-indent happy */
37}
38#endif
39#endif
40
41#include "gnunet_common.h"
42#include <gcrypt.h>
43
44/**
45 * @brief type for ABE master keys
46 */
47struct GNUNET_CRYPTO_AbeMasterKey;
48
49/**
50 * @brief type for ABE keys
51 */
52struct GNUNET_CRYPTO_AbeKey;
53
54
55
56/**
57 * @ingroup abe
58 * Create a new CP-ABE master key. Caller must free return value.
59 *
60 * @return fresh private key; free using #GNUNET_free
61 */
62struct GNUNET_ABE_AbeMasterKey *
63GNUNET_ABE_cpabe_create_master_key (void);
64void
65GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key);
66
67/**
68 * @ingroup abe
69 * Create a new CP-ABE key. Caller must free return value.
70 *
71 * @return fresh private key; free using #GNUNET_free
72 */
73struct GNUNET_ABE_AbeKey *
74GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *msk,
75 char **attrs);
76void
77GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
78 int delete_pub);
79
80
81/**
82 * @ingroup abe
83 * Encrypt a block using sessionkey.
84 *
85 * @param block the block to encrypt
86 * @param size the size of the @a block
87 * @param sessionkey the key used to encrypt
88 * @param iv the initialization vector to use, use INITVALUE
89 * for streams.
90 * @return the size of the encrypted block, -1 for errors
91 */
92ssize_t
93GNUNET_ABE_cpabe_encrypt (const void *block,
94 size_t size,
95 const char *policy,
96 const struct GNUNET_ABE_AbeMasterKey *key,
97 void **result);
98
99/**
100 * @ingroup abe
101 * Encrypt a block using sessionkey.
102 *
103 * @param block the block to encrypt
104 * @param size the size of the @a block
105 * @param sessionkey the key used to encrypt
106 * @param iv the initialization vector to use, use INITVALUE
107 * for streams.
108 * @return the size of the encrypted block, -1 for errors
109 */
110ssize_t
111GNUNET_ABE_cpabe_decrypt (const void *block,
112 size_t size,
113 const struct GNUNET_ABE_AbeKey *key,
114 void **result);
115
116ssize_t
117GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
118 void **result);
119
120struct GNUNET_ABE_AbeKey*
121GNUNET_ABE_cpabe_deserialize_key (const void *data,
122 size_t len);
123
124ssize_t
125GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key,
126 void **result);
127
128struct GNUNET_ABE_AbeMasterKey*
129GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
130 size_t len);
131
132
133#if 0 /* keep Emacsens' auto-indent happy */
134{
135#endif
136#ifdef __cplusplus
137}
138#endif
139
140
141/* ifndef GNUNET_ABE_LIB_H */
142#endif
143/* end of gnunet_abe_lib.h */
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 2fd67ae1b..e886a561c 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -395,11 +395,6 @@ struct GNUNET_CRYPTO_PaillierCiphertext
395 unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8]; 395 unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
396}; 396};
397 397
398/**
399 * @brief type for ABE master keys
400 */
401struct GNUNET_CRYPTO_AbeMasterKey;
402
403 398
404/* **************** Functions and Macros ************* */ 399/* **************** Functions and Macros ************* */
405 400
@@ -2142,83 +2137,6 @@ GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2142 const struct GNUNET_CRYPTO_RsaPublicKey *public_key); 2137 const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2143 2138
2144 2139
2145/**
2146 * @ingroup crypto
2147 * Create a new CP-ABE master key. Caller must free return value.
2148 *
2149 * @return fresh private key; free using #GNUNET_free
2150 */
2151struct GNUNET_CRYPTO_AbeMasterKey *
2152GNUNET_CRYPTO_cpabe_create_master_key (void);
2153void
2154GNUNET_CRYPTO_cpabe_delete_master_key (struct GNUNET_CRYPTO_AbeMasterKey *key);
2155
2156/**
2157 * @ingroup crypto
2158 * Create a new CP-ABE key. Caller must free return value.
2159 *
2160 * @return fresh private key; free using #GNUNET_free
2161 */
2162struct GNUNET_CRYPTO_AbeKey *
2163GNUNET_CRYPTO_cpabe_create_key (struct GNUNET_CRYPTO_AbeMasterKey *msk,
2164 char **attrs);
2165void
2166GNUNET_CRYPTO_cpabe_delete_key (struct GNUNET_CRYPTO_AbeKey *key,
2167 int delete_pub);
2168
2169
2170/**
2171 * @ingroup crypto
2172 * Encrypt a block using sessionkey.
2173 *
2174 * @param block the block to encrypt
2175 * @param size the size of the @a block
2176 * @param sessionkey the key used to encrypt
2177 * @param iv the initialization vector to use, use INITVALUE
2178 * for streams.
2179 * @return the size of the encrypted block, -1 for errors
2180 */
2181ssize_t
2182GNUNET_CRYPTO_cpabe_encrypt (const void *block,
2183 size_t size,
2184 const char *policy,
2185 const struct GNUNET_CRYPTO_AbeMasterKey *key,
2186 void **result);
2187
2188/**
2189 * @ingroup crypto
2190 * Encrypt a block using sessionkey.
2191 *
2192 * @param block the block to encrypt
2193 * @param size the size of the @a block
2194 * @param sessionkey the key used to encrypt
2195 * @param iv the initialization vector to use, use INITVALUE
2196 * for streams.
2197 * @return the size of the encrypted block, -1 for errors
2198 */
2199ssize_t
2200GNUNET_CRYPTO_cpabe_decrypt (const void *block,
2201 size_t size,
2202 const struct GNUNET_CRYPTO_AbeKey *key,
2203 void **result);
2204
2205ssize_t
2206GNUNET_CRYPTO_cpabe_serialize_key (const struct GNUNET_CRYPTO_AbeKey *key,
2207 void **result);
2208
2209struct GNUNET_CRYPTO_AbeKey*
2210GNUNET_CRYPTO_cpabe_deserialize_key (const void *data,
2211 size_t len);
2212
2213ssize_t
2214GNUNET_CRYPTO_cpabe_serialize_master_key (const struct GNUNET_CRYPTO_AbeMasterKey *key,
2215 void **result);
2216
2217struct GNUNET_CRYPTO_AbeMasterKey*
2218GNUNET_CRYPTO_cpabe_deserialize_master_key (const void *data,
2219 size_t len);
2220
2221
2222#if 0 /* keep Emacsens' auto-indent happy */ 2140#if 0 /* keep Emacsens' auto-indent happy */
2223{ 2141{
2224#endif 2142#endif
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index cc9ff4745..eb655157d 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -119,18 +119,6 @@ libgnunetutil_la_LIBADD = \
119 $(LTLIBINTL) \ 119 $(LTLIBINTL) \
120 -lltdl $(Z_LIBS) -lunistring $(XLIB) 120 -lltdl $(Z_LIBS) -lunistring $(XLIB)
121 121
122if HAVE_PBC
123if HAVE_ABE
124libgnunetutil_la_SOURCES += \
125 crypto_abe.c
126libgnunetutil_la_LIBADD += \
127 $(ABE_LIBADD) \
128 -lgabe \
129 -lpbc \
130 -lglib-2.0
131endif
132endif
133
134libgnunetutil_la_LDFLAGS = \ 122libgnunetutil_la_LDFLAGS = \
135 $(GN_LIB_LDFLAGS) \ 123 $(GN_LIB_LDFLAGS) \
136 -version-info 13:0:0 124 -version-info 13:0:0
@@ -564,17 +552,6 @@ test_speedup_SOURCES = \
564test_speedup_LDADD = \ 552test_speedup_LDADD = \
565 libgnunetutil.la 553 libgnunetutil.la
566 554
567if HAVE_PBC
568if HAVE_ABE
569test_crypto_abe_SOURCES = \
570 test_crypto_abe.c
571test_crypto_abe_LDADD = \
572 libgnunetutil.la
573check_PROGRAMS += \
574 test_crypto_abe
575endif
576endif
577
578perf_crypto_hash_SOURCES = \ 555perf_crypto_hash_SOURCES = \
579 perf_crypto_hash.c 556 perf_crypto_hash.c
580perf_crypto_hash_LDADD = \ 557perf_crypto_hash_LDADD = \