Hi folks,
I've been trying to generate RSA key pairs. To do this I looked at the example
provided in Denis Bider's Crypto++ User Guide. The following:
#include "rsa.h"
#include "osrng.h"
using namespace CryptoPP;
using namespace std;
int main() {
// InvertibleRSAFunction is used directly only because the private key
// won't actually be used to perform any cryptographic operation;
// otherwise, an appropriate typedef'ed type from rsa.h would have been used.
AutoSeededRandomPool rng;
InvertibleRSAFunction privkey(rng,1024);
//...
return 0;
}
// Taken from Denis Bider's user guide in the rsa.h section
...generates this error:
RSA.cpp: In function `int main()':
RSA.cpp:15: no matching function for call to
`CryptoPP::InvertibleRSAFunction::InvertibleRSAFunction
(CryptoPP::AutoSeededRandomPool &, int)'
rsa.h:99: candidates are:
CryptoPP::InvertibleRSAFunction::InvertibleRSAFunction(const
CryptoPP::InvertibleRSAFunction &)
rsa.h:99:
CryptoPP::InvertibleRSAFunction::InvertibleRSAFunction()
It seems that there is no constructor available for these arguments. Perhaps
the user guide is getting old with the release of version 5.0 of
Crypto++5.0??
Anyway I've tried the following instead:
#include "rsa.h"
#include "osrng.h"
using namespace CryptoPP;
using namespace std;
int main() {
AutoSeededRandomPool rng;
InvertibleRSAFunction privkey; // Just use the default constructor
privkey.Initialize(rng,1024,17); // Use the Initialize method
return 0;
}
Now I thought this would work but then I get this error:
RSA.cpp: In function `int main()':
RSA.cpp:16: request for member `Initialize' in `privkey', which is of
non-aggregate type `CryptoPP::InvertibleRSAFunction ()()'
Any hint on what I am doing wrong?
I compiled both samples using:
g++ -c RSA.cpp -o RSA.o
g++ -o RSA RSA.o -L. -lcryptopp
compiler: g++ 2.95.4
uname: Linux zephyr 2.4.19 #1 Thu Oct 24 19:54:10 EDT 2002 i686 AMD Athlon(TM)
XP 2000+ AuthenticAMD GNU/Linux
Thanks,
Jean-Pierre Parent