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;
58 * Create a new CP-ABE master key. Caller must free return value.
60 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key
62 struct GNUNET_ABE_AbeMasterKey *
63 GNUNET_ABE_cpabe_create_master_key (void);
67 * Delete a CP-ABE master key.
69 * @param key the master key
70 * @return fresh private key; free using #GNUNET_free
73 GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key);
77 * Create a new CP-ABE key. Caller must free return value.
79 * @param key the master key
80 * @param attrs the attributes to append to the key
81 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_key
83 struct GNUNET_ABE_AbeKey *
84 GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
89 * Delete a CP-ABE key.
91 * @param key the key to delete
92 * @param delete_pub GNUNET_YES if the public key should also be freed (bug in gabe)
93 * @return fresh private key; free using #GNUNET_free
96 GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
102 * Encrypt a block using sessionkey.
104 * @param block the block to encrypt
105 * @param size the size of the @a block
106 * @param policy the ABE policy
107 * @param key the key used to encrypt
108 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
109 * @return the size of the encrypted block, -1 for errors
112 GNUNET_ABE_cpabe_encrypt (const void *block,
115 const struct GNUNET_ABE_AbeMasterKey *key,
120 * Decrypt a block using the ABE key.
122 * @param block the block to encrypt
123 * @param size the size of the @a block
124 * @param key the key used to decrypt
125 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
126 * @return the size of the encrypted block, -1 for errors
129 GNUNET_ABE_cpabe_decrypt (const void *block,
131 const struct GNUNET_ABE_AbeKey *key,
136 * Serialize an ABE key.
138 * @param key the key to serialize
139 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
140 * @return the size of the encrypted block, -1 for errors
143 GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
148 * Deserialize a serialized ABE key.
150 * @param data the data to deserialize
151 * @param len the length of the data.
152 * @return the ABE key. NULL of unsuccessful
154 struct GNUNET_ABE_AbeKey*
155 GNUNET_ABE_cpabe_deserialize_key (const void *data,
160 * Serialize an ABE master key.
162 * @param key the key to serialize
163 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
164 * @return the size of the encrypted block, -1 for errors
167 GNUNET_ABE_cpabe_serialize_master_key (const struct 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 */