aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhashsum.h12
-rw-r--r--libhashsum_init_blake224_hasher.c1
-rw-r--r--libhashsum_init_blake256_hasher.c1
-rw-r--r--libhashsum_init_blake2b_hasher.c1
-rw-r--r--libhashsum_init_blake2s_hasher.c1
-rw-r--r--libhashsum_init_blake384_hasher.c1
-rw-r--r--libhashsum_init_blake512_hasher.c1
-rw-r--r--libhashsum_init_keccak__.c20
-rw-r--r--libhashsum_init_md2_hasher.c1
-rw-r--r--libhashsum_init_md4_hasher.c1
-rw-r--r--libhashsum_init_md5_hasher.c1
-rw-r--r--libhashsum_init_ripemd_128_hasher.c1
-rw-r--r--libhashsum_init_ripemd_160_hasher.c1
-rw-r--r--libhashsum_init_ripemd_256_hasher.c1
-rw-r--r--libhashsum_init_ripemd_320_hasher.c1
-rw-r--r--libhashsum_init_sha0_hasher.c1
-rw-r--r--libhashsum_init_sha1_hasher.c1
-rw-r--r--libhashsum_init_sha2_hasher.c1
18 files changed, 48 insertions, 0 deletions
diff --git a/libhashsum.h b/libhashsum.h
index ea31b9d..7673a74 100644
--- a/libhashsum.h
+++ b/libhashsum.h
@@ -481,6 +481,18 @@ struct libhashsum_hasher {
unsigned char hash_excess_bits; /* TODO test */
/**
+ * Estimate, approximate performance relative to
+ * some unspecified reference point
+ *
+ * Higher is faster
+ *
+ * If the value is zero, no estimate is available
+ *
+ * @since 1.1
+ */
+ uint64_t relative_performance; /* TODO man */
+
+ /**
* Update the hash state given additional
* input data
*
diff --git a/libhashsum_init_blake224_hasher.c b/libhashsum_init_blake224_hasher.c
index b78b12a..2c982d5 100644
--- a/libhashsum_init_blake224_hasher.c
+++ b/libhashsum_init_blake224_hasher.c
@@ -108,6 +108,7 @@ libhashsum_init_blake224_hasher(struct libhashsum_hasher *this, const void *salt
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 13377838180743567ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_blake256_hasher.c b/libhashsum_init_blake256_hasher.c
index 1b89eb2..1e8c101 100644
--- a/libhashsum_init_blake256_hasher.c
+++ b/libhashsum_init_blake256_hasher.c
@@ -108,6 +108,7 @@ libhashsum_init_blake256_hasher(struct libhashsum_hasher *this, const void *salt
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 13377838180743567ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_blake2b_hasher.c b/libhashsum_init_blake2b_hasher.c
index 9a78419..17ebf31 100644
--- a/libhashsum_init_blake2b_hasher.c
+++ b/libhashsum_init_blake2b_hasher.c
@@ -170,6 +170,7 @@ libhashsum_init_blake2b_hasher(struct libhashsum_hasher *this, size_t hashbits,
this->standard_partial_byte_input_encoding = LIBHASHSUM_UNSUPPORTED;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 24633935505133251ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_blake2s_hasher.c b/libhashsum_init_blake2s_hasher.c
index 7758006..6762888 100644
--- a/libhashsum_init_blake2s_hasher.c
+++ b/libhashsum_init_blake2s_hasher.c
@@ -170,6 +170,7 @@ libhashsum_init_blake2s_hasher(struct libhashsum_hasher *this, size_t hashbits,
this->standard_partial_byte_input_encoding = LIBHASHSUM_UNSUPPORTED;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 16309869015413425ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_blake384_hasher.c b/libhashsum_init_blake384_hasher.c
index a507593..d4d60a7 100644
--- a/libhashsum_init_blake384_hasher.c
+++ b/libhashsum_init_blake384_hasher.c
@@ -108,6 +108,7 @@ libhashsum_init_blake384_hasher(struct libhashsum_hasher *this, const void *salt
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 21062754517124396ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_blake512_hasher.c b/libhashsum_init_blake512_hasher.c
index b80d4e8..37aff97 100644
--- a/libhashsum_init_blake512_hasher.c
+++ b/libhashsum_init_blake512_hasher.c
@@ -108,6 +108,7 @@ libhashsum_init_blake512_hasher(struct libhashsum_hasher *this, const void *salt
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 21062754517124396ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
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;
diff --git a/libhashsum_init_md2_hasher.c b/libhashsum_init_md2_hasher.c
index 2fb1668..35d00ac 100644
--- a/libhashsum_init_md2_hasher.c
+++ b/libhashsum_init_md2_hasher.c
@@ -142,6 +142,7 @@ libhashsum_init_md2_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_UNSUPPORTED;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 636028372060772ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_md4_hasher.c b/libhashsum_init_md4_hasher.c
index d5f7876..6472309 100644
--- a/libhashsum_init_md4_hasher.c
+++ b/libhashsum_init_md4_hasher.c
@@ -187,6 +187,7 @@ libhashsum_init_md4_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 45941107656992312ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_md5_hasher.c b/libhashsum_init_md5_hasher.c
index 737bb49..dd74ebb 100644
--- a/libhashsum_init_md5_hasher.c
+++ b/libhashsum_init_md5_hasher.c
@@ -202,6 +202,7 @@ libhashsum_init_md5_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 28263143931935570ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_ripemd_128_hasher.c b/libhashsum_init_ripemd_128_hasher.c
index e27f72a..0caf5c4 100644
--- a/libhashsum_init_ripemd_128_hasher.c
+++ b/libhashsum_init_ripemd_128_hasher.c
@@ -223,6 +223,7 @@ libhashsum_init_ripemd_128_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 21773847511300567ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_ripemd_160_hasher.c b/libhashsum_init_ripemd_160_hasher.c
index 8b55546..3316aa7 100644
--- a/libhashsum_init_ripemd_160_hasher.c
+++ b/libhashsum_init_ripemd_160_hasher.c
@@ -226,6 +226,7 @@ libhashsum_init_ripemd_160_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 12306656764693412ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_ripemd_256_hasher.c b/libhashsum_init_ripemd_256_hasher.c
index c08c262..65d3e35 100644
--- a/libhashsum_init_ripemd_256_hasher.c
+++ b/libhashsum_init_ripemd_256_hasher.c
@@ -234,6 +234,7 @@ libhashsum_init_ripemd_256_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 24811564606436716ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_ripemd_320_hasher.c b/libhashsum_init_ripemd_320_hasher.c
index b513620..92360fb 100644
--- a/libhashsum_init_ripemd_320_hasher.c
+++ b/libhashsum_init_ripemd_320_hasher.c
@@ -240,6 +240,7 @@ libhashsum_init_ripemd_320_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_MOST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 12450536920018911ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_sha0_hasher.c b/libhashsum_init_sha0_hasher.c
index 379d7db..69cd7c6 100644
--- a/libhashsum_init_sha0_hasher.c
+++ b/libhashsum_init_sha0_hasher.c
@@ -68,6 +68,7 @@ libhashsum_init_sha0_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_LEAST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 54814763498234941ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_sha1_hasher.c b/libhashsum_init_sha1_hasher.c
index 3be6428..df7d2aa 100644
--- a/libhashsum_init_sha1_hasher.c
+++ b/libhashsum_init_sha1_hasher.c
@@ -68,6 +68,7 @@ libhashsum_init_sha1_hasher(struct libhashsum_hasher *this)
this->standard_partial_byte_input_encoding = LIBHASHSUM_LEAST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = 259304505616284017ULL;
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
diff --git a/libhashsum_init_sha2_hasher.c b/libhashsum_init_sha2_hasher.c
index e6aab61..dc9d0f2 100644
--- a/libhashsum_init_sha2_hasher.c
+++ b/libhashsum_init_sha2_hasher.c
@@ -97,6 +97,7 @@ libhashsum_init_sha2_hasher(struct libhashsum_hasher *this, unsigned algobits, s
this->standard_partial_byte_input_encoding = LIBHASHSUM_LEAST_SIGNIFICANT;
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
this->hash_excess_bits = 0;
+ this->relative_performance = (algobits == 32U ? 277891737809888154ULL : 32055903736688859ULL);
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;