diff options
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | po/de.po | 4 | ||||
-rw-r--r-- | po/es.po | 4 | ||||
-rw-r--r-- | po/fr.po | 4 | ||||
-rw-r--r-- | po/it.po | 4 | ||||
-rw-r--r-- | po/sr.po | 4 | ||||
-rw-r--r-- | po/sv.po | 4 | ||||
-rw-r--r-- | po/vi.po | 4 | ||||
-rw-r--r-- | po/zh_CN.po | 4 | ||||
-rw-r--r-- | src/Makefile.am | 7 | ||||
-rw-r--r-- | src/abe/Makefile.am | 49 | ||||
-rw-r--r-- | src/abe/abe.c | 519 | ||||
-rw-r--r-- | src/abe/test_cpabe.c | 89 | ||||
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/gnunet_abe_lib.h | 193 | ||||
-rw-r--r-- | src/util/crypto_abe.c | 438 |
18 files changed, 17 insertions, 1328 deletions
@@ -141,9 +141,6 @@ Dependencies of optional components/functionality: | |||
141 | * texi2mdoc (for automatic mdoc generation [*2], not | 141 | * texi2mdoc (for automatic mdoc generation [*2], not |
142 | the texi2mdoc script distributed with | 142 | the texi2mdoc script distributed with |
143 | autogen but the texi2mdoc C application) | 143 | autogen but the texi2mdoc C application) |
144 | - Attribute-Based Encryption (experimental): | ||
145 | * libpbc >= 0.5.14 | ||
146 | * libgabe | ||
147 | - PABC credential support | 144 | - PABC credential support |
148 | * libpabc any (for re:claimID zero-knowledge privacy | 145 | * libpabc any (for re:claimID zero-knowledge privacy |
149 | credentials) | 146 | credentials) |
diff --git a/configure.ac b/configure.ac index b1bc03e91..20258d622 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -736,18 +736,6 @@ CHECK_WITH_LIB([opus], [opus_decode_float], [opus/opus.h], [HAVE_OPUS]) | |||
736 | # check for libogg | 736 | # check for libogg |
737 | CHECK_WITH_LIB([ogg], [ogg_stream_flush_fill], [ogg/ogg.h], [HAVE_OGG]) | 737 | CHECK_WITH_LIB([ogg], [ogg_stream_flush_fill], [ogg/ogg.h], [HAVE_OGG]) |
738 | 738 | ||
739 | PKG_CHECK_MODULES([GLIB], [glib-2.0], | ||
740 | [AC_CHECK_HEADER([pbc/pbc.h], [pbc=1], [pbc=0]) | ||
741 | AC_CHECK_HEADER([gabe.h], [abe=1], [abe=0]) | ||
742 | AM_CONDITIONAL([HAVE_PBC], [test "x$pbc" = "x1"]) | ||
743 | AM_CONDITIONAL([HAVE_ABE], [test "x$abe" = "x1"]) | ||
744 | AC_DEFINE_UNQUOTED([HAVE_PBC], [$pbc], [Define to 1 if pbc is available]) | ||
745 | AC_DEFINE_UNQUOTED([HAVE_ABE], [$abe], [Define to 1 if abe is available])], | ||
746 | [AM_CONDITIONAL([HAVE_PBC], [false]) | ||
747 | AM_CONDITIONAL([HAVE_ABE], [false]) | ||
748 | AC_DEFINE([HAVE_PBC], [0], [Define to 1 if pbc is available]) | ||
749 | AC_DEFINE([HAVE_ABE], [0], [Define to 1 if abe is available])]) | ||
750 | |||
751 | PKG_CHECK_MODULES([GST], | 739 | PKG_CHECK_MODULES([GST], |
752 | [glib-2.0 gobject-2.0 gstreamer-1.0 gstreamer-app-1.0 gstreamer-audio-1.0], | 740 | [glib-2.0 gobject-2.0 gstreamer-1.0 gstreamer-app-1.0 gstreamer-audio-1.0], |
753 | [gst=1], | 741 | [gst=1], |
@@ -1444,7 +1432,6 @@ src/zonemaster/zonemaster.conf | |||
1444 | src/rest/Makefile | 1432 | src/rest/Makefile |
1445 | src/abd/Makefile | 1433 | src/abd/Makefile |
1446 | src/abd/abd.conf | 1434 | src/abd/abd.conf |
1447 | src/abe/Makefile | ||
1448 | src/reclaim/Makefile | 1435 | src/reclaim/Makefile |
1449 | src/messenger/Makefile | 1436 | src/messenger/Makefile |
1450 | src/messenger/messenger.conf | 1437 | src/messenger/messenger.conf |
diff --git a/po/POTFILES.in b/po/POTFILES.in index b7e7684c6..5be8fd86c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in | |||
@@ -4,7 +4,6 @@ src/abd/delegate_misc.c | |||
4 | src/abd/gnunet-abd.c | 4 | src/abd/gnunet-abd.c |
5 | src/abd/gnunet-service-abd.c | 5 | src/abd/gnunet-service-abd.c |
6 | src/abd/plugin_gnsrecord_abd.c | 6 | src/abd/plugin_gnsrecord_abd.c |
7 | src/abe/abe.c | ||
8 | src/arm/arm_api.c | 7 | src/arm/arm_api.c |
9 | src/arm/arm_monitor_api.c | 8 | src/arm/arm_monitor_api.c |
10 | src/arm/gnunet-arm.c | 9 | src/arm/gnunet-arm.c |
@@ -10,7 +10,7 @@ msgid "" | |||
10 | msgstr "" | 10 | msgstr "" |
11 | "Project-Id-Version: gnunet 0.10.1\n" | 11 | "Project-Id-Version: gnunet 0.10.1\n" |
12 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 12 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
13 | "POT-Creation-Date: 2022-06-04 22:36+0200\n" | 13 | "POT-Creation-Date: 2022-06-13 12:32+0200\n" |
14 | "PO-Revision-Date: 2015-03-08 16:16+0100\n" | 14 | "PO-Revision-Date: 2015-03-08 16:16+0100\n" |
15 | "Last-Translator: Mario Blättermann <mario.blaettermann@gmail.com>\n" | 15 | "Last-Translator: Mario Blättermann <mario.blaettermann@gmail.com>\n" |
16 | "Language-Team: German <translation-team-de@lists.sourceforge.net>\n" | 16 | "Language-Team: German <translation-team-de@lists.sourceforge.net>\n" |
@@ -5876,7 +5876,7 @@ msgstr "" | |||
5876 | msgid "re:claimID command line tool" | 5876 | msgid "re:claimID command line tool" |
5877 | msgstr "" | 5877 | msgstr "" |
5878 | 5878 | ||
5879 | #: src/reclaim/plugin_rest_openid_connect.c:2793 | 5879 | #: src/reclaim/plugin_rest_openid_connect.c:3003 |
5880 | #, fuzzy | 5880 | #, fuzzy |
5881 | msgid "OpenID Connect REST API initialized\n" | 5881 | msgid "OpenID Connect REST API initialized\n" |
5882 | msgstr " Verbindung fehlgeschlagen\n" | 5882 | msgstr " Verbindung fehlgeschlagen\n" |
@@ -8,7 +8,7 @@ msgid "" | |||
8 | msgstr "" | 8 | msgstr "" |
9 | "Project-Id-Version: gnunet 0.9.5a\n" | 9 | "Project-Id-Version: gnunet 0.9.5a\n" |
10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
11 | "POT-Creation-Date: 2022-06-04 22:36+0200\n" | 11 | "POT-Creation-Date: 2022-06-13 12:32+0200\n" |
12 | "PO-Revision-Date: 2013-02-23 17:50+0100\n" | 12 | "PO-Revision-Date: 2013-02-23 17:50+0100\n" |
13 | "Last-Translator: Miguel Ángel Arruga Vivas <rosen644835@gmail.com>\n" | 13 | "Last-Translator: Miguel Ángel Arruga Vivas <rosen644835@gmail.com>\n" |
14 | "Language-Team: Spanish <es@li.org>\n" | 14 | "Language-Team: Spanish <es@li.org>\n" |
@@ -6065,7 +6065,7 @@ msgstr "" | |||
6065 | msgid "re:claimID command line tool" | 6065 | msgid "re:claimID command line tool" |
6066 | msgstr "" | 6066 | msgstr "" |
6067 | 6067 | ||
6068 | #: src/reclaim/plugin_rest_openid_connect.c:2793 | 6068 | #: src/reclaim/plugin_rest_openid_connect.c:3003 |
6069 | #, fuzzy | 6069 | #, fuzzy |
6070 | msgid "OpenID Connect REST API initialized\n" | 6070 | msgid "OpenID Connect REST API initialized\n" |
6071 | msgstr "Conexión fallida\n" | 6071 | msgstr "Conexión fallida\n" |
@@ -7,7 +7,7 @@ msgid "" | |||
7 | msgstr "" | 7 | msgstr "" |
8 | "Project-Id-Version: gnunet 0.10.1\n" | 8 | "Project-Id-Version: gnunet 0.10.1\n" |
9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
10 | "POT-Creation-Date: 2022-06-04 22:36+0200\n" | 10 | "POT-Creation-Date: 2022-06-13 12:32+0200\n" |
11 | "PO-Revision-Date: 2021-11-21 00:53+0100\n" | 11 | "PO-Revision-Date: 2021-11-21 00:53+0100\n" |
12 | "Last-Translator: Stéphane Aulery <lkppo@free.fr>\n" | 12 | "Last-Translator: Stéphane Aulery <lkppo@free.fr>\n" |
13 | "Language-Team: French <traduc@traduc.org>\n" | 13 | "Language-Team: French <traduc@traduc.org>\n" |
@@ -5650,7 +5650,7 @@ msgstr "" | |||
5650 | msgid "re:claimID command line tool" | 5650 | msgid "re:claimID command line tool" |
5651 | msgstr "" | 5651 | msgstr "" |
5652 | 5652 | ||
5653 | #: src/reclaim/plugin_rest_openid_connect.c:2793 | 5653 | #: src/reclaim/plugin_rest_openid_connect.c:3003 |
5654 | msgid "OpenID Connect REST API initialized\n" | 5654 | msgid "OpenID Connect REST API initialized\n" |
5655 | msgstr "" | 5655 | msgstr "" |
5656 | 5656 | ||
@@ -8,7 +8,7 @@ msgid "" | |||
8 | msgstr "" | 8 | msgstr "" |
9 | "Project-Id-Version: gnunet 0.10.1\n" | 9 | "Project-Id-Version: gnunet 0.10.1\n" |
10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
11 | "POT-Creation-Date: 2022-06-04 22:36+0200\n" | 11 | "POT-Creation-Date: 2022-06-13 12:32+0200\n" |
12 | "PO-Revision-Date: 2019-10-16 11:00+0200\n" | 12 | "PO-Revision-Date: 2019-10-16 11:00+0200\n" |
13 | "Last-Translator: Sebastiano Pistore <sebastianopistore.info@protonmail.ch>\n" | 13 | "Last-Translator: Sebastiano Pistore <sebastianopistore.info@protonmail.ch>\n" |
14 | "Language-Team: Italian <tp@lists.linux.it>\n" | 14 | "Language-Team: Italian <tp@lists.linux.it>\n" |
@@ -5676,7 +5676,7 @@ msgstr "" | |||
5676 | msgid "re:claimID command line tool" | 5676 | msgid "re:claimID command line tool" |
5677 | msgstr "" | 5677 | msgstr "" |
5678 | 5678 | ||
5679 | #: src/reclaim/plugin_rest_openid_connect.c:2793 | 5679 | #: src/reclaim/plugin_rest_openid_connect.c:3003 |
5680 | msgid "OpenID Connect REST API initialized\n" | 5680 | msgid "OpenID Connect REST API initialized\n" |
5681 | msgstr "" | 5681 | msgstr "" |
5682 | 5682 | ||
@@ -6,7 +6,7 @@ msgid "" | |||
6 | msgstr "" | 6 | msgstr "" |
7 | "Project-Id-Version: gnunet-0.10.1\n" | 7 | "Project-Id-Version: gnunet-0.10.1\n" |
8 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 8 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
9 | "POT-Creation-Date: 2022-06-04 22:36+0200\n" | 9 | "POT-Creation-Date: 2022-06-13 12:32+0200\n" |
10 | "PO-Revision-Date: 2020-10-23 18:39+0200\n" | 10 | "PO-Revision-Date: 2020-10-23 18:39+0200\n" |
11 | "Last-Translator: Мирослав Николић <miroslavnikolic@rocketmail.com>\n" | 11 | "Last-Translator: Мирослав Николић <miroslavnikolic@rocketmail.com>\n" |
12 | "Language-Team: Serbian <(nothing)>\n" | 12 | "Language-Team: Serbian <(nothing)>\n" |
@@ -5898,7 +5898,7 @@ msgstr "" | |||
5898 | msgid "re:claimID command line tool" | 5898 | msgid "re:claimID command line tool" |
5899 | msgstr "" | 5899 | msgstr "" |
5900 | 5900 | ||
5901 | #: src/reclaim/plugin_rest_openid_connect.c:2793 | 5901 | #: src/reclaim/plugin_rest_openid_connect.c:3003 |
5902 | msgid "OpenID Connect REST API initialized\n" | 5902 | msgid "OpenID Connect REST API initialized\n" |
5903 | msgstr "" | 5903 | msgstr "" |
5904 | 5904 | ||
@@ -7,7 +7,7 @@ msgid "" | |||
7 | msgstr "" | 7 | msgstr "" |
8 | "Project-Id-Version: GNUnet 0.7.0b\n" | 8 | "Project-Id-Version: GNUnet 0.7.0b\n" |
9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
10 | "POT-Creation-Date: 2022-06-04 22:36+0200\n" | 10 | "POT-Creation-Date: 2022-06-13 12:32+0200\n" |
11 | "PO-Revision-Date: 2006-01-21 17:16+0100\n" | 11 | "PO-Revision-Date: 2006-01-21 17:16+0100\n" |
12 | "Last-Translator: Daniel Nylander <po@danielnylander.se>\n" | 12 | "Last-Translator: Daniel Nylander <po@danielnylander.se>\n" |
13 | "Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n" | 13 | "Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n" |
@@ -5909,7 +5909,7 @@ msgstr "" | |||
5909 | msgid "re:claimID command line tool" | 5909 | msgid "re:claimID command line tool" |
5910 | msgstr "" | 5910 | msgstr "" |
5911 | 5911 | ||
5912 | #: src/reclaim/plugin_rest_openid_connect.c:2793 | 5912 | #: src/reclaim/plugin_rest_openid_connect.c:3003 |
5913 | #, fuzzy | 5913 | #, fuzzy |
5914 | msgid "OpenID Connect REST API initialized\n" | 5914 | msgid "OpenID Connect REST API initialized\n" |
5915 | msgstr " Anslutning misslyckades\n" | 5915 | msgstr " Anslutning misslyckades\n" |
@@ -8,7 +8,7 @@ msgid "" | |||
8 | msgstr "" | 8 | msgstr "" |
9 | "Project-Id-Version: gnunet 0.8.0a\n" | 9 | "Project-Id-Version: gnunet 0.8.0a\n" |
10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 10 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
11 | "POT-Creation-Date: 2022-06-04 22:36+0200\n" | 11 | "POT-Creation-Date: 2022-06-13 12:32+0200\n" |
12 | "PO-Revision-Date: 2008-09-10 22:05+0930\n" | 12 | "PO-Revision-Date: 2008-09-10 22:05+0930\n" |
13 | "Last-Translator: Clytie Siddall <clytie@riverland.net.au>\n" | 13 | "Last-Translator: Clytie Siddall <clytie@riverland.net.au>\n" |
14 | "Language-Team: Vietnamese <vi-VN@googlegroups.com>\n" | 14 | "Language-Team: Vietnamese <vi-VN@googlegroups.com>\n" |
@@ -5965,7 +5965,7 @@ msgstr "" | |||
5965 | msgid "re:claimID command line tool" | 5965 | msgid "re:claimID command line tool" |
5966 | msgstr "" | 5966 | msgstr "" |
5967 | 5967 | ||
5968 | #: src/reclaim/plugin_rest_openid_connect.c:2793 | 5968 | #: src/reclaim/plugin_rest_openid_connect.c:3003 |
5969 | #, fuzzy | 5969 | #, fuzzy |
5970 | msgid "OpenID Connect REST API initialized\n" | 5970 | msgid "OpenID Connect REST API initialized\n" |
5971 | msgstr "Lỗi sơ khởi lõi.\n" | 5971 | msgstr "Lỗi sơ khởi lõi.\n" |
diff --git a/po/zh_CN.po b/po/zh_CN.po index a7c3d43e4..ba0486a4f 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po | |||
@@ -7,7 +7,7 @@ msgid "" | |||
7 | msgstr "" | 7 | msgstr "" |
8 | "Project-Id-Version: gnunet-0.8.1\n" | 8 | "Project-Id-Version: gnunet-0.8.1\n" |
9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" | 9 | "Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n" |
10 | "POT-Creation-Date: 2022-06-04 22:36+0200\n" | 10 | "POT-Creation-Date: 2022-06-13 12:32+0200\n" |
11 | "PO-Revision-Date: 2011-07-09 12:12+0800\n" | 11 | "PO-Revision-Date: 2011-07-09 12:12+0800\n" |
12 | "Last-Translator: Wylmer Wang <wantinghard@gmail.com>\n" | 12 | "Last-Translator: Wylmer Wang <wantinghard@gmail.com>\n" |
13 | "Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n" | 13 | "Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n" |
@@ -5758,7 +5758,7 @@ msgstr "" | |||
5758 | msgid "re:claimID command line tool" | 5758 | msgid "re:claimID command line tool" |
5759 | msgstr "" | 5759 | msgstr "" |
5760 | 5760 | ||
5761 | #: src/reclaim/plugin_rest_openid_connect.c:2793 | 5761 | #: src/reclaim/plugin_rest_openid_connect.c:3003 |
5762 | msgid "OpenID Connect REST API initialized\n" | 5762 | msgid "OpenID Connect REST API initialized\n" |
5763 | msgstr "" | 5763 | msgstr "" |
5764 | 5764 | ||
diff --git a/src/Makefile.am b/src/Makefile.am index 4c665c3b3..d7c0b51f0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -6,12 +6,7 @@ TESTBED = testbed-logger testbed | |||
6 | if HAVE_EXPERIMENTAL | 6 | if HAVE_EXPERIMENTAL |
7 | EXP_DIR = \ | 7 | EXP_DIR = \ |
8 | rps \ | 8 | rps \ |
9 | abd | 9 | abd \ |
10 | if HAVE_ABE | ||
11 | EXP_DIR += \ | ||
12 | abe | ||
13 | endif | ||
14 | EXP_DIR += \ | ||
15 | auction | 10 | auction |
16 | endif | 11 | endif |
17 | 12 | ||
diff --git a/src/abe/Makefile.am b/src/abe/Makefile.am deleted file mode 100644 index cccd3ccb0..000000000 --- a/src/abe/Makefile.am +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | # This Makefile.am is in the public domain | ||
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | ||
3 | |||
4 | plugindir = $(libdir)/gnunet | ||
5 | |||
6 | libexecdir= $(pkglibdir)/libexec/ | ||
7 | |||
8 | pkgcfgdir= $(pkgdatadir)/config.d/ | ||
9 | |||
10 | if USE_COVERAGE | ||
11 | AM_CFLAGS = --coverage -O0 | ||
12 | XLIB = -lgcov | ||
13 | endif | ||
14 | |||
15 | libgnunetabe_la_SOURCES = abe.c | ||
16 | |||
17 | libgnunetabe_la_LIBADD = \ | ||
18 | $(GCLIBADD)\ | ||
19 | $(LIBGCRYPT_LIBS) \ | ||
20 | $(LTLIBICONV) \ | ||
21 | $(LTLIBINTL) \ | ||
22 | $(ABE_LIBADD) \ | ||
23 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
24 | -lgmp \ | ||
25 | -lgabe \ | ||
26 | -lpbc \ | ||
27 | -lglib-2.0 \ | ||
28 | -lltdl $(Z_LIBS) -lunistring $(XLIB) | ||
29 | |||
30 | libgnunetabe_la_LDFLAGS = \ | ||
31 | $(GN_LIB_LDFLAGS) \ | ||
32 | -version-info 1:0:0 | ||
33 | |||
34 | lib_LTLIBRARIES = libgnunetabe.la | ||
35 | |||
36 | if ENABLE_TEST_RUN | ||
37 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | ||
38 | TESTS = $(check_PROGRAMS) | ||
39 | endif | ||
40 | |||
41 | check_PROGRAMS = test_cpabe | ||
42 | |||
43 | test_cpabe_SOURCES = \ | ||
44 | test_cpabe.c | ||
45 | test_cpabe_LDADD = \ | ||
46 | libgnunetabe.la \ | ||
47 | $(top_builddir)/src/util/libgnunetutil.la | ||
48 | check_PROGRAMS += \ | ||
49 | test_cpabe | ||
diff --git a/src/abe/abe.c b/src/abe/abe.c deleted file mode 100644 index a03944821..000000000 --- a/src/abe/abe.c +++ /dev/null | |||
@@ -1,519 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. Copyright (C) 2001-2018 Christian Grothoff | ||
3 | (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | |||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * @file abe/abe.c | ||
24 | * @brief functions for Attribute-Based Encryption | ||
25 | * @author Martin Schanzenbach | ||
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 | |||
36 | struct GNUNET_ABE_AbeMasterKey | ||
37 | { | ||
38 | gabe_pub_t*pub; | ||
39 | gabe_msk_t*msk; | ||
40 | }; | ||
41 | |||
42 | struct GNUNET_ABE_AbeKey | ||
43 | { | ||
44 | gabe_pub_t*pub; | ||
45 | gabe_prv_t*prv; | ||
46 | }; | ||
47 | |||
48 | static int | ||
49 | init_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 | GNUNET_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 | |||
80 | |||
81 | static int | ||
82 | aes_128_cbc_encrypt (char*pt, | ||
83 | int size, | ||
84 | element_t k, | ||
85 | char **ct) | ||
86 | { | ||
87 | gcry_cipher_hd_t handle; | ||
88 | struct GNUNET_CRYPTO_SymmetricSessionKey skey; | ||
89 | unsigned char iv[16]; | ||
90 | char*buf; | ||
91 | int padding; | ||
92 | int buf_size; | ||
93 | uint8_t len[4]; | ||
94 | |||
95 | init_aes (k, 1, &handle, &skey, iv); | ||
96 | |||
97 | /* TODO make less crufty */ | ||
98 | |||
99 | /* stuff in real length (big endian) before padding */ | ||
100 | len[0] = (size & 0xff000000) >> 24; | ||
101 | len[1] = (size & 0xff0000) >> 16; | ||
102 | len[2] = (size & 0xff00) >> 8; | ||
103 | len[3] = (size & 0xff) >> 0; | ||
104 | padding = 16 - ((4 + size) % 16); | ||
105 | buf_size = 4 + size + padding; | ||
106 | buf = GNUNET_malloc (buf_size); | ||
107 | GNUNET_memcpy (buf, len, 4); | ||
108 | GNUNET_memcpy (buf + 4, pt, size); | ||
109 | *ct = GNUNET_malloc (buf_size); | ||
110 | |||
111 | GNUNET_assert (0 == gcry_cipher_encrypt (handle, *ct, buf_size, buf, | ||
112 | buf_size)); | ||
113 | gcry_cipher_close (handle); | ||
114 | // AES_cbc_encrypt(pt->data, ct->data, pt->len, &key, iv, AES_ENCRYPT); | ||
115 | GNUNET_free (buf); | ||
116 | return buf_size; | ||
117 | } | ||
118 | |||
119 | |||
120 | static int | ||
121 | aes_128_cbc_decrypt (char*ct, | ||
122 | int size, | ||
123 | element_t k, | ||
124 | char **pt) | ||
125 | { | ||
126 | struct GNUNET_CRYPTO_SymmetricSessionKey skey; | ||
127 | gcry_cipher_hd_t handle; | ||
128 | unsigned char iv[16]; | ||
129 | char*tmp; | ||
130 | uint32_t len; | ||
131 | |||
132 | init_aes (k, 1, &handle, &skey, iv); | ||
133 | |||
134 | tmp = GNUNET_malloc (size); | ||
135 | |||
136 | // AES_cbc_encrypt(ct->data, pt->data, ct->len, &key, iv, AES_DECRYPT); | ||
137 | GNUNET_assert (0 == gcry_cipher_decrypt (handle, tmp, size, ct, size)); | ||
138 | gcry_cipher_close (handle); | ||
139 | /* TODO make less crufty */ | ||
140 | |||
141 | /* get real length */ | ||
142 | len = 0; | ||
143 | len = len | ||
144 | | ((tmp[0]) << 24) | ((tmp[1]) << 16) | ||
145 | | ((tmp[2]) << 8) | ((tmp[3]) << 0); | ||
146 | /* truncate any garbage from the padding */ | ||
147 | *pt = GNUNET_malloc (len); | ||
148 | GNUNET_memcpy (*pt, tmp + 4, len); | ||
149 | GNUNET_free (tmp); | ||
150 | return len; | ||
151 | } | ||
152 | |||
153 | |||
154 | /** | ||
155 | * @ingroup abe | ||
156 | * Create a new CP-ABE master key. Caller must free return value. | ||
157 | * | ||
158 | * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key | ||
159 | */ | ||
160 | struct GNUNET_ABE_AbeMasterKey* | ||
161 | GNUNET_ABE_cpabe_create_master_key (void) | ||
162 | { | ||
163 | struct GNUNET_ABE_AbeMasterKey*key; | ||
164 | |||
165 | key = GNUNET_new (struct GNUNET_ABE_AbeMasterKey); | ||
166 | gabe_setup (&key->pub, &key->msk); | ||
167 | GNUNET_assert (NULL != key->pub); | ||
168 | GNUNET_assert (NULL != key->msk); | ||
169 | return key; | ||
170 | } | ||
171 | |||
172 | |||
173 | /** | ||
174 | * @ingroup abe | ||
175 | * Delete a CP-ABE master key. | ||
176 | * | ||
177 | * @param key the master key | ||
178 | * @return fresh private key; free using #GNUNET_free | ||
179 | */ | ||
180 | void | ||
181 | GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key) | ||
182 | { | ||
183 | gabe_msk_free (key->msk); | ||
184 | gabe_pub_free (key->pub); | ||
185 | // GNUNET_free (key->msk); | ||
186 | // gabe_msk_free (key->msk); //For some reason free of pub implicit? | ||
187 | GNUNET_free (key); | ||
188 | } | ||
189 | |||
190 | |||
191 | /** | ||
192 | * @ingroup abe | ||
193 | * Create a new CP-ABE key. Caller must free return value. | ||
194 | * | ||
195 | * @param key the master key | ||
196 | * @param attrs the attributes to append to the key | ||
197 | * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_key | ||
198 | */ | ||
199 | struct GNUNET_ABE_AbeKey* | ||
200 | GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key, | ||
201 | char **attrs) | ||
202 | { | ||
203 | struct GNUNET_ABE_AbeKey *prv_key; | ||
204 | int size; | ||
205 | char *tmp; | ||
206 | |||
207 | prv_key = GNUNET_new (struct GNUNET_ABE_AbeKey); | ||
208 | prv_key->prv = gabe_keygen (key->pub, key->msk, attrs); | ||
209 | size = gabe_pub_serialize (key->pub, &tmp); | ||
210 | prv_key->pub = gabe_pub_unserialize (tmp, size); | ||
211 | GNUNET_free (tmp); | ||
212 | GNUNET_assert (NULL != prv_key->prv); | ||
213 | return prv_key; | ||
214 | } | ||
215 | |||
216 | |||
217 | /** | ||
218 | * @ingroup abe | ||
219 | * Delete a CP-ABE key. | ||
220 | * | ||
221 | * @param key the key to delete | ||
222 | * @param delete_pub GNUNE_YES if the public key should also be freed (bug in gabe) | ||
223 | * @return fresh private key; free using #GNUNET_free | ||
224 | */ | ||
225 | void | ||
226 | GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key, | ||
227 | int delete_pub) | ||
228 | { | ||
229 | // Memory management in gabe is buggy | ||
230 | gabe_prv_free (key->prv); | ||
231 | if (GNUNET_YES == delete_pub) | ||
232 | gabe_pub_free (key->pub); | ||
233 | GNUNET_free (key); | ||
234 | } | ||
235 | |||
236 | |||
237 | static ssize_t | ||
238 | write_cpabe (void **result, | ||
239 | uint32_t file_len, | ||
240 | char*cph_buf, | ||
241 | int cph_buf_len, | ||
242 | char*aes_buf, | ||
243 | int aes_buf_len) | ||
244 | { | ||
245 | char *ptr; | ||
246 | uint32_t *len; | ||
247 | |||
248 | *result = GNUNET_malloc (12 + cph_buf_len + aes_buf_len); | ||
249 | ptr = *result; | ||
250 | len = (uint32_t *) ptr; | ||
251 | *len = htonl (file_len); | ||
252 | ptr += 4; | ||
253 | len = (uint32_t *) ptr; | ||
254 | *len = htonl (aes_buf_len); | ||
255 | ptr += 4; | ||
256 | GNUNET_memcpy (ptr, aes_buf, aes_buf_len); | ||
257 | ptr += aes_buf_len; | ||
258 | len = (uint32_t *) ptr; | ||
259 | *len = htonl (cph_buf_len); | ||
260 | ptr += 4; | ||
261 | GNUNET_memcpy (ptr, cph_buf, cph_buf_len); | ||
262 | return 12 + cph_buf_len + aes_buf_len; | ||
263 | } | ||
264 | |||
265 | |||
266 | static ssize_t | ||
267 | read_cpabe (const void *data, | ||
268 | char**cph_buf, | ||
269 | int *cph_buf_len, | ||
270 | char**aes_buf, | ||
271 | int *aes_buf_len) | ||
272 | { | ||
273 | int buf_len; | ||
274 | char *ptr; | ||
275 | uint32_t *len; | ||
276 | |||
277 | ptr = (char *) data; | ||
278 | len = (uint32_t *) ptr; | ||
279 | buf_len = ntohl (*len); | ||
280 | ptr += 4; | ||
281 | len = (uint32_t *) ptr; | ||
282 | *aes_buf_len = ntohl (*len); | ||
283 | ptr += 4; | ||
284 | *aes_buf = GNUNET_malloc (*aes_buf_len); | ||
285 | GNUNET_memcpy (*aes_buf, ptr, *aes_buf_len); | ||
286 | ptr += *aes_buf_len; | ||
287 | len = (uint32_t *) ptr; | ||
288 | *cph_buf_len = ntohl (*len); | ||
289 | ptr += 4; | ||
290 | *cph_buf = GNUNET_malloc (*cph_buf_len); | ||
291 | GNUNET_memcpy (*cph_buf, ptr, *cph_buf_len); | ||
292 | |||
293 | return buf_len; | ||
294 | } | ||
295 | |||
296 | |||
297 | /** | ||
298 | * @ingroup abe | ||
299 | * Encrypt a block using sessionkey. | ||
300 | * | ||
301 | * @param block the block to encrypt | ||
302 | * @param size the size of the @a block | ||
303 | * @param policy the ABE policy | ||
304 | * @param key the key used to encrypt | ||
305 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free | ||
306 | * @return the size of the encrypted block, -1 for errors | ||
307 | */ | ||
308 | ssize_t | ||
309 | GNUNET_ABE_cpabe_encrypt (const void *block, | ||
310 | size_t size, | ||
311 | const char *policy, | ||
312 | const struct GNUNET_ABE_AbeMasterKey *key, | ||
313 | void **result) | ||
314 | { | ||
315 | gabe_cph_t*cph; | ||
316 | char*plt; | ||
317 | char*cph_buf; | ||
318 | char*aes_buf; | ||
319 | element_t m; | ||
320 | int cph_buf_len; | ||
321 | int aes_buf_len; | ||
322 | ssize_t result_len; | ||
323 | |||
324 | if (! (cph = gabe_enc (key->pub, m, (char *) policy))) | ||
325 | return GNUNET_SYSERR; | ||
326 | cph_buf_len = gabe_cph_serialize (cph, | ||
327 | &cph_buf); | ||
328 | gabe_cph_free (cph); | ||
329 | GNUNET_free (cph); | ||
330 | plt = GNUNET_memdup (block, size); | ||
331 | aes_buf_len = aes_128_cbc_encrypt (plt, size, m, &aes_buf); | ||
332 | GNUNET_free (plt); | ||
333 | element_clear (m); | ||
334 | result_len = write_cpabe (result, size, cph_buf, cph_buf_len, aes_buf, | ||
335 | aes_buf_len); | ||
336 | GNUNET_free (cph_buf); | ||
337 | GNUNET_free (aes_buf); | ||
338 | return result_len; | ||
339 | } | ||
340 | |||
341 | |||
342 | /** | ||
343 | * @ingroup abe | ||
344 | * Decrypt a block using the ABE key. | ||
345 | * | ||
346 | * @param block the block to encrypt | ||
347 | * @param size the size of the @a block | ||
348 | * @param key the key used to decrypt | ||
349 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free | ||
350 | * @return the size of the encrypted block, -1 for errors | ||
351 | */ | ||
352 | ssize_t | ||
353 | GNUNET_ABE_cpabe_decrypt (const void *block, | ||
354 | size_t size, | ||
355 | const struct GNUNET_ABE_AbeKey *key, | ||
356 | void **result) | ||
357 | { | ||
358 | char*aes_buf; | ||
359 | char*cph_buf; | ||
360 | gabe_cph_t*cph; | ||
361 | element_t m; | ||
362 | int cph_buf_size; | ||
363 | int aes_buf_size; | ||
364 | int plt_len; | ||
365 | |||
366 | read_cpabe (block, &cph_buf, &cph_buf_size, &aes_buf, &aes_buf_size); | ||
367 | cph = gabe_cph_unserialize (key->pub, cph_buf, cph_buf_size); | ||
368 | if (! gabe_dec (key->pub, key->prv, cph, m)) | ||
369 | { | ||
370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
371 | "%s\n", gabe_error ()); | ||
372 | GNUNET_free (aes_buf); | ||
373 | GNUNET_free (cph_buf); | ||
374 | gabe_cph_free (cph); | ||
375 | GNUNET_free (cph); | ||
376 | element_clear (m); | ||
377 | return GNUNET_SYSERR; | ||
378 | } | ||
379 | gabe_cph_free (cph); | ||
380 | GNUNET_free (cph); | ||
381 | plt_len = aes_128_cbc_decrypt (aes_buf, aes_buf_size, m, (char **) result); | ||
382 | GNUNET_free (cph_buf); | ||
383 | GNUNET_free (aes_buf); | ||
384 | element_clear (m); | ||
385 | // freeing is buggy in gabe | ||
386 | // gabe_prv_free (prv); | ||
387 | // gabe_pub_free (pub); | ||
388 | return plt_len; | ||
389 | } | ||
390 | |||
391 | |||
392 | /** | ||
393 | * @ingroup abe | ||
394 | * Serialize an ABE key. | ||
395 | * | ||
396 | * @param key the key to serialize | ||
397 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free | ||
398 | * @return the size of the encrypted block, -1 for errors | ||
399 | */ | ||
400 | ssize_t | ||
401 | GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key, | ||
402 | void **result) | ||
403 | { | ||
404 | ssize_t len; | ||
405 | char *pub; | ||
406 | char *prv; | ||
407 | int pub_len; | ||
408 | int prv_len; | ||
409 | |||
410 | pub_len = gabe_pub_serialize (key->pub, &pub); | ||
411 | prv_len = gabe_prv_serialize (key->prv, &prv); | ||
412 | |||
413 | len = pub_len + prv_len + 12; | ||
414 | write_cpabe (result, len, pub, pub_len, prv, prv_len); | ||
415 | |||
416 | GNUNET_free (pub); | ||
417 | GNUNET_free (prv); | ||
418 | |||
419 | return len; | ||
420 | } | ||
421 | |||
422 | |||
423 | /** | ||
424 | * @ingroup abe | ||
425 | * Deserialize a serialized ABE key. | ||
426 | * | ||
427 | * @param data the data to deserialize | ||
428 | * @param len the length of the data. | ||
429 | * @return the ABE key. NULL of unsuccessful | ||
430 | */ | ||
431 | struct GNUNET_ABE_AbeKey* | ||
432 | GNUNET_ABE_cpabe_deserialize_key (const void *data, | ||
433 | size_t len) | ||
434 | { | ||
435 | struct GNUNET_ABE_AbeKey *key; | ||
436 | char *pub; | ||
437 | char *prv; | ||
438 | int prv_len; | ||
439 | int pub_len; | ||
440 | |||
441 | key = GNUNET_new (struct GNUNET_ABE_AbeKey); | ||
442 | read_cpabe (data, | ||
443 | &pub, | ||
444 | &pub_len, | ||
445 | &prv, | ||
446 | &prv_len); | ||
447 | key->pub = gabe_pub_unserialize (pub, pub_len); | ||
448 | key->prv = gabe_prv_unserialize (key->pub, prv, prv_len); | ||
449 | |||
450 | GNUNET_free (pub); | ||
451 | GNUNET_free (prv); | ||
452 | return key; | ||
453 | } | ||
454 | |||
455 | |||
456 | /** | ||
457 | * @ingroup abe | ||
458 | * Serialize an ABE master key. | ||
459 | * | ||
460 | * @param key the key to serialize | ||
461 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free | ||
462 | * @return the size of the encrypted block, -1 for errors | ||
463 | */ | ||
464 | ssize_t | ||
465 | GNUNET_ABE_cpabe_serialize_master_key (const struct | ||
466 | GNUNET_ABE_AbeMasterKey *key, | ||
467 | void **result) | ||
468 | { | ||
469 | ssize_t len; | ||
470 | char *pub; | ||
471 | char *msk; | ||
472 | int pub_len; | ||
473 | int msk_len; | ||
474 | |||
475 | pub_len = gabe_pub_serialize (key->pub, &pub); | ||
476 | msk_len = gabe_msk_serialize (key->msk, &msk); | ||
477 | |||
478 | len = pub_len + msk_len + 12; | ||
479 | write_cpabe (result, len, pub, pub_len, msk, msk_len); | ||
480 | |||
481 | GNUNET_free (pub); | ||
482 | GNUNET_free (msk); | ||
483 | |||
484 | return len; | ||
485 | } | ||
486 | |||
487 | |||
488 | /** | ||
489 | * @ingroup abe | ||
490 | * Deserialize an ABE master key. | ||
491 | * | ||
492 | * @param data the data to deserialize | ||
493 | * @param len the length of the data. | ||
494 | * @return the ABE key. NULL of unsuccessful | ||
495 | */ | ||
496 | struct GNUNET_ABE_AbeMasterKey* | ||
497 | GNUNET_ABE_cpabe_deserialize_master_key (const void *data, | ||
498 | size_t len) | ||
499 | { | ||
500 | struct GNUNET_ABE_AbeMasterKey *key; | ||
501 | char *msk; | ||
502 | char *pub; | ||
503 | int msk_len; | ||
504 | int pub_len; | ||
505 | |||
506 | key = GNUNET_new (struct GNUNET_ABE_AbeMasterKey); | ||
507 | read_cpabe (data, | ||
508 | &pub, | ||
509 | &pub_len, | ||
510 | &msk, | ||
511 | &msk_len); | ||
512 | key->pub = gabe_pub_unserialize (pub, pub_len); | ||
513 | key->msk = gabe_msk_unserialize (key->pub, msk, msk_len); | ||
514 | |||
515 | GNUNET_free (pub); | ||
516 | GNUNET_free (msk); | ||
517 | |||
518 | return key; | ||
519 | } | ||
diff --git a/src/abe/test_cpabe.c b/src/abe/test_cpabe.c deleted file mode 100644 index aefb0f99f..000000000 --- a/src/abe/test_cpabe.c +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2002, 2003, 2004, 2006 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | |||
20 | */ | ||
21 | /** | ||
22 | * @author Martin Schanzenbach | ||
23 | * @file util/test_crypto_abe.c | ||
24 | * @brief test for ABE ciphers | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_abe_lib.h" | ||
29 | |||
30 | #define TESTSTRING "Hello World!" | ||
31 | |||
32 | static int | ||
33 | testAbecipher () | ||
34 | { | ||
35 | struct GNUNET_ABE_AbeMasterKey *msk; | ||
36 | struct GNUNET_ABE_AbeKey *key; | ||
37 | char *result; | ||
38 | char **attrs; | ||
39 | int size; | ||
40 | char *res; | ||
41 | |||
42 | msk = GNUNET_ABE_cpabe_create_master_key (); | ||
43 | size = GNUNET_ABE_cpabe_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, | ||
44 | "testattr", // Policy | ||
45 | msk, | ||
46 | (void *) &result); | ||
47 | GNUNET_assert (-1 != size); | ||
48 | attrs = GNUNET_malloc (2 * sizeof(char*)); | ||
49 | attrs[0] = "testattr"; | ||
50 | attrs[1] = NULL; | ||
51 | key = GNUNET_ABE_cpabe_create_key (msk, | ||
52 | attrs); | ||
53 | |||
54 | size = GNUNET_ABE_cpabe_decrypt (result, size, | ||
55 | key, | ||
56 | (void *) &res); | ||
57 | if (strlen (TESTSTRING) + 1 != size) | ||
58 | { | ||
59 | printf ("abeciphertest failed: decryptBlock returned %d\n", size); | ||
60 | return 1; | ||
61 | } | ||
62 | if (0 != strcmp (res, TESTSTRING)) | ||
63 | { | ||
64 | printf ("abeciphertest failed: %s != %s\n", res, TESTSTRING); | ||
65 | return 1; | ||
66 | } | ||
67 | else | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | |||
72 | int | ||
73 | main (int argc, char *argv[]) | ||
74 | { | ||
75 | int failureCount = 0; | ||
76 | |||
77 | GNUNET_log_setup ("test-crypto-abe", "WARNING", NULL); | ||
78 | failureCount += testAbecipher (); | ||
79 | |||
80 | if (failureCount != 0) | ||
81 | { | ||
82 | printf ("%d TESTS FAILED!\n", failureCount); | ||
83 | return -1; | ||
84 | } | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | |||
89 | /* end of test_crypto_aes.c */ | ||
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 67c29208c..586645567 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -61,7 +61,6 @@ gnunetinclude_HEADERS = \ | |||
61 | gnunet_hello_uri_lib.h \ | 61 | gnunet_hello_uri_lib.h \ |
62 | gnunet_helper_lib.h \ | 62 | gnunet_helper_lib.h \ |
63 | gnunet_identity_service.h \ | 63 | gnunet_identity_service.h \ |
64 | gnunet_abe_lib.h \ | ||
65 | gnunet_reclaim_lib.h \ | 64 | gnunet_reclaim_lib.h \ |
66 | gnunet_reclaim_plugin.h \ | 65 | gnunet_reclaim_plugin.h \ |
67 | gnunet_reclaim_service.h \ | 66 | gnunet_reclaim_service.h \ |
diff --git a/src/include/gnunet_abe_lib.h b/src/include/gnunet_abe_lib.h deleted file mode 100644 index 7aeb3520d..000000000 --- a/src/include/gnunet_abe_lib.h +++ /dev/null | |||
@@ -1,193 +0,0 @@ | |||
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 it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file include/gnunet_abe_lib.h | ||
23 | * @brief Attribute-Based Encryption 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 | ||
34 | extern "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 | */ | ||
47 | struct GNUNET_CRYPTO_AbeMasterKey; | ||
48 | |||
49 | /** | ||
50 | * @brief type for ABE keys | ||
51 | */ | ||
52 | struct GNUNET_CRYPTO_AbeKey; | ||
53 | |||
54 | |||
55 | /** | ||
56 | * @ingroup abe | ||
57 | * Create a new CP-ABE master key. Caller must free return value. | ||
58 | * | ||
59 | * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key | ||
60 | */ | ||
61 | struct GNUNET_ABE_AbeMasterKey * | ||
62 | GNUNET_ABE_cpabe_create_master_key (void); | ||
63 | |||
64 | /** | ||
65 | * @ingroup abe | ||
66 | * Delete a CP-ABE master key. | ||
67 | * | ||
68 | * @param key the master key | ||
69 | * @return fresh private key; free using #GNUNET_free | ||
70 | */ | ||
71 | void | ||
72 | GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key); | ||
73 | |||
74 | /** | ||
75 | * @ingroup abe | ||
76 | * Create a new CP-ABE key. Caller must free return value. | ||
77 | * | ||
78 | * @param key the master key | ||
79 | * @param attrs the attributes to append to the key | ||
80 | * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_key | ||
81 | */ | ||
82 | struct GNUNET_ABE_AbeKey * | ||
83 | GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key, | ||
84 | char **attrs); | ||
85 | |||
86 | /** | ||
87 | * @ingroup abe | ||
88 | * Delete a CP-ABE key. | ||
89 | * | ||
90 | * @param key the key to delete | ||
91 | * @param delete_pub GNUNET_YES if the public key should also be freed (bug in gabe) | ||
92 | * @return fresh private key; free using #GNUNET_free | ||
93 | */ | ||
94 | void | ||
95 | GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key, | ||
96 | int delete_pub); | ||
97 | |||
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 policy the ABE policy | ||
106 | * @param key the key used to encrypt | ||
107 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free | ||
108 | * @return the size of the encrypted block, -1 for errors | ||
109 | */ | ||
110 | ssize_t | ||
111 | GNUNET_ABE_cpabe_encrypt (const void *block, | ||
112 | size_t size, | ||
113 | const char *policy, | ||
114 | const struct GNUNET_ABE_AbeMasterKey *key, | ||
115 | void **result); | ||
116 | |||
117 | /** | ||
118 | * @ingroup abe | ||
119 | * Decrypt a block using the ABE key. | ||
120 | * | ||
121 | * @param block the block to encrypt | ||
122 | * @param size the size of the @a block | ||
123 | * @param key the key used to decrypt | ||
124 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free | ||
125 | * @return the size of the encrypted block, -1 for errors | ||
126 | */ | ||
127 | ssize_t | ||
128 | GNUNET_ABE_cpabe_decrypt (const void *block, | ||
129 | size_t size, | ||
130 | const struct GNUNET_ABE_AbeKey *key, | ||
131 | void **result); | ||
132 | |||
133 | /** | ||
134 | * @ingroup abe | ||
135 | * Serialize an ABE key. | ||
136 | * | ||
137 | * @param key the key to serialize | ||
138 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free | ||
139 | * @return the size of the encrypted block, -1 for errors | ||
140 | */ | ||
141 | ssize_t | ||
142 | GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key, | ||
143 | void **result); | ||
144 | |||
145 | /** | ||
146 | * @ingroup abe | ||
147 | * Deserialize a serialized ABE key. | ||
148 | * | ||
149 | * @param data the data to deserialize | ||
150 | * @param len the length of the data. | ||
151 | * @return the ABE key. NULL of unsuccessful | ||
152 | */ | ||
153 | struct GNUNET_ABE_AbeKey* | ||
154 | GNUNET_ABE_cpabe_deserialize_key (const void *data, | ||
155 | size_t len); | ||
156 | |||
157 | /** | ||
158 | * @ingroup abe | ||
159 | * Serialize an ABE master key. | ||
160 | * | ||
161 | * @param key the key to serialize | ||
162 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free | ||
163 | * @return the size of the encrypted block, -1 for errors | ||
164 | */ | ||
165 | ssize_t | ||
166 | GNUNET_ABE_cpabe_serialize_master_key (const struct | ||
167 | GNUNET_ABE_AbeMasterKey *key, | ||
168 | void **result); | ||
169 | |||
170 | /** | ||
171 | * @ingroup abe | ||
172 | * Deserialize an ABE master key. | ||
173 | * | ||
174 | * @param data the data to deserialize | ||
175 | * @param len the length of the data. | ||
176 | * @return the ABE key. NULL of unsuccessful | ||
177 | */ | ||
178 | struct GNUNET_ABE_AbeMasterKey* | ||
179 | GNUNET_ABE_cpabe_deserialize_master_key (const void *data, | ||
180 | size_t len); | ||
181 | |||
182 | |||
183 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
184 | { | ||
185 | #endif | ||
186 | #ifdef __cplusplus | ||
187 | } | ||
188 | #endif | ||
189 | |||
190 | |||
191 | /* ifndef GNUNET_ABE_LIB_H */ | ||
192 | #endif | ||
193 | /* end of gnunet_abe_lib.h */ | ||
diff --git a/src/util/crypto_abe.c b/src/util/crypto_abe.c deleted file mode 100644 index c089b29db..000000000 --- a/src/util/crypto_abe.c +++ /dev/null | |||
@@ -1,438 +0,0 @@ | |||
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 it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
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 | |||
35 | struct GNUNET_CRYPTO_AbeMasterKey | ||
36 | { | ||
37 | gabe_pub_t*pub; | ||
38 | gabe_msk_t*msk; | ||
39 | }; | ||
40 | |||
41 | struct GNUNET_CRYPTO_AbeKey | ||
42 | { | ||
43 | gabe_pub_t*pub; | ||
44 | gabe_prv_t*prv; | ||
45 | }; | ||
46 | |||
47 | static int | ||
48 | init_aes (element_t k, int enc, | ||
49 | gcry_cipher_hd_t*handle, | ||
50 | struct GNUNET_CRYPTO_SymmetricSessionKey *key, | ||
51 | unsigned char*iv) | ||
52 | { | ||
53 | int rc; | ||
54 | int key_len; | ||
55 | unsigned char*key_buf; | ||
56 | |||
57 | key_len = element_length_in_bytes (k) < 33 ? 3 : element_length_in_bytes (k); | ||
58 | key_buf = (unsigned char *) malloc (key_len); | ||
59 | element_to_bytes (key_buf, k); | ||
60 | |||
61 | GNUNET_memcpy (key->aes_key, | ||
62 | key_buf, | ||
63 | GNUNET_CRYPTO_AES_KEY_LENGTH); | ||
64 | GNUNET_assert (0 == | ||
65 | gcry_cipher_open (handle, GCRY_CIPHER_AES256, | ||
66 | GCRY_CIPHER_MODE_CFB, 0)); | ||
67 | rc = gcry_cipher_setkey (*handle, | ||
68 | key->aes_key, | ||
69 | sizeof(key->aes_key)); | ||
70 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); | ||
71 | memset (iv, 0, 16); // TODO make reasonable | ||
72 | rc = gcry_cipher_setiv (*handle, | ||
73 | iv, | ||
74 | 16); | ||
75 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); | ||
76 | |||
77 | free (key_buf); | ||
78 | return rc; | ||
79 | } | ||
80 | |||
81 | |||
82 | static int | ||
83 | aes_128_cbc_encrypt (char*pt, | ||
84 | int size, | ||
85 | element_t k, | ||
86 | char **ct) | ||
87 | { | ||
88 | gcry_cipher_hd_t handle; | ||
89 | struct GNUNET_CRYPTO_SymmetricSessionKey skey; | ||
90 | unsigned char iv[16]; | ||
91 | char*buf; | ||
92 | int padding; | ||
93 | int buf_size; | ||
94 | uint8_t len[4]; | ||
95 | |||
96 | init_aes (k, 1, &handle, &skey, iv); | ||
97 | |||
98 | /* TODO make less crufty */ | ||
99 | |||
100 | /* stuff in real length (big endian) before padding */ | ||
101 | len[0] = (size & 0xff000000) >> 24; | ||
102 | len[1] = (size & 0xff0000) >> 16; | ||
103 | len[2] = (size & 0xff00) >> 8; | ||
104 | len[3] = (size & 0xff) >> 0; | ||
105 | padding = 16 - ((4 + size) % 16); | ||
106 | buf_size = 4 + size + padding; | ||
107 | buf = GNUNET_malloc (buf_size); | ||
108 | GNUNET_memcpy (buf, len, 4); | ||
109 | GNUNET_memcpy (buf + 4, pt, size); | ||
110 | *ct = GNUNET_malloc (buf_size); | ||
111 | |||
112 | GNUNET_assert (0 == gcry_cipher_encrypt (handle, *ct, buf_size, buf, | ||
113 | buf_size)); | ||
114 | gcry_cipher_close (handle); | ||
115 | // AES_cbc_encrypt(pt->data, ct->data, pt->len, &key, iv, AES_ENCRYPT); | ||
116 | GNUNET_free (buf); | ||
117 | return buf_size; | ||
118 | } | ||
119 | |||
120 | |||
121 | static int | ||
122 | aes_128_cbc_decrypt (char*ct, | ||
123 | int size, | ||
124 | element_t k, | ||
125 | char **pt) | ||
126 | { | ||
127 | struct GNUNET_CRYPTO_SymmetricSessionKey skey; | ||
128 | gcry_cipher_hd_t handle; | ||
129 | unsigned char iv[16]; | ||
130 | char*tmp; | ||
131 | uint32_t len; | ||
132 | |||
133 | init_aes (k, 1, &handle, &skey, iv); | ||
134 | |||
135 | tmp = GNUNET_malloc (size); | ||
136 | |||
137 | // AES_cbc_encrypt(ct->data, pt->data, ct->len, &key, iv, AES_DECRYPT); | ||
138 | GNUNET_assert (0 == gcry_cipher_decrypt (handle, tmp, size, ct, size)); | ||
139 | gcry_cipher_close (handle); | ||
140 | /* TODO make less crufty */ | ||
141 | |||
142 | /* get real length */ | ||
143 | len = 0; | ||
144 | len = len | ||
145 | | ((tmp[0]) << 24) | ((tmp[1]) << 16) | ||
146 | | ((tmp[2]) << 8) | ((tmp[3]) << 0); | ||
147 | /* truncate any garbage from the padding */ | ||
148 | *pt = GNUNET_malloc (len); | ||
149 | GNUNET_memcpy (*pt, tmp + 4, len); | ||
150 | GNUNET_free (tmp); | ||
151 | return len; | ||
152 | } | ||
153 | |||
154 | |||
155 | struct GNUNET_CRYPTO_AbeMasterKey* | ||
156 | GNUNET_CRYPTO_cpabe_create_master_key (void) | ||
157 | { | ||
158 | struct GNUNET_CRYPTO_AbeMasterKey*key; | ||
159 | |||
160 | key = GNUNET_new (struct GNUNET_CRYPTO_AbeMasterKey); | ||
161 | gabe_setup (&key->pub, &key->msk); | ||
162 | GNUNET_assert (NULL != key->pub); | ||
163 | GNUNET_assert (NULL != key->msk); | ||
164 | return key; | ||
165 | } | ||
166 | |||
167 | |||
168 | void | ||
169 | GNUNET_CRYPTO_cpabe_delete_master_key (struct GNUNET_CRYPTO_AbeMasterKey *key) | ||
170 | { | ||
171 | gabe_msk_free (key->msk); | ||
172 | gabe_pub_free (key->pub); | ||
173 | // GNUNET_free (key->msk); | ||
174 | // gabe_msk_free (key->msk); //For some reason free of pub implicit? | ||
175 | GNUNET_free (key); | ||
176 | } | ||
177 | |||
178 | |||
179 | struct GNUNET_CRYPTO_AbeKey* | ||
180 | GNUNET_CRYPTO_cpabe_create_key (struct GNUNET_CRYPTO_AbeMasterKey *key, | ||
181 | char **attrs) | ||
182 | { | ||
183 | struct GNUNET_CRYPTO_AbeKey *prv_key; | ||
184 | int size; | ||
185 | char *tmp; | ||
186 | |||
187 | prv_key = GNUNET_new (struct GNUNET_CRYPTO_AbeKey); | ||
188 | prv_key->prv = gabe_keygen (key->pub, key->msk, attrs); | ||
189 | size = gabe_pub_serialize (key->pub, &tmp); | ||
190 | prv_key->pub = gabe_pub_unserialize (tmp, size); | ||
191 | GNUNET_free (tmp); | ||
192 | GNUNET_assert (NULL != prv_key->prv); | ||
193 | return prv_key; | ||
194 | } | ||
195 | |||
196 | |||
197 | void | ||
198 | GNUNET_CRYPTO_cpabe_delete_key (struct GNUNET_CRYPTO_AbeKey *key, | ||
199 | int delete_pub) | ||
200 | { | ||
201 | // Memory management in gabe is buggy | ||
202 | gabe_prv_free (key->prv); | ||
203 | if (GNUNET_YES == delete_pub) | ||
204 | gabe_pub_free (key->pub); | ||
205 | GNUNET_free (key); | ||
206 | } | ||
207 | |||
208 | |||
209 | ssize_t | ||
210 | write_cpabe (void **result, | ||
211 | uint32_t file_len, | ||
212 | char*cph_buf, | ||
213 | int cph_buf_len, | ||
214 | char*aes_buf, | ||
215 | int aes_buf_len) | ||
216 | { | ||
217 | char *ptr; | ||
218 | uint32_t *len; | ||
219 | |||
220 | *result = GNUNET_malloc (12 + cph_buf_len + aes_buf_len); | ||
221 | ptr = *result; | ||
222 | len = (uint32_t *) ptr; | ||
223 | *len = htonl (file_len); | ||
224 | ptr += 4; | ||
225 | len = (uint32_t *) ptr; | ||
226 | *len = htonl (aes_buf_len); | ||
227 | ptr += 4; | ||
228 | GNUNET_memcpy (ptr, aes_buf, aes_buf_len); | ||
229 | ptr += aes_buf_len; | ||
230 | len = (uint32_t *) ptr; | ||
231 | *len = htonl (cph_buf_len); | ||
232 | ptr += 4; | ||
233 | GNUNET_memcpy (ptr, cph_buf, cph_buf_len); | ||
234 | return 12 + cph_buf_len + aes_buf_len; | ||
235 | } | ||
236 | |||
237 | |||
238 | ssize_t | ||
239 | read_cpabe (const void *data, | ||
240 | char**cph_buf, | ||
241 | int *cph_buf_len, | ||
242 | char**aes_buf, | ||
243 | int *aes_buf_len) | ||
244 | { | ||
245 | int buf_len; | ||
246 | char *ptr; | ||
247 | uint32_t *len; | ||
248 | |||
249 | ptr = (char *) data; | ||
250 | len = (uint32_t *) ptr; | ||
251 | buf_len = ntohl (*len); | ||
252 | ptr += 4; | ||
253 | len = (uint32_t *) ptr; | ||
254 | *aes_buf_len = ntohl (*len); | ||
255 | ptr += 4; | ||
256 | *aes_buf = GNUNET_malloc (*aes_buf_len); | ||
257 | GNUNET_memcpy (*aes_buf, ptr, *aes_buf_len); | ||
258 | ptr += *aes_buf_len; | ||
259 | len = (uint32_t *) ptr; | ||
260 | *cph_buf_len = ntohl (*len); | ||
261 | ptr += 4; | ||
262 | *cph_buf = GNUNET_malloc (*cph_buf_len); | ||
263 | GNUNET_memcpy (*cph_buf, ptr, *cph_buf_len); | ||
264 | |||
265 | return buf_len; | ||
266 | } | ||
267 | |||
268 | |||
269 | ssize_t | ||
270 | GNUNET_CRYPTO_cpabe_encrypt (const void *block, | ||
271 | size_t size, | ||
272 | const char *policy, | ||
273 | const struct GNUNET_CRYPTO_AbeMasterKey *key, | ||
274 | void **result) | ||
275 | { | ||
276 | gabe_cph_t*cph; | ||
277 | char*plt; | ||
278 | char*cph_buf; | ||
279 | char*aes_buf; | ||
280 | element_t m; | ||
281 | int cph_buf_len; | ||
282 | int aes_buf_len; | ||
283 | ssize_t result_len; | ||
284 | |||
285 | if (! (cph = gabe_enc (key->pub, m, (char *) policy))) | ||
286 | return GNUNET_SYSERR; | ||
287 | cph_buf_len = gabe_cph_serialize (cph, | ||
288 | &cph_buf); | ||
289 | gabe_cph_free (cph); | ||
290 | GNUNET_free (cph); | ||
291 | plt = GNUNET_memdup (block, size); | ||
292 | aes_buf_len = aes_128_cbc_encrypt (plt, size, m, &aes_buf); | ||
293 | GNUNET_free (plt); | ||
294 | element_clear (m); | ||
295 | result_len = write_cpabe (result, size, cph_buf, cph_buf_len, aes_buf, | ||
296 | aes_buf_len); | ||
297 | GNUNET_free (cph_buf); | ||
298 | GNUNET_free (aes_buf); | ||
299 | return result_len; | ||
300 | } | ||
301 | |||
302 | |||
303 | ssize_t | ||
304 | GNUNET_CRYPTO_cpabe_decrypt (const void *block, | ||
305 | size_t size, | ||
306 | const struct GNUNET_CRYPTO_AbeKey *key, | ||
307 | void **result) | ||
308 | { | ||
309 | char*aes_buf; | ||
310 | char*cph_buf; | ||
311 | gabe_cph_t*cph; | ||
312 | element_t m; | ||
313 | int cph_buf_size; | ||
314 | int aes_buf_size; | ||
315 | int plt_len; | ||
316 | |||
317 | read_cpabe (block, &cph_buf, &cph_buf_size, &aes_buf, &aes_buf_size); | ||
318 | cph = gabe_cph_unserialize (key->pub, cph_buf, cph_buf_size); | ||
319 | if (! gabe_dec (key->pub, key->prv, cph, m)) | ||
320 | { | ||
321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
322 | "%s\n", gabe_error ()); | ||
323 | GNUNET_free (aes_buf); | ||
324 | GNUNET_free (cph_buf); | ||
325 | gabe_cph_free (cph); | ||
326 | GNUNET_free (cph); | ||
327 | element_clear (m); | ||
328 | return GNUNET_SYSERR; | ||
329 | } | ||
330 | gabe_cph_free (cph); | ||
331 | GNUNET_free (cph); | ||
332 | plt_len = aes_128_cbc_decrypt (aes_buf, aes_buf_size, m, (char **) result); | ||
333 | GNUNET_free (cph_buf); | ||
334 | GNUNET_free (aes_buf); | ||
335 | element_clear (m); | ||
336 | // freeing is buggy in gabe | ||
337 | // gabe_prv_free (prv); | ||
338 | // gabe_pub_free (pub); | ||
339 | return plt_len; | ||
340 | } | ||
341 | |||
342 | |||
343 | ssize_t | ||
344 | GNUNET_CRYPTO_cpabe_serialize_key (const struct GNUNET_CRYPTO_AbeKey *key, | ||
345 | void **result) | ||
346 | { | ||
347 | ssize_t len; | ||
348 | char *pub; | ||
349 | char *prv; | ||
350 | int pub_len; | ||
351 | int prv_len; | ||
352 | |||
353 | pub_len = gabe_pub_serialize (key->pub, &pub); | ||
354 | prv_len = gabe_prv_serialize (key->prv, &prv); | ||
355 | |||
356 | len = pub_len + prv_len + 12; | ||
357 | write_cpabe (result, len, pub, pub_len, prv, prv_len); | ||
358 | |||
359 | GNUNET_free (pub); | ||
360 | GNUNET_free (prv); | ||
361 | |||
362 | return len; | ||
363 | } | ||
364 | |||
365 | |||
366 | struct GNUNET_CRYPTO_AbeKey* | ||
367 | GNUNET_CRYPTO_cpabe_deserialize_key (const void *data, | ||
368 | size_t len) | ||
369 | { | ||
370 | struct GNUNET_CRYPTO_AbeKey *key; | ||
371 | char *pub; | ||
372 | char *prv; | ||
373 | int prv_len; | ||
374 | int pub_len; | ||
375 | |||
376 | key = GNUNET_new (struct GNUNET_CRYPTO_AbeKey); | ||
377 | read_cpabe (data, | ||
378 | &pub, | ||
379 | &pub_len, | ||
380 | &prv, | ||
381 | &prv_len); | ||
382 | key->pub = gabe_pub_unserialize (pub, pub_len); | ||
383 | key->prv = gabe_prv_unserialize (key->pub, prv, prv_len); | ||
384 | |||
385 | GNUNET_free (pub); | ||
386 | GNUNET_free (prv); | ||
387 | return key; | ||
388 | } | ||
389 | |||
390 | |||
391 | ssize_t | ||
392 | GNUNET_CRYPTO_cpabe_serialize_master_key (const struct | ||
393 | GNUNET_CRYPTO_AbeMasterKey *key, | ||
394 | void **result) | ||
395 | { | ||
396 | ssize_t len; | ||
397 | char *pub; | ||
398 | char *msk; | ||
399 | int pub_len; | ||
400 | int msk_len; | ||
401 | |||
402 | pub_len = gabe_pub_serialize (key->pub, &pub); | ||
403 | msk_len = gabe_msk_serialize (key->msk, &msk); | ||
404 | |||
405 | len = pub_len + msk_len + 12; | ||
406 | write_cpabe (result, len, pub, pub_len, msk, msk_len); | ||
407 | |||
408 | GNUNET_free (pub); | ||
409 | GNUNET_free (msk); | ||
410 | |||
411 | return len; | ||
412 | } | ||
413 | |||
414 | |||
415 | struct GNUNET_CRYPTO_AbeMasterKey* | ||
416 | GNUNET_CRYPTO_cpabe_deserialize_master_key (const void *data, | ||
417 | size_t len) | ||
418 | { | ||
419 | struct GNUNET_CRYPTO_AbeMasterKey *key; | ||
420 | char *msk; | ||
421 | char *pub; | ||
422 | int msk_len; | ||
423 | int pub_len; | ||
424 | |||
425 | key = GNUNET_new (struct GNUNET_CRYPTO_AbeMasterKey); | ||
426 | read_cpabe (data, | ||
427 | &pub, | ||
428 | &pub_len, | ||
429 | &msk, | ||
430 | &msk_len); | ||
431 | key->pub = gabe_pub_unserialize (pub, pub_len); | ||
432 | key->msk = gabe_msk_unserialize (key->pub, msk, msk_len); | ||
433 | |||
434 | GNUNET_free (pub); | ||
435 | GNUNET_free (msk); | ||
436 | |||
437 | return key; | ||
438 | } | ||