]> de.git.xonotic.org Git - xonotic/d0_blind_id.git/blobdiff - main.c
back to 1024 bits
[xonotic/d0_blind_id.git] / main.c
diff --git a/main.c b/main.c
index 0efb624e7d59b42599c342137394e786495dda5a..2e8e24e1ef344508a0e3b5d56345dacb937d7ce8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -35,7 +35,9 @@ void bench(double *b)
        lastclock = b;
 }
 
+#ifndef WIN32
 #include <sys/signal.h>
+#endif
 volatile BOOL quit = 0;
 void mysignal(int signo)
 {
@@ -43,7 +45,17 @@ void mysignal(int signo)
        quit = 1;
 }
 
-#include <err.h>
+#include <stdarg.h>
+#include <stdlib.h>
+static void errx(int status, const char *format, ...)
+{
+       va_list ap;
+       va_start(ap, format);
+       vfprintf(stderr, format, ap);
+       fputs("\n", stderr);
+       exit(status);
+}
+
 int main(int argc, char **argv)
 {
        char buf[65536]; size_t bufsize;
@@ -76,7 +88,9 @@ int main(int argc, char **argv)
                errx(3, "readpub fail");
        */
 
+#ifndef WIN32
        signal(SIGINT, mysignal);
+#endif
 
        int n = 0;
        double bench_gen = 0, bench_fp = 0, bench_stop = 0;
@@ -119,8 +133,10 @@ int main(int argc, char **argv)
                bufsize = sizeof(buf); if(!d0_blind_id_authenticate_with_private_id_start(ctx_other, 1, 1, "hello world", 11, buf, &bufsize))
                        errx(9, "start fail");
                bench(&bench_chall);
-               buf2size = sizeof(buf2); if(!d0_blind_id_authenticate_with_private_id_challenge(ctx_self, 1, 1, buf, bufsize, buf2, &buf2size, NULL))
+               buf2size = sizeof(buf2); if(!d0_blind_id_authenticate_with_private_id_challenge(ctx_self, 1, 1, buf, bufsize, buf2, &buf2size, &status))
                        errx(10, "challenge fail");
+               if(!status)
+                       errx(14, "signature prefail");
                bench(&bench_resp);
                bufsize = sizeof(buf); if(!d0_blind_id_authenticate_with_private_id_response(ctx_other, buf2, buf2size, buf, &bufsize))
                        errx(11, "response fail");
@@ -132,10 +148,10 @@ int main(int argc, char **argv)
                if(!status)
                        errx(14, "signature fail");
                bench(&bench_dhkey1);
-               bufsize = sizeof(buf); if(!d0_blind_id_sessionkey_public_id(ctx_self, buf, &bufsize))
+               bufsize = 20; if(!d0_blind_id_sessionkey_public_id(ctx_self, buf, &bufsize))
                        errx(15, "dhkey1 fail");
                bench(&bench_dhkey2);
-               buf2size = sizeof(buf2); if(!d0_blind_id_sessionkey_public_id(ctx_other, buf2, &buf2size))
+               buf2size = 20; if(!d0_blind_id_sessionkey_public_id(ctx_other, buf2, &buf2size))
                        errx(16, "dhkey2 fail");
                bench(&bench_stop);
                if(bufsize != buf2size || memcmp(buf, buf2, bufsize))