summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-01-03 10:11:40 +0100
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-01-03 10:11:40 +0100
commitfb85cf602c67994646c156aa9e05d2b9aa10816c (patch)
treeed14e694bb1ce9c11e7cebd0aa445ad41f7c2c7e /src/include
parent7c1f035ed971e12882cd7a65c7d36883842945b1 (diff)
downloadgnunet-fb85cf602c67994646c156aa9e05d2b9aa10816c.tar.gz
gnunet-fb85cf602c67994646c156aa9e05d2b9aa10816c.zip
-move abe functionality out of util; prepare for release
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_abe_lib.h143
-rw-r--r--src/include/gnunet_crypto_lib.h82
2 files changed, 143 insertions, 82 deletions
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