aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_block_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-24 13:46:07 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-24 13:46:07 +0000
commit8d9525a642c6bd74a2903ccb6358da8ebb081864 (patch)
tree1e26db482e5ab9869bbc5cc687e1cd27c592eda6 /src/include/gnunet_block_lib.h
parent32892c4aa7736eb8039f28d79b5cdb53cdc0061c (diff)
downloadgnunet-8d9525a642c6bd74a2903ccb6358da8ebb081864.tar.gz
gnunet-8d9525a642c6bd74a2903ccb6358da8ebb081864.zip
blocklib
Diffstat (limited to 'src/include/gnunet_block_lib.h')
-rw-r--r--src/include/gnunet_block_lib.h249
1 files changed, 249 insertions, 0 deletions
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
new file mode 100644
index 000000000..513605eb2
--- /dev/null
+++ b/src/include/gnunet_block_lib.h
@@ -0,0 +1,249 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
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 2, 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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file include/gnunet_block_lib.h
23 * @brief library for data block manipulation
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_BLOCK_LIB_H
27#define GNUNET_BLOCK_LIB_H
28
29#include "gnunet_util_lib.h"
30#ifdef __cplusplus
31extern "C"
32{
33#if 0 /* keep Emacsens' auto-indent happy */
34}
35#endif
36#endif
37
38/**
39 * Blocks in the datastore and the datacache must have a unique type.
40 */
41enum GNUNET_BLOCK_Type
42 {
43 /**
44 * Any type of block, used as a wildcard when searching. Should
45 * never be attached to a specific block.
46 */
47 GNUNET_BLOCK_TYPE_ANY = 0,
48
49 /**
50 * Data block (leaf) in the CHK tree.
51 */
52 GNUNET_BLOCK_TYPE_DBLOCK = 1,
53
54 /**
55 * Inner block in the CHK tree.
56 */
57 GNUNET_BLOCK_TYPE_IBLOCK = 2,
58
59 /**
60 * Type of a block representing a keyword search result.
61 */
62 GNUNET_BLOCK_TYPE_KBLOCK = 3,
63
64 /**
65 * Type of a block that is used to advertise content in a namespace.
66 */
67 GNUNET_BLOCK_TYPE_SBLOCK = 4,
68
69 /**
70 * Type of a block representing a block to be encoded on demand from disk.
71 * Should never appear on the network directly.
72 */
73 GNUNET_BLOCK_TYPE_ONDEMAND = 5,
74
75 /**
76 * Type of a block that is used to advertise a namespace.
77 */
78 GNUNET_BLOCK_TYPE_NBLOCK = 6
79
80 };
81
82
83
84
85
86/**
87 * @brief keyword block (advertising data under a keyword)
88 */
89struct KBlock
90{
91
92 /**
93 * GNUNET_RSA_Signature using RSA-key generated from search keyword.
94 */
95 struct GNUNET_CRYPTO_RsaSignature signature;
96
97 /**
98 * What is being signed and why?
99 */
100 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
101
102 /**
103 * Key generated (!) from the H(keyword) as the seed!
104 */
105 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
106
107 /* 0-terminated URI here */
108
109 /* variable-size Meta-Data follows here */
110
111};
112
113/**
114 * @brief namespace content block (advertising data under an identifier in a namespace)
115 */
116struct SBlock
117{
118
119 /**
120 * GNUNET_RSA_Signature using RSA-key of the namespace
121 */
122 struct GNUNET_CRYPTO_RsaSignature signature;
123
124 /**
125 * What is being signed and why?
126 */
127 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
128
129 /**
130 * Hash of the hash of the human-readable identifier used for
131 * this entry (the hash of the human-readable identifier is
132 * used as the key for decryption; the xor of this identifier
133 * and the hash of the "keyspace" is the datastore-query hash).
134 */
135 GNUNET_HashCode identifier;
136
137 /**
138 * Public key of the namespace.
139 */
140 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
141
142 /* 0-terminated update-identifier here */
143
144 /* 0-terminated URI here (except for NBlocks) */
145
146 /* variable-size Meta-Data follows here */
147
148};
149
150
151/**
152 * @brief namespace advertisement block (advertising root of a namespace)
153 */
154struct NBlock
155{
156
157 /**
158 * GNUNET_RSA_Signature using RSA-key generated from search keyword.
159 */
160 struct GNUNET_CRYPTO_RsaSignature ksk_signature;
161
162 /**
163 * What is being signed and why?
164 */
165 struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose;
166
167 /**
168 * Key generated (!) from the H(keyword) as the seed!
169 */
170 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
171
172 /**
173 * GNUNET_RSA_Signature using RSA-key of the namespace
174 */
175 struct GNUNET_CRYPTO_RsaSignature ns_signature;
176
177 /**
178 * What is being signed and why?
179 */
180 struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose;
181
182 /**
183 * Public key of the namespace.
184 */
185 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
186
187 /* from here on, data is encrypted with H(keyword) */
188
189 /* 0-terminated root identifier here */
190
191 /* variable-size Meta-Data follows here */
192
193};
194
195
196
197
198/**
199 * @brief index block (indexing a DBlock that
200 * can be obtained directly from reading
201 * the plaintext file)
202 */
203struct OnDemandBlock
204{
205 /**
206 * Hash code of the entire content of the
207 * file that was indexed (used to uniquely
208 * identify the plaintext file).
209 */
210 GNUNET_HashCode file_id;
211
212 /**
213 * At which offset should we be able to find
214 * this on-demand encoded block? (in NBO)
215 */
216 uint64_t offset GNUNET_PACKED;
217
218};
219
220
221/**
222 * Check if the given block is well-formed (and of the given type).
223 *
224 * @param type type of the block
225 * @param block the block data (or at least "size" bytes claiming to be one)
226 * @param size size of "kb" in bytes; check that it is large enough
227 * @param query where to store the query that this block answers
228 * @return GNUNET_OK if this is actually a well-formed KBlock
229 * GNUNET_NO if we could not determine the query,
230 * GNUNET_SYSERR if the block is malformed
231 */
232int
233GNUNET_BLOCK_check_block (enum GNUNET_BLOCK_Type type,
234 const void *block,
235 size_t size,
236 GNUNET_HashCode *query);
237
238
239#if 0 /* keep Emacsens' auto-indent happy */
240{
241#endif
242#ifdef __cplusplus
243}
244#endif
245
246
247/* ifndef GNUNET_BLOCK_LIB_H */
248#endif
249/* end of gnunet_block_lib.h */