aboutsummaryrefslogtreecommitdiffstats
path: root/libhashsum_init_keccak__.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libhashsum_init_keccak__.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libhashsum_init_keccak__.c b/libhashsum_init_keccak__.c
index f9c8be1..53a9e52 100644
--- a/libhashsum_init_keccak__.c
+++ b/libhashsum_init_keccak__.c
@@ -140,6 +140,25 @@ destroy(struct libhashsum_hasher *this)
}
+static uint64_t
+estimate_performance(long int r, long int c)
+{
+ uint64_t base = 22517998136852480ULL / (uint64_t)r;
+ switch (r + c) {
+ case 1600:
+ return base / 368ULL;
+ case 800:
+ return base / 2042ULL;
+ case 400:
+ return base / 1858ULL;
+ case 200:
+ return base / 1747ULL;
+ default:
+ return 0;
+ }
+}
+
+
int
libhashsum_init_keccak__(struct libhashsum_hasher *this, size_t hashbits, void *spec_, size_t squeezes, const char *suffix)
{
@@ -170,6 +189,7 @@ libhashsum_init_keccak__(struct libhashsum_hasher *this, size_t hashbits, void *
}
this->input_block_size = libkeccak_zerocopy_chunksize(&this->state.keccak.s);
+ this->relative_performance = estimate_performance(spec->bitrate, spec->capacity);
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;