20 #ifndef lime_localStorage_hpp
21 #define lime_localStorage_hpp
23 #include "soci/soci.h"
48 Db(
const std::string &filename);
51 void load_LimeUser(
const DeviceId &deviceId,
long int &Uid, std::string &url,
const bool allStatus=
false);
62 template <
typename Curve>
64 template <
typename Curve>
72 #ifdef EC25519_ENABLED
73 extern template long int Db::check_peerDevice<C255>(
const std::string &peerDeviceId,
const DSA<C255, lime::DSAtype::publicKey> &Ik,
const bool updateInvalid);
74 extern template long int Db::store_peerDevice<C255>(
const std::string &peerDeviceId,
const DSA<C255, lime::DSAtype::publicKey> &Ik);
78 extern template long int Db::check_peerDevice<C448>(
const std::string &peerDeviceId,
const DSA<C448, lime::DSAtype::publicKey> &Ik,
const bool updateInvalid);
79 extern template long int Db::store_peerDevice<C448>(
const std::string &peerDeviceId,
const DSA<C448, lime::DSAtype::publicKey> &Ik);
82 #ifdef EC25519_ENABLED
83 extern template long int Db::check_peerDevice<C255K512>(
const std::string &peerDeviceId,
const DSA<C255K512::EC, lime::DSAtype::publicKey> &Ik,
const bool updateInvalid);
84 extern template long int Db::store_peerDevice<C255K512>(
const std::string &peerDeviceId,
const DSA<C255K512::EC, lime::DSAtype::publicKey> &Ik);
85 extern template long int Db::check_peerDevice<C255MLK512>(
const std::string &peerDeviceId,
const DSA<C255MLK512::EC, lime::DSAtype::publicKey> &Ik,
const bool updateInvalid);
86 extern template long int Db::store_peerDevice<C255MLK512>(
const std::string &peerDeviceId,
const DSA<C255MLK512::EC, lime::DSAtype::publicKey> &Ik);
89 extern template long int Db::check_peerDevice<C448MLK1024>(
const std::string &peerDeviceId,
const DSA<C448MLK1024::EC, lime::DSAtype::publicKey> &Ik,
const bool updateInvalid);
90 extern template long int Db::store_peerDevice<C448MLK1024>(
const std::string &peerDeviceId,
const DSA<C448MLK1024::EC, lime::DSAtype::publicKey> &Ik);
92 #endif // HAVE_BCTBXPQ
lime::PeerDeviceStatus get_peerDeviceStatus(const std::string &peerDeviceId)
get the status of a peer device: unknown, untrusted, trusted, unsafe device's Id matching a local acc...
Definition: lime_localStorage.cpp:481
void delete_LimeUser(const DeviceId &deviceId)
if exists, delete user
Definition: lime_localStorage.cpp:736
void commit_transaction()
commit a transaction on this Db
Definition: lime_localStorage.cpp:763
long int store_peerDevice(const std::string &peerDeviceId, const DSA< typename Curve::EC, lime::DSAtype::publicKey > &peerIk)
Store peer device information(DeviceId - GRUU -, public Ik, Uid to link it to a user) in local storag...
Definition: lime_localStorage.cpp:704
void load_LimeUser(const DeviceId &deviceId, long int &Uid, std::string &url, const bool allStatus=false)
Check for existence, retrieve Uid for local user based on its userId (GRUU) and curve from table lime...
Definition: lime_localStorage.cpp:273
void delete_peerDevice(const std::string &peerDeviceId)
delete a peerDevice from local storage
Definition: lime_localStorage.cpp:627
bool is_updateRequested(const DeviceId &deviceId)
checks if a device needs to be updated return true if the device exists and updateTs is older than OP...
Definition: lime_localStorage.cpp:594
void clean_DRSessions()
Delete old stale sessions and old stored message key. Apply to all users in localStorage.
Definition: lime_localStorage.cpp:308
void start_transaction()
start a transaction on this Db
Definition: lime_localStorage.cpp:754
PeerDeviceStatus
Definition: lime.hpp:59
~Db()
Definition: lime_localStorage.hpp:49
void set_peerDeviceStatus(const DeviceId &peerDeviceId, const std::vector< uint8_t > &Ik, lime::PeerDeviceStatus status)
set the peer device status flag in local storage: unsafe, trusted or untrusted.
Definition: lime_localStorage.cpp:363
std::recursive_mutex m_db_mutex
mutex on database access
Definition: lime_localStorage.hpp:39
void clean_SPk()
Delete old stale SPk. Apply to all users in localStorage.
Definition: lime_localStorage.cpp:323
void rollback_transaction()
rollback a transaction on this Db
Definition: lime_localStorage.cpp:772
Database access class.
Definition: lime_localStorage.hpp:34
long int check_peerDevice(const std::string &peerDeviceId, const DSA< typename Curve::EC, lime::DSAtype::publicKey > &peerIk, const bool updateInvalid=false)
Check peer device information(DeviceId - GRUU -, public Ik, Uid to link it to a user) in local storag...
Definition: lime_localStorage.cpp:644
soci::session sql
soci connexion to DB
Definition: lime_localStorage.hpp:37
void set_updateTs(const DeviceId &deviceId)
update the update timestamp to now()
Definition: lime_localStorage.cpp:609