revert PICrypt hardkey
This commit is contained in:
@@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
#define PICRYPT_DISABLED_WARNING piCout << "[PICrypt]" << "Warning: PICrypt is disabled, to enable install sodium library and rebuild pip";
|
#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() {
|
PICrypt::PICrypt() {
|
||||||
@@ -52,7 +53,7 @@ PIByteArray PICrypt::setKey(const PIString & secret) {
|
|||||||
#ifdef PIP_CRYPT
|
#ifdef PIP_CRYPT
|
||||||
hash.resize(crypto_generichash_BYTES);
|
hash.resize(crypto_generichash_BYTES);
|
||||||
PIByteArray s(secret.data(), secret.size());
|
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());
|
hash.resize(key_.size());
|
||||||
setKey(hash);
|
setKey(hash);
|
||||||
#endif
|
#endif
|
||||||
@@ -147,7 +148,7 @@ PIByteArray PICrypt::hash(const PIString & secret) {
|
|||||||
if (!init()) return hash;
|
if (!init()) return hash;
|
||||||
hash.resize(crypto_generichash_BYTES);
|
hash.resize(crypto_generichash_BYTES);
|
||||||
PIByteArray s(secret.data(), secret.size());
|
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
|
#else
|
||||||
PICRYPT_DISABLED_WARNING
|
PICRYPT_DISABLED_WARNING
|
||||||
#endif
|
#endif
|
||||||
@@ -160,7 +161,7 @@ PIByteArray PICrypt::hash(const PIByteArray & data) {
|
|||||||
#ifdef PIP_CRYPT
|
#ifdef PIP_CRYPT
|
||||||
if (!init()) return hash;
|
if (!init()) return hash;
|
||||||
hash.resize(crypto_generichash_BYTES);
|
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
|
#else
|
||||||
PICRYPT_DISABLED_WARNING
|
PICRYPT_DISABLED_WARNING
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user