srecord 1.65.0
 
Loading...
Searching...
No Matches
gcrypt.h
Go to the documentation of this file.
1//
2// srecord - Manipulate EPROM load files
3// Copyright (C) 2009-2011 Peter Miller
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation; either version 3 of the License, or (at
8// 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 GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18
19#ifndef SRECORD_INPUT_FILTER_MESSAGE_GCRYPT_H
20#define SRECORD_INPUT_FILTER_MESSAGE_GCRYPT_H
21
23
24namespace srecord
25{
26
27/**
28 * The srecord::input_filter_message_gcrypt class is used to represent a
29 * filter that runs the data through one of the hashing algorithms in
30 * the gcrypt library.
31 *
32 * http://freshmeat.net/projects/libgcrypt/
33 * http://directory.fsf.org/project/libgcrypt/
34 */
35class input_filter_message_gcrypt:
37{
38public:
39 /**
40 * The destructor.
41 */
43
44private:
45 /**
46 * The constructor. It is private on purpose, use one of the
47 * create_* class method instead.
48 *
49 * @param deeper
50 * The source of data to be filtered.
51 * @param algo
52 * The algorithm number (private to class).
53 * @param hmac
54 * Turn the hash into a HMAC.
55 * @param address
56 * Where to place the hash in memory.
57 * @param hmac
58 * Add a message authentication code
59 */
60 input_filter_message_gcrypt(const input::pointer &deeper,
61 unsigned long address, int algo, bool hmac);
62
63private:
64 /**
65 * The create class method is used to create a new dynamically
66 * allocated instance of this class.
67 *
68 * @param deeper
69 * The source of data to be filtered.
70 * @param algo
71 * The algorithm to be used. This is for debug.
72 * The actual algorithm numbers are private to the class.
73 * Choose a random number, it will likely segfault. Seriously.
74 * @param address
75 * Where to place the hash in memory.
76 * @param hmac
77 * Add a message authentication code
78 */
79 static pointer create(const input::pointer &deeper, unsigned long address,
80 int algo, bool hmac = false);
81
82 /**
83 * The algorithm_from_name class method is used to translate an
84 * algorithm name into an algorithm number.
85 *
86 * @param name
87 * The name of the algorithm.
88 * @return
89 * an algorithm number. It does not return if the name is
90 * unknown, it exits with a fatal error message instead.
91 */
92 static int algorithm_from_name(const char *name);
93
94public:
95 /**
96 * The create class method is used to create a new dynamically
97 * allocated instance of this class.
98 *
99 * @param deeper
100 * The source of data to be filtered.
101 * @param address
102 * Where to place the hash in memory.
103 * @param algo
104 * The algorithm to be used. This is for debug.
105 * The actual algorithm numbers are private to the class.
106 * @param hmac
107 * Turn the hash into a HMAC.
108 */
109 static pointer create(const input::pointer &deeper, unsigned long address,
110 const char *algo, bool hmac = false);
111
112 /**
113 * The create_md5 class method is used to create a new dynamically
114 * allocated instance of this class, that calculates MD5 hashes.
115 *
116 * @param deeper
117 * The source of data to be filtered.
118 * @param address
119 * Where to place the hash in memory.
120 */
121 static pointer create_md5(const input::pointer &deeper,
122 unsigned long address);
123
124 /**
125 * The create_sha1 class method is used to create a new dynamically
126 * allocated instance of this class, that calculates SHA1 hashes.
127 *
128 * @param deeper
129 * The source of data to be filtered.
130 * @param address
131 * Where to place the hash in memory.
132 */
133 static pointer create_sha1(const input::pointer &deeper,
134 unsigned long address);
135
136 /**
137 * The create_rmd160 class method is used to create a new dynamically
138 * allocated instance of this class, that calculates RMD160 hashes.
139 *
140 * @param deeper
141 * The source of data to be filtered.
142 * @param address
143 * Where to place the hash in memory.
144 */
146 unsigned long address);
147
148 /**
149 * The create_md2 class method is used to create a new dynamically
150 * allocated instance of this class, that calculates MD2 hashes.
151 *
152 * @param deeper
153 * The source of data to be filtered.
154 * @param address
155 * Where to place the hash in memory.
156 */
157 static pointer create_md2(const input::pointer &deeper,
158 unsigned long address);
159
160 /**
161 * The create_tiger class method is used to create a new dynamically
162 * allocated instance of this class, that calculates TIGER/192 hashes.
163 *
164 * @param deeper
165 * The source of data to be filtered.
166 * @param address
167 * Where to place the hash in memory.
168 */
169 static pointer create_tiger(const input::pointer &deeper,
170 unsigned long address);
171
172 /**
173 * The create_haval class method is used to create a new dynamically
174 * allocated instance of this class, that calculates HAVAL/160 hashes.
175 *
176 * @param deeper
177 * The source of data to be filtered.
178 * @param address
179 * Where to place the hash in memory.
180 */
181 static pointer create_haval(const input::pointer &deeper,
182 unsigned long address);
183
184 /**
185 * The create_sha256 class method is used to create a new dynamically
186 * allocated instance of this class, that calculates SHA-256 hashes.
187 *
188 * @param deeper
189 * The source of data to be filtered.
190 * @param address
191 * Where to place the hash in memory.
192 */
194 unsigned long address);
195
196 /**
197 * The create_sha384 class method is used to create a new dynamically
198 * allocated instance of this class, that calculates SHA-384 hashes.
199 *
200 * @param deeper
201 * The source of data to be filtered.
202 * @param address
203 * Where to place the hash in memory.
204 */
206 unsigned long address);
207
208 /**
209 * The create_sha512 class method is used to create a new dynamically
210 * allocated instance of this class, that calculates SHA-512 hashes.
211 *
212 * @param deeper
213 * The source of data to be filtered.
214 * @param address
215 * Where to place the hash in memory.
216 */
218 unsigned long address);
219
220 /**
221 * The create_sha224 class method is used to create a new dynamically
222 * allocated instance of this class, that calculates SHA-224 hashes.
223 *
224 * @param deeper
225 * The source of data to be filtered.
226 * @param address
227 * Where to place the hash in memory.
228 */
230 unsigned long address);
231
232 /**
233 * The create_md4 class method is used to create a new dynamically
234 * allocated instance of this class, that calculates MD4 hashes.
235 *
236 * @param deeper
237 * The source of data to be filtered.
238 * @param address
239 * Where to place the hash in memory.
240 */
241 static pointer create_md4(const input::pointer &deeper,
242 unsigned long address);
243
244 /**
245 * The create_crc32 class method is used to create a new dynamically
246 * allocated instance of this class, that calculates CRC-32 hashes.
247 *
248 * @param deeper
249 * The source of data to be filtered.
250 * @param address
251 * Where to place the hash in memory.
252 */
253 static pointer create_crc32(const input::pointer &deeper,
254 unsigned long address);
255
256 /**
257 * The create_crc32_rfc1510 class method is used to create a new
258 * dynamically allocated instance of this class, that calculates
259 * CRC32 RFC1510 hashes.
260 *
261 * @param deeper
262 * The source of data to be filtered.
263 * @param address
264 * Where to place the hash in memory.
265 */
267 unsigned long address);
268
269 /**
270 * The create_crc24_rfc2440 class method is used to create a new
271 * dynamically allocated instance of this class, that calculates
272 * CRC24 RFC2440 hashes.
273 *
274 * @param deeper
275 * The source of data to be filtered.
276 * @param address
277 * Where to place the hash in memory.
278 */
280 unsigned long address);
281
282 /**
283 * The create_whirlpool class method is used to create a new
284 * dynamically allocated instance of this class, that calculates
285 * WHIRLPOOL hashes.
286 *
287 * @param deeper
288 * The source of data to be filtered.
289 * @param address
290 * Where to place the hash in memory.
291 */
293 unsigned long address);
294
295protected:
296 // See base class for documentation.
298
299 // See base class for documentation.
300 const char *get_algorithm_name() const;
301
302private:
303 /**
304 * The algo instance variable is used to remember the algorithm
305 * number.
306 */
307 int algo;
308
309 /**
310 * The hmac instance variable is used to remember whether or not to
311 * turn the hash into a HMAC.
312 */
313 bool hmac;
314
315 /**
316 * The address instance variable is used to remember where to place
317 * the hash in memory.
318 */
319 unsigned long address;
320
321 /**
322 * The default constructor. Do not use.
323 */
324 input_filter_message_gcrypt();
325
326 /**
327 * The copy constructor. Do not use.
328 */
329 input_filter_message_gcrypt(const input_filter_message_gcrypt &);
330
331 /**
332 * The assignment operator. Do not use.
333 */
334 input_filter_message_gcrypt &operator=(const input_filter_message_gcrypt &);
335};
336
337};
338
339// vim: set ts=8 sw=4 et :
340#endif // SRECORD_INPUT_FILTER_MESSAGE_GCRYPT_H
static pointer create_crc32(const input::pointer &deeper, unsigned long address)
The create_crc32 class method is used to create a new dynamically allocated instance of this class,...
static pointer create_sha512(const input::pointer &deeper, unsigned long address)
The create_sha512 class method is used to create a new dynamically allocated instance of this class,...
virtual ~input_filter_message_gcrypt()
The destructor.
static pointer create_crc32_rfc1510(const input::pointer &deeper, unsigned long address)
The create_crc32_rfc1510 class method is used to create a new dynamically allocated instance of this ...
void process(const memory &input, record &output)
The process method is used to process the data from the input.
static pointer create_sha256(const input::pointer &deeper, unsigned long address)
The create_sha256 class method is used to create a new dynamically allocated instance of this class,...
const char * get_algorithm_name() const
The get_algorithm_name method is used in error messages.
static pointer create_haval(const input::pointer &deeper, unsigned long address)
The create_haval class method is used to create a new dynamically allocated instance of this class,...
static pointer create_md4(const input::pointer &deeper, unsigned long address)
The create_md4 class method is used to create a new dynamically allocated instance of this class,...
static pointer create_md2(const input::pointer &deeper, unsigned long address)
The create_md2 class method is used to create a new dynamically allocated instance of this class,...
static pointer create_sha1(const input::pointer &deeper, unsigned long address)
The create_sha1 class method is used to create a new dynamically allocated instance of this class,...
static pointer create_rmd160(const input::pointer &deeper, unsigned long address)
The create_rmd160 class method is used to create a new dynamically allocated instance of this class,...
static pointer create_md5(const input::pointer &deeper, unsigned long address)
The create_md5 class method is used to create a new dynamically allocated instance of this class,...
static pointer create_whirlpool(const input::pointer &deeper, unsigned long address)
The create_whirlpool class method is used to create a new dynamically allocated instance of this clas...
static pointer create(const input::pointer &deeper, unsigned long address, const char *algo, bool hmac=false)
The create class method is used to create a new dynamically allocated instance of this class.
static pointer create_sha384(const input::pointer &deeper, unsigned long address)
The create_sha384 class method is used to create a new dynamically allocated instance of this class,...
static pointer create_tiger(const input::pointer &deeper, unsigned long address)
The create_tiger class method is used to create a new dynamically allocated instance of this class,...
static pointer create_crc24_rfc2440(const input::pointer &deeper, unsigned long address)
The create_crc24_rfc2440 class method is used to create a new dynamically allocated instance of this ...
static pointer create_sha224(const input::pointer &deeper, unsigned long address)
The create_sha224 class method is used to create a new dynamically allocated instance of this class,...
input_filter_message(const input::pointer &deeper, bool naked=false)
The constructor.
The srecord::input class is used to represent an abstract EPROM load file source.
Definition input.h:39
std::shared_ptr< input > pointer
Definition input.h:41
The srecord::memory class is used to simulate memory contents.
Definition memory.h:40
The srecord::output class is used to represent an abstract output vector.
Definition output.h:39
The srecord::record class is used to represent a data record read from a file.
Definition record.h:35