Loading...
Searching...
No Matches
lime::Lime< Curve > Class Template Reference

Implement the abstract class LimeGeneric. More...

`#include <lime_impl.hpp>`

Inheritance diagram for lime::Lime< Curve >:

## Public Member Functions

| Lime (std::shared_ptr< lime::Db > localStorage, const std::string &deviceId, const std::string &url, const limeX3DHServerPostData &X3DH_post_data)
| Create user constructor.
| Lime (std::shared_ptr< lime::Db > localStorage, const std::string &deviceId, const std::string &url, const limeX3DHServerPostData &X3DH_post_data, const long int Uid)
| Load user constructor.
| ~Lime ()
| Lime (Lime< Curve > &a)=delete
Lime< Curve > & | operator= (Lime< Curve > &a)=delete
void | publish_user (const limeCallback &callback, const uint16_t OPkInitialBatchSize) override
| Publish on X3DH server the user, it is performed just after creation in local storage this will, on success, trigger generation and sending of SPk and OPks for our new user.
void | delete_user (const limeCallback &callback) override
| Delete user from local Storage and from X3DH server.
void | delete_peerDevice (const std::string &peerDeviceId) override
| Purge cached sessions for a given peer Device (used when a peer device is being deleted).
void | update_SPk (const limeCallback &callback) override
| Check if the current SPk needs to be updated, if yes, generate a new one and publish it on server.
void | update_OPk (const limeCallback &callback, uint16_t OPkServerLowLimit, uint16_t OPkBatchSize) override
| check if we shall upload more OPks on X3DH server
void | get_Ik (std::vector< uint8_t > &Ik) override
| Retrieve self public Identity key.
void | encrypt (std::shared_ptr< const std::vector< uint8_t > > recipientUserId, std::shared_ptr< std::vector< RecipientData > > recipients, std::shared_ptr< const std::vector< uint8_t > > plainMessage, const lime::EncryptionPolicy encryptionPolicy, std::shared_ptr< std::vector< uint8_t > > cipherMessage, const limeCallback &callback) override
| Encrypt a buffer(text or file) for a given list of recipient devices if specified localDeviceId is not found in local Storage, throw an exception.
lime::PeerDeviceStatus | decrypt (const std::vector< uint8_t > &recipientUserId, const std::string &senderDeviceId, const std::vector< uint8_t > &DRmessage, const std::vector< uint8_t > &cipherMessage, std::vector< uint8_t > &plainMessage) override
| Decrypt the given message.
void | set_x3dhServerUrl (const std::string &x3dhServerUrl) override
| Set the X3DH key server URL for this identified user.
std::string | get_x3dhServerUrl () override
| Get the X3DH key server URL for this identified user.
void | stale_sessions (const std::string &peerDeviceId) override
| Stale all sessions between localDeviceId and peerDevice. If peerDevice keep using this session to encrypt and we decrypt with success, the session will be reactivated but to encrypt a message to this peerDevice, a new session will be created. If no session is active between the given device, this call has no effect.
Public Member Functions inherited from lime::LimeGeneric
virtual | ~LimeGeneric ()

## Detailed Description

template<typename Curve>
class lime::Lime< Curve >

Implement the abstract class LimeGeneric.

Template Parameters

  Curve | The elliptic curve to use: C255 or C448

## Constructor & Destructor Documentation

## Lime() [1/3]

template<typename Curve>

lime::Lime< Curve >::Lime | ( | std::shared_ptr< lime::Db > | localStorage,
|  | const std::string & | deviceId,
|  | const std::string & | url,
|  | const limeX3DHServerPostData & | X3DH_post_data )

Create user constructor.

Create a user in DB, if already existing, throw an exception

Parameters

  [in,out] | localStorage | pointer to DB accessor
  [in] | deviceId | device Id(shall be GRUU), stored in the structure
  [in] | url | URL of the X3DH key server used to publish our keys
  [in] | X3DH_post_data | A function used to communicate with the X3DH server

## Lime() [2/3]

template<typename Curve>

lime::Lime< Curve >::Lime | ( | std::shared_ptr< lime::Db > | localStorage,
|  | const std::string & | deviceId,
|  | const std::string & | url,
|  | const limeX3DHServerPostData & | X3DH_post_data,
|  | const long int | Uid )

Load user constructor.

before calling this constructor, user existence in DB is checked and its Uid retrieved just load it into Lime class

Parameters

  [in,out] | localStorage | pointer to DB accessor
  [in] | deviceId | device Id(shall be GRUU), stored in the structure
  [in] | url | URL of the X3DH key server used to publish our keys(retrieved from DB)
  [in] | X3DH_post_data | A function used to communicate with the X3DH server
  [in] | Uid | the DB internal Id for this user, speed up DB operations by holding it in DB

## ~Lime()

template<typename Curve>

lime::Lime< Curve >::~Lime | ( |  | ) |

## Lime() [3/3]

template<typename Curve>

lime::Lime< Curve >::Lime | ( | Lime< Curve > & | a | ) |

delete

## Member Function Documentation

## decrypt()

template<typename Curve>

lime::PeerDeviceStatus lime::Lime< Curve >::decrypt | ( | const std::vector< uint8_t > & | recipientUserId,
|  | const std::string & | senderDeviceId,
|  | const std::vector< uint8_t > & | DRmessage,
|  | const std::vector< uint8_t > & | cipherMessage,
|  | std::vector< uint8_t > & | plainMessage )

override virtual

Decrypt the given message.

Parameters

  [in] | recipientUserId | the Id of intended recipient, shall be a sip:uri of user or conference, is used as associated data to ensure no-one can mess with intended recipient it is not necessarily the sip:uri base of the GRUU as this could be a message from alice first device intended to bob being decrypted on alice second device
  [in] | senderDeviceId | the device Id (GRUU) of the message sender
  [in] | DRmessage | the Double Ratchet message targeted to current device
  [in] | cipherMessage | part of cipher routed to all recipient devices(it may be actually empty depending on sender encryption policy and message characteristics)
  [out] | plainMessage | the output buffer

Returns
  true if the decryption is successfull, false otherwise

Implements lime::LimeGeneric.

## delete_peerDevice()

template<typename Curve>

void lime::Lime< Curve >::delete_peerDevice | ( | const std::string & | peerDeviceId | ) |

override virtual

Purge cached sessions for a given peer Device (used when a peer device is being deleted).

Parameters

  [in] | peerDeviceId | The peer device to remove from cache

Implements lime::LimeGeneric.

## delete_user()

template<typename Curve>

void lime::Lime< Curve >::delete_user | ( | const limeCallback & | callback | ) |

override virtual

Delete user from local Storage and from X3DH server.

Parameters

  [in] | callback | call when completed

Implements lime::LimeGeneric.

## encrypt()

template<typename Curve>

void lime::Lime< Curve >::encrypt | ( | std::shared_ptr< const std::vector< uint8_t > > | recipientUserId,
|  | std::shared_ptr< std::vector< RecipientData > > | recipients,
|  | std::shared_ptr< const std::vector< uint8_t > > | plainMessage,
|  | const lime::EncryptionPolicy | encryptionPolicy,
|  | std::shared_ptr< std::vector< uint8_t > > | cipherMessage,
|  | const limeCallback & | callback )

override virtual

Encrypt a buffer(text or file) for a given list of recipient devices if specified localDeviceId is not found in local Storage, throw an exception.

    Clarification on recipients:

    recipients information needed are a list of the device Id and one userId. The device Id shall be their GRUU while the userId is a sip:uri.

    recipient User Id is used to identify the actual intended recipient. Example: alice have two devices and is signed up on a conference having
    bob and claire as other members. The recipientUserId will be the conference sip:uri and device list will include:
         - alice other device
         - bob devices
         - claire devices
    If Alice write to Bob only, the recipientUserId will be bob sip:uri and recipient devices list :
         - alice other device
         - bob devices

    In all cases, the identified source of the message will be the localDeviceId

    If the X3DH server can't provide keys for a peer device, its status is set to fail and its DRmessage is empty. Other devices get their encrypted message
    If no peer device could get encrypted for all of them are missing keys on the X3DH server, the callback will still be called with success exit status

Note
  all parameters are shared pointers as the process being asynchronous, the ownership will be taken internally exempting caller to manage the buffers.

Parameters

  [in] | recipientUserId | the Id of intended recipient, shall be a sip:uri of user or conference, is used as associated data to ensure no-one can mess with intended recipient

  [in,out]

  recipients

  a list of RecipientData holding:
  - the recipient device Id(GRUU)
  - an empty buffer to store the DRmessage which must then be routed to that recipient
  - the peer Status. If peerStatus is set to fail, this entry is ignored otherwise the peerStatus is set by the encrypt, see ::PeerDeviceStatus definition for details

  [in] | plainMessage | a buffer holding the message to encrypt, can be text or data.
  [in] | encryptionPolicy | select how to manage the encryption: direct use of Double Ratchet message or encrypt in the cipher message and use the DR message to share the cipher message key
  [out] | cipherMessage | points to the buffer to store the encrypted message which must be routed to all recipients(if one is produced, depends on encryption policy)
  [in] | callback | This operation contact the X3DH server and is thus asynchronous, when server responds, this callback will be called giving the exit status and an error message in case of failure. It is advised to capture a copy of cipherMessage and recipients shared_ptr in this callback so they can access the output of encryption as it won't be part of the callback parameters.

Implements lime::LimeGeneric.

## get_Ik()

template<typename Curve>

void lime::Lime< Curve >::get_Ik | ( | std::vector< uint8_t > & | Ik | ) |

override virtual

Retrieve self public Identity key.

Parameters

  [out] | Ik | the public EdDSA formatted Identity key

Implements lime::LimeGeneric.

## get_x3dhServerUrl()

template<typename Curve>

std::string lime::Lime< Curve >::get_x3dhServerUrl | ( |  | ) |

override virtual

Get the X3DH key server URL for this identified user.

Returns
  The complete url(including port) of the X3DH key server

Implements lime::LimeGeneric.

## operator=()

template<typename Curve>

Lime< Curve > & lime::Lime< Curve >::operator= | ( | Lime< Curve > & | a | ) |

delete

## publish_user()

template<typename Curve>

void lime::Lime< Curve >::publish_user | ( | const limeCallback & | callback,
|  | const uint16_t | OPkInitialBatchSize )

override virtual

Publish on X3DH server the user, it is performed just after creation in local storage this will, on success, trigger generation and sending of SPk and OPks for our new user.

Parameters

  [in] | callback | call when completed
  [in] | OPkInitialBatchSize | Number of OPks in the first batch uploaded to X3DH server

Implements lime::LimeGeneric.

## set_x3dhServerUrl()

template<typename Curve>

void lime::Lime< Curve >::set_x3dhServerUrl | ( | const std::string & | x3dhServerUrl | ) |

override virtual

Set the X3DH key server URL for this identified user.

Parameters

  [in] | x3dhServerUrl | The complete url(including port) of the X3DH key server

Implements lime::LimeGeneric.

## stale_sessions()

template<typename Curve>

void lime::Lime< Curve >::stale_sessions | ( | const std::string & | peerDeviceId | ) |

override virtual

Stale all sessions between localDeviceId and peerDevice. If peerDevice keep using this session to encrypt and we decrypt with success, the session will be reactivated but to encrypt a message to this peerDevice, a new session will be created. If no session is active between the given device, this call has no effect.

Parameters

  [in] | peerDeviceId | The device Id of peer, shall be its GRUU

Implements lime::LimeGeneric.

## update_OPk()

template<typename Curve>

void lime::Lime< Curve >::update_OPk | ( | const limeCallback & | callback,
|  | uint16_t | OPkServerLowLimit,
|  | uint16_t | OPkBatchSize )

override virtual

check if we shall upload more OPks on X3DH server

- ask server four our keys (returns the count and all their Ids)
- check if it's under the low limit, if yes, generate a batch of keys and upload them

Parameters

  [in] | callback | Called with success or failure when operation is completed.
  [in] | OPkServerLowLimit | If server holds less OPk than this limit, generate and upload a batch of OPks
  [in] | OPkBatchSize | Number of OPks in a batch uploaded to server

Implements lime::LimeGeneric.

## update_SPk()

template<typename Curve>

void lime::Lime< Curve >::update_SPk | ( | const limeCallback & | callback | ) |

override virtual

Check if the current SPk needs to be updated, if yes, generate a new one and publish it on server.

Parameters

  [in] | callback | Called with success or failure when operation is completed.

Implements lime::LimeGeneric.

The documentation for this class was generated from the following files:

- /build/lime-9DdzML/lime-5.3.105+dfsg/src/lime_impl.hpp
- /build/lime-9DdzML/lime-5.3.105+dfsg/src/lime.cpp
- /build/lime-9DdzML/lime-5.3.105+dfsg/src/lime_localStorage.cpp
- /build/lime-9DdzML/lime-5.3.105+dfsg/src/lime_x3dh.cpp
- /build/lime-9DdzML/lime-5.3.105+dfsg/src/lime_x3dh_protocol.cpp