1 /** \ingroup KeyGeneration
3 * @author David Llewellyn-Jones <david@flypig.co.uk>
8 * Copyright David Llewellyn-Jones, 2020
9 * Released under the GPLv2.
11 * @brief Core Contact Tracing functionality
12 * @section DESCRIPTION
14 * This class provides the core Contact Tracing functionality. It provides an
16 * 1. Generating a random Tracing Key.
17 * 2. Generating a Daily Tracing Key based on the current day number.
18 * 3. Generating a Rolling Proximity Identifier based on the current time
21 * Values can be extracted and set in binary or base64 format.
25 /** \addtogroup KeyGeneration
39 // Data sizes in bytes
42 * The size in bytes of a Tracing Key in binary format
47 * The size in bytes of a Tracing Key in base64 format
49 #define TK_SIZE_BASE64 (44)
54 * An opaque structure for storing the main state.
56 * The internal structure can be found in contrac.c
58 typedef struct _Contrac Contrac
;
60 // Function prototypes
62 Contrac
* contrac_new();
63 void contrac_delete(Contrac
* data
);
65 bool contrac_generate_tracing_key(Contrac
* data
);
66 bool contrac_set_day_number(Contrac
* data
, uint32_t day_number
);
67 bool contrac_set_time_interval_number(Contrac
* data
, uint8_t time_interval_number
);
68 bool contrac_update_current_time(Contrac
* data
);
69 bool contrac_get_initialised(Contrac
const * data
);
71 unsigned char const * contrac_get_tracing_key(Contrac
const * data
);
72 void contrac_get_tracing_key_base64(Contrac
const * data
, char * base64
);
74 void contrac_set_tracing_key(Contrac
* data
, unsigned char const * tracing_key
);
75 bool contrac_set_tracing_key_base64(Contrac
* data
, char const * tracing_key
);
77 unsigned char const * contrac_get_daily_key(Contrac
const * data
);
78 void contrac_get_daily_key_base64(Contrac
const * data
, char * base64
);
80 unsigned char const * contrac_get_proximity_id(Contrac
const * data
);
81 void contrac_get_proximity_id_base64(Contrac
const * data
, char * base64
);
83 // Function definitions
87 /** @} addtogroup KeyGeneration */