main.c: missing va_end(ap).
[xonotic/d0_blind_id.git] / main.c
diff --git a/main.c b/main.c
index 71d67f3..9995fd5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -29,6 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
+ * $Format:commit %H$
  * $Id$
  */
 
@@ -53,7 +54,7 @@ void bench(double *b)
 #ifndef WIN32
 #include <sys/signal.h>
 #endif
-volatile BOOL quit = 0;
+volatile D0_BOOL quit = 0;
 void mysignal(int signo)
 {
        (void) signo;
@@ -67,6 +68,7 @@ static void errx(int status, const char *format, ...)
        va_list ap;
        va_start(ap, format);
        vfprintf(stderr, format, ap);
+       va_end(ap);
        fputs("\n", stderr);
        exit(status);
 }
@@ -118,9 +120,9 @@ int main(int argc, char **argv)
                buf2size = sizeof(buf2) - 1; if(!d0_blind_id_fingerprint64_public_id(ctx_other, buf2, &buf2size))
                        errx(4, "fp64 fail");
                bench(&bench_stop);
+               ++n;
                if(n % 1024 == 0)
                        printf("gen=%f fp=%f\n", n/bench_gen, n/bench_fp);
-               ++n;
        }
        while(!(quit || argc != 2 || (buf2size > strlen(argv[1]) && !memcmp(buf2, argv[1], strlen(argv[1])))));
 
@@ -140,10 +142,21 @@ int main(int argc, char **argv)
                errx(8, "readpub2 fail");
 
        n = 0;
-       double bench_auth = 0, bench_chall = 0, bench_resp = 0, bench_verify = 0, bench_dhkey1 = 0, bench_dhkey2 = 0;
-       BOOL status;
+       double bench_auth = 0, bench_chall = 0, bench_resp = 0, bench_verify = 0, bench_dhkey1 = 0, bench_dhkey2 = 0, bench_sign = 0, bench_signverify = 0;
+       D0_BOOL status;
        while(!quit)
        {
+               bench(&bench_sign);
+               bufsize = sizeof(buf); if(!d0_blind_id_sign_with_private_id_sign(ctx_other, 1, 1, "hello world", 11, buf, &bufsize))
+                       errx(9, "sign fail");
+               bench(&bench_signverify);
+               buf2size = sizeof(buf2); if(!d0_blind_id_sign_with_private_id_verify(ctx_self, 1, 1, buf, bufsize, buf2, &buf2size, &status))
+                       errx(9, "signverify fail");
+               bench(&bench_stop);
+               if(buf2size != 11 || memcmp(buf2, "hello world", 11))
+                       errx(13, "signhello fail");
+               if(!status)
+                       errx(14, "signsignature fail");
                bench(&bench_auth);
                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");
@@ -173,7 +186,7 @@ int main(int argc, char **argv)
                        errx(17, "dhkey match fail");
                ++n;
                if(n % 1024 == 0)
-                       printf("auth=%f chall=%f resp=%f verify=%f dh1=%f dh2=%f\n", n/bench_auth, n/bench_chall, n/bench_resp, n/bench_verify, n/bench_dhkey1, n/bench_dhkey2);
+                       printf("sign=%f signverify=%f auth=%f chall=%f resp=%f verify=%f dh1=%f dh2=%f\n", n/bench_sign, n/bench_signverify, n/bench_auth, n/bench_chall, n/bench_resp, n/bench_verify, n/bench_dhkey1, n/bench_dhkey2);
        }
 
        return 0;