Add remaining documentation
[libcontrac.git] / include / contrac / contrac.h
1 /** \ingroup KeyGeneration
2 * @file
3 * @author David Llewellyn-Jones <david@flypig.co.uk>
4 * @version $(VERSION)
5 *
6 * @section LICENSE
7 *
8 * Copyright David Llewellyn-Jones, 2020
9 * Released under the GPLv2.
10 *
11 * @brief Core Contact Tracing functionality
12 * @section DESCRIPTION
13 *
14 * This class provides the core Contact Tracing functionality. It provides an
15 * interfaces for:
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
19 * interval number.
20 *
21 * Values can be extracted and set in binary or base64 format.
22 *
23 */
24
25 /** \addtogroup KeyGeneration
26 * @{
27 */
28
29 #ifndef __CONTRAC_H
30 #define __CONTRAC_H
31
32 // Includes
33
34 #include <stdint.h>
35 #include <stdbool.h>
36
37 // Defines
38
39 // Data sizes in bytes
40
41 /**
42 * The size in bytes of a Tracing Key in binary format
43 */
44 #define TK_SIZE (32)
45
46 /**
47 * The size in bytes of a Tracing Key in base64 format
48 */
49 #define TK_SIZE_BASE64 (44)
50
51 // Structures
52
53 /**
54 * An opaque structure for storing the main state.
55 *
56 * The internal structure can be found in contrac.c
57 */
58 typedef struct _Contrac Contrac;
59
60 // Function prototypes
61
62 Contrac * contrac_new();
63 void contrac_delete(Contrac * data);
64
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);
70 uint32_t contrac_get_day_number(Contrac * data);
71 uint8_t contrac_get_time_interval_number(Contrac * data);
72
73 unsigned char const * contrac_get_tracing_key(Contrac const * data);
74 void contrac_get_tracing_key_base64(Contrac const * data, char * base64);
75
76 void contrac_set_tracing_key(Contrac * data, unsigned char const * tracing_key);
77 bool contrac_set_tracing_key_base64(Contrac * data, char const * tracing_key);
78
79 unsigned char const * contrac_get_daily_key(Contrac const * data);
80 void contrac_get_daily_key_base64(Contrac const * data, char * base64);
81
82 unsigned char const * contrac_get_proximity_id(Contrac const * data);
83 void contrac_get_proximity_id_base64(Contrac const * data, char * base64);
84
85 // Function definitions
86
87 #endif // __CONTRAC_H
88
89 /** @} addtogroup KeyGeneration */
90