2 This file is part of GNUnet.
3 Copyright (C) 2001-2018 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file include/gnunet_abe_lib.h
23 * @brief Attribute-Based Encryption primitives for GNUnet
25 * @author Martin Schanzenbach
27 * @defgroup abe ABE Crypto library: Attribute-Based Encryption operations
30 #ifndef GNUNET_ABE_LIB_H
31 #define GNUNET_ABE_LIB_H
36 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_common.h"
45 * @brief type for ABE master keys
47 struct GNUNET_CRYPTO_AbeMasterKey;
50 * @brief type for ABE keys
52 struct GNUNET_CRYPTO_AbeKey;
57 * Create a new CP-ABE master key. Caller must free return value.
59 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key
61 struct GNUNET_ABE_AbeMasterKey *
62 GNUNET_ABE_cpabe_create_master_key (void);
66 * Delete a CP-ABE master key.
68 * @param key the master key
69 * @return fresh private key; free using #GNUNET_free
72 GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key);
76 * Create a new CP-ABE key. Caller must free return value.
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
82 struct GNUNET_ABE_AbeKey *
83 GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
88 * Delete a CP-ABE key.
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
95 GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
101 * Encrypt a block using sessionkey.
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
111 GNUNET_ABE_cpabe_encrypt (const void *block,
114 const struct GNUNET_ABE_AbeMasterKey *key,
119 * Decrypt a block using the ABE key.
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
128 GNUNET_ABE_cpabe_decrypt (const void *block,
130 const struct GNUNET_ABE_AbeKey *key,
135 * Serialize an ABE key.
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
142 GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
147 * Deserialize a serialized ABE key.
149 * @param data the data to deserialize
150 * @param len the length of the data.
151 * @return the ABE key. NULL of unsuccessful
153 struct GNUNET_ABE_AbeKey*
154 GNUNET_ABE_cpabe_deserialize_key (const void *data,
159 * Serialize an ABE master key.
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
166 GNUNET_ABE_cpabe_serialize_master_key (const struct
167 GNUNET_ABE_AbeMasterKey *key,
172 * Deserialize an ABE master key.
174 * @param data the data to deserialize
175 * @param len the length of the data.
176 * @return the ABE key. NULL of unsuccessful
178 struct GNUNET_ABE_AbeMasterKey*
179 GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
183 #if 0 /* keep Emacsens' auto-indent happy */
191 /* ifndef GNUNET_ABE_LIB_H */
193 /* end of gnunet_abe_lib.h */