Commit 530c404c authored by Matthieu Tanon's avatar Matthieu Tanon

Fix typos in comments

parent 5cbc62af
......@@ -120,7 +120,7 @@ Db::Db(string filename) : sql{sqlite3, filename}{
FOREIGN KEY(Uid) REFERENCES lime_LocalUsers(Uid) ON UPDATE CASCADE ON DELETE CASCADE);";
/* DR Message Skipped DH : Store chains of skipped message keys, this table store the DHr identifying the chain
* - DHid(primary key)
* - DHid (primary key)
* - SessionId : foreign key, link to the DR session the skipped keys are attached
* - DHr : the peer ECDH public key used in this key chain
* - received : count messages successfully decoded since the last MK insertion in that chain, allow to delete chains that are too old
......@@ -158,7 +158,7 @@ Db::Db(string filename) : sql{sqlite3, filename}{
UserId TEXT NOT NULL, \
Ik BLOB NOT NULL, \
server TEXT NOT NULL, \
curveId INTEGER NOT NULL DEFAULT 0);"; // default the curveId value to 0 which is not one of the possible values(defined in lime.hpp)
curveId INTEGER NOT NULL DEFAULT 0);"; // default the curveId value to 0 which is not one of the possible values (defined in lime.hpp)
/* Peer Devices :
* - Did : primary key, used to make link with DR_sessions table.
......@@ -178,7 +178,7 @@ Db::Db(string filename) : sql{sqlite3, filename}{
/* Signed pre-key :
* - SPKid : the primary key must be a random number as it is public, so avoid leaking information on number of key used
* - SPK : Public key||Private Key (ECDH keys)
* - timeStamp : Application shall renew SPK regurlarly(SPK_LifeTime). Old key are disactivated and deleted after a period(SPK_LimboTime))
* - timeStamp : Application shall renew SPK regurlarly (SPK_LifeTime). Old key are disactivated and deleted after a period (SPK_LimboTime))
* - Status : a boolean: can be active(1) or stale(0), by default any newly inserted key is set to active
* - Uid : User Id from lime_LocalUsers table: who's key is this
*/
......@@ -210,10 +210,10 @@ Db::Db(string filename) : sql{sqlite3, filename}{
};
/**
* @brief Check for existence, retrieve Uid for local user based on its userId(GRUU) and curve from table lime_LocalUsers
* @brief Check for existence, retrieve Uid for local user based on its userId (GRUU) and curve from table lime_LocalUsers
*
* @param[in] deviceId a string holding the user to look for in DB, shall be its GRUU
* @param[out] Uid the DB internal Id matching given userId(if find in DB, 0 otherwise)
* @param[out] Uid the DB internal Id matching given userId (if find in DB, 0 otherwise)
* @param[out] curveId the curve selected at user creation
* @param[out] url the url of the X3DH server this user is registered on
*
......@@ -254,7 +254,7 @@ void Db::load_LimeUser(const std::string &deviceId, long int &Uid, lime::CurveId
* Once we moved to next chain(as soon as peer got an answer from us and replies), the count won't be reset anymore
*/
void Db::clean_DRSessions() {
// WARNIMG: not sure this code is portable it may work with sqlite3 only
// WARNING: not sure this code is portable it may work with sqlite3 only
// delete stale sessions considered to old
sql<<"DELETE FROM DR_sessions WHERE Status=0 AND timeStamp < date('now', '-"<<lime::settings::DRSession_limboTime_days<<" day');";
......@@ -267,7 +267,7 @@ void Db::clean_DRSessions() {
* - SPk in stale status for more than SPK_limboTime_days are deleted
*/
void Db::clean_SPk() {
// WARNIMG: not sure this code is portable it may work with sqlite3 only
// WARNING: not sure this code is portable it may work with sqlite3 only
// delete stale sessions considered to old
sql<<"DELETE FROM X3DH_SPK WHERE Status=0 AND timeStamp < date('now', '-"<<lime::settings::SPK_limboTime_days<<" day');";
}
......@@ -461,7 +461,7 @@ bool DR<DHKey>::session_save() {
MSk_DHr_Clean = true; // flag the cleaning needed in DR_MSk_DH table, we may have to remove a row in it if no more row are linked to it in DR_MSk_MK
} else { // we did not consume a key
if (m_dirty == DRSessionDbStatus::dirty_decrypt || m_dirty == DRSessionDbStatus::dirty_ratchet) { // if we did a message decrypt :
// update the count of posterior messages received in the stored skipped messages keys for this session(all stored chains)
// update the count of posterior messages received in the stored skipped messages keys for this session (all stored chains)
m_localStorage->sql<<"UPDATE DR_MSk_DHr SET received = received + 1 WHERE sessionId = :sessionId", use(m_dbSessionId);
}
}
......@@ -491,7 +491,7 @@ bool DR<DHKey>::session_save() {
}
}
// Now do the cleaning(remove unused row from DR_MKs_DHr table) if needed
// Now do the cleaning (remove unused row from DR_MKs_DHr table) if needed
if (MSk_DHr_Clean == true) {
uint16_t Nr;
m_localStorage->sql<<"SELECT Nr from DR_MSk_MK WHERE DHid = :DHid LIMIT 1;", into(Nr), use(m_usedDHid);
......@@ -556,7 +556,7 @@ bool DR<Curve>::trySkippedMessageKeys(const uint16_t Nr, const X<Curve> &DHr, DR
m_usedDHid=0; // make sure the DHid is not set when we didn't find anything as it is later used to remove confirmed used key from DB
return false;
}
// record the Nr of extracted to be able to delete it fron base later(if decrypt ends well)
// record the Nr of extracted to be able to delete it fron base later (if decrypt ends well)
m_usedNr=Nr;
MK_blob.read(0, (char *)(MK.data()), MK.size());
......
......@@ -58,7 +58,7 @@ static int http_after_all(void) {
return 0;
}
// this emulate a network transmission: bob got a mailbox(2 buffers actually) where we can post/retrieve data to/from
// this emulate a network transmission: bob got a mailbox (2 buffers actually) where we can post/retrieve data to/from
static std::vector<uint8_t> bobCipherHeaderMailbox{};
static std::vector<uint8_t> bobCipherMessageMailbox{};
static void sendMessageTo(std::string recipient, std::vector<uint8_t> &cipherHeader, std::vector<uint8_t> &cipherMessage) {
......@@ -95,7 +95,7 @@ static void process_auth_requested (void *data, belle_sip_auth_event_t *event){
// and set it as username to retrieve the correct credentials and send them back
BCTBX_SLOGI<<"Accessing credentials for user "<<std::string(userData->username.data());
// for test purpose we use a server which accept commands in name of any user using credential of the only one user active on it
// for test purpose we use a server which accept commands in name of any user using credentials of the only one user active on it
// so we will set the username with the one test server accepts but real life example shall use the correct credentials
belle_sip_auth_event_set_username(event, lime_tester::test_server_user_name.data());
......@@ -206,7 +206,7 @@ static void helloworld_basic_test(const lime::CurveId curve, const std::string &
try {
BCTBX_SLOGI<<"Create alice and bob LimeManagers"<<endl;
// create Random devices names (in case we use a shared test server, devices id shall be the GRUU, X3DH/Lime does not connect user(sip:uri) and device(gruu)
// create Random devices names (in case we use a shared test server, devices id shall be the GRUU, X3DH/Lime does not connect user (sip:uri) and device (gruu)
// From Lime perspective, only devices exists and they must be uniquely identifies on the X3DH server.
auto aliceDeviceId = lime_tester::makeRandomDeviceName("alice.");
auto bobDeviceId = lime_tester::makeRandomDeviceName("bob.");
......@@ -219,22 +219,22 @@ static void helloworld_basic_test(const lime::CurveId curve, const std::string &
auto bobManager = std::unique_ptr<LimeManager>(new LimeManager(dbFilenameBob, X3DHServerPost));
BCTBX_SLOGI<<"Create "<<*aliceDeviceId<<" and "<<*bobDeviceId<<" users"<<endl;
// create users, this operation is asynchronous(as the user is also created on X3DH server)
// create users, this operation is asynchronous (as the user is also created on X3DH server)
// The OPkInitialBatchSize parameter is optionnal and is used to set how many One-Time pre-keys will be
// uploaded to the X3DH server at creation. Default value is set in lime::settings.
// Last parameter is a callback acceptiong as parameters a return code and a string
// - In case of successfull operation the return code is lime::callbackReturn::success, and string is empty
// Last parameter is a callback accepting as parameters a return code and a string
// - In case of successful operation the return code is lime::callbackReturn::success, and string is empty
// - In case of failure, the return code is lime::callbackReturn::fail and the string shall give details on the failure cause
auto tmp_aliceDeviceId = *aliceDeviceId; // use a temporary variable as it may be a local variable which get out of scope right after call to create_user
aliceManager->create_user(tmp_aliceDeviceId, x3dh_server_url, curve, lime_tester::OPkInitialBatchSize, callback);
tmp_aliceDeviceId.clear(); // deviceId may go out of scope as soon as we come back from call
//wait for the operation to complete
// wait for the operation to complete
BC_ASSERT_TRUE(lime_tester::wait_for(stack,&counters.operation_success,++expected_success,lime_tester::wait_for_timeout));
auto tmp_bobDeviceId = *bobDeviceId; // use a temporary variable as it may be a local variable which get out of scope right after call to create_user
bobManager->create_user(tmp_bobDeviceId, x3dh_server_url, curve, callback);
tmp_bobDeviceId.clear(); // deviceId may go out of scope as soon as we come back from call
//wait for the operation to complete
// wait for the operation to complete
BC_ASSERT_TRUE(lime_tester::wait_for(stack,&counters.operation_success,++expected_success,lime_tester::wait_for_timeout));
......@@ -250,7 +250,7 @@ static void helloworld_basic_test(const lime::CurveId curve, const std::string &
// - cipherHeader : output of encryption process targeted to this recipient device only
auto recipients = make_shared<std::vector<recipientData>>();
recipients->emplace_back(*bobDeviceId); // we have only one recipient identified by its device id.
//Shall we have more recipients(bob can have several devices or be a conference sip:uri, alice other devices must get a copy of the message), we just need to emplace_back some more recipients Device Id(GRUU)
// Shall we have more recipients (bob can have several devices or be a conference sip:uri, alice other devices must get a copy of the message), we just need to emplace_back some more recipients Device Id (GRUU)
// the plain message, type is std::vector<uint8_t> as it can be text as in this test but also any kind of data.
auto message = make_shared<const std::vector<uint8_t>>(lime_tester::messages_pattern[0].begin(), lime_tester::messages_pattern[0].end());
......@@ -259,9 +259,9 @@ static void helloworld_basic_test(const lime::CurveId curve, const std::string &
BCTBX_SLOGI<<"Alice encrypt the message"<<endl;
/************** SENDER SIDE CODE *****************************/
// encrypt, parameters are:
// - localDeviceId to select which of the users managed by the LimeManager we shall use to perform the encryption(in our example we have only one local device). This one doesn't need to be a shared pointer.
// - recipientUser: an id of the recipient user(which can hold several devices), typically its sip:uri
// - recipientData vector(see above), list all recipient devices, will hold their cipher header
// - localDeviceId to select which of the users managed by the LimeManager we shall use to perform the encryption (in our example we have only one local device). This one doesn't need to be a shared pointer.
// - recipientUser: an id of the recipient user (which can hold several devices), typically its sip:uri
// - recipientData vector (see above), list all recipient devices, will hold their cipher header
// - plain message
// - cipher message (this one must then be distributed to all recipients devices)
// - a callback (prototype: void(lime::callbackReturn, std::string))
......@@ -274,7 +274,7 @@ static void helloworld_basic_test(const lime::CurveId curve, const std::string &
// IMPORTANT : recipients and cipherMessage are captured by copy not reference. They are shared_ptr, their original scope is likely to be the function where the encrypt is called.
// they shall then be destroyed when getting out of this function and thus won't be valid anymore when this closure is called. By getting a copy we just increase their
// use count and are sure to still have them valid when we are called.
// When the closure itself is destroyed (when last reference to it is destroyed), it will trigger destruction of the captured values(-1 in use count for the shared_ptr)
// When the closure itself is destroyed (when last reference to it is destroyed), it will trigger destruction of the captured values (-1 in use count for the shared_ptr)
// After this closure is called it is destroyed(internal reference is dropped) decreasing the count and allowing the release of the buffer.
//
// It may be wise to use weak_ptr instead of shared ones so if any problem occurs resulting in callback never being called/destroyed, it won't held this buffer from being destroyed
......@@ -288,7 +288,7 @@ static void helloworld_basic_test(const lime::CurveId curve, const std::string &
// Send the message to recipient
// that function must, before returning, send or copy the data to send them later
// recipients and cipherMessage are likely to be be destroyed as soon as we get out of this closure
// In this exanple we know that bodDevice is in recipients[0], real code shall loop on recipients vector
// In this example we know that bodDevice is in recipients[0], real code shall loop on recipients vector
sendMessageTo("bob", (*recipients)[0].cipherHeader, *cipherMessage);
} else {
counters.operation_failed++;
......@@ -339,7 +339,7 @@ static void helloworld_basic_test(const lime::CurveId curve, const std::string &
/************** Users maintenance ****************************/
// Around once a day the update function shall be called on LimeManagers
// it will perform localStorage cleanings
// update of cryptographic material(Signed Pre-key and One-time Pre-keys)
// update of cryptographic material (Signed Pre-key and One-time Pre-keys)
// The update take as optionnal parameters :
// - lower bound for One-time Pre-key available on server
// - One-time Pre-key batch size to be generated and uploaded if lower limit on server is reached
......@@ -413,7 +413,7 @@ static void helloworld_verifyIdentity_test(const lime::CurveId curve, const std:
try {
BCTBX_SLOGI<<"Create alice and bob LimeManagers"<<endl;
// create Random devices names (in case we use a shared test server, devices id shall be the GRUU, X3DH/Lime does not connect user(sip:uri) and device(gruu)
// create random devices names (in case we use a shared test server, devices id shall be the GRUU, X3DH/Lime does not connect user (sip:uri) and device (gruu)
// From Lime perspective, only devices exists and they must be uniquely identifies on the X3DH server.
auto aliceDeviceId = lime_tester::makeRandomDeviceName("alice.");
auto bobDeviceId = lime_tester::makeRandomDeviceName("bob.");
......@@ -435,13 +435,13 @@ static void helloworld_verifyIdentity_test(const lime::CurveId curve, const std:
auto tmp_aliceDeviceId = *aliceDeviceId; // use a temporary variable as it may be a local variable which get out of scope right after call to create_user
aliceManager->create_user(tmp_aliceDeviceId, x3dh_server_url, curve, lime_tester::OPkInitialBatchSize, callback);
tmp_aliceDeviceId.clear(); // deviceId may go out of scope as soon as we come back from call
//wait for the operation to complete
// wait for the operation to complete
BC_ASSERT_TRUE(lime_tester::wait_for(stack,&counters.operation_success,++expected_success,lime_tester::wait_for_timeout));
auto tmp_bobDeviceId = *bobDeviceId; // use a temporary variable as it may be a local variable which get out of scope right after call to create_user
bobManager->create_user(tmp_bobDeviceId, x3dh_server_url, curve, callback);
tmp_bobDeviceId.clear(); // deviceId may go out of scope as soon as we come back from call
//wait for the operation to complete
// wait for the operation to complete
BC_ASSERT_TRUE(lime_tester::wait_for(stack,&counters.operation_success,++expected_success,lime_tester::wait_for_timeout));
// [verify] Retrieve from Managers Bob and Alice device Identity Key
......@@ -477,7 +477,7 @@ static void helloworld_verifyIdentity_test(const lime::CurveId curve, const std:
// - cipherHeader : output of encryption process targeted to this recipient device only
auto recipients = make_shared<std::vector<recipientData>>();
recipients->emplace_back(*bobDeviceId); // we have only one recipient identified by its device id.
//Shall we have more recipients(bob can have several devices or be a conference sip:uri, alice other devices must get a copy of the message), we just need to emplace_back some more recipients Device Id(GRUU)
// Shall we have more recipients (bob can have several devices or be a conference sip:uri, alice other devices must get a copy of the message), we just need to emplace_back some more recipients Device Id (GRUU)
// the plain message, type is std::vector<uint8_t> as it can be text as in this test but also any kind of data.
auto message = make_shared<const std::vector<uint8_t>>(lime_tester::messages_pattern[0].begin(), lime_tester::messages_pattern[0].end());
......@@ -486,9 +486,9 @@ static void helloworld_verifyIdentity_test(const lime::CurveId curve, const std:
BCTBX_SLOGI<<"Alice encrypt the message"<<endl;
/************** SENDER SIDE CODE *****************************/
// encrypt, parameters are:
// - localDeviceId to select which of the users managed by the LimeManager we shall use to perform the encryption(in our example we have only one local device). This one doesn't need to be a shared pointer.
// - recipientUser: an id of the recipient user(which can hold several devices), typically its sip:uri
// - recipientData vector(see above), list all recipient devices, will hold their cipher header
// - localDeviceId to select which of the users managed by the LimeManager we shall use to perform the encryption (in our example we have only one local device). This one doesn't need to be a shared pointer.
// - recipientUser: an id of the recipient user (which can hold several devices), typically its sip:uri
// - recipientData vector (see above), list all recipient devices, will hold their cipher header
// - plain message
// - cipher message (this one must then be distributed to all recipients devices)
// - a callback (prototype: void(lime::callbackReturn, std::string))
......@@ -514,7 +514,7 @@ static void helloworld_verifyIdentity_test(const lime::CurveId curve, const std:
// Send the message to recipient
// that function must, before returning, send or copy the data to send them later
// recipients and cipherMessage are likely to be be destroyed as soon as we get out of this closure
// In this exanple we know that bodDevice is in recipients[0], real code shall loop on recipients vector
// In this example we know that bodDevice is in recipients[0], real code shall loop on recipients vector
sendMessageTo("bob", (*recipients)[0].cipherHeader, *cipherMessage);
// [verify] now we can also check the trusted status of recipients, as we set as trusted Bob's key, it shall be trusted
BC_ASSERT_TRUE((*recipients)[0].identityVerified);
......@@ -570,7 +570,7 @@ static void helloworld_verifyIdentity_test(const lime::CurveId curve, const std:
/************** Users maintenance ****************************/
// Around once a day the update function shall be called on LimeManagers
// it will perform localStorage cleanings
// update of cryptographic material(Signed Pre-key and One-time Pre-keys)
// update of cryptographic material (Signed Pre-key and One-time Pre-keys)
// The update take as optionnal parameters :
// - lower bound for One-time Pre-key available on server
// - One-time Pre-key batch size to be generated and uploaded if lower limit on server is reached
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment