GNUnet  0.10.x
Data Structures | Functions
revocation_api.c File Reference

API to perform and access key revocations. More...

#include "platform.h"
#include "gnunet_revocation_service.h"
#include "gnunet_signatures.h"
#include "gnunet_protocols.h"
#include "revocation.h"
#include <gcrypt.h>
Include dependency graph for revocation_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_REVOCATION_Query
 Handle for the key revocation query. More...
 
struct  GNUNET_REVOCATION_Handle
 Handle for the key revocation operation. More...
 

Functions

static void query_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
static void handle_revocation_query_response (void *cls, const struct QueryResponseMessage *qrm)
 Handle response to our revocation query. More...
 
struct GNUNET_REVOCATION_QueryGNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EcdsaPublicKey *key, GNUNET_REVOCATION_Callback func, void *func_cls)
 Check if a key was revoked. More...
 
void GNUNET_REVOCATION_query_cancel (struct GNUNET_REVOCATION_Query *q)
 Cancel key revocation check. More...
 
static void revocation_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
static void handle_revocation_response (void *cls, const struct RevocationResponseMessage *rrm)
 Handle response to our revocation query. More...
 
struct GNUNET_REVOCATION_HandleGNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EcdsaPublicKey *key, const struct GNUNET_CRYPTO_EcdsaSignature *sig, uint64_t pow, GNUNET_REVOCATION_Callback func, void *func_cls)
 Perform key revocation. More...
 
void GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h)
 Cancel key revocation. More...
 
static void pow_hash (const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
 Calculate the 'proof-of-work' hash (an expensive hash). More...
 
static unsigned int count_leading_zeroes (const struct GNUNET_HashCode *hash)
 Count the leading zeroes in hash. More...
 
int GNUNET_REVOCATION_check_pow (const struct GNUNET_CRYPTO_EcdsaPublicKey *key, uint64_t pow, unsigned int matching_bits)
 Check if the given proof-of-work value would be acceptable for revoking the given key. More...
 
void GNUNET_REVOCATION_sign_revocation (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_CRYPTO_EcdsaSignature *sig)
 Create a revocation signature. More...
 

Detailed Description

API to perform and access key revocations.

Author
Christian Grothoff

Definition in file revocation_api.c.

Function Documentation

◆ query_mq_error_handler()

static void query_mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_NSE_Handle *
errorerror code

Definition at line 64 of file revocation_api.c.

References GNUNET_REVOCATION_Query::func, GNUNET_REVOCATION_Query::func_cls, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_REVOCATION_query_cancel(), GNUNET_SYSERR, and q.

Referenced by GNUNET_REVOCATION_query().

66 {
67  struct GNUNET_REVOCATION_Query *q = cls;
68 
70  "Revocation query MQ error\n");
71  q->func(q->func_cls,
74 }
void GNUNET_REVOCATION_query_cancel(struct GNUNET_REVOCATION_Query *q)
Cancel key revocation check.
void * func_cls
Closure for func.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Handle for the key revocation query.
#define GNUNET_log(kind,...)
GNUNET_REVOCATION_Callback func
Function to call with the result.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_revocation_query_response()

static void handle_revocation_query_response ( void *  cls,
const struct QueryResponseMessage qrm 
)
static

Handle response to our revocation query.

Parameters
clsour struct GNUNET_REVOCATION_Query handle
qrmresponse we got

Definition at line 84 of file revocation_api.c.

References GNUNET_REVOCATION_Query::func, GNUNET_REVOCATION_Query::func_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_REVOCATION_query_cancel(), QueryResponseMessage::is_valid, and q.

86 {
87  struct GNUNET_REVOCATION_Query *q = cls;
88 
90  "Revocation query result: %d\n",
91  (uint32_t)ntohl(qrm->is_valid));
92  q->func(q->func_cls,
93  ntohl(qrm->is_valid));
95 }
void GNUNET_REVOCATION_query_cancel(struct GNUNET_REVOCATION_Query *q)
Cancel key revocation check.
void * func_cls
Closure for func.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:66
Handle for the key revocation query.
#define GNUNET_log(kind,...)
GNUNET_REVOCATION_Callback func
Function to call with the result.
Here is the call graph for this function:

◆ revocation_mq_error_handler()

static void revocation_mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_NSE_Handle *
errorerror code

Definition at line 195 of file revocation_api.c.

References GNUNET_REVOCATION_Handle::func, GNUNET_REVOCATION_Handle::func_cls, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_REVOCATION_revoke_cancel(), GNUNET_SYSERR, and h.

Referenced by GNUNET_REVOCATION_revoke().

197 {
198  struct GNUNET_REVOCATION_Handle *h = cls;
199 
201  "Revocation MQ error\n");
202  h->func(h->func_cls,
203  GNUNET_SYSERR);
205 }
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
void * func_cls
Closure for func.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
Handle for the key revocation operation.
GNUNET_REVOCATION_Callback func
Function to call once we are done.
void GNUNET_REVOCATION_revoke_cancel(struct GNUNET_REVOCATION_Handle *h)
Cancel key revocation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_revocation_response()

static void handle_revocation_response ( void *  cls,
const struct RevocationResponseMessage rrm 
)
static

Handle response to our revocation query.

Parameters
clsour struct GNUNET_REVOCATION_Handle handle
rrmresponse we got

Definition at line 215 of file revocation_api.c.

References GNUNET_REVOCATION_Handle::func, GNUNET_REVOCATION_Handle::func_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_REVOCATION_revoke_cancel(), h, and RevocationResponseMessage::is_valid.

217 {
218  struct GNUNET_REVOCATION_Handle *h = cls;
219 
221  "Revocation transmission result: %d\n",
222  (uint32_t)ntohl(rrm->is_valid));
223  h->func(h->func_cls,
224  ntohl(rrm->is_valid));
226 }
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
void * func_cls
Closure for func.
#define GNUNET_log(kind,...)
Handle for the key revocation operation.
GNUNET_REVOCATION_Callback func
Function to call once we are done.
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:124
void GNUNET_REVOCATION_revoke_cancel(struct GNUNET_REVOCATION_Handle *h)
Cancel key revocation.
Here is the call graph for this function:

◆ pow_hash()

static void pow_hash ( const void *  buf,
size_t  buf_len,
struct GNUNET_HashCode result 
)
static

Calculate the 'proof-of-work' hash (an expensive hash).

Parameters
bufdata to hash
buf_lennumber of bytes in buf
resultwhere to write the resulting hash

Definition at line 332 of file revocation_api.c.

References GNUNET_break.

Referenced by GNUNET_REVOCATION_check_pow().

335 {
336  GNUNET_break(0 ==
337  gcry_kdf_derive(buf, buf_len,
338  GCRY_KDF_SCRYPT,
339  1 /* subalgo */,
340  "gnunet-revocation-proof-of-work",
341  strlen("gnunet-revocation-proof-of-work"),
342  2 /* iterations; keep cost of individual op small */,
343  sizeof(struct GNUNET_HashCode), result));
344 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static char buf[2048]
A 512-bit hashcode.
Here is the caller graph for this function:

◆ count_leading_zeroes()

static unsigned int count_leading_zeroes ( const struct GNUNET_HashCode hash)
static

Count the leading zeroes in hash.

Parameters
hashto count leading zeros in
Returns
the number of leading zero bits.

Definition at line 354 of file revocation_api.c.

References GNUNET_CRYPTO_hash_get_bit().

Referenced by GNUNET_REVOCATION_check_pow().

355 {
356  unsigned int hash_count;
357 
358  hash_count = 0;
359  while ((0 == GNUNET_CRYPTO_hash_get_bit(hash, hash_count)))
360  hash_count++;
361  return hash_count;
362 }
int GNUNET_CRYPTO_hash_get_bit(const struct GNUNET_HashCode *code, unsigned int bit)
Obtain a bit from a hashcode.
Definition: crypto_hash.c:236
Here is the call graph for this function:
Here is the caller graph for this function: