*/
#include "platform.h"
-#include "plugin_block.h"
+#include "gnunet_block_plugin.h"
#include "block_fs.h"
#include "gnunet_signatures.h"
*/
#define BLOOMFILTER_K 16
-/**
- * Mingle hash with the mingle_number to produce different bits.
- */
-static void
-mingle_hash (const GNUNET_HashCode * in,
- int32_t mingle_number,
- GNUNET_HashCode * hc)
-{
- GNUNET_HashCode m;
-
- GNUNET_CRYPTO_hash (&mingle_number,
- sizeof (int32_t),
- &m);
- GNUNET_CRYPTO_hash_xor (&m, in, hc);
-}
-
-
/**
* Function called to validate a reply or a request. For
* request evaluation, simply pass "NULL" for the reply_block.
switch (type)
{
- case GNUNET_BLOCK_TYPE_DBLOCK:
- case GNUNET_BLOCK_TYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_DBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_IBLOCK:
if (xquery_size != 0)
{
GNUNET_break_op (0);
if (reply_block == NULL)
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
return GNUNET_BLOCK_EVALUATION_OK_LAST;
- case GNUNET_BLOCK_TYPE_KBLOCK:
- case GNUNET_BLOCK_TYPE_NBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_KBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_NBLOCK:
if (xquery_size != 0)
{
GNUNET_break_op (0);
GNUNET_CRYPTO_hash (reply_block,
reply_block_size,
&chash);
- mingle_hash (&chash, bf_mutator, &mhash);
+ GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
if (NULL != *bf)
{
if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf,
}
GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
return GNUNET_BLOCK_EVALUATION_OK_MORE;
- case GNUNET_BLOCK_TYPE_SBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_SBLOCK:
if (xquery_size != sizeof (GNUNET_HashCode))
{
GNUNET_break_op (0);
if (reply_block == NULL)
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
nsid = xquery;
- if (reply_block_size < sizeof (struct NBlock))
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ if (reply_block_size < sizeof (struct SBlock))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ }
sb = reply_block;
GNUNET_CRYPTO_hash (&sb->subspace,
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
&sh,
sizeof (GNUNET_HashCode)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Reply mismatched in terms of namespace. Discarded.\n"));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
+ "block-fs",
+ _("Reply mismatched in terms of namespace. Discarded.\n"));
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
}
GNUNET_CRYPTO_hash (reply_block,
reply_block_size,
&chash);
- mingle_hash (&chash, bf_mutator, &mhash);
+ GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
if (NULL != *bf)
{
if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf,
switch (type)
{
- case GNUNET_BLOCK_TYPE_DBLOCK:
- case GNUNET_BLOCK_TYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_DBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_IBLOCK:
GNUNET_CRYPTO_hash (block, block_size, key);
return GNUNET_OK;
- case GNUNET_BLOCK_TYPE_KBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_KBLOCK:
if (block_size < sizeof (struct KBlock))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
kb = block;
if (block_size - sizeof (struct KBlock) !=
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) )
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK,
&kb->keyspace))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
if (key != NULL)
GNUNET_CRYPTO_hash (&kb->keyspace,
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
key);
return GNUNET_OK;
- case GNUNET_BLOCK_TYPE_SBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_SBLOCK:
if (block_size < sizeof (struct SBlock))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
sb = block;
if (block_size !=
ntohl (sb->purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK,
&sb->subspace))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
if (key != NULL)
*key = sb->identifier;
return GNUNET_OK;
- case GNUNET_BLOCK_TYPE_NBLOCK:
+ case GNUNET_BLOCK_TYPE_FS_NBLOCK:
if (block_size < sizeof (struct NBlock))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
nb = block;
if (block_size - sizeof (struct NBlock) !=
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) )
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
if (block_size !=
ntohl (nb->ksk_purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG,
&nb->keyspace))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK,
&nb->subspace))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
/* FIXME: we used to xor ID with NSID,
why not here? */
{
static enum GNUNET_BLOCK_Type types[] =
{
- GNUNET_BLOCK_TYPE_DBLOCK,
- GNUNET_BLOCK_TYPE_IBLOCK,
- GNUNET_BLOCK_TYPE_KBLOCK,
- GNUNET_BLOCK_TYPE_SBLOCK,
- GNUNET_BLOCK_TYPE_NBLOCK,
+ GNUNET_BLOCK_TYPE_FS_DBLOCK,
+ GNUNET_BLOCK_TYPE_FS_IBLOCK,
+ GNUNET_BLOCK_TYPE_FS_KBLOCK,
+ GNUNET_BLOCK_TYPE_FS_SBLOCK,
+ GNUNET_BLOCK_TYPE_FS_NBLOCK,
GNUNET_BLOCK_TYPE_ANY /* end of list */
};
struct GNUNET_BLOCK_PluginFunctions *api;