]> de.git.xonotic.org Git - xonotic/d0_blind_id.git/blobdiff - main.c
separate RSA modulus from DL modulus; we still need the RSA modulus to generate the...
[xonotic/d0_blind_id.git] / main.c
diff --git a/main.c b/main.c
index 88bf520bf8b6bcf26fd70f8b3e5c4b31c0fd582b..5da16d066629c4bdfdd085e38f8ef66288f1691d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,3 +1,22 @@
+/*
+Blind-ID library for user identification using RSA blind signatures
+Copyright (C) 2010  Rudolf Polzer
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
 #include "d0_blind_id.h"
 
 #include <stdio.h>
@@ -34,12 +53,23 @@ int main(int argc, char **argv)
        ctx_self = d0_blind_id_new();
        ctx_other = d0_blind_id_new();
 
-       if(!d0_blind_id_generate_private_keys(ctx_self, 1024))
+       printf("keygen RSA...\n");
+       if(!d0_blind_id_generate_private_key(ctx_self, 1024))
+               errx(1, "keygen fail");
+       bufsize = sizeof(buf); if(!d0_blind_id_write_public_key(ctx_self, buf, &bufsize))
+               errx(2, "writepub fail");
+       if(!d0_blind_id_read_public_key(ctx_other, buf, bufsize))
+               errx(3, "readpub fail");
+
+       printf("keygen modulus...\n");
+       if(!d0_blind_id_generate_private_id_modulus(ctx_other))
                errx(1, "keygen fail");
-       bufsize = sizeof(buf); if(!d0_blind_id_write_public_keys(ctx_self, buf, &bufsize))
+       /*
+       bufsize = sizeof(buf); if(!d0_blind_id_write_private_id_modulus(ctx_other, buf, &bufsize))
                errx(2, "writepub fail");
-       if(!d0_blind_id_read_public_keys(ctx_other, buf, bufsize))
+       if(!d0_blind_id_read_private_id_modulus(ctx_self, buf, bufsize))
                errx(3, "readpub fail");
+       */
 
        signal(SIGINT, mysignal);
 
@@ -77,22 +107,25 @@ int main(int argc, char **argv)
 
        n = 0;
        double bench_auth = 0, bench_chall = 0, bench_resp = 0, bench_verify = 0;
+       BOOL status;
        while(!quit)
        {
                bench(&bench_auth);
-               bufsize = sizeof(buf); if(!d0_blind_id_authenticate_with_private_id_start(ctx_other, 1, "hello world", 11, buf, &bufsize))
+               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, buf, bufsize, buf2, &buf2size))
+               buf2size = sizeof(buf2); if(!d0_blind_id_authenticate_with_private_id_challenge(ctx_self, 1, 1, buf, bufsize, buf2, &buf2size, NULL))
                        errx(10, "challenge fail");
                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");
                bench(&bench_verify);
-               buf2ssize = sizeof(buf2); if(!d0_blind_id_authenticate_with_private_id_verify(ctx_self, buf, bufsize, buf2, &buf2ssize))
+               buf2ssize = sizeof(buf2); if(!d0_blind_id_authenticate_with_private_id_verify(ctx_self, buf, bufsize, buf2, &buf2ssize, &status))
                        errx(12, "verify fail");
                if(buf2ssize != 11 || memcmp(buf2, "hello world", 11))
                        errx(13, "hello fail");
+               if(!status)
+                       errx(14, "signature fail");
                bench(&bench_stop);
                ++n;
                if(n % 1024 == 0)