summaryrefslogtreecommitdiff
path: root/src/revocation/plugin_block_revocation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/revocation/plugin_block_revocation.c')
-rw-r--r--src/revocation/plugin_block_revocation.c179
1 files changed, 88 insertions, 91 deletions
diff --git a/src/revocation/plugin_block_revocation.c b/src/revocation/plugin_block_revocation.c
index 2d03eb8b2..e7b4a8cde 100644
--- a/src/revocation/plugin_block_revocation.c
+++ b/src/revocation/plugin_block_revocation.c
@@ -11,12 +11,12 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
/**
* @file block/plugin_block_revocation.c
@@ -49,11 +49,8 @@
/**
* Context used inside the plugin.
*/
-struct InternalContext
-{
-
+struct InternalContext {
unsigned int matching_bits;
-
};
@@ -70,37 +67,37 @@ struct InternalContext
* by this @a type of block (this is not an error)
*/
static struct GNUNET_BLOCK_Group *
-block_plugin_revocation_create_group (void *cls,
- enum GNUNET_BLOCK_Type type,
- uint32_t nonce,
- const void *raw_data,
- size_t raw_data_size,
- va_list va)
+block_plugin_revocation_create_group(void *cls,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t nonce,
+ const void *raw_data,
+ size_t raw_data_size,
+ va_list va)
{
unsigned int bf_size;
const char *guard;
- guard = va_arg (va, const char *);
- if (0 == strcmp (guard,
- "seen-set-size"))
- bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int),
- BLOOMFILTER_K);
- else if (0 == strcmp (guard,
- "filter-size"))
- bf_size = va_arg (va, unsigned int);
+ guard = va_arg(va, const char *);
+ if (0 == strcmp(guard,
+ "seen-set-size"))
+ bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size(va_arg(va, unsigned int),
+ BLOOMFILTER_K);
+ else if (0 == strcmp(guard,
+ "filter-size"))
+ bf_size = va_arg(va, unsigned int);
else
- {
- GNUNET_break (0);
- bf_size = REVOCATION_BF_SIZE;
- }
- GNUNET_break (NULL == va_arg (va, const char *));
- return GNUNET_BLOCK_GROUP_bf_create (cls,
- bf_size,
- BLOOMFILTER_K,
- type,
- nonce,
- raw_data,
- raw_data_size);
+ {
+ GNUNET_break(0);
+ bf_size = REVOCATION_BF_SIZE;
+ }
+ GNUNET_break(NULL == va_arg(va, const char *));
+ return GNUNET_BLOCK_GROUP_bf_create(cls,
+ bf_size,
+ BLOOMFILTER_K,
+ type,
+ nonce,
+ raw_data,
+ raw_data_size);
}
@@ -121,16 +118,16 @@ block_plugin_revocation_create_group (void *cls,
* @return characterization of result
*/
static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_revocation_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
+block_plugin_revocation_evaluate(void *cls,
+ struct GNUNET_BLOCK_Context *ctx,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_BLOCK_Group *group,
+ enum GNUNET_BLOCK_EvaluationOptions eo,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size,
+ const void *reply_block,
+ size_t reply_block_size)
{
struct InternalContext *ic = cls;
struct GNUNET_HashCode chash;
@@ -138,34 +135,34 @@ block_plugin_revocation_evaluate (void *cls,
if (NULL == reply_block)
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- if (reply_block_size != sizeof (*rm))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
+ if (reply_block_size != sizeof(*rm))
+ {
+ GNUNET_break_op(0);
+ return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ }
if (GNUNET_YES !=
- GNUNET_REVOCATION_check_pow (&rm->public_key,
- rm->proof_of_work,
- ic->matching_bits))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
+ GNUNET_REVOCATION_check_pow(&rm->public_key,
+ rm->proof_of_work,
+ ic->matching_bits))
+ {
+ GNUNET_break_op(0);
+ return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ }
if (GNUNET_OK !=
- GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_REVOCATION,
- &rm->purpose,
- &rm->signature,
- &rm->public_key))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- GNUNET_CRYPTO_hash (&rm->public_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
- &chash);
+ GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_REVOCATION,
+ &rm->purpose,
+ &rm->signature,
+ &rm->public_key))
+ {
+ GNUNET_break_op(0);
+ return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ }
+ GNUNET_CRYPTO_hash(&rm->public_key,
+ sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
+ &chash);
if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (group,
- &chash))
+ GNUNET_BLOCK_GROUP_bf_test_and_set(group,
+ &chash))
return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
}
@@ -183,22 +180,22 @@ block_plugin_revocation_evaluate (void *cls,
* (or if extracting a key from a block of this type does not work)
*/
static int
-block_plugin_revocation_get_key (void *cls,
- enum GNUNET_BLOCK_Type type,
- const void *block,
- size_t block_size,
- struct GNUNET_HashCode *key)
+block_plugin_revocation_get_key(void *cls,
+ enum GNUNET_BLOCK_Type type,
+ const void *block,
+ size_t block_size,
+ struct GNUNET_HashCode *key)
{
const struct RevokeMessage *rm = block;
- if (block_size != sizeof (*rm))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- GNUNET_CRYPTO_hash (&rm->public_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
- key);
+ if (block_size != sizeof(*rm))
+ {
+ GNUNET_break_op(0);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_CRYPTO_hash(&rm->public_key,
+ sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
+ key);
return GNUNET_OK;
}
@@ -209,7 +206,7 @@ block_plugin_revocation_get_key (void *cls,
* @param cls the configuration to use
*/
void *
-libgnunet_plugin_block_revocation_init (void *cls)
+libgnunet_plugin_block_revocation_init(void *cls)
{
static enum GNUNET_BLOCK_Type types[] =
{
@@ -222,19 +219,19 @@ libgnunet_plugin_block_revocation_init (void *cls)
unsigned long long matching_bits;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "REVOCATION",
- "WORKBITS",
- &matching_bits))
+ GNUNET_CONFIGURATION_get_value_number(cfg,
+ "REVOCATION",
+ "WORKBITS",
+ &matching_bits))
return NULL;
- api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
+ api = GNUNET_new(struct GNUNET_BLOCK_PluginFunctions);
api->evaluate = &block_plugin_revocation_evaluate;
api->get_key = &block_plugin_revocation_get_key;
api->create_group = &block_plugin_revocation_create_group;
api->types = types;
- ic = GNUNET_new (struct InternalContext);
- ic->matching_bits = (unsigned int) matching_bits;
+ ic = GNUNET_new(struct InternalContext);
+ ic->matching_bits = (unsigned int)matching_bits;
api->cls = ic;
return api;
}
@@ -244,13 +241,13 @@ libgnunet_plugin_block_revocation_init (void *cls)
* Exit point from the plugin.
*/
void *
-libgnunet_plugin_block_revocation_done (void *cls)
+libgnunet_plugin_block_revocation_done(void *cls)
{
struct GNUNET_BLOCK_PluginFunctions *api = cls;
struct InternalContext *ic = api->cls;
- GNUNET_free (ic);
- GNUNET_free (api);
+ GNUNET_free(ic);
+ GNUNET_free(api);
return NULL;
}