// Returns 0 on success, -1 on failure // If a failure occurs the password will contain a description of the error int Keygen(char const *_sysInfoFilename, char const *_userInfoFilename, char const **_password) { int fileLen; char const *sysInfoData = ReadFileToBuf(_sysInfoFilename, &fileLen); if (!sysInfoData) { *_password = "******"; return -1; } return Keygen(sysInfoData, fileLen, _userInfoFilename, _password); }
bool RSA::DefaultTest(unsigned int size) { if(size < 64) { std::cout << "RSA test invald input\n"; return false; } BigInteger pub, priv, modulus; Utils::TestGenerator generator; Keygen(pub, priv, modulus, &generator, size); BigInteger message = generator.getBig(size) % modulus; BigInteger crypto = Encrypt(message, pub, modulus); BigInteger message1 = Decrypt(crypto, priv, modulus); bool result = (message1 == message); if(result) std::cout << "RSA test OK\n"; else std::cout << "RSA test ERROR\n"; return result; }