#include <cstdio>
#include <iostream>
#include <exception>

#include "files.h"
#include "hex.h"
#include "rsa.h"
#include "osrng.h"
#include "des.h"
#include "integer.h"

using namespace CryptoPP;
using namespace std;

int main(int argc, char *argv[])
{
	try {
		Integer e, eStart(atoi(argv[1]));

		// Make sure e is odd
		e = eStart+(1-eStart%2);

		AutoSeededX917RNG<DES_EDE3> rng;
		InvertibleRSAFunction frsa;

		frsa.Initialize(rng, 1024, e);			

		HexEncoder hexOut(new FileSink(argv[2]));
		frsa.DEREncode(hexOut);
		hexOut.MessageEnd();
	}
	catch(CryptoPP::Exception &e) {
		cout << "CryptoPP::Exception caught: " << e.what() << endl;
	}
}
