#include <crypto/rsaes.h>
#include <crypto/rem.h>

#define STR_AUX(a) #a
#define STR(a) STR_AUX(a)

NTL_CLIENT


int main()
{
	ostring M = " This is a test message !!!";
	ostring L = "Label";
	ostring C, K;

#if !defined(Kdf)
#error "Error - Kdf not defined."
#endif

#if !defined(KHash)
#error "Error - KHash not defined."
#endif

#if (KHash == 1)
	SHA1 hash(20);
	Kdf kdf(hash);
#elif (KHash == 2)
	SHA256 hash(20);
	Kdf kdf(hash);
#elif (KHash == 3)
	MD5 hash(16);
	Kdf kdf(hash);
#else
#error "Error - KHash value not defined."
#endif

#if !defined(RHash)
#error "Error - RHash not defined."
#endif

#if (RHash == 1)
        SHA1 h(20);
#elif (RHash == 2)
        SHA256 h(20);
#elif (RHash == 3)
        MD5 h(16);
#else
#error "Error - RHash value not defined."
#endif

	REM1 rem(h, kdf);

	RSAES rsa(rem, 512);

	ofstream io(STR(DESC));
	ofstream trace(STR(TRACE));

	rsa.PrettyPrint(io);
	rsa.logfile = &trace;

	C = rsa.encrypt(L, M);

	if(M != rsa.decrypt(L, C))
		cout << "\n RSAES failed \n";
	else
		cout << "\n RSAES success \n";
}

