aboutsummaryrefslogtreecommitdiff
path: root/src/zklaim/zklaim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/zklaim/zklaim.c')
-rw-r--r--src/zklaim/zklaim.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/zklaim/zklaim.c b/src/zklaim/zklaim.c
new file mode 100644
index 000000000..a53c193d1
--- /dev/null
+++ b/src/zklaim/zklaim.c
@@ -0,0 +1,79 @@
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*/
19
20/**
21 * @file abe/abe.c
22 * @brief functions for Attribute-Based Encryption
23 * @author Martin Schanzenbach
24 */
25
26
27#include "platform.h"
28#include <zklaim/zklaim.h>
29#include "gnunet_crypto_lib.h"
30
31struct GNUNET_ZKLAIM_Context
32{
33 zklaim_ctx* ctx;
34 gcry_sexp_t priv;
35 gcry_sexp_t pub;
36};
37
38struct GNUNET_ZKLAIM_Payload
39{
40 zklaim_payload pl;
41};
42
43struct GNUNET_ZKLAIM_Context*
44GNUNET_ZKLAIM_new ()
45{
46 struct GNUNET_ZKLAIM_Context *ctx;
47 unsigned char *pubbuf;
48 size_t publen;
49
50 ctx = GNUNET_new (struct GNUNET_ZKLAIM_Context);
51 ctx->ctx = zklaim_context_new();
52 zklaim_pub2buf(ctx->pub, &pubbuf, &publen);
53 zklaim_gen_pk(&ctx->priv);
54 zklaim_get_pub(ctx->priv, &ctx->pub);
55 if (sizeof(ctx->ctx->pub_key) != publen) {
56 printf("size mismatch!");
57 return NULL;
58 }
59
60 memcpy(ctx->ctx->pub_key, pubbuf, sizeof(ctx->ctx->pub_key));
61 free(pubbuf);
62 return ctx;
63}
64
65int
66GNUNET_ZKLAIM_add_payload (struct GNUNET_ZKLAIM_Context *ctx,
67 struct GNUNET_ZKLAIM_Payload *pl)
68{
69 zklaim_add_pl (ctx->ctx, pl->pl);
70 return GNUNET_OK;
71}
72
73int
74GNUNET_ZKLAIM_finalize (struct GNUNET_ZKLAIM_Context *ctx)
75{
76 zklaim_hash_ctx (ctx->ctx);
77 zklaim_ctx_sign (ctx->ctx, ctx->priv);
78 return 1;
79}