]> git.codecow.com Git - Monocypher.git/commitdiff
added sha512 speed benchmark
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 14 Jan 2018 17:34:30 +0000 (18:34 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 14 Jan 2018 17:34:30 +0000 (18:34 +0100)
tests/speed-sodium.c
tests/speed.c

index 4e188cff4864eda56971267bbdcacc3b2d88b56a..4b38ed8b2eb302c6c3c558b09fd19c23179dcaa7 100644 (file)
@@ -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");
index cd9eb5bbc3845494a63a5953b329c4d7e6c02450..a04dc6ba16754863b6d9eaf42ec0e8339c02d71c 100644 (file)
@@ -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");