From: Loup Vaillant Date: Sun, 14 Jan 2018 17:34:30 +0000 (+0100) Subject: added sha512 speed benchmark X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=6c9f1afd95ef405301b786179e608dda13ee3276;p=Monocypher.git added sha512 speed benchmark --- diff --git a/tests/speed-sodium.c b/tests/speed-sodium.c index 4e188cf..4b38ed8 100644 --- a/tests/speed-sodium.c +++ b/tests/speed-sodium.c @@ -52,6 +52,17 @@ static u64 blake2b(void) TIMING_END; } +static u64 sha512(void) +{ + static u8 in [SIZE]; p_random(in , SIZE); + static u8 hash[ 64]; + + TIMING_START { + crypto_hash_sha512(hash, in, SIZE); + } + TIMING_END; +} + static u64 argon2i(void) { static u8 password [ 16]; p_random(password, 16); @@ -112,14 +123,12 @@ static u64 edDSA_check(void) int main() { - if (sodium_init() == -1) { - printf("Libsodium init failed. Abort.\n"); - return 1; - } + SODIUM_INIT; print("Chacha20 ", chacha20() * MULT/DIV, "Mb/s" ); print("Poly1305 ", poly1305() * MULT/DIV, "Mb/s" ); print("Auth'd encryption", authenticated() * MULT/DIV, "Mb/s" ); print("Blake2b ", blake2b() * MULT/DIV, "Mb/s" ); + print("Sha512 ", sha512() * MULT/DIV, "Mb/s" ); print("Argon2i ", argon2i() * MULT/DIV, "Mb/s (3 passes)" ); print("x25519 ", x25519() / DIV, "exchanges per second"); print("EdDSA(sign) ", edDSA_sign() / DIV, "signatures per second"); diff --git a/tests/speed.c b/tests/speed.c index cd9eb5b..a04dc6b 100644 --- a/tests/speed.c +++ b/tests/speed.c @@ -56,6 +56,17 @@ static u64 blake2b(void) TIMING_END; } +static u64 sha512(void) +{ + static u8 in [SIZE]; p_random(in , SIZE); + static u8 hash[ 64]; + + TIMING_START { + crypto_sha512(hash, in, SIZE); + } + TIMING_END; +} + static u64 argon2i(void) { size_t nb_blocks = SIZE / 1024; @@ -120,6 +131,7 @@ int main() print("Poly1305 ", poly1305() * MULT/DIV, "Mb/s" ); print("Auth'd encryption", authenticated() * MULT/DIV, "Mb/s" ); print("Blake2b ", blake2b() * MULT/DIV, "Mb/s" ); + print("Sha512 ", sha512() * MULT/DIV, "Mb/s" ); print("Argon2i ", argon2i() * MULT/DIV, "Mb/s (3 passes)" ); print("x25519 ", x25519() / DIV, "exchanges per second"); print("EdDSA(sign) ", edDSA_sign() / DIV, "signatures per second");