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 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.
17 * @file include/gnunet_abe_lib.h
18 * @brief Attribute-Based Encryption primitives for GNUnet
20 * @author Martin Schanzenbach
22 * @defgroup abe ABE Crypto library: Attribute-Based Encryption operations
25 #ifndef GNUNET_ABE_LIB_H
26 #define GNUNET_ABE_LIB_H
31 #if 0 /* keep Emacsens' auto-indent happy */
36 #include "gnunet_common.h"
40 * @brief type for ABE master keys
42 struct GNUNET_CRYPTO_AbeMasterKey;
45 * @brief type for ABE keys
47 struct GNUNET_CRYPTO_AbeKey;
53 * Create a new CP-ABE master key. Caller must free return value.
55 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key
57 struct GNUNET_ABE_AbeMasterKey *
58 GNUNET_ABE_cpabe_create_master_key (void);
62 * Delete a CP-ABE master key.
64 * @param key the master key
65 * @return fresh private key; free using #GNUNET_free
68 GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key);
72 * Create a new CP-ABE key. Caller must free return value.
74 * @param key the master key
75 * @param attrs the attributes to append to the key
76 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_key
78 struct GNUNET_ABE_AbeKey *
79 GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
84 * Delete a CP-ABE key.
86 * @param key the key to delete
87 * @param delete_pub GNUNE_YES if the public key should also be freed (bug in gabe)
88 * @return fresh private key; free using #GNUNET_free
91 GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
97 * Encrypt a block using sessionkey.
99 * @param block the block to encrypt
100 * @param size the size of the @a block
101 * @param policy the ABE policy
102 * @param key the key used to encrypt
103 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
104 * @return the size of the encrypted block, -1 for errors
107 GNUNET_ABE_cpabe_encrypt (const void *block,
110 const struct GNUNET_ABE_AbeMasterKey *key,
115 * Decrypt a block using the ABE key.
117 * @param block the block to encrypt
118 * @param size the size of the @a block
119 * @param key the key used to decrypt
120 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
121 * @return the size of the encrypted block, -1 for errors
124 GNUNET_ABE_cpabe_decrypt (const void *block,
126 const struct GNUNET_ABE_AbeKey *key,
131 * Serialize an ABE key.
133 * @param key the key to serialize
134 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
135 * @return the size of the encrypted block, -1 for errors
138 GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
143 * Deserialize a serialized ABE key.
145 * @param data the data to deserialize
146 * @param len the length of the data.
147 * @return the ABE key. NULL of unsuccessful
149 struct GNUNET_ABE_AbeKey*
150 GNUNET_ABE_cpabe_deserialize_key (const void *data,
155 * Serialize an ABE master key.
157 * @param key the key to serialize
158 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
159 * @return the size of the encrypted block, -1 for errors
162 GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key,
167 * Deserialize an ABE master key.
169 * @param data the data to deserialize
170 * @param len the length of the data.
171 * @return the ABE key. NULL of unsuccessful
173 struct GNUNET_ABE_AbeMasterKey*
174 GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
178 #if 0 /* keep Emacsens' auto-indent happy */
186 /* ifndef GNUNET_ABE_LIB_H */
188 /* end of gnunet_abe_lib.h */