#ifndef MAC_H_INCLUDED
#define MAC_H_INCLUDED

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

class MAC
{
 public:
	const int keylen;
	const int outlen;
	virtual ostring eval(const ostring& K, const ostring& txt) = 0;

	virtual void PrettyPrint(std::ostream&) = 0;

	MAC(int key, int out) : keylen(key), outlen(out) { };
};


class HMAC : public MAC
{
 public:
	HASH &h;

	ostring eval(const ostring& K, const ostring& txt);
	void PrettyPrint(std::ostream&);

	HMAC(HASH& H, int k, int o) : h(H), MAC(k, o)
	{
		if(h.chainlen > keylen || keylen > h.blocklen || outlen < 1 || outlen > h.outlen)
                	throw Key_error();
	};
};

#endif /* MAC_H_INCLUDED */

