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_MHASHPP_H
22 #define SH_MHASHPP_H
23 
24 #define _Bool bool
25 #include <mhash.h>
26 
27 #include "common.h"
28 
29 class BitString ;
30 
31 class MHashPP {
32 	public:
33 	enum Command { endhash } ;
34 
35 	MHashPP (void) ;
36 	MHashPP (hashid a) ;
37 
38 	void init (hashid a) ;
39 
40 	const std::vector<BYTE>& end (void) ;
41 
42 	/**
43 	 * feed the std::string v to the hashing algorithm
44 	 * \param v the std::string to be feeded to the hashing algorithm (without '\0' at the end)
45 	 **/
46 	MHashPP& operator<< (std::string v) ;
47 
48 	/**
49 	 * feed the BitString v to the hashing algorithm
50 	 * \param v the BitString to be feeded to the hashing algorithm (v.getLength() % 8 == 0 must hold)
51 	 **/
52 	MHashPP& operator<< (BitString v) ;
53 
54 	/**
55 	 * feed the byte v to the hashing algorithm
56 	 * \param v the byte to be feeded to the hashing algorithm
57 	 **/
58 	MHashPP& operator<< (BYTE v) ;
59 
60 	/**
61 	 * interpret the command c
62 	 * \param c a command (member of MHashPP::Command)
63 	 **/
64 	MHashPP& operator<< (Command c) ;
65 
66 	/**
67 	 * get the hash bits
68 	 * \return the hash value of the data that has been passed via <<
69 	 **/
70 	BitString getHashBits (void) ;
71 
72 	const std::vector<BYTE>& getHashBytes (void) ;
73 
74 	/**
75 	 * get the hash size
76 	 * \return the size of the value returned by getHashBits in bytes
77 	 **/
78 	unsigned int getHashSize (void) ;
79 
80 	private:
81 	/// true iff HashD contains a legal hash descriptor and data can be passed via <<
82 	bool hashing ;
83 	MHASH HashD ;
84 
85 	/// true iff HashBytes contains a valid hash value
86 	bool HashBytesValid ;
87 	std::vector<BYTE> HashBytes ;
88 
89 	std::string getAlgorithmName (void) ;
90 	static std::string getAlgorithmName (hashid id) ;
91 } ;
92 
93 #endif // ndef SH_MHASHPP_H
94