diff --git a/src/core/toxencrypt.cpp b/src/core/toxencrypt.cpp index 04cdb92b6..986a73ebe 100644 --- a/src/core/toxencrypt.cpp +++ b/src/core/toxencrypt.cpp @@ -55,6 +55,16 @@ ToxEncrypt::ToxEncrypt(Tox_Pass_Key* key) : passKey{key} {} +/** + * @brief Gets the minimum number of bytes needed for isEncrypted() + * @return Minimum number of bytes needed to check if data was encrypted + * using this module. + */ +int ToxEncrypt::getMinBytes() +{ + return TOX_PASS_ENCRYPTION_EXTRA_LENGTH; +} + /** * @brief Checks if the data was encrypted by this module. * @param ciphertext The data to check. @@ -145,6 +155,8 @@ QByteArray ToxEncrypt::decryptPass(const QString& password, const QByteArray& ci * @param password Password to use for encryption. * @return A std::unique_ptr containing a ToxEncrypt object on success, or an * or an empty std::unique_ptr on failure. + * + * Derives a key from the password and a new random salt. */ std::unique_ptr ToxEncrypt::makeToxEncrypt(const QString& password) { @@ -170,6 +182,8 @@ std::unique_ptr ToxEncrypt::makeToxEncrypt(const QString& password) * @param toxSave The data to read the salt for decryption from. * @return A std::unique_ptr containing a ToxEncrypt object on success, or an * or an empty std::unique_ptr on failure. + * + * Derives a key from the password and the salt read from toxSave. */ std::unique_ptr ToxEncrypt::makeToxEncrypt(const QString& password, const QByteArray& toxSave) { diff --git a/src/core/toxencrypt.h b/src/core/toxencrypt.h index 338541d04..6281efb12 100644 --- a/src/core/toxencrypt.h +++ b/src/core/toxencrypt.h @@ -35,6 +35,7 @@ public: ToxEncrypt(const ToxEncrypt& other) = delete; ToxEncrypt& operator=(const ToxEncrypt& other) = delete; + static int getMinBytes(); static bool isEncrypted(const QByteArray& ciphertext); static QByteArray encryptPass(const QString& password, const QByteArray& plaintext); static QByteArray decryptPass(const QString& password, const QByteArray& ciphertext); @@ -44,7 +45,7 @@ public: QByteArray decrypt(const QByteArray& ciphertext) const; private: - ToxEncrypt(Tox_Pass_Key* key); + explicit ToxEncrypt(Tox_Pass_Key* key); private: Tox_Pass_Key* passKey = nullptr;