1 /* $Id: sph_haval.h 218 2010-06-08 17:06:34Z tp $ */
5 * HAVAL is actually a family of 15 hash functions, depending on whether
6 * the internal computation uses 3, 4 or 5 passes, and on the output
7 * length, which is 128, 160, 192, 224 or 256 bits. This implementation
8 * provides interface functions for all 15, which internally map to
9 * three cores (depending on the number of passes). Note that output
10 * lengths other than 256 bits are not obtained by a simple truncation
11 * of a longer result; the requested length is encoded within the
14 * HAVAL was published in: Yuliang Zheng, Josef Pieprzyk and Jennifer
15 * Seberry: "HAVAL -- a one-way hashing algorithm with variable length
16 * of output", Advances in Cryptology -- AUSCRYPT'92, Lecture Notes in
17 * Computer Science, Vol.718, pp.83-104, Springer-Verlag, 1993.
19 * This paper, and a reference implementation, are available on the
20 * Calyptix web site: http://labs.calyptix.com/haval.php
22 * The HAVAL reference paper is quite unclear on the data encoding
23 * details, i.e. endianness (both byte order within a 32-bit word, and
24 * word order within a message block). This implementation has been
25 * made compatible with the reference implementation referenced above.
27 * @warning A collision for HAVAL-128/3 (HAVAL with three passes and
28 * 128-bit output) has been published; this function is thus considered
29 * as cryptographically broken. The status for other variants is unclear;
32 * ==========================(LICENSE BEGIN)============================
34 * Copyright (c) 2007-2010 Projet RNRT SAPHIR
36 * Permission is hereby granted, free of charge, to any person obtaining
37 * a copy of this software and associated documentation files (the
38 * "Software"), to deal in the Software without restriction, including
39 * without limitation the rights to use, copy, modify, merge, publish,
40 * distribute, sublicense, and/or sell copies of the Software, and to
41 * permit persons to whom the Software is furnished to do so, subject to
42 * the following conditions:
44 * The above copyright notice and this permission notice shall be
45 * included in all copies or substantial portions of the Software.
47 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
50 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
51 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
52 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
53 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55 * ===========================(LICENSE END)=============================
65 #include "sph_types.h"
68 * Output size (in bits) for HAVAL-128/3.
70 #define SPH_SIZE_haval128_3 128
73 * Output size (in bits) for HAVAL-128/4.
75 #define SPH_SIZE_haval128_4 128
78 * Output size (in bits) for HAVAL-128/5.
80 #define SPH_SIZE_haval128_5 128
83 * Output size (in bits) for HAVAL-160/3.
85 #define SPH_SIZE_haval160_3 160
88 * Output size (in bits) for HAVAL-160/4.
90 #define SPH_SIZE_haval160_4 160
93 * Output size (in bits) for HAVAL-160/5.
95 #define SPH_SIZE_haval160_5 160
98 * Output size (in bits) for HAVAL-192/3.
100 #define SPH_SIZE_haval192_3 192
103 * Output size (in bits) for HAVAL-192/4.
105 #define SPH_SIZE_haval192_4 192
108 * Output size (in bits) for HAVAL-192/5.
110 #define SPH_SIZE_haval192_5 192
113 * Output size (in bits) for HAVAL-224/3.
115 #define SPH_SIZE_haval224_3 224
118 * Output size (in bits) for HAVAL-224/4.
120 #define SPH_SIZE_haval224_4 224
123 * Output size (in bits) for HAVAL-224/5.
125 #define SPH_SIZE_haval224_5 224
128 * Output size (in bits) for HAVAL-256/3.
130 #define SPH_SIZE_haval256_3 256
133 * Output size (in bits) for HAVAL-256/4.
135 #define SPH_SIZE_haval256_4 256
138 * Output size (in bits) for HAVAL-256/5.
140 #define SPH_SIZE_haval256_5 256
143 * This structure is a context for HAVAL computations: it contains the
144 * intermediate values and some data from the last entered block. Once
145 * a HAVAL computation has been performed, the context can be reused for
146 * another computation.
148 * The contents of this structure are private. A running HAVAL computation
149 * can be cloned by copying the context (e.g. with a simple
150 * <code>memcpy()</code>).
153 #ifndef DOXYGEN_IGNORE
154 unsigned char buf[128]; /* first field, for alignment */
155 sph_u32 s0, s1, s2, s3, s4, s5, s6, s7;
156 unsigned olen, passes;
160 sph_u32 count_high, count_low;
166 * Type for a HAVAL-128/3 context (identical to the common context).
168 typedef sph_haval_context sph_haval128_3_context;
171 * Type for a HAVAL-128/4 context (identical to the common context).
173 typedef sph_haval_context sph_haval128_4_context;
176 * Type for a HAVAL-128/5 context (identical to the common context).
178 typedef sph_haval_context sph_haval128_5_context;
181 * Type for a HAVAL-160/3 context (identical to the common context).
183 typedef sph_haval_context sph_haval160_3_context;
186 * Type for a HAVAL-160/4 context (identical to the common context).
188 typedef sph_haval_context sph_haval160_4_context;
191 * Type for a HAVAL-160/5 context (identical to the common context).
193 typedef sph_haval_context sph_haval160_5_context;
196 * Type for a HAVAL-192/3 context (identical to the common context).
198 typedef sph_haval_context sph_haval192_3_context;
201 * Type for a HAVAL-192/4 context (identical to the common context).
203 typedef sph_haval_context sph_haval192_4_context;
206 * Type for a HAVAL-192/5 context (identical to the common context).
208 typedef sph_haval_context sph_haval192_5_context;
211 * Type for a HAVAL-224/3 context (identical to the common context).
213 typedef sph_haval_context sph_haval224_3_context;
216 * Type for a HAVAL-224/4 context (identical to the common context).
218 typedef sph_haval_context sph_haval224_4_context;
221 * Type for a HAVAL-224/5 context (identical to the common context).
223 typedef sph_haval_context sph_haval224_5_context;
226 * Type for a HAVAL-256/3 context (identical to the common context).
228 typedef sph_haval_context sph_haval256_3_context;
231 * Type for a HAVAL-256/4 context (identical to the common context).
233 typedef sph_haval_context sph_haval256_4_context;
236 * Type for a HAVAL-256/5 context (identical to the common context).
238 typedef sph_haval_context sph_haval256_5_context;
241 * Initialize the context for HAVAL-128/3.
243 * @param cc context to initialize (pointer to a
244 * <code>sph_haval128_3_context</code> structure)
246 void sph_haval128_3_init(void *cc);
249 * Process some data bytes for HAVAL-128/3. If <code>len</code> is 0,
250 * then this function does nothing.
252 * @param cc the HAVAL-128/3 context
253 * @param data the input data
254 * @param len the input data length (in bytes)
256 void sph_haval128_3(void *cc, const void *data, size_t len);
259 * Close a HAVAL-128/3 computation. The output buffer must be wide
260 * enough to accomodate the result (16 bytes). The context is automatically
263 * @param cc the HAVAL-128/3 context
264 * @param dst the output buffer
266 void sph_haval128_3_close(void *cc, void *dst);
269 * Close a HAVAL-128/3 computation. Up to 7 extra input bits may be added
270 * to the input message; these are the <code>n</code> upper bits of
271 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
272 * <code>ub</code>, the second extra bit has value 64, and so on). Other
273 * bits in <code>ub</code> are ignored.
275 * The output buffer must be wide enough to accomodate the result (16
276 * bytes). The context is automatically reinitialized.
278 * @param cc the HAVAL-128/3 context
279 * @param ub the extra bits
280 * @param n the number of extra bits (0 to 7)
281 * @param dst the output buffer
283 void sph_haval128_3_addbits_and_close(void *cc,
284 unsigned ub, unsigned n, void *dst);
287 * Initialize the context for HAVAL-128/4.
289 * @param cc context to initialize (pointer to a
290 * <code>sph_haval128_4_context</code> structure)
292 void sph_haval128_4_init(void *cc);
295 * Process some data bytes for HAVAL-128/4. If <code>len</code> is 0,
296 * then this function does nothing.
298 * @param cc the HAVAL-128/4 context
299 * @param data the input data
300 * @param len the input data length (in bytes)
302 void sph_haval128_4(void *cc, const void *data, size_t len);
305 * Close a HAVAL-128/4 computation. The output buffer must be wide
306 * enough to accomodate the result (16 bytes). The context is automatically
309 * @param cc the HAVAL-128/4 context
310 * @param dst the output buffer
312 void sph_haval128_4_close(void *cc, void *dst);
315 * Close a HAVAL-128/4 computation. Up to 7 extra input bits may be added
316 * to the input message; these are the <code>n</code> upper bits of
317 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
318 * <code>ub</code>, the second extra bit has value 64, and so on). Other
319 * bits in <code>ub</code> are ignored.
321 * The output buffer must be wide enough to accomodate the result (16
322 * bytes). The context is automatically reinitialized.
324 * @param cc the HAVAL-128/4 context
325 * @param ub the extra bits
326 * @param n the number of extra bits (0 to 7)
327 * @param dst the output buffer
329 void sph_haval128_4_addbits_and_close(void *cc,
330 unsigned ub, unsigned n, void *dst);
333 * Initialize the context for HAVAL-128/5.
335 * @param cc context to initialize (pointer to a
336 * <code>sph_haval128_5_context</code> structure)
338 void sph_haval128_5_init(void *cc);
341 * Process some data bytes for HAVAL-128/5. If <code>len</code> is 0,
342 * then this function does nothing.
344 * @param cc the HAVAL-128/5 context
345 * @param data the input data
346 * @param len the input data length (in bytes)
348 void sph_haval128_5(void *cc, const void *data, size_t len);
351 * Close a HAVAL-128/5 computation. The output buffer must be wide
352 * enough to accomodate the result (16 bytes). The context is automatically
355 * @param cc the HAVAL-128/5 context
356 * @param dst the output buffer
358 void sph_haval128_5_close(void *cc, void *dst);
361 * Close a HAVAL-128/5 computation. Up to 7 extra input bits may be added
362 * to the input message; these are the <code>n</code> upper bits of
363 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
364 * <code>ub</code>, the second extra bit has value 64, and so on). Other
365 * bits in <code>ub</code> are ignored.
367 * The output buffer must be wide enough to accomodate the result (16
368 * bytes). The context is automatically reinitialized.
370 * @param cc the HAVAL-128/5 context
371 * @param ub the extra bits
372 * @param n the number of extra bits (0 to 7)
373 * @param dst the output buffer
375 void sph_haval128_5_addbits_and_close(void *cc,
376 unsigned ub, unsigned n, void *dst);
379 * Initialize the context for HAVAL-160/3.
381 * @param cc context to initialize (pointer to a
382 * <code>sph_haval160_3_context</code> structure)
384 void sph_haval160_3_init(void *cc);
387 * Process some data bytes for HAVAL-160/3. If <code>len</code> is 0,
388 * then this function does nothing.
390 * @param cc the HAVAL-160/3 context
391 * @param data the input data
392 * @param len the input data length (in bytes)
394 void sph_haval160_3(void *cc, const void *data, size_t len);
397 * Close a HAVAL-160/3 computation. The output buffer must be wide
398 * enough to accomodate the result (20 bytes). The context is automatically
401 * @param cc the HAVAL-160/3 context
402 * @param dst the output buffer
404 void sph_haval160_3_close(void *cc, void *dst);
407 * Close a HAVAL-160/3 computation. Up to 7 extra input bits may be added
408 * to the input message; these are the <code>n</code> upper bits of
409 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
410 * <code>ub</code>, the second extra bit has value 64, and so on). Other
411 * bits in <code>ub</code> are ignored.
413 * The output buffer must be wide enough to accomodate the result (20
414 * bytes). The context is automatically reinitialized.
416 * @param cc the HAVAL-160/3 context
417 * @param ub the extra bits
418 * @param n the number of extra bits (0 to 7)
419 * @param dst the output buffer
421 void sph_haval160_3_addbits_and_close(void *cc,
422 unsigned ub, unsigned n, void *dst);
425 * Initialize the context for HAVAL-160/4.
427 * @param cc context to initialize (pointer to a
428 * <code>sph_haval160_4_context</code> structure)
430 void sph_haval160_4_init(void *cc);
433 * Process some data bytes for HAVAL-160/4. If <code>len</code> is 0,
434 * then this function does nothing.
436 * @param cc the HAVAL-160/4 context
437 * @param data the input data
438 * @param len the input data length (in bytes)
440 void sph_haval160_4(void *cc, const void *data, size_t len);
443 * Close a HAVAL-160/4 computation. The output buffer must be wide
444 * enough to accomodate the result (20 bytes). The context is automatically
447 * @param cc the HAVAL-160/4 context
448 * @param dst the output buffer
450 void sph_haval160_4_close(void *cc, void *dst);
453 * Close a HAVAL-160/4 computation. Up to 7 extra input bits may be added
454 * to the input message; these are the <code>n</code> upper bits of
455 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
456 * <code>ub</code>, the second extra bit has value 64, and so on). Other
457 * bits in <code>ub</code> are ignored.
459 * The output buffer must be wide enough to accomodate the result (20
460 * bytes). The context is automatically reinitialized.
462 * @param cc the HAVAL-160/4 context
463 * @param ub the extra bits
464 * @param n the number of extra bits (0 to 7)
465 * @param dst the output buffer
467 void sph_haval160_3_addbits_and_close(void *cc,
468 unsigned ub, unsigned n, void *dst);
471 * Initialize the context for HAVAL-160/5.
473 * @param cc context to initialize (pointer to a
474 * <code>sph_haval160_5_context</code> structure)
476 void sph_haval160_5_init(void *cc);
479 * Process some data bytes for HAVAL-160/5. If <code>len</code> is 0,
480 * then this function does nothing.
482 * @param cc the HAVAL-160/5 context
483 * @param data the input data
484 * @param len the input data length (in bytes)
486 void sph_haval160_5(void *cc, const void *data, size_t len);
489 * Close a HAVAL-160/5 computation. The output buffer must be wide
490 * enough to accomodate the result (20 bytes). The context is automatically
493 * @param cc the HAVAL-160/5 context
494 * @param dst the output buffer
496 void sph_haval160_5_close(void *cc, void *dst);
499 * Close a HAVAL-160/5 computation. Up to 7 extra input bits may be added
500 * to the input message; these are the <code>n</code> upper bits of
501 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
502 * <code>ub</code>, the second extra bit has value 64, and so on). Other
503 * bits in <code>ub</code> are ignored.
505 * The output buffer must be wide enough to accomodate the result (20
506 * bytes). The context is automatically reinitialized.
508 * @param cc the HAVAL-160/5 context
509 * @param ub the extra bits
510 * @param n the number of extra bits (0 to 7)
511 * @param dst the output buffer
513 void sph_haval160_5_addbits_and_close(void *cc,
514 unsigned ub, unsigned n, void *dst);
517 * Initialize the context for HAVAL-192/3.
519 * @param cc context to initialize (pointer to a
520 * <code>sph_haval192_3_context</code> structure)
522 void sph_haval192_3_init(void *cc);
525 * Process some data bytes for HAVAL-192/3. If <code>len</code> is 0,
526 * then this function does nothing.
528 * @param cc the HAVAL-192/3 context
529 * @param data the input data
530 * @param len the input data length (in bytes)
532 void sph_haval192_3(void *cc, const void *data, size_t len);
535 * Close a HAVAL-192/3 computation. The output buffer must be wide
536 * enough to accomodate the result (24 bytes). The context is automatically
539 * @param cc the HAVAL-192/3 context
540 * @param dst the output buffer
542 void sph_haval192_3_close(void *cc, void *dst);
545 * Close a HAVAL-192/3 computation. Up to 7 extra input bits may be added
546 * to the input message; these are the <code>n</code> upper bits of
547 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
548 * <code>ub</code>, the second extra bit has value 64, and so on). Other
549 * bits in <code>ub</code> are ignored.
551 * The output buffer must be wide enough to accomodate the result (24
552 * bytes). The context is automatically reinitialized.
554 * @param cc the HAVAL-192/3 context
555 * @param ub the extra bits
556 * @param n the number of extra bits (0 to 7)
557 * @param dst the output buffer
559 void sph_haval192_3_addbits_and_close(void *cc,
560 unsigned ub, unsigned n, void *dst);
563 * Initialize the context for HAVAL-192/4.
565 * @param cc context to initialize (pointer to a
566 * <code>sph_haval192_4_context</code> structure)
568 void sph_haval192_4_init(void *cc);
571 * Process some data bytes for HAVAL-192/4. If <code>len</code> is 0,
572 * then this function does nothing.
574 * @param cc the HAVAL-192/4 context
575 * @param data the input data
576 * @param len the input data length (in bytes)
578 void sph_haval192_4(void *cc, const void *data, size_t len);
581 * Close a HAVAL-192/4 computation. The output buffer must be wide
582 * enough to accomodate the result (24 bytes). The context is automatically
585 * @param cc the HAVAL-192/4 context
586 * @param dst the output buffer
588 void sph_haval192_4_close(void *cc, void *dst);
591 * Close a HAVAL-192/4 computation. Up to 7 extra input bits may be added
592 * to the input message; these are the <code>n</code> upper bits of
593 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
594 * <code>ub</code>, the second extra bit has value 64, and so on). Other
595 * bits in <code>ub</code> are ignored.
597 * The output buffer must be wide enough to accomodate the result (24
598 * bytes). The context is automatically reinitialized.
600 * @param cc the HAVAL-192/4 context
601 * @param ub the extra bits
602 * @param n the number of extra bits (0 to 7)
603 * @param dst the output buffer
605 void sph_haval192_4_addbits_and_close(void *cc,
606 unsigned ub, unsigned n, void *dst);
609 * Initialize the context for HAVAL-192/5.
611 * @param cc context to initialize (pointer to a
612 * <code>sph_haval192_5_context</code> structure)
614 void sph_haval192_5_init(void *cc);
617 * Process some data bytes for HAVAL-192/5. If <code>len</code> is 0,
618 * then this function does nothing.
620 * @param cc the HAVAL-192/5 context
621 * @param data the input data
622 * @param len the input data length (in bytes)
624 void sph_haval192_5(void *cc, const void *data, size_t len);
627 * Close a HAVAL-192/5 computation. The output buffer must be wide
628 * enough to accomodate the result (24 bytes). The context is automatically
631 * @param cc the HAVAL-192/5 context
632 * @param dst the output buffer
634 void sph_haval192_5_close(void *cc, void *dst);
637 * Close a HAVAL-192/5 computation. Up to 7 extra input bits may be added
638 * to the input message; these are the <code>n</code> upper bits of
639 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
640 * <code>ub</code>, the second extra bit has value 64, and so on). Other
641 * bits in <code>ub</code> are ignored.
643 * The output buffer must be wide enough to accomodate the result (24
644 * bytes). The context is automatically reinitialized.
646 * @param cc the HAVAL-192/5 context
647 * @param ub the extra bits
648 * @param n the number of extra bits (0 to 7)
649 * @param dst the output buffer
651 void sph_haval192_5_addbits_and_close(void *cc,
652 unsigned ub, unsigned n, void *dst);
655 * Initialize the context for HAVAL-224/3.
657 * @param cc context to initialize (pointer to a
658 * <code>sph_haval224_3_context</code> structure)
660 void sph_haval224_3_init(void *cc);
663 * Process some data bytes for HAVAL-224/3. If <code>len</code> is 0,
664 * then this function does nothing.
666 * @param cc the HAVAL-224/3 context
667 * @param data the input data
668 * @param len the input data length (in bytes)
670 void sph_haval224_3(void *cc, const void *data, size_t len);
673 * Close a HAVAL-224/3 computation. The output buffer must be wide
674 * enough to accomodate the result (28 bytes). The context is automatically
677 * @param cc the HAVAL-224/3 context
678 * @param dst the output buffer
680 void sph_haval224_3_close(void *cc, void *dst);
683 * Close a HAVAL-224/3 computation. Up to 7 extra input bits may be added
684 * to the input message; these are the <code>n</code> upper bits of
685 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
686 * <code>ub</code>, the second extra bit has value 64, and so on). Other
687 * bits in <code>ub</code> are ignored.
689 * The output buffer must be wide enough to accomodate the result (28
690 * bytes). The context is automatically reinitialized.
692 * @param cc the HAVAL-224/3 context
693 * @param ub the extra bits
694 * @param n the number of extra bits (0 to 7)
695 * @param dst the output buffer
697 void sph_haval224_3_addbits_and_close(void *cc,
698 unsigned ub, unsigned n, void *dst);
701 * Initialize the context for HAVAL-224/4.
703 * @param cc context to initialize (pointer to a
704 * <code>sph_haval224_4_context</code> structure)
706 void sph_haval224_4_init(void *cc);
709 * Process some data bytes for HAVAL-224/4. If <code>len</code> is 0,
710 * then this function does nothing.
712 * @param cc the HAVAL-224/4 context
713 * @param data the input data
714 * @param len the input data length (in bytes)
716 void sph_haval224_4(void *cc, const void *data, size_t len);
719 * Close a HAVAL-224/4 computation. The output buffer must be wide
720 * enough to accomodate the result (28 bytes). The context is automatically
723 * @param cc the HAVAL-224/4 context
724 * @param dst the output buffer
726 void sph_haval224_4_close(void *cc, void *dst);
729 * Close a HAVAL-224/4 computation. Up to 7 extra input bits may be added
730 * to the input message; these are the <code>n</code> upper bits of
731 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
732 * <code>ub</code>, the second extra bit has value 64, and so on). Other
733 * bits in <code>ub</code> are ignored.
735 * The output buffer must be wide enough to accomodate the result (28
736 * bytes). The context is automatically reinitialized.
738 * @param cc the HAVAL-224/4 context
739 * @param ub the extra bits
740 * @param n the number of extra bits (0 to 7)
741 * @param dst the output buffer
743 void sph_haval224_4_addbits_and_close(void *cc,
744 unsigned ub, unsigned n, void *dst);
747 * Initialize the context for HAVAL-224/5.
749 * @param cc context to initialize (pointer to a
750 * <code>sph_haval224_5_context</code> structure)
752 void sph_haval224_5_init(void *cc);
755 * Process some data bytes for HAVAL-224/5. If <code>len</code> is 0,
756 * then this function does nothing.
758 * @param cc the HAVAL-224/5 context
759 * @param data the input data
760 * @param len the input data length (in bytes)
762 void sph_haval224_5(void *cc, const void *data, size_t len);
765 * Close a HAVAL-224/5 computation. The output buffer must be wide
766 * enough to accomodate the result (28 bytes). The context is automatically
769 * @param cc the HAVAL-224/5 context
770 * @param dst the output buffer
772 void sph_haval224_5_close(void *cc, void *dst);
775 * Close a HAVAL-224/5 computation. Up to 7 extra input bits may be added
776 * to the input message; these are the <code>n</code> upper bits of
777 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
778 * <code>ub</code>, the second extra bit has value 64, and so on). Other
779 * bits in <code>ub</code> are ignored.
781 * The output buffer must be wide enough to accomodate the result (28
782 * bytes). The context is automatically reinitialized.
784 * @param cc the HAVAL-224/5 context
785 * @param ub the extra bits
786 * @param n the number of extra bits (0 to 7)
787 * @param dst the output buffer
789 void sph_haval224_5_addbits_and_close(void *cc,
790 unsigned ub, unsigned n, void *dst);
793 * Initialize the context for HAVAL-256/3.
795 * @param cc context to initialize (pointer to a
796 * <code>sph_haval256_3_context</code> structure)
798 void sph_haval256_3_init(void *cc);
801 * Process some data bytes for HAVAL-256/3. If <code>len</code> is 0,
802 * then this function does nothing.
804 * @param cc the HAVAL-256/3 context
805 * @param data the input data
806 * @param len the input data length (in bytes)
808 void sph_haval256_3(void *cc, const void *data, size_t len);
811 * Close a HAVAL-256/3 computation. The output buffer must be wide
812 * enough to accomodate the result (32 bytes). The context is automatically
815 * @param cc the HAVAL-256/3 context
816 * @param dst the output buffer
818 void sph_haval256_3_close(void *cc, void *dst);
821 * Close a HAVAL-256/3 computation. Up to 7 extra input bits may be added
822 * to the input message; these are the <code>n</code> upper bits of
823 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
824 * <code>ub</code>, the second extra bit has value 64, and so on). Other
825 * bits in <code>ub</code> are ignored.
827 * The output buffer must be wide enough to accomodate the result (32
828 * bytes). The context is automatically reinitialized.
830 * @param cc the HAVAL-256/3 context
831 * @param ub the extra bits
832 * @param n the number of extra bits (0 to 7)
833 * @param dst the output buffer
835 void sph_haval256_3_addbits_and_close(void *cc,
836 unsigned ub, unsigned n, void *dst);
839 * Initialize the context for HAVAL-256/4.
841 * @param cc context to initialize (pointer to a
842 * <code>sph_haval256_4_context</code> structure)
844 void sph_haval256_4_init(void *cc);
847 * Process some data bytes for HAVAL-256/4. If <code>len</code> is 0,
848 * then this function does nothing.
850 * @param cc the HAVAL-256/4 context
851 * @param data the input data
852 * @param len the input data length (in bytes)
854 void sph_haval256_4(void *cc, const void *data, size_t len);
857 * Close a HAVAL-256/4 computation. The output buffer must be wide
858 * enough to accomodate the result (32 bytes). The context is automatically
861 * @param cc the HAVAL-256/4 context
862 * @param dst the output buffer
864 void sph_haval256_4_close(void *cc, void *dst);
867 * Close a HAVAL-256/4 computation. Up to 7 extra input bits may be added
868 * to the input message; these are the <code>n</code> upper bits of
869 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
870 * <code>ub</code>, the second extra bit has value 64, and so on). Other
871 * bits in <code>ub</code> are ignored.
873 * The output buffer must be wide enough to accomodate the result (32
874 * bytes). The context is automatically reinitialized.
876 * @param cc the HAVAL-256/4 context
877 * @param ub the extra bits
878 * @param n the number of extra bits (0 to 7)
879 * @param dst the output buffer
881 void sph_haval256_4_addbits_and_close(void *cc,
882 unsigned ub, unsigned n, void *dst);
885 * Initialize the context for HAVAL-256/5.
887 * @param cc context to initialize (pointer to a
888 * <code>sph_haval256_5_context</code> structure)
890 void sph_haval256_5_init(void *cc);
893 * Process some data bytes for HAVAL-256/5. If <code>len</code> is 0,
894 * then this function does nothing.
896 * @param cc the HAVAL-256/5 context
897 * @param data the input data
898 * @param len the input data length (in bytes)
900 void sph_haval256_5(void *cc, const void *data, size_t len);
903 * Close a HAVAL-256/5 computation. The output buffer must be wide
904 * enough to accomodate the result (32 bytes). The context is automatically
907 * @param cc the HAVAL-256/5 context
908 * @param dst the output buffer
910 void sph_haval256_5_close(void *cc, void *dst);
913 * Close a HAVAL-256/5 computation. Up to 7 extra input bits may be added
914 * to the input message; these are the <code>n</code> upper bits of
915 * the <code>ub</code> byte (i.e. the first extra bit has value 128 in
916 * <code>ub</code>, the second extra bit has value 64, and so on). Other
917 * bits in <code>ub</code> are ignored.
919 * The output buffer must be wide enough to accomodate the result (32
920 * bytes). The context is automatically reinitialized.
922 * @param cc the HAVAL-256/5 context
923 * @param ub the extra bits
924 * @param n the number of extra bits (0 to 7)
925 * @param dst the output buffer
927 void sph_haval256_5_addbits_and_close(void *cc,
928 unsigned ub, unsigned n, void *dst);
931 * Apply the HAVAL compression function on the provided data. The
932 * <code>msg</code> parameter contains the 32 32-bit input blocks,
933 * as numerical values (hence after the little-endian decoding). The
934 * <code>val</code> parameter contains the 8 32-bit input blocks for
935 * the compression function; the output is written in place in this
936 * array. This function uses three internal passes.
938 * @param msg the message block (32 values)
939 * @param val the function 256-bit input and output
941 void sph_haval_3_comp(const sph_u32 msg[32], sph_u32 val[8]);
944 * Apply the HAVAL compression function on the provided data. The
945 * <code>msg</code> parameter contains the 32 32-bit input blocks,
946 * as numerical values (hence after the little-endian decoding). The
947 * <code>val</code> parameter contains the 8 32-bit input blocks for
948 * the compression function; the output is written in place in this
949 * array. This function uses four internal passes.
951 * @param msg the message block (32 values)
952 * @param val the function 256-bit input and output
954 void sph_haval_4_comp(const sph_u32 msg[32], sph_u32 val[8]);
957 * Apply the HAVAL compression function on the provided data. The
958 * <code>msg</code> parameter contains the 32 32-bit input blocks,
959 * as numerical values (hence after the little-endian decoding). The
960 * <code>val</code> parameter contains the 8 32-bit input blocks for
961 * the compression function; the output is written in place in this
962 * array. This function uses five internal passes.
964 * @param msg the message block (32 values)
965 * @param val the function 256-bit input and output
967 void sph_haval_5_comp(const sph_u32 msg[32], sph_u32 val[8]);