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/>.
20 * @file include/gnunet_abe_lib.h
21 * @brief Attribute-Based Encryption primitives for GNUnet
23 * @author Martin Schanzenbach
25 * @defgroup abe ABE Crypto library: Attribute-Based Encryption operations
28 #ifndef GNUNET_ABE_LIB_H
29 #define GNUNET_ABE_LIB_H
34 #if 0 /* keep Emacsens' auto-indent happy */
39 #include "gnunet_common.h"
43 * @brief type for ABE master keys
45 struct GNUNET_CRYPTO_AbeMasterKey;
48 * @brief type for ABE keys
50 struct GNUNET_CRYPTO_AbeKey;
56 * Create a new CP-ABE master key. Caller must free return value.
58 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key
60 struct GNUNET_ABE_AbeMasterKey *
61 GNUNET_ABE_cpabe_create_master_key (void);
65 * Delete a CP-ABE master key.
67 * @param key the master key
68 * @return fresh private key; free using #GNUNET_free
71 GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key);
75 * Create a new CP-ABE key. Caller must free return value.
77 * @param key the master key
78 * @param attrs the attributes to append to the key
79 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_key
81 struct GNUNET_ABE_AbeKey *
82 GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
87 * Delete a CP-ABE key.
89 * @param key the key to delete
90 * @param delete_pub GNUNE_YES if the public key should also be freed (bug in gabe)
91 * @return fresh private key; free using #GNUNET_free
94 GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
100 * Encrypt a block using sessionkey.
102 * @param block the block to encrypt
103 * @param size the size of the @a block
104 * @param policy the ABE policy
105 * @param key the key used to encrypt
106 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
107 * @return the size of the encrypted block, -1 for errors
110 GNUNET_ABE_cpabe_encrypt (const void *block,
113 const struct GNUNET_ABE_AbeMasterKey *key,
118 * Decrypt a block using the ABE key.
120 * @param block the block to encrypt
121 * @param size the size of the @a block
122 * @param key the key used to decrypt
123 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
124 * @return the size of the encrypted block, -1 for errors
127 GNUNET_ABE_cpabe_decrypt (const void *block,
129 const struct GNUNET_ABE_AbeKey *key,
134 * Serialize an ABE key.
136 * @param key the key to serialize
137 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
138 * @return the size of the encrypted block, -1 for errors
141 GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
146 * Deserialize a serialized ABE key.
148 * @param data the data to deserialize
149 * @param len the length of the data.
150 * @return the ABE key. NULL of unsuccessful
152 struct GNUNET_ABE_AbeKey*
153 GNUNET_ABE_cpabe_deserialize_key (const void *data,
158 * Serialize an ABE master key.
160 * @param key the key to serialize
161 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
162 * @return the size of the encrypted block, -1 for errors
165 GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key,
170 * Deserialize an ABE master key.
172 * @param data the data to deserialize
173 * @param len the length of the data.
174 * @return the ABE key. NULL of unsuccessful
176 struct GNUNET_ABE_AbeMasterKey*
177 GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
181 #if 0 /* keep Emacsens' auto-indent happy */
189 /* ifndef GNUNET_ABE_LIB_H */
191 /* end of gnunet_abe_lib.h */