Files Classes Functions Hierarchy
#include <passwordverifier001test.h>
Static Public Member Functions | |
| static int | unittest01 () |
| Basic test for conformation of password. | |
| static void | test02 () |
Definition at line 7 of file passwordverifier001test.h.
| void passwordverifier001test::test02 | ( | ) | [static] |
Definition at line 8 of file passwordverifier001test.cpp.
References SHOW.
Referenced by main().
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 }
| int passwordverifier001test::unittest01 | ( | ) | [static] |
Basic test for conformation of password.
Definition at line 42 of file passwordverifier001test.cpp.
References passwordverifier001::eval(), passwordverifier001::generatePassword(), passwordverifier001::generateRandomFunction(), passwordverifier001::j1, passwordverifier001::j2, passwordverifier001::k1, passwordverifier001::n1, passwordverifier001::n2, passwordverifier001::parameters_get(), passwordverifier001::parameters_set(), passwordverifier001::password, SHOW, and passwordverifier001::verify().
Referenced by main().
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 }
1.5.8