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 67 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().

69 {
70  struct GNUNET_REVOCATION_Query *q = cls;
71 
73  "Revocation query MQ error\n");
74  q->func (q->func_cls,
77 }
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:79
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 87 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.

89 {
90  struct GNUNET_REVOCATION_Query *q = cls;
91 
93  "Revocation query result: %d\n",
94  (uint32_t) ntohl (qrm->is_valid));
95  q->func (q->func_cls,
96  ntohl (qrm->is_valid));
98 }
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:69
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 201 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().

203 {
204  struct GNUNET_REVOCATION_Handle *h = cls;
205 
207  "Revocation MQ error\n");
208  h->func (h->func_cls,
209  GNUNET_SYSERR);
211 }
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:79
#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 221 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.

223 {
224  struct GNUNET_REVOCATION_Handle *h = cls;
225 
227  "Revocation transmission result: %d\n",
228  (uint32_t) ntohl (rrm->is_valid));
229  h->func (h->func_cls,
230  ntohl (rrm->is_valid));
232 }
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:131
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 338 of file revocation_api.c.

References GNUNET_break.

Referenced by GNUNET_REVOCATION_check_pow().

341 {
342  GNUNET_break (0 ==
343  gcry_kdf_derive (buf, buf_len,
344  GCRY_KDF_SCRYPT,
345  1 /* subalgo */,
346  "gnunet-revocation-proof-of-work",
347  strlen ("gnunet-revocation-proof-of-work"),
348  2 /* iterations; keep cost of individual op small */,
349  sizeof (struct GNUNET_HashCode), result));
350 }
#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 360 of file revocation_api.c.

References GNUNET_CRYPTO_hash_get_bit().

Referenced by GNUNET_REVOCATION_check_pow().

361 {
362  unsigned int hash_count;
363 
364  hash_count = 0;
365  while ((0 == GNUNET_CRYPTO_hash_get_bit (hash, hash_count)))
366  hash_count++;
367  return hash_count;
368 }
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: