Improved security

This commit is contained in:
Leonetienne
2022-05-22 20:13:41 +02:00
parent 4ce86b8f54
commit 4ca1b74e24
5 changed files with 22 additions and 11 deletions
+5 -2
View File
@@ -7,8 +7,8 @@ namespace Leonetienne::GCrypt {
GHash::GHash() :
// Initialize our cipher with a static, but randomly distributed key.
cipher(
// Can't use Key::FromPassword here, because it depends on GHash.
// Instead use a hardcoded key.
// The key really does not matter, as it gets changed
// each time before digesting anything.
Key(StringToBitblock("nsoCZfvdqpRkeVTt9wzvPR3TT26peOW9E2kTHh3pdPCq2M7BpskvUljJHSrobUTI")),
GCipher::DIRECTION::ENCIPHER
) {
@@ -18,6 +18,9 @@ namespace Leonetienne::GCrypt {
}
void GHash::DigestBlock(const Block& data) {
// Set the cipher key to the current data to be hashed
cipher.SetKey(Key(data));
// Encipher the current block, and xor it on the current hashsum
block ^= cipher.Digest(data);
return;