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

NTL_CLIENT

void SC2 :: PrettyPrint(ostream& tofile)
{
	tofile << "SC2(Kdf=";
	k.PrettyPrint(tofile);
	tofile << ", keylen=" << keylen << ")";
}

ostring SC2 :: encrypt(const ostring& key, const ostring& mssg)
{
	if (key.size() != keylen)
		throw General_error();

	long l = mssg.size();
	ostring mask, cipher;

	mask = k.eval(key, l);

	cipher = Xor(mask,mssg);

	return cipher;
}

ostring SC2 :: decrypt(const ostring& key, const ostring& cipher)
{
	if (key.size() != keylen)
		throw General_error();

	long l;
        ostring mask, mssg;

	l = cipher.size();
        mask = k.eval(key, l);

        mssg = Xor(mask,cipher);

        return mssg;
}

