]> git.codecow.com Git - Monocypher.git/commitdiff
Properly initialise libsodium for the speed benchmarks
authorLoup Vaillant <loup@loup-vaillant.fr>
Mon, 4 Sep 2017 06:55:05 +0000 (08:55 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Mon, 4 Sep 2017 06:55:05 +0000 (08:55 +0200)
Without this initialisation, libsodium can't select the fastest
implementation for the platform, and has to revert to a portable,
slower one.  This leads to misleading benchmarks.

tests/speed.c

index 4fc506b9bfafc49842998d1a04b20cd32f51a959..19d3ef4f68855943b56ae46ee6c085e61ddbf7bd 100644 (file)
@@ -480,6 +480,10 @@ static void d_ed25519(void)
 
 int main()
 {
+    if (sodium_init() == -1) {
+        printf("Libsodium init failed.  Abort.  No test performed\n");
+        return 1;
+    }
     printf("\nComparing with Libsodium\n");
     printf("------------------------\n");
     print("Chacha20    ", chacha20(), "Libsodium");