1 /*
2  * steghide 0.5.1 - a steganography program
3  * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  *
19  */
20 
21 #ifndef SH_ENCMODE_H
22 #define SH_ENCMODE_H
23 
24 #include <string>
25 
26 class EncryptionMode {
27 	public:
28 	/// number of bits needed to code the mode
29 	static const unsigned int IRep_size = 3 ;
30 
31 	/// integer representation of encryption mode
32 	enum IRep {
33 		ECB = 0,
34 		CBC = 1,
35 		OFB = 2,
36 		CFB = 3,
37 		NOFB = 4,
38 		NCFB = 5,
39 		CTR = 6,
40 		STREAM = 7
41 	} ;
42 
43 	/**
44 	 * construct a new EncryptionMode object setting Value to ECB
45 	 **/
46 	EncryptionMode (void) ;
47 	EncryptionMode (IRep irep) ;
48 	/**
49 	 * construct a new EncryptionMode object from a std::string representation
50 	 * \param srep a valid(!) std::string representation
51 	 **/
52 	EncryptionMode (std::string srep) ;
53 
54 	void setValue (IRep irep) ;
55 
56 	std::string getStringRep (void) const ;
57 	IRep getIntegerRep (void) const ;
58 
59 	bool operator== (const EncryptionMode& mode) const
60 		{ return (Value == mode.Value) ; } ;
61 
62 	static bool isValidStringRep (std::string srep) ;
63 	static bool isValidIntegerRep (unsigned int irep) ;
64 
65 	static std::string translate (IRep irep) ;
66 	static IRep translate (std::string srep) ;
67 
68 	private:
69 	static const unsigned int NumValues = 8 ;
70 	IRep Value ;
71 
72 	typedef struct struct_Translation {
73 		IRep	irep ;
74 		char*	srep ;
75 	} Translation ;
76 	static const Translation Translations[] ;
77 } ;
78 
79 #endif // ndef SH_ENCMODE_H
80