Tidied up example/static test executables
This commit is contained in:
@@ -15,10 +15,10 @@ namespace Leonetienne::GCrypt {
|
||||
key.FromByteString("nsoCZfvdqpRkeVTt9wzvPR3TT26peOW9E2kTHh3pdPCq2M7BpskvUljJHSrobUTI");
|
||||
|
||||
cipher = GCipher(
|
||||
// The key really does not matter, as it gets changed
|
||||
// each time before digesting anything.
|
||||
key,
|
||||
GCipher::DIRECTION::ENCIPHER
|
||||
// The key really does not matter, as it gets changed
|
||||
// each time before digesting anything.
|
||||
key,
|
||||
GCipher::DIRECTION::ENCIPHER
|
||||
);
|
||||
|
||||
return;
|
||||
@@ -26,10 +26,11 @@ namespace Leonetienne::GCrypt {
|
||||
|
||||
void GHash::DigestBlock(const Block& data) {
|
||||
// Set the cipher key to the current data to be hashed
|
||||
cipher.SetKey(Key(data));
|
||||
cipher.SetKey(data);
|
||||
|
||||
// Encipher the current block, and xor it on the current hashsum
|
||||
// Encipher the current block, and matrix-mult it with the current hashsum
|
||||
block ^= cipher.Digest(data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ namespace Leonetienne::GCrypt {
|
||||
}
|
||||
|
||||
// Return the next bit.
|
||||
return hasher.GetHashsum()[nextBit++];
|
||||
return hasher.GetHashsum().GetBit(nextBit++);
|
||||
}
|
||||
|
||||
void GPrng::AdvanceBlock() {
|
||||
@@ -50,8 +50,6 @@ namespace Leonetienne::GCrypt {
|
||||
// 1) Fetch complete current hashsum (it might have been partially given out already)
|
||||
// 2) Bitshift it, and matrix-mult it with the seed (that is irreversible)
|
||||
// That should be a one-way function, and create a new unique block.
|
||||
// We don't even have to AdvanceBlock(), because we've only given out
|
||||
// hashsum', not hashsum.
|
||||
|
||||
// Performance improvement over the previous method:
|
||||
// (generating 100.000 blocks):
|
||||
@@ -65,6 +63,9 @@ namespace Leonetienne::GCrypt {
|
||||
hashsum.ShiftBitsLeftInplace();
|
||||
hashsum *= seed;
|
||||
|
||||
// Advance the block, so that the following block will be a new block
|
||||
AdvanceBlock();
|
||||
|
||||
// Return our hashsum
|
||||
return hashsum;
|
||||
}
|
||||
|
Reference in New Issue
Block a user