/*
 *	Keys class
 *	By Jeremy Lennert
 *	February 7, 2001
 *	v. 1.0
 *
 *	Keys.h
 *
 *	Contains definition for a "keys" struct used by various
 *	source files associated with the Decrypter program as an
 *	all-purpose data type for storing keys to various ciphers.
 *
 *	Currently, it can only hold keys for the following types
 *	of ciphers:
 *		1. 8-bit constant XOR
 *		2. simple monoalphabetic shift
 *		3. simple monoalphabetic general substitution
 *	additional types of storage will be added in tandem with
 *	their need by the Decrypter program.
 *
 *	A key of type zero is used by cryptanalysis algorithms
 *	to indicate that no suitable key was found.
 *
 *	Values for the key must be passed in at creation and
 *	cannot be altered; otherwise, it would be a different key!
 */

#ifndef Keys_h
#define Keys_h

typedef enum keytype {
	KEYTYPE_XOR = 1,
	KEYTYPE_SHIFT = 2,
	KEYTYPE_SUBST = 3
} keytype;

class Keys
{
public:
	Keys(int t);
	Keys(int t, unsigned char c);	// Constructor for key type 1, 2
	Keys(int t, const unsigned char *s);	// Constructor for key type 3
	Keys(Keys *k);		// Copy constructor

	keytype Type();	// Returns type
	int Ckey();	// Returns ckey; -1 if key not of type 1, 2
	const unsigned char* Skey();	// Returns skey
	void decrypt(unsigned char *ciphertext);	// Decrypts string with key

	~Keys();	// Destructor
protected:
	keytype type;		// Code to indicate cipher type; see enumeration above
	unsigned char ckey;		// Key for type 1, 2
	unsigned char skey[256];	// Key for type 3
};

#endif