proj home

Files   Classes   Functions   Hierarchy  

passwordverifier001test.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 using namespace std;
00003 
00004 #include <passwordverifier001.h>
00005 #include <passwordverifier001test.h>
00006 #include <print.h>
00007 
00008 void passwordverifier001test::test02()
00009 {
00010   ZZ pass;
00011   conv(pass,"8493903");
00012 
00013   ZZ j1;
00014   conv(j1,"23");
00015   ZZ k1;
00016   conv(k1,"12");
00017 
00018   ZZ n1;
00019   conv(n1,"8294");
00020   //conv(n1,"8294");
00021 
00022   cout << SHOW(pass) << endl;
00023   cout << SHOW(j1) << endl;
00024   cout << SHOW(n1) << endl;
00025 
00026   ZZ w;
00027   //w = (pass ^ j1 ) % n1;
00028   w = PowerMod(pass%n1,j1,n1);
00029 
00030   cout << SHOW(w) << endl;
00031 
00032 
00033 /*
00034 
00035   ZZ j2;
00036   conv(j2,"3");
00037   
00038 */
00039 
00040 }
00041 
00042 int passwordverifier001test::unittest01()
00043 {
00044   uintc nbits=20;
00045   cout << SHOW(nbits) << endl;
00046   passwordverifier001 client(nbits);
00047   cout << "Create a passord" << endl;
00048   
00049   client.generatePassword();
00050   cout << SHOW(client.password) << endl;
00051 
00052   passwordverifier001 server(nbits);
00053   server.password = client.password;
00054   cout << SHOW(server.password) << endl;
00055 
00056   cout << "Both the server and client share the password." << endl << endl;
00057 
00058   cout << "Client requests parameters." << endl;
00059   cout << "Server is generating the function parameters." << endl;
00060   server.generateRandomFunction();
00061   string param;
00062   server.parameters_get(param);
00063   cout << SHOW(param) << endl << endl;
00064   client.parameters_set(param);
00065 
00066   string param2;
00067   client.parameters_get(param2);
00068   cout << SHOW(param2) << endl << endl;
00069 
00070 cout << endl << "Double Check" << endl;
00071 cout << SHOW(client.j1) << endl;
00072 cout << SHOW(client.j2) << endl;
00073 cout << SHOW(client.n1) << endl;
00074 cout << SHOW(client.n2) << endl;
00075 cout << SHOW(client.k1) << endl;
00076 cout << SHOW(server.j1) << endl;
00077 cout << SHOW(server.j2) << endl;
00078 cout << SHOW(server.n1) << endl;
00079 cout << SHOW(server.n2) << endl;
00080 cout << SHOW(server.k1) << endl;
00081 cout << endl;
00082 
00083   string answer;
00084   client.eval(answer);
00085   cout << "Client evaluates the answer." << endl;
00086   cout << SHOW(answer) << endl << endl;
00087 
00088   cout << "Server verifies this." << endl;
00089   string answer2;
00090   server.eval(answer2);
00091   cout << SHOW(answer2) << endl << endl;
00092  
00093 
00094   bool result;
00095   result = server.verify(answer);
00096   cout << SHOW(result) << endl;
00097 
00098   if (result==false)
00099     return 1;
00100 
00101   return 0;
00102 }
00103 
00104 
00105 

Generated on Fri Mar 4 00:49:31 2011 for Chelton Evans Source by  doxygen 1.5.8