diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-08-01 19:23:13 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-08-01 19:23:13 -0300 |
| commit | 634554a0df8dfd35630f17b5fee44c54b7af73a5 (patch) | |
| tree | 752503318c639afd205e72ba88c16c87d5f3e298 /src/sha256.cc | |
| parent | 82b82dca7d621bf4530416c7c5e9fc69874eecd3 (diff) | |
| download | querymanager-634554a0df8dfd35630f17b5fee44c54b7af73a5.tar.gz querymanager-634554a0df8dfd35630f17b5fee44c54b7af73a5.zip | |
fix problem with concurrent writes + implement website queries
There was a problem with concurrent writes not being visible
until after restart, due to how cached prepared statements work
with SQLite (see comment in `database.cc`).
Diffstat (limited to 'src/sha256.cc')
| -rw-r--r-- | src/sha256.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sha256.cc b/src/sha256.cc index 1070c6b..9e2bb23 100644 --- a/src/sha256.cc +++ b/src/sha256.cc @@ -144,7 +144,24 @@ bool TestPassword(const uint8 *Auth, int AuthSize, const char *Password){ for(int i = 0; i < 32; i += 1){ Result |= Digest[i] ^ Hash[i]; } - return Result == 0;; + return Result == 0; +} + +bool GenerateAuth(const char *Password, uint8 *Auth, int AuthSize){ + if(AuthSize != 64){ + LOG_ERR("Expected 64 bytes buffer for authentication data (got %d)", AuthSize); + return false; + } + + uint8 *Hash = &Auth[ 0]; + uint8 *Salt = &Auth[32]; + CryptoRandom(Salt, 32); + SHA256((const uint8*)Password, (int)strlen(Password), Hash); + for(int i = 0; i < 32; i += 1){ + Hash[i] ^= Salt[i]; + } + SHA256(Hash, 32, Hash); + return true; } // CheckSHA256 |
