diff options
Diffstat (limited to 'src/include/gnunet_abe_lib.h')
-rw-r--r-- | src/include/gnunet_abe_lib.h | 74 |
1 files changed, 62 insertions, 12 deletions
diff --git a/src/include/gnunet_abe_lib.h b/src/include/gnunet_abe_lib.h index 77b0f9e99..f73ea2431 100644 --- a/src/include/gnunet_abe_lib.h +++ b/src/include/gnunet_abe_lib.h | |||
@@ -19,8 +19,8 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file include/gnunet_crypto_lib.h | 22 | * @file include/gnunet_abe_lib.h |
23 | * @brief cryptographic primitives for GNUnet | 23 | * @brief Attribute-Based Encryption primitives for GNUnet |
24 | * | 24 | * |
25 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
26 | * | 26 | * |
@@ -57,10 +57,18 @@ struct GNUNET_CRYPTO_AbeKey; | |||
57 | * @ingroup abe | 57 | * @ingroup abe |
58 | * Create a new CP-ABE master key. Caller must free return value. | 58 | * Create a new CP-ABE master key. Caller must free return value. |
59 | * | 59 | * |
60 | * @return fresh private key; free using #GNUNET_free | 60 | * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key |
61 | */ | 61 | */ |
62 | struct GNUNET_ABE_AbeMasterKey * | 62 | struct GNUNET_ABE_AbeMasterKey * |
63 | GNUNET_ABE_cpabe_create_master_key (void); | 63 | GNUNET_ABE_cpabe_create_master_key (void); |
64 | |||
65 | /** | ||
66 | * @ingroup abe | ||
67 | * Delete a CP-ABE master key. | ||
68 | * | ||
69 | * @param key the master key | ||
70 | * @return fresh private key; free using #GNUNET_free | ||
71 | */ | ||
64 | void | 72 | void |
65 | GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key); | 73 | GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key); |
66 | 74 | ||
@@ -68,11 +76,22 @@ GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key); | |||
68 | * @ingroup abe | 76 | * @ingroup abe |
69 | * Create a new CP-ABE key. Caller must free return value. | 77 | * Create a new CP-ABE key. Caller must free return value. |
70 | * | 78 | * |
71 | * @return fresh private key; free using #GNUNET_free | 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 | ||
72 | */ | 82 | */ |
73 | struct GNUNET_ABE_AbeKey * | 83 | struct GNUNET_ABE_AbeKey * |
74 | GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *msk, | 84 | GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key, |
75 | char **attrs); | 85 | char **attrs); |
86 | |||
87 | /** | ||
88 | * @ingroup abe | ||
89 | * Delete a CP-ABE key. | ||
90 | * | ||
91 | * @param key the key to delete | ||
92 | * @param delete_pub GNUNE_YES if the public key should also be freed (bug in gabe) | ||
93 | * @return fresh private key; free using #GNUNET_free | ||
94 | */ | ||
76 | void | 95 | void |
77 | GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key, | 96 | GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key, |
78 | int delete_pub); | 97 | int delete_pub); |
@@ -84,9 +103,9 @@ GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key, | |||
84 | * | 103 | * |
85 | * @param block the block to encrypt | 104 | * @param block the block to encrypt |
86 | * @param size the size of the @a block | 105 | * @param size the size of the @a block |
87 | * @param sessionkey the key used to encrypt | 106 | * @param policy the ABE policy |
88 | * @param iv the initialization vector to use, use INITVALUE | 107 | * @param key the key used to encrypt |
89 | * for streams. | 108 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free |
90 | * @return the size of the encrypted block, -1 for errors | 109 | * @return the size of the encrypted block, -1 for errors |
91 | */ | 110 | */ |
92 | ssize_t | 111 | ssize_t |
@@ -98,13 +117,12 @@ GNUNET_ABE_cpabe_encrypt (const void *block, | |||
98 | 117 | ||
99 | /** | 118 | /** |
100 | * @ingroup abe | 119 | * @ingroup abe |
101 | * Encrypt a block using sessionkey. | 120 | * Decrypt a block using the ABE key. |
102 | * | 121 | * |
103 | * @param block the block to encrypt | 122 | * @param block the block to encrypt |
104 | * @param size the size of the @a block | 123 | * @param size the size of the @a block |
105 | * @param sessionkey the key used to encrypt | 124 | * @param key the key used to decrypt |
106 | * @param iv the initialization vector to use, use INITVALUE | 125 | * @param result the result buffer. Will be allocated. Free using #GNUNET_free |
107 | * for streams. | ||
108 | * @return the size of the encrypted block, -1 for errors | 126 | * @return the size of the encrypted block, -1 for errors |
109 | */ | 127 | */ |
110 | ssize_t | 128 | ssize_t |
@@ -113,18 +131,50 @@ GNUNET_ABE_cpabe_decrypt (const void *block, | |||
113 | const struct GNUNET_ABE_AbeKey *key, | 131 | const struct GNUNET_ABE_AbeKey *key, |
114 | void **result); | 132 | void **result); |
115 | 133 | ||
134 | /** | ||
135 | * @ingroup abe | ||
136 | * Serialize an ABE key. | ||
137 | * | ||
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 | ||
141 | */ | ||
116 | ssize_t | 142 | ssize_t |
117 | GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key, | 143 | GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key, |
118 | void **result); | 144 | void **result); |
119 | 145 | ||
146 | /** | ||
147 | * @ingroup abe | ||
148 | * Deserialize a serialized ABE key. | ||
149 | * | ||
150 | * @param data the data to deserialize | ||
151 | * @param len the length of the data. | ||
152 | * @return the ABE key. NULL of unsuccessful | ||
153 | */ | ||
120 | struct GNUNET_ABE_AbeKey* | 154 | struct GNUNET_ABE_AbeKey* |
121 | GNUNET_ABE_cpabe_deserialize_key (const void *data, | 155 | GNUNET_ABE_cpabe_deserialize_key (const void *data, |
122 | size_t len); | 156 | size_t len); |
123 | 157 | ||
158 | /** | ||
159 | * @ingroup abe | ||
160 | * Serialize an ABE master key. | ||
161 | * | ||
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 | ||
165 | */ | ||
124 | ssize_t | 166 | ssize_t |
125 | GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key, | 167 | GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key, |
126 | void **result); | 168 | void **result); |
127 | 169 | ||
170 | /** | ||
171 | * @ingroup abe | ||
172 | * Deserialize an ABE master key. | ||
173 | * | ||
174 | * @param data the data to deserialize | ||
175 | * @param len the length of the data. | ||
176 | * @return the ABE key. NULL of unsuccessful | ||
177 | */ | ||
128 | struct GNUNET_ABE_AbeMasterKey* | 178 | struct GNUNET_ABE_AbeMasterKey* |
129 | GNUNET_ABE_cpabe_deserialize_master_key (const void *data, | 179 | GNUNET_ABE_cpabe_deserialize_master_key (const void *data, |
130 | size_t len); | 180 | size_t len); |