diff --git a/libs/crypt/picrypt.cpp b/libs/crypt/picrypt.cpp index 38b38250..e5c79041 100644 --- a/libs/crypt/picrypt.cpp +++ b/libs/crypt/picrypt.cpp @@ -24,7 +24,8 @@ #define PICRYPT_DISABLED_WARNING piCout << "[PICrypt]" << "Warning: PICrypt is disabled, to enable install sodium library and rebuild pip"; -const char hash_def_key[] = "=picryptpicrypt="; +const char hash_def_key[] = "_picrypt_\0\0\0\0\0\0\0"; +const int hash_def_key_size = 9; PICrypt::PICrypt() { @@ -52,7 +53,7 @@ PIByteArray PICrypt::setKey(const PIString & secret) { #ifdef PIP_CRYPT hash.resize(crypto_generichash_BYTES); PIByteArray s(secret.data(), secret.size()); - crypto_generichash(hash.data(), hash.size(), s.data(), s.size(), (const uchar*)hash_def_key, sizeof(hash_def_key) - 1); + crypto_generichash(hash.data(), hash.size(), s.data(), s.size(), (const uchar*)hash_def_key, hash_def_key_size); hash.resize(key_.size()); setKey(hash); #endif @@ -147,7 +148,7 @@ PIByteArray PICrypt::hash(const PIString & secret) { if (!init()) return hash; hash.resize(crypto_generichash_BYTES); PIByteArray s(secret.data(), secret.size()); - crypto_generichash(hash.data(), hash.size(), s.data(), s.size(), (const uchar*)hash_def_key, sizeof(hash_def_key) - 1); + crypto_generichash(hash.data(), hash.size(), s.data(), s.size(),(const uchar*)hash_def_key, hash_def_key_size); #else PICRYPT_DISABLED_WARNING #endif @@ -160,7 +161,7 @@ PIByteArray PICrypt::hash(const PIByteArray & data) { #ifdef PIP_CRYPT if (!init()) return hash; hash.resize(crypto_generichash_BYTES); - crypto_generichash(hash.data(), hash.size(), data.data(), data.size(), (const uchar*)hash_def_key, sizeof(hash_def_key) - 1); + crypto_generichash(hash.data(), hash.size(), data.data(), data.size(), (const uchar*)hash_def_key, hash_def_key_size); #else PICRYPT_DISABLED_WARNING #endif