X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fsptps_speed.c;h=4cb1221b771cd8836c04b5b3e03282cabe4fc317;hb=d8d1ab4ee1e92ec84fe9ea86eec2396275483a92;hp=d9776b7ef2714086fe2397c67c1832b8b7fcdd86;hpb=37b729d7fdd49da5466696f7995a96ebb54fbcbb;p=tinc diff --git a/src/sptps_speed.c b/src/sptps_speed.c index d9776b7e..4cb1221b 100644 --- a/src/sptps_speed.c +++ b/src/sptps_speed.c @@ -1,6 +1,6 @@ /* sptps_speed.c -- SPTPS benchmark - Copyright (C) 2013 Guus Sliepen , + Copyright (C) 2013-2014 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ */ #include "system.h" +#include "utils.h" #include @@ -32,15 +33,16 @@ bool send_request(void *c, const char *msg, ...) { return false; } struct list_t *connection_list = NULL; bool send_meta(void *c, const char *msg , int len) { return false; } char *logfilename = NULL; +bool do_detach = false; struct timeval now; -static bool send_data(void *handle, uint8_t type, const char *data, size_t len) { +static bool send_data(void *handle, uint8_t type, const void *data, size_t len) { int fd = *(int *)handle; send(fd, data, len, 0); return true; } -static bool receive_record(void *handle, uint8_t type, const char *data, uint16_t len) { +static bool receive_record(void *handle, uint8_t type, const void *data, uint16_t len) { return true; } @@ -96,23 +98,30 @@ int main(int argc, char *argv[]) { key1 = ecdsa_generate(); key2 = ecdsa_generate(); - // ECDSA signatures + // Ed25519 signatures - fprintf(stderr, "ECDSA sign for %lg seconds: ", duration); + fprintf(stderr, "Ed25519 sign for %lg seconds: ", duration); for(clock_start(); clock_countto(duration);) - ecdsa_sign(key1, buf1, 256, buf2); + if(!ecdsa_sign(key1, buf1, 256, buf2)) + return 1; fprintf(stderr, "%22.2lf op/s\n", rate); - fprintf(stderr, "ECDSA verify for %lg seconds: ", duration); + fprintf(stderr, "Ed25519 verify for %lg seconds: ", duration); for(clock_start(); clock_countto(duration);) - ecdsa_verify(key1, buf1, 256, buf2); + if(!ecdsa_verify(key1, buf1, 256, buf2)) { + fprintf(stderr, "Signature verification failed\n"); + return 1; + } fprintf(stderr, "%20.2lf op/s\n", rate); ecdh1 = ecdh_generate_public(buf1); fprintf(stderr, "ECDH for %lg seconds: ", duration); for(clock_start(); clock_countto(duration);) { ecdh2 = ecdh_generate_public(buf2); - ecdh_compute_shared(ecdh2, buf1, buf3); + if(!ecdh2) + return 1; + if(!ecdh_compute_shared(ecdh2, buf1, buf3)) + return 1; } fprintf(stderr, "%28.2lf op/s\n", rate); ecdh_free(ecdh1); @@ -121,7 +130,7 @@ int main(int argc, char *argv[]) { int fd[2]; if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { - fprintf(stderr, "Could not create a UNIX socket pair: %s\n", strerror(errno)); + fprintf(stderr, "Could not create a UNIX socket pair: %s\n", sockstrerror(sockerrno)); return 1; } @@ -174,7 +183,7 @@ int main(int argc, char *argv[]) { close(fd[1]); if(socketpair(AF_UNIX, SOCK_DGRAM, 0, fd)) { - fprintf(stderr, "Could not create a UNIX socket pair: %s\n", strerror(errno)); + fprintf(stderr, "Could not create a UNIX socket pair: %s\n", sockstrerror(sockerrno)); return 1; }