mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(toxencrypt): add function to get min length for isEncrypted() to
succeed Also improve documentation
This commit is contained in:
parent
38cecdc780
commit
a5955c67ed
@ -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> ToxEncrypt::makeToxEncrypt(const QString& password)
|
||||
{
|
||||
@ -170,6 +182,8 @@ std::unique_ptr<ToxEncrypt> 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> ToxEncrypt::makeToxEncrypt(const QString& password, const QByteArray& toxSave)
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user