libcontrac
A library for contact tracing
Data Structures | Macros | Functions
contrac.c File Reference

Core Contact Tracing functionality. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <time.h>
#include <openssl/crypto.h>
#include <openssl/rand.h>
#include <openssl/err.h>
#include "contrac/log.h"
#include "contrac/utils.h"
#include "contrac/rpi.h"
#include "contrac/contrac.h"
Include dependency graph for contrac.c:

Data Structures

struct  Contrac
 The core structure for storing Contact Tracing state. More...
 

Macros

#define STATUS_TK   (1 << 0)
 
#define STATUS_DTK   (1 << 1)
 
#define STATUS_RPI   (1 << 2)
 
#define STATUS_INITIALISED   (STATUS_TK | STATUS_DTK | STATUS_RPI)
 

Functions

Contrac * contrac_new ()
 
void contrac_delete (Contrac *data)
 
bool contrac_generate_tracing_key (Contrac *data)
 
bool contrac_set_day_number (Contrac *data, uint32_t day_number)
 
bool contrac_set_time_interval_number (Contrac *data, uint8_t time_interval_number)
 
bool contrac_get_initialised (Contrac const *data)
 
uint32_t contrac_get_day_number (Contrac *data)
 
uint8_t contrac_get_time_interval_number (Contrac *data)
 
void contrac_set_tracing_key (Contrac *data, unsigned char const *tracing_key)
 
unsigned char const * contrac_get_tracing_key (Contrac const *data)
 
void contrac_get_tracing_key_base64 (Contrac const *data, char *base64)
 
bool contrac_set_tracing_key_base64 (Contrac *data, char const *tracing_key)
 
unsigned char const * contrac_get_daily_key (Contrac const *data)
 
void contrac_get_daily_key_base64 (Contrac const *data, char *base64)
 
unsigned char const * contrac_get_proximity_id (Contrac const *data)
 
void contrac_get_proximity_id_base64 (Contrac const *data, char *base64)
 
bool contrac_update_current_time (Contrac *data)
 

Detailed Description

Core Contact Tracing functionality.

Author
David Llewellyn-Jones david.nosp@m.@fly.nosp@m.pig.c.nosp@m.o.uk
Version
0.01

LICENSE

Copyright David Llewellyn-Jones, 2020 Released under the GPLv2.

DESCRIPTION

This class provides the core Contact Tracing functionality. It provides an interfaces for:

  1. Generating a random Tracing Key.
  2. Generating a Daily Tracing Key based on the current day number.
  3. Generating a Rolling Proximity Identifier based on the current time interval number.

Values can be extracted and set in binary or base64 format.