EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Data Structures | Macros | Functions
crypt_service.h File Reference

File containing the definition of crypt service configuration utilities. More...

#include <sqlite3.h>
#include <utarray.h>
#include "crypt_config.h"
#include "../utils/allocs.h"
#include "../utils/attributes.h"
#include "../utils/os.h"
Include dependency graph for crypt_service.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  crypt_pair
 crypt context structure definition More...
 

Macros

#define MAIN_CRYPT_KEY_ID   "main"
 
#define __must_free_crypt_service   __must_check
 

Functions

void free_crypt_service (struct crypt_context *ctx)
 Frees the crypt context. More...
 
__must_free_crypt_service struct crypt_contextload_crypt_service (const char *crypt_db_path, const char *key_id, uint8_t *user_secret, int user_secret_size)
 Load the crypt service. More...
 
struct crypt_pairget_crypt_pair (struct crypt_context *ctx, const char *key)
 Retrieves a key/value pair from the crypt. More...
 
int put_crypt_pair (struct crypt_context *ctx, struct crypt_pair *pair)
 Inserts a key/value pair into the crypt. More...
 
void free_crypt_pair (struct crypt_pair *pair)
 Frees the crypt pair. More...
 

Detailed Description

File containing the definition of crypt service configuration utilities.

Author
Alexandru Mereacre
Date
2021

Macro Definition Documentation

◆ __must_free_crypt_service

#define __must_free_crypt_service   __must_check

◆ MAIN_CRYPT_KEY_ID

#define MAIN_CRYPT_KEY_ID   "main"

Function Documentation

◆ free_crypt_pair()

void free_crypt_pair ( struct crypt_pair pair)

Frees the crypt pair.

Parameters
pairThe crypt pair

◆ free_crypt_service()

void free_crypt_service ( struct crypt_context ctx)

Frees the crypt context.

Parameters
ctxThe crypt context

◆ get_crypt_pair()

struct crypt_pair* get_crypt_pair ( struct crypt_context ctx,
const char *  key 
)

Retrieves a key/value pair from the crypt.

Parameters
ctxThe crypt context
keyThe key string
Returns
struct crypt_pair* The returned pair, NULL on failure

◆ load_crypt_service()

__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.

Parameters
crypt_db_pathThe crypt db path
key_idThe crypt secrets key id
[in,out]user_secretThe user secret. If creating a new key, the user secret will be loaded from this variable. If loading an existing key, the existing key will be writen to the buffer.
user_secret_sizeThe user secret size, if zero use the hardware secure element
Returns
The crypt contex, NULL on failure. Use free_crypt_service() to deallocate.

◆ put_crypt_pair()

int put_crypt_pair ( struct crypt_context ctx,
struct crypt_pair pair 
)

Inserts a key/value pair into the crypt.

Parameters
ctxThe crypt context
pairThe key/value pair
Returns
0 on success, -1 on failure