#include <crypto/crypto.h>
#include <crypto/hc.h>

NTL_CLIENT


void HC :: PrettyPrint(ostream& tofile)
{
	tofile << "\n=============";
	tofile << "\nHybrid Cipher";
	tofile << "\n=============\n";
	dem.PrettyPrint(tofile);
	kem.PrettyPrint(tofile);
}


ostring HC :: encrypt(const ostring& mssg, const ostring& Label)
{
	ostring K, C0, C1, C, txt;

	dem.logfile = logfile;
	kem.logfile = logfile;

	*logfile << "==================================";
	*logfile << "\nTrace for HC encrypt";
	*logfile << "\n==================================\n";

	K = kem.encrypt(C0);
	C1 = dem.encrypt(K, Label, mssg);
	C = C0 + C1;
	return C;
}


ostring HC :: decrypt(const ostring& cipher, const ostring& Label)
{
	int l;
	ostring C1, K, M;

	K = kem.decrypt(cipher, l);
	C1 = cipher.substr(l, cipher.size()-l);
	return dem.decrypt(K, Label, C1);
}
