23 #include <unordered_map>
128 std::unordered_map<std::string, std::shared_ptr<LimeGeneric>> m_users_cache;
129 std::mutex m_users_mutex;
130 std::string m_db_access;
131 std::shared_ptr<std::recursive_mutex> m_db_mutex;
133 void load_user(std::shared_ptr<LimeGeneric> &user,
const std::string &localDeviceId,
const bool allStatus=
false);
154 void create_user(
const std::string &localDeviceId,
const std::string &x3dhServerUrl,
const lime::CurveId curve,
const uint16_t OPkInitialBatchSize,
const limeCallback &callback);
178 bool is_user(
const std::string &localDeviceId);
237 lime::PeerDeviceStatus decrypt(
const std::string &localDeviceId,
const std::string &recipientUserId,
const std::string &senderDeviceId,
const std::vector<uint8_t> &DRmessage,
const std::vector<uint8_t> &
cipherMessage, std::vector<uint8_t> &plainMessage);
242 lime::PeerDeviceStatus decrypt(
const std::string &localDeviceId,
const std::string &recipientUserId,
const std::string &senderDeviceId,
const std::vector<uint8_t> &DRmessage, std::vector<uint8_t> &plainMessage);
262 void update(
const limeCallback &callback, uint16_t OPkServerLowLimit, uint16_t OPkBatchSize);
361 void stale_sessions(
const std::string &localDeviceId,
const std::string &peerDeviceId);
371 void set_x3dhServerUrl(
const std::string &localDeviceId,
const std::string &x3dhServerUrl);
A pure abstract class defining the API to encrypt/decrypt/manage user and its keys.
Definition: lime_lime.hpp:35
Manage several Lime objects(one is needed for each local user).
Definition: lime.hpp:126
LimeManager operator=(const LimeManager &)=delete
void delete_user(const std::string &localDeviceId, const limeCallback &callback)
Delete a user from local database and from the X3DH server.
Definition: lime_manager.cpp:83
lime::PeerDeviceStatus get_peerDeviceStatus(const std::string &peerDeviceId)
get the status of a peer device: unknown, untrusted, trusted, unsafe
Definition: lime_manager.cpp:217
void set_peerDeviceStatus(const std::string &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_manager.cpp:203
void delete_peerDevice(const std::string &peerDeviceId)
delete a peerDevice from local storage
Definition: lime_manager.cpp:231
bool is_user(const std::string &localDeviceId)
Check if a user is present and active in local storage.
Definition: lime_manager.cpp:101
std::string get_x3dhServerUrl(const std::string &localDeviceId)
Get the X3DH key server URL for this identified user.
Definition: lime_manager.cpp:265
void get_selfIdentityKey(const std::string &localDeviceId, std::vector< uint8_t > &Ik)
retrieve self Identity Key, an EdDSA formatted public key
Definition: lime_manager.cpp:196
void set_x3dhServerUrl(const std::string &localDeviceId, const std::string &x3dhServerUrl)
Set the X3DH key server URL for this identified user.
Definition: lime_manager.cpp:256
lime::PeerDeviceStatus decrypt(const std::string &localDeviceId, const std::string &recipientUserId, const std::string &senderDeviceId, const std::vector< uint8_t > &DRmessage, const std::vector< uint8_t > &cipherMessage, std::vector< uint8_t > &plainMessage)
Decrypt the given message.
Definition: lime_manager.cpp:124
LimeManager(const LimeManager &)=delete
void create_user(const std::string &localDeviceId, const std::string &x3dhServerUrl, const lime::CurveId curve, const uint16_t OPkInitialBatchSize, const limeCallback &callback)
Create a user in local database and publish it on the given X3DH server.
Definition: lime_manager.cpp:60
void update(const limeCallback &callback, uint16_t OPkServerLowLimit, uint16_t OPkBatchSize)
Update: shall be called once a day at least, performs checks, updates and cleaning operations.
Definition: lime_manager.cpp:151
void encrypt(const std::string &localDeviceId, std::shared_ptr< const std::string > recipientUserId, std::shared_ptr< std::vector< RecipientData >> recipients, std::shared_ptr< const std::vector< uint8_t >> plainMessage, std::shared_ptr< std::vector< uint8_t >> cipherMessage, const limeCallback &callback, lime::EncryptionPolicy encryptionPolicy=lime::EncryptionPolicy::optimizeUploadSize)
Encrypt a buffer (text or file) for a given list of recipient devices.
Definition: lime_manager.cpp:115
void stale_sessions(const std::string &localDeviceId, const std::string &peerDeviceId)
Stale all sessions between localDeviceId and peerDevice. If peerDevice keep using this session to enc...
Definition: lime_manager.cpp:244
bool is_localUser(const std::string &deviceId)
checks if a device iD exists in the local users
Definition: lime_manager.cpp:224
CallbackReturn
Definition: lime.hpp:84
EncryptionPolicy
Definition: lime.hpp:41
@ optimizeGlobalBandwidth
std::function< void(const lime::CallbackReturn status, const std::string message)> limeCallback
Callback use to give a status on asynchronous operation.
Definition: lime.hpp:95
CurveId
Definition: lime.hpp:34
PeerDeviceStatus
Definition: lime.hpp:53
std::function< void(int responseCode, const std::vector< uint8_t > &responseBody)> limeX3DHServerResponseProcess
Get the response from server. The external service providing secure communication to the X3DH server ...
Definition: lime.hpp:105
std::function< void(const std::string &url, const std::string &from, const std::vector< uint8_t > &message, const limeX3DHServerResponseProcess &reponseProcess)> limeX3DHServerPostData
Post a message to the X3DH server.
Definition: lime.hpp:115
The encrypt function input/output data structure.
Definition: lime.hpp:67
std::vector< uint8_t > DRmessage
Definition: lime.hpp:75
lime::PeerDeviceStatus peerStatus
Definition: lime.hpp:69
const std::string deviceId
Definition: lime.hpp:68
RecipientData(const std::string &deviceId)
Definition: lime.hpp:80