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

File containing the definition of the sqlite crypt writer utilities. More...

#include <stdint.h>
#include <sqlite3.h>
Include dependency graph for sqlite_crypt_writer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  store_row
 The store row structure definition. More...
 
struct  secrets_row
 The secrets row structure definition. More...
 

Macros

#define CRYPT_STORE_TABLE_NAME   "store"
 
#define CRYPT_STORE_CREATE_TABLE
 
#define CRYPT_STORE_INSERT_INTO    "INSERT INTO " CRYPT_STORE_TABLE_NAME " VALUES(@key, @value, @id, @iv);"
 
#define CRYPT_STORE_DELETE_FROM    "DELETE FROM " CRYPT_STORE_TABLE_NAME " WHERE key=@key;"
 
#define CRYPT_STORE_GET    "SELECT value, id, iv FROM " CRYPT_STORE_TABLE_NAME " WHERE key=?;"
 
#define CRYPT_SECRETS_TABLE_NAME   "secrets"
 
#define CRYPT_SECRETS_CREATE_TABLE
 
#define CRYPT_SECRETS_INSERT_INTO    "INSERT INTO " CRYPT_SECRETS_TABLE_NAME " VALUES(@id, @value, @salt, @iv);"
 
#define CRYPT_SECRETS_GET    "SELECT value, salt, iv FROM " CRYPT_SECRETS_TABLE_NAME " WHERE id=?;"
 

Functions

int open_sqlite_crypt_db (const char *db_path, sqlite3 **sql)
 Opens the sqlite crypt db. More...
 
void free_sqlite_crypt_db (sqlite3 *db)
 Closes the sqlite db. More...
 
int save_sqlite_store_entry (sqlite3 *db, struct store_row *row)
 Save a store entry into the sqlite db. More...
 
int save_sqlite_secrets_entry (sqlite3 *db, struct secrets_row *row)
 Save a secrets entry into the sqlite db. More...
 
struct store_rowget_sqlite_store_row (sqlite3 *db, const char *key)
 Get the sqlite store entry object. More...
 
void free_sqlite_store_row (struct store_row *row)
 Frees a store row entry. More...
 
struct secrets_rowget_sqlite_secrets_row (sqlite3 *db, const char *id)
 Get the sqlite secrets entry object. More...
 
void free_sqlite_secrets_row (struct secrets_row *row)
 Frees a secrets row entry. More...
 

Detailed Description

File containing the definition of the sqlite crypt writer utilities.

Author
Alexandru Mereacre
Date
2021

Macro Definition Documentation

◆ CRYPT_SECRETS_CREATE_TABLE

#define CRYPT_SECRETS_CREATE_TABLE
Value:
"CREATE TABLE " CRYPT_SECRETS_TABLE_NAME \
" (id TEXT NOT NULL, value TEXT, salt TEXT, iv TEXT, " \
"PRIMARY KEY (id));"
#define CRYPT_SECRETS_TABLE_NAME
Definition: sqlite_crypt_writer.h:29

◆ CRYPT_SECRETS_GET

#define CRYPT_SECRETS_GET    "SELECT value, salt, iv FROM " CRYPT_SECRETS_TABLE_NAME " WHERE id=?;"

◆ CRYPT_SECRETS_INSERT_INTO

#define CRYPT_SECRETS_INSERT_INTO    "INSERT INTO " CRYPT_SECRETS_TABLE_NAME " VALUES(@id, @value, @salt, @iv);"

◆ CRYPT_SECRETS_TABLE_NAME

#define CRYPT_SECRETS_TABLE_NAME   "secrets"

◆ CRYPT_STORE_CREATE_TABLE

#define CRYPT_STORE_CREATE_TABLE
Value:
"CREATE TABLE " CRYPT_STORE_TABLE_NAME \
" (key TEXT NOT NULL, value TEXT, id TEXT, iv TEXT, " \
"PRIMARY KEY (key));"
#define CRYPT_STORE_TABLE_NAME
Definition: sqlite_crypt_writer.h:17

◆ CRYPT_STORE_DELETE_FROM

#define CRYPT_STORE_DELETE_FROM    "DELETE FROM " CRYPT_STORE_TABLE_NAME " WHERE key=@key;"

◆ CRYPT_STORE_GET

#define CRYPT_STORE_GET    "SELECT value, id, iv FROM " CRYPT_STORE_TABLE_NAME " WHERE key=?;"

◆ CRYPT_STORE_INSERT_INTO

#define CRYPT_STORE_INSERT_INTO    "INSERT INTO " CRYPT_STORE_TABLE_NAME " VALUES(@key, @value, @id, @iv);"

◆ CRYPT_STORE_TABLE_NAME

#define CRYPT_STORE_TABLE_NAME   "store"

Function Documentation

◆ free_sqlite_crypt_db()

void free_sqlite_crypt_db ( sqlite3 *  db)

Closes the sqlite db.

Parameters
dbThe sqlite db structure pointer

◆ free_sqlite_secrets_row()

void free_sqlite_secrets_row ( struct secrets_row row)

Frees a secrets row entry.

Parameters
rowThe secrets row value

◆ free_sqlite_store_row()

void free_sqlite_store_row ( struct store_row row)

Frees a store row entry.

Parameters
rowThe store row value

◆ get_sqlite_secrets_row()

struct secrets_row* get_sqlite_secrets_row ( sqlite3 *  db,
const char *  id 
)

Get the sqlite secrets entry object.

Parameters
dbThe sqlite db structure pointer
idThe secrets column id
Returns
struct secrets_row* row value, NULL on failure

◆ get_sqlite_store_row()

struct store_row* get_sqlite_store_row ( sqlite3 *  db,
const char *  key 
)

Get the sqlite store entry object.

Parameters
dbThe sqlite db structure pointer
keyThe store column key
Returns
struct store_row* row value, NULL on failure

◆ open_sqlite_crypt_db()

int open_sqlite_crypt_db ( const char *  db_path,
sqlite3 **  sql 
)

Opens the sqlite crypt db.

Parameters
db_pathThe sqlite db path
[out]sqlThe returned sqlite db structure pointer
Returns
0 on success, -1 on failure

◆ save_sqlite_secrets_entry()

int save_sqlite_secrets_entry ( sqlite3 *  db,
struct secrets_row row 
)

Save a secrets entry into the sqlite db.

Parameters
dbThe sqlite db structure pointer
rowThe secrets row structure
Returns
int 0 on success, -1 on failure

◆ save_sqlite_store_entry()

int save_sqlite_store_entry ( sqlite3 *  db,
struct store_row row 
)

Save a store entry into the sqlite db.

Parameters
dbThe sqlite db structure pointer
rowThe store row structure
Returns
int 0 on success, -1 on failure