/* * hw8.cpp * * Created on: Mar 26, 2014 * Author: carola */ #include using namespace std; /*********************************************************************** * Function and class headers. This should ideally be in a separate file cryptoLib.h ***********************************************************************/ /* * TODO: * * Class or struct definitions go here for: * User * PublicKeyDB */ class PublicKeyDB{ /* TODO: Fill in details. */ }; /************************************************************************* * Global variables and constants *************************************************************************/ // Mysterious library function that returns public and private encryption keys. Those should be generated from large prime numbers. int c=0; const int keys[15]= {95, 5, 29, 119, 7, 55, 115, 7, 63, 161, 7, 19, 121, 11, 91}; void next_n_e_d(int* n, int* e, int* d){ *n=keys[c++]; *e=keys[c++]; *d=keys[c++]; c=c%15; } // Default capacity for strings. #define STRING_CAPACITY 256 // Global storage for all public keys for all users. PublicKeyDB publicKeys = PublicKeyDB(); /********************************************************************************************** * Function and class implementations. This should ideally be in a separate file cryptoLib.cpp **********************************************************************************************/ int pow_mod(int a, int b, int m){ // Computes a^b mod m. Assume b>0. int result = 1; int i; for(i=0; i