2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file include/gnunet_block_lib.h
23 * @brief library for data block manipulation
24 * @author Christian Grothoff
26 #ifndef GNUNET_BLOCK_LIB_H
27 #define GNUNET_BLOCK_LIB_H
29 #include "gnunet_util_lib.h"
33 #if 0 /* keep Emacsens' auto-indent happy */
39 * Blocks in the datastore and the datacache must have a unique type.
41 enum GNUNET_BLOCK_Type
44 * Any type of block, used as a wildcard when searching. Should
45 * never be attached to a specific block.
47 GNUNET_BLOCK_TYPE_ANY = 0,
50 * Data block (leaf) in the CHK tree.
52 GNUNET_BLOCK_TYPE_DBLOCK = 1,
55 * Inner block in the CHK tree.
57 GNUNET_BLOCK_TYPE_IBLOCK = 2,
60 * Type of a block representing a keyword search result.
62 GNUNET_BLOCK_TYPE_KBLOCK = 3,
65 * Type of a block that is used to advertise content in a namespace.
67 GNUNET_BLOCK_TYPE_SBLOCK = 4,
70 * Type of a block representing a block to be encoded on demand from disk.
71 * Should never appear on the network directly.
73 GNUNET_BLOCK_TYPE_ONDEMAND = 5,
76 * Type of a block that is used to advertise a namespace.
78 GNUNET_BLOCK_TYPE_NBLOCK = 6
84 * @brief keyword block (advertising data under a keyword)
90 * GNUNET_RSA_Signature using RSA-key generated from search keyword.
92 struct GNUNET_CRYPTO_RsaSignature signature;
95 * What is being signed and why?
97 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
100 * Key generated (!) from the H(keyword) as the seed!
102 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
104 /* 0-terminated URI here */
106 /* variable-size Meta-Data follows here */
112 * @brief namespace content block (advertising data under an identifier in a namespace)
118 * GNUNET_RSA_Signature using RSA-key of the namespace
120 struct GNUNET_CRYPTO_RsaSignature signature;
123 * What is being signed and why?
125 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
128 * Hash of the hash of the human-readable identifier used for
129 * this entry (the hash of the human-readable identifier is
130 * used as the key for decryption; the xor of this identifier
131 * and the hash of the "keyspace" is the datastore-query hash).
133 GNUNET_HashCode identifier;
136 * Public key of the namespace.
138 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
140 /* 0-terminated update-identifier here */
142 /* 0-terminated URI here (except for NBlocks) */
144 /* variable-size Meta-Data follows here */
150 * @brief namespace advertisement block (advertising root of a namespace)
156 * GNUNET_RSA_Signature using RSA-key generated from search keyword.
158 struct GNUNET_CRYPTO_RsaSignature ksk_signature;
161 * What is being signed and why?
163 struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose;
166 * Key generated (!) from the H(keyword) as the seed!
168 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
171 * GNUNET_RSA_Signature using RSA-key of the namespace
173 struct GNUNET_CRYPTO_RsaSignature ns_signature;
176 * What is being signed and why?
178 struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose;
181 * Public key of the namespace.
183 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
185 /* from here on, data is encrypted with H(keyword) */
187 /* 0-terminated root identifier here */
189 /* variable-size Meta-Data follows here */
195 * @brief index block (indexing a DBlock that
196 * can be obtained directly from reading
197 * the plaintext file)
202 * Hash code of the entire content of the
203 * file that was indexed (used to uniquely
204 * identify the plaintext file).
206 GNUNET_HashCode file_id;
209 * At which offset should we be able to find
210 * this on-demand encoded block? (in NBO)
212 uint64_t offset GNUNET_PACKED;
218 * Check if the given block is well-formed (and of the given type).
220 * @param type type of the block
221 * @param block the block data (or at least "size" bytes claiming to be one)
222 * @param size size of "kb" in bytes; check that it is large enough
223 * @param query where to store the query that this block answers
224 * @return GNUNET_OK if this is actually a well-formed KBlock
225 * GNUNET_NO if we could not determine the query,
226 * GNUNET_SYSERR if the block is malformed
229 GNUNET_BLOCK_check_block (enum GNUNET_BLOCK_Type type,
232 GNUNET_HashCode *query);
235 #if 0 /* keep Emacsens' auto-indent happy */
243 /* ifndef GNUNET_BLOCK_LIB_H */
245 /* end of gnunet_block_lib.h */