Merge branch 'master' into pisteampackerconfig
# Conflicts: # libs/client_server/piclientserver_server.cpp # libs/crypt/picrypt.cpp # libs/io_utils/pistreampacker.cpp # main.cpp
This commit is contained in:
@@ -19,8 +19,13 @@
|
||||
|
||||
#include "picrypt.h"
|
||||
|
||||
#include "pitranslator.h"
|
||||
#ifdef PIP_CRYPT
|
||||
#include <sodium.h>
|
||||
|
||||
#define PICRYPT_DISABLED_WARNING \
|
||||
piCout << "[PICrypt]" \
|
||||
<< "Warning: PICrypt is disabled, to enable install sodium library and rebuild pip"_tr("PICrypt");
|
||||
namespace {
|
||||
constexpr char hash_def_key[] = "_picrypt_\0\0\0\0\0\0\0";
|
||||
constexpr int hash_def_key_size = 9;
|
||||
@@ -29,7 +34,7 @@ constexpr int hash_def_key_size = 9;
|
||||
PICrypt::PICrypt() {
|
||||
if (!init()) {
|
||||
piCout << "[PICrypt]"
|
||||
<< "Error while initialize sodium!";
|
||||
<< "Error while initialize sodium!"_tr("PICrypt");
|
||||
}
|
||||
nonce_.resize(crypto_secretbox_NONCEBYTES);
|
||||
key_.resize(crypto_secretbox_KEYBYTES);
|
||||
@@ -181,10 +186,10 @@ ullong PICrypt::shorthash(const PIString & s, PIByteArray key) {
|
||||
}
|
||||
if (crypto_shorthash_BYTES != sizeof(hash))
|
||||
piCout << "[PICrypt]"
|
||||
<< "internal error: bad hash size";
|
||||
<< "internal error: bad hash size"_tr("PICrypt");
|
||||
if (key.size() != crypto_shorthash_KEYBYTES) {
|
||||
piCout << "[PICrypt]"
|
||||
<< "invalid key size" << key.size() << ", shoud be" << crypto_shorthash_KEYBYTES << ", filled zeros";
|
||||
<< "invalid key size %1, should be %2, filled with zeros"_tr("PICrypt").arg(key.size()).arg(crypto_shorthash_KEYBYTES);
|
||||
key.resize(crypto_shorthash_KEYBYTES, 0);
|
||||
}
|
||||
PIByteArray in(s.data(), s.size());
|
||||
|
||||
Reference in New Issue
Block a user