GNUnet  0.11.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 65 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().

67 {
68  struct GNUNET_REVOCATION_Query *q = cls;
69 
71  "Revocation query MQ error\n");
72  q->func (q->func_cls,
75 }
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 85 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.

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

199 {
200  struct GNUNET_REVOCATION_Handle *h = cls;
201 
203  "Revocation MQ error\n");
204  h->func (h->func_cls,
205  GNUNET_SYSERR);
207 }
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
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 217 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.

219 {
220  struct GNUNET_REVOCATION_Handle *h = cls;
221 
223  "Revocation transmission result: %d\n",
224  (uint32_t) ntohl (rrm->is_valid));
225  h->func (h->func_cls,
226  ntohl (rrm->is_valid));
228 }
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
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:128
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 334 of file revocation_api.c.

References GNUNET_break.

Referenced by GNUNET_REVOCATION_check_pow().

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

References GNUNET_CRYPTO_hash_get_bit().

Referenced by GNUNET_REVOCATION_check_pow().

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