diff options
author | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2018-01-03 10:11:40 +0100 |
---|---|---|
committer | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2018-01-03 10:11:40 +0100 |
commit | fb85cf602c67994646c156aa9e05d2b9aa10816c (patch) | |
tree | ed14e694bb1ce9c11e7cebd0aa445ad41f7c2c7e /src/include/gnunet_abe_lib.h | |
parent | 7c1f035ed971e12882cd7a65c7d36883842945b1 (diff) | |
download | gnunet-fb85cf602c67994646c156aa9e05d2b9aa10816c.tar.gz gnunet-fb85cf602c67994646c156aa9e05d2b9aa10816c.zip |
-move abe functionality out of util; prepare for release
Diffstat (limited to 'src/include/gnunet_abe_lib.h')
-rw-r--r-- | src/include/gnunet_abe_lib.h | 143 |
1 files changed, 143 insertions, 0 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 | ||
34 | extern "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 | */ | ||
47 | struct GNUNET_CRYPTO_AbeMasterKey; | ||
48 | |||
49 | /** | ||
50 | * @brief type for ABE keys | ||
51 | */ | ||
52 | struct 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 | */ | ||
62 | struct GNUNET_ABE_AbeMasterKey * | ||
63 | GNUNET_ABE_cpabe_create_master_key (void); | ||
64 | void | ||
65 | GNUNET_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 | */ | ||
73 | struct GNUNET_ABE_AbeKey * | ||
74 | GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *msk, | ||
75 | char **attrs); | ||
76 | void | ||
77 | GNUNET_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 | */ | ||
92 | ssize_t | ||
93 | GNUNET_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 | */ | ||
110 | ssize_t | ||
111 | GNUNET_ABE_cpabe_decrypt (const void *block, | ||
112 | size_t size, | ||
113 | const struct GNUNET_ABE_AbeKey *key, | ||
114 | void **result); | ||
115 | |||
116 | ssize_t | ||
117 | GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key, | ||
118 | void **result); | ||
119 | |||
120 | struct GNUNET_ABE_AbeKey* | ||
121 | GNUNET_ABE_cpabe_deserialize_key (const void *data, | ||
122 | size_t len); | ||
123 | |||
124 | ssize_t | ||
125 | GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key, | ||
126 | void **result); | ||
127 | |||
128 | struct GNUNET_ABE_AbeMasterKey* | ||
129 | GNUNET_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 */ | ||