EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
crypt_service.h
Go to the documentation of this file.
1 
11 #ifndef CRYPT_SERVICE_H
12 #define CRYPT_SERVICE_H
13 
14 #include <sqlite3.h>
15 #include <utarray.h>
16 
17 #include "crypt_config.h"
18 
19 #include "../utils/allocs.h"
20 #include "../utils/attributes.h"
21 #include "../utils/os.h"
22 #define MAIN_CRYPT_KEY_ID "main"
23 
28 struct crypt_pair {
29  const char *key;
30  uint8_t *value;
31  ssize_t value_size;
32 };
33 
39 void free_crypt_service(struct crypt_context *ctx);
40 
41 #if __GNUC__ >= 11
47 #define __must_free_crypt_service \
48  __attribute__((malloc(free_crypt_service, 1))) __must_check
49 #else
50 #define __must_free_crypt_service __must_check
51 #endif /* __GNUC__ >= 11 */
52 
67 load_crypt_service(const char *crypt_db_path, const char *key_id,
68  uint8_t *user_secret, int user_secret_size);
69 
77 struct crypt_pair *get_crypt_pair(struct crypt_context *ctx, const char *key);
78 
86 int put_crypt_pair(struct crypt_context *ctx, struct crypt_pair *pair);
87 
93 void free_crypt_pair(struct crypt_pair *pair);
94 
95 #endif
File containing the definition of crypt configuration structure.
void free_crypt_service(struct crypt_context *ctx)
Frees the crypt context.
Definition: crypt_service.c:37
void free_crypt_pair(struct crypt_pair *pair)
Frees the crypt pair.
Definition: crypt_service.c:417
int put_crypt_pair(struct crypt_context *ctx, struct crypt_pair *pair)
Inserts a key/value pair into the crypt.
Definition: crypt_service.c:501
__must_free_crypt_service struct crypt_context * load_crypt_service(const char *crypt_db_path, const char *key_id, uint8_t *user_secret, int user_secret_size)
Load the crypt service.
Definition: crypt_service.c:246
struct crypt_pair * get_crypt_pair(struct crypt_context *ctx, const char *key)
Retrieves a key/value pair from the crypt.
Definition: crypt_service.c:426
#define __must_free_crypt_service
Definition: crypt_service.h:50
crypt context structure definition
Definition: crypt_config.h:25
char key_id[MAX_KEY_ID_SIZE]
Definition: crypt_config.h:28
crypt context structure definition
Definition: crypt_service.h:28
uint8_t * value
Definition: crypt_service.h:30
const char * key
Definition: crypt_service.h:29
ssize_t value_size
Definition: crypt_service.h:31