/* $Id: sph_haval.h 218 2010-06-08 17:06:34Z tp $ */1/**2* HAVAL interface.3*4* HAVAL is actually a family of 15 hash functions, depending on whether5* the internal computation uses 3, 4 or 5 passes, and on the output6* length, which is 128, 160, 192, 224 or 256 bits. This implementation7* provides interface functions for all 15, which internally map to8* three cores (depending on the number of passes). Note that output9* lengths other than 256 bits are not obtained by a simple truncation10* of a longer result; the requested length is encoded within the11* padding data.12*13* HAVAL was published in: Yuliang Zheng, Josef Pieprzyk and Jennifer14* Seberry: "HAVAL -- a one-way hashing algorithm with variable length15* of output", Advances in Cryptology -- AUSCRYPT'92, Lecture Notes in16* Computer Science, Vol.718, pp.83-104, Springer-Verlag, 1993.17*18* This paper, and a reference implementation, are available on the19* Calyptix web site: http://labs.calyptix.com/haval.php20*21* The HAVAL reference paper is quite unclear on the data encoding22* details, i.e. endianness (both byte order within a 32-bit word, and23* word order within a message block). This implementation has been24* made compatible with the reference implementation referenced above.25*26* @warning A collision for HAVAL-128/3 (HAVAL with three passes and27* 128-bit output) has been published; this function is thus considered28* as cryptographically broken. The status for other variants is unclear;29* use only with care.30*31* ==========================(LICENSE BEGIN)============================32*33* Copyright (c) 2007-2010 Projet RNRT SAPHIR34*35* Permission is hereby granted, free of charge, to any person obtaining36* a copy of this software and associated documentation files (the37* "Software"), to deal in the Software without restriction, including38* without limitation the rights to use, copy, modify, merge, publish,39* distribute, sublicense, and/or sell copies of the Software, and to40* permit persons to whom the Software is furnished to do so, subject to41* the following conditions:42*43* The above copyright notice and this permission notice shall be44* included in all copies or substantial portions of the Software.45*46* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,47* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF48* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.49* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY50* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,51* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE52* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.53*54* ===========================(LICENSE END)=============================55*56* @file sph_haval.h57* @author Thomas Pornin <[email protected]>58*/5960#ifndef SPH_HAVAL_H__61#define SPH_HAVAL_H__6263#include <stddef.h>64#include "sph_types.h"6566/**67* Output size (in bits) for HAVAL-128/3.68*/69#define SPH_SIZE_haval128_3 1287071/**72* Output size (in bits) for HAVAL-128/4.73*/74#define SPH_SIZE_haval128_4 1287576/**77* Output size (in bits) for HAVAL-128/5.78*/79#define SPH_SIZE_haval128_5 1288081/**82* Output size (in bits) for HAVAL-160/3.83*/84#define SPH_SIZE_haval160_3 1608586/**87* Output size (in bits) for HAVAL-160/4.88*/89#define SPH_SIZE_haval160_4 1609091/**92* Output size (in bits) for HAVAL-160/5.93*/94#define SPH_SIZE_haval160_5 1609596/**97* Output size (in bits) for HAVAL-192/3.98*/99#define SPH_SIZE_haval192_3 192100101/**102* Output size (in bits) for HAVAL-192/4.103*/104#define SPH_SIZE_haval192_4 192105106/**107* Output size (in bits) for HAVAL-192/5.108*/109#define SPH_SIZE_haval192_5 192110111/**112* Output size (in bits) for HAVAL-224/3.113*/114#define SPH_SIZE_haval224_3 224115116/**117* Output size (in bits) for HAVAL-224/4.118*/119#define SPH_SIZE_haval224_4 224120121/**122* Output size (in bits) for HAVAL-224/5.123*/124#define SPH_SIZE_haval224_5 224125126/**127* Output size (in bits) for HAVAL-256/3.128*/129#define SPH_SIZE_haval256_3 256130131/**132* Output size (in bits) for HAVAL-256/4.133*/134#define SPH_SIZE_haval256_4 256135136/**137* Output size (in bits) for HAVAL-256/5.138*/139#define SPH_SIZE_haval256_5 256140141/**142* This structure is a context for HAVAL computations: it contains the143* intermediate values and some data from the last entered block. Once144* a HAVAL computation has been performed, the context can be reused for145* another computation.146*147* The contents of this structure are private. A running HAVAL computation148* can be cloned by copying the context (e.g. with a simple149* <code>memcpy()</code>).150*/151typedef struct {152#ifndef DOXYGEN_IGNORE153unsigned char buf[128]; /* first field, for alignment */154sph_u32 s0, s1, s2, s3, s4, s5, s6, s7;155unsigned olen, passes;156#if SPH_64157sph_u64 count;158#else159sph_u32 count_high, count_low;160#endif161#endif162} sph_haval_context;163164/**165* Type for a HAVAL-128/3 context (identical to the common context).166*/167typedef sph_haval_context sph_haval128_3_context;168169/**170* Type for a HAVAL-128/4 context (identical to the common context).171*/172typedef sph_haval_context sph_haval128_4_context;173174/**175* Type for a HAVAL-128/5 context (identical to the common context).176*/177typedef sph_haval_context sph_haval128_5_context;178179/**180* Type for a HAVAL-160/3 context (identical to the common context).181*/182typedef sph_haval_context sph_haval160_3_context;183184/**185* Type for a HAVAL-160/4 context (identical to the common context).186*/187typedef sph_haval_context sph_haval160_4_context;188189/**190* Type for a HAVAL-160/5 context (identical to the common context).191*/192typedef sph_haval_context sph_haval160_5_context;193194/**195* Type for a HAVAL-192/3 context (identical to the common context).196*/197typedef sph_haval_context sph_haval192_3_context;198199/**200* Type for a HAVAL-192/4 context (identical to the common context).201*/202typedef sph_haval_context sph_haval192_4_context;203204/**205* Type for a HAVAL-192/5 context (identical to the common context).206*/207typedef sph_haval_context sph_haval192_5_context;208209/**210* Type for a HAVAL-224/3 context (identical to the common context).211*/212typedef sph_haval_context sph_haval224_3_context;213214/**215* Type for a HAVAL-224/4 context (identical to the common context).216*/217typedef sph_haval_context sph_haval224_4_context;218219/**220* Type for a HAVAL-224/5 context (identical to the common context).221*/222typedef sph_haval_context sph_haval224_5_context;223224/**225* Type for a HAVAL-256/3 context (identical to the common context).226*/227typedef sph_haval_context sph_haval256_3_context;228229/**230* Type for a HAVAL-256/4 context (identical to the common context).231*/232typedef sph_haval_context sph_haval256_4_context;233234/**235* Type for a HAVAL-256/5 context (identical to the common context).236*/237typedef sph_haval_context sph_haval256_5_context;238239/**240* Initialize the context for HAVAL-128/3.241*242* @param cc context to initialize (pointer to a243* <code>sph_haval128_3_context</code> structure)244*/245void sph_haval128_3_init(void *cc);246247/**248* Process some data bytes for HAVAL-128/3. If <code>len</code> is 0,249* then this function does nothing.250*251* @param cc the HAVAL-128/3 context252* @param data the input data253* @param len the input data length (in bytes)254*/255void sph_haval128_3(void *cc, const void *data, size_t len);256257/**258* Close a HAVAL-128/3 computation. The output buffer must be wide259* enough to accomodate the result (16 bytes). The context is automatically260* reinitialized.261*262* @param cc the HAVAL-128/3 context263* @param dst the output buffer264*/265void sph_haval128_3_close(void *cc, void *dst);266267/**268* Close a HAVAL-128/3 computation. Up to 7 extra input bits may be added269* to the input message; these are the <code>n</code> upper bits of270* the <code>ub</code> byte (i.e. the first extra bit has value 128 in271* <code>ub</code>, the second extra bit has value 64, and so on). Other272* bits in <code>ub</code> are ignored.273*274* The output buffer must be wide enough to accomodate the result (16275* bytes). The context is automatically reinitialized.276*277* @param cc the HAVAL-128/3 context278* @param ub the extra bits279* @param n the number of extra bits (0 to 7)280* @param dst the output buffer281*/282void sph_haval128_3_addbits_and_close(void *cc,283unsigned ub, unsigned n, void *dst);284285/**286* Initialize the context for HAVAL-128/4.287*288* @param cc context to initialize (pointer to a289* <code>sph_haval128_4_context</code> structure)290*/291void sph_haval128_4_init(void *cc);292293/**294* Process some data bytes for HAVAL-128/4. If <code>len</code> is 0,295* then this function does nothing.296*297* @param cc the HAVAL-128/4 context298* @param data the input data299* @param len the input data length (in bytes)300*/301void sph_haval128_4(void *cc, const void *data, size_t len);302303/**304* Close a HAVAL-128/4 computation. The output buffer must be wide305* enough to accomodate the result (16 bytes). The context is automatically306* reinitialized.307*308* @param cc the HAVAL-128/4 context309* @param dst the output buffer310*/311void sph_haval128_4_close(void *cc, void *dst);312313/**314* Close a HAVAL-128/4 computation. Up to 7 extra input bits may be added315* to the input message; these are the <code>n</code> upper bits of316* the <code>ub</code> byte (i.e. the first extra bit has value 128 in317* <code>ub</code>, the second extra bit has value 64, and so on). Other318* bits in <code>ub</code> are ignored.319*320* The output buffer must be wide enough to accomodate the result (16321* bytes). The context is automatically reinitialized.322*323* @param cc the HAVAL-128/4 context324* @param ub the extra bits325* @param n the number of extra bits (0 to 7)326* @param dst the output buffer327*/328void sph_haval128_4_addbits_and_close(void *cc,329unsigned ub, unsigned n, void *dst);330331/**332* Initialize the context for HAVAL-128/5.333*334* @param cc context to initialize (pointer to a335* <code>sph_haval128_5_context</code> structure)336*/337void sph_haval128_5_init(void *cc);338339/**340* Process some data bytes for HAVAL-128/5. If <code>len</code> is 0,341* then this function does nothing.342*343* @param cc the HAVAL-128/5 context344* @param data the input data345* @param len the input data length (in bytes)346*/347void sph_haval128_5(void *cc, const void *data, size_t len);348349/**350* Close a HAVAL-128/5 computation. The output buffer must be wide351* enough to accomodate the result (16 bytes). The context is automatically352* reinitialized.353*354* @param cc the HAVAL-128/5 context355* @param dst the output buffer356*/357void sph_haval128_5_close(void *cc, void *dst);358359/**360* Close a HAVAL-128/5 computation. Up to 7 extra input bits may be added361* to the input message; these are the <code>n</code> upper bits of362* the <code>ub</code> byte (i.e. the first extra bit has value 128 in363* <code>ub</code>, the second extra bit has value 64, and so on). Other364* bits in <code>ub</code> are ignored.365*366* The output buffer must be wide enough to accomodate the result (16367* bytes). The context is automatically reinitialized.368*369* @param cc the HAVAL-128/5 context370* @param ub the extra bits371* @param n the number of extra bits (0 to 7)372* @param dst the output buffer373*/374void sph_haval128_5_addbits_and_close(void *cc,375unsigned ub, unsigned n, void *dst);376377/**378* Initialize the context for HAVAL-160/3.379*380* @param cc context to initialize (pointer to a381* <code>sph_haval160_3_context</code> structure)382*/383void sph_haval160_3_init(void *cc);384385/**386* Process some data bytes for HAVAL-160/3. If <code>len</code> is 0,387* then this function does nothing.388*389* @param cc the HAVAL-160/3 context390* @param data the input data391* @param len the input data length (in bytes)392*/393void sph_haval160_3(void *cc, const void *data, size_t len);394395/**396* Close a HAVAL-160/3 computation. The output buffer must be wide397* enough to accomodate the result (20 bytes). The context is automatically398* reinitialized.399*400* @param cc the HAVAL-160/3 context401* @param dst the output buffer402*/403void sph_haval160_3_close(void *cc, void *dst);404405/**406* Close a HAVAL-160/3 computation. Up to 7 extra input bits may be added407* to the input message; these are the <code>n</code> upper bits of408* the <code>ub</code> byte (i.e. the first extra bit has value 128 in409* <code>ub</code>, the second extra bit has value 64, and so on). Other410* bits in <code>ub</code> are ignored.411*412* The output buffer must be wide enough to accomodate the result (20413* bytes). The context is automatically reinitialized.414*415* @param cc the HAVAL-160/3 context416* @param ub the extra bits417* @param n the number of extra bits (0 to 7)418* @param dst the output buffer419*/420void sph_haval160_3_addbits_and_close(void *cc,421unsigned ub, unsigned n, void *dst);422423/**424* Initialize the context for HAVAL-160/4.425*426* @param cc context to initialize (pointer to a427* <code>sph_haval160_4_context</code> structure)428*/429void sph_haval160_4_init(void *cc);430431/**432* Process some data bytes for HAVAL-160/4. If <code>len</code> is 0,433* then this function does nothing.434*435* @param cc the HAVAL-160/4 context436* @param data the input data437* @param len the input data length (in bytes)438*/439void sph_haval160_4(void *cc, const void *data, size_t len);440441/**442* Close a HAVAL-160/4 computation. The output buffer must be wide443* enough to accomodate the result (20 bytes). The context is automatically444* reinitialized.445*446* @param cc the HAVAL-160/4 context447* @param dst the output buffer448*/449void sph_haval160_4_close(void *cc, void *dst);450451/**452* Close a HAVAL-160/4 computation. Up to 7 extra input bits may be added453* to the input message; these are the <code>n</code> upper bits of454* the <code>ub</code> byte (i.e. the first extra bit has value 128 in455* <code>ub</code>, the second extra bit has value 64, and so on). Other456* bits in <code>ub</code> are ignored.457*458* The output buffer must be wide enough to accomodate the result (20459* bytes). The context is automatically reinitialized.460*461* @param cc the HAVAL-160/4 context462* @param ub the extra bits463* @param n the number of extra bits (0 to 7)464* @param dst the output buffer465*/466void sph_haval160_3_addbits_and_close(void *cc,467unsigned ub, unsigned n, void *dst);468469/**470* Initialize the context for HAVAL-160/5.471*472* @param cc context to initialize (pointer to a473* <code>sph_haval160_5_context</code> structure)474*/475void sph_haval160_5_init(void *cc);476477/**478* Process some data bytes for HAVAL-160/5. If <code>len</code> is 0,479* then this function does nothing.480*481* @param cc the HAVAL-160/5 context482* @param data the input data483* @param len the input data length (in bytes)484*/485void sph_haval160_5(void *cc, const void *data, size_t len);486487/**488* Close a HAVAL-160/5 computation. The output buffer must be wide489* enough to accomodate the result (20 bytes). The context is automatically490* reinitialized.491*492* @param cc the HAVAL-160/5 context493* @param dst the output buffer494*/495void sph_haval160_5_close(void *cc, void *dst);496497/**498* Close a HAVAL-160/5 computation. Up to 7 extra input bits may be added499* to the input message; these are the <code>n</code> upper bits of500* the <code>ub</code> byte (i.e. the first extra bit has value 128 in501* <code>ub</code>, the second extra bit has value 64, and so on). Other502* bits in <code>ub</code> are ignored.503*504* The output buffer must be wide enough to accomodate the result (20505* bytes). The context is automatically reinitialized.506*507* @param cc the HAVAL-160/5 context508* @param ub the extra bits509* @param n the number of extra bits (0 to 7)510* @param dst the output buffer511*/512void sph_haval160_5_addbits_and_close(void *cc,513unsigned ub, unsigned n, void *dst);514515/**516* Initialize the context for HAVAL-192/3.517*518* @param cc context to initialize (pointer to a519* <code>sph_haval192_3_context</code> structure)520*/521void sph_haval192_3_init(void *cc);522523/**524* Process some data bytes for HAVAL-192/3. If <code>len</code> is 0,525* then this function does nothing.526*527* @param cc the HAVAL-192/3 context528* @param data the input data529* @param len the input data length (in bytes)530*/531void sph_haval192_3(void *cc, const void *data, size_t len);532533/**534* Close a HAVAL-192/3 computation. The output buffer must be wide535* enough to accomodate the result (24 bytes). The context is automatically536* reinitialized.537*538* @param cc the HAVAL-192/3 context539* @param dst the output buffer540*/541void sph_haval192_3_close(void *cc, void *dst);542543/**544* Close a HAVAL-192/3 computation. Up to 7 extra input bits may be added545* to the input message; these are the <code>n</code> upper bits of546* the <code>ub</code> byte (i.e. the first extra bit has value 128 in547* <code>ub</code>, the second extra bit has value 64, and so on). Other548* bits in <code>ub</code> are ignored.549*550* The output buffer must be wide enough to accomodate the result (24551* bytes). The context is automatically reinitialized.552*553* @param cc the HAVAL-192/3 context554* @param ub the extra bits555* @param n the number of extra bits (0 to 7)556* @param dst the output buffer557*/558void sph_haval192_3_addbits_and_close(void *cc,559unsigned ub, unsigned n, void *dst);560561/**562* Initialize the context for HAVAL-192/4.563*564* @param cc context to initialize (pointer to a565* <code>sph_haval192_4_context</code> structure)566*/567void sph_haval192_4_init(void *cc);568569/**570* Process some data bytes for HAVAL-192/4. If <code>len</code> is 0,571* then this function does nothing.572*573* @param cc the HAVAL-192/4 context574* @param data the input data575* @param len the input data length (in bytes)576*/577void sph_haval192_4(void *cc, const void *data, size_t len);578579/**580* Close a HAVAL-192/4 computation. The output buffer must be wide581* enough to accomodate the result (24 bytes). The context is automatically582* reinitialized.583*584* @param cc the HAVAL-192/4 context585* @param dst the output buffer586*/587void sph_haval192_4_close(void *cc, void *dst);588589/**590* Close a HAVAL-192/4 computation. Up to 7 extra input bits may be added591* to the input message; these are the <code>n</code> upper bits of592* the <code>ub</code> byte (i.e. the first extra bit has value 128 in593* <code>ub</code>, the second extra bit has value 64, and so on). Other594* bits in <code>ub</code> are ignored.595*596* The output buffer must be wide enough to accomodate the result (24597* bytes). The context is automatically reinitialized.598*599* @param cc the HAVAL-192/4 context600* @param ub the extra bits601* @param n the number of extra bits (0 to 7)602* @param dst the output buffer603*/604void sph_haval192_4_addbits_and_close(void *cc,605unsigned ub, unsigned n, void *dst);606607/**608* Initialize the context for HAVAL-192/5.609*610* @param cc context to initialize (pointer to a611* <code>sph_haval192_5_context</code> structure)612*/613void sph_haval192_5_init(void *cc);614615/**616* Process some data bytes for HAVAL-192/5. If <code>len</code> is 0,617* then this function does nothing.618*619* @param cc the HAVAL-192/5 context620* @param data the input data621* @param len the input data length (in bytes)622*/623void sph_haval192_5(void *cc, const void *data, size_t len);624625/**626* Close a HAVAL-192/5 computation. The output buffer must be wide627* enough to accomodate the result (24 bytes). The context is automatically628* reinitialized.629*630* @param cc the HAVAL-192/5 context631* @param dst the output buffer632*/633void sph_haval192_5_close(void *cc, void *dst);634635/**636* Close a HAVAL-192/5 computation. Up to 7 extra input bits may be added637* to the input message; these are the <code>n</code> upper bits of638* the <code>ub</code> byte (i.e. the first extra bit has value 128 in639* <code>ub</code>, the second extra bit has value 64, and so on). Other640* bits in <code>ub</code> are ignored.641*642* The output buffer must be wide enough to accomodate the result (24643* bytes). The context is automatically reinitialized.644*645* @param cc the HAVAL-192/5 context646* @param ub the extra bits647* @param n the number of extra bits (0 to 7)648* @param dst the output buffer649*/650void sph_haval192_5_addbits_and_close(void *cc,651unsigned ub, unsigned n, void *dst);652653/**654* Initialize the context for HAVAL-224/3.655*656* @param cc context to initialize (pointer to a657* <code>sph_haval224_3_context</code> structure)658*/659void sph_haval224_3_init(void *cc);660661/**662* Process some data bytes for HAVAL-224/3. If <code>len</code> is 0,663* then this function does nothing.664*665* @param cc the HAVAL-224/3 context666* @param data the input data667* @param len the input data length (in bytes)668*/669void sph_haval224_3(void *cc, const void *data, size_t len);670671/**672* Close a HAVAL-224/3 computation. The output buffer must be wide673* enough to accomodate the result (28 bytes). The context is automatically674* reinitialized.675*676* @param cc the HAVAL-224/3 context677* @param dst the output buffer678*/679void sph_haval224_3_close(void *cc, void *dst);680681/**682* Close a HAVAL-224/3 computation. Up to 7 extra input bits may be added683* to the input message; these are the <code>n</code> upper bits of684* the <code>ub</code> byte (i.e. the first extra bit has value 128 in685* <code>ub</code>, the second extra bit has value 64, and so on). Other686* bits in <code>ub</code> are ignored.687*688* The output buffer must be wide enough to accomodate the result (28689* bytes). The context is automatically reinitialized.690*691* @param cc the HAVAL-224/3 context692* @param ub the extra bits693* @param n the number of extra bits (0 to 7)694* @param dst the output buffer695*/696void sph_haval224_3_addbits_and_close(void *cc,697unsigned ub, unsigned n, void *dst);698699/**700* Initialize the context for HAVAL-224/4.701*702* @param cc context to initialize (pointer to a703* <code>sph_haval224_4_context</code> structure)704*/705void sph_haval224_4_init(void *cc);706707/**708* Process some data bytes for HAVAL-224/4. If <code>len</code> is 0,709* then this function does nothing.710*711* @param cc the HAVAL-224/4 context712* @param data the input data713* @param len the input data length (in bytes)714*/715void sph_haval224_4(void *cc, const void *data, size_t len);716717/**718* Close a HAVAL-224/4 computation. The output buffer must be wide719* enough to accomodate the result (28 bytes). The context is automatically720* reinitialized.721*722* @param cc the HAVAL-224/4 context723* @param dst the output buffer724*/725void sph_haval224_4_close(void *cc, void *dst);726727/**728* Close a HAVAL-224/4 computation. Up to 7 extra input bits may be added729* to the input message; these are the <code>n</code> upper bits of730* the <code>ub</code> byte (i.e. the first extra bit has value 128 in731* <code>ub</code>, the second extra bit has value 64, and so on). Other732* bits in <code>ub</code> are ignored.733*734* The output buffer must be wide enough to accomodate the result (28735* bytes). The context is automatically reinitialized.736*737* @param cc the HAVAL-224/4 context738* @param ub the extra bits739* @param n the number of extra bits (0 to 7)740* @param dst the output buffer741*/742void sph_haval224_4_addbits_and_close(void *cc,743unsigned ub, unsigned n, void *dst);744745/**746* Initialize the context for HAVAL-224/5.747*748* @param cc context to initialize (pointer to a749* <code>sph_haval224_5_context</code> structure)750*/751void sph_haval224_5_init(void *cc);752753/**754* Process some data bytes for HAVAL-224/5. If <code>len</code> is 0,755* then this function does nothing.756*757* @param cc the HAVAL-224/5 context758* @param data the input data759* @param len the input data length (in bytes)760*/761void sph_haval224_5(void *cc, const void *data, size_t len);762763/**764* Close a HAVAL-224/5 computation. The output buffer must be wide765* enough to accomodate the result (28 bytes). The context is automatically766* reinitialized.767*768* @param cc the HAVAL-224/5 context769* @param dst the output buffer770*/771void sph_haval224_5_close(void *cc, void *dst);772773/**774* Close a HAVAL-224/5 computation. Up to 7 extra input bits may be added775* to the input message; these are the <code>n</code> upper bits of776* the <code>ub</code> byte (i.e. the first extra bit has value 128 in777* <code>ub</code>, the second extra bit has value 64, and so on). Other778* bits in <code>ub</code> are ignored.779*780* The output buffer must be wide enough to accomodate the result (28781* bytes). The context is automatically reinitialized.782*783* @param cc the HAVAL-224/5 context784* @param ub the extra bits785* @param n the number of extra bits (0 to 7)786* @param dst the output buffer787*/788void sph_haval224_5_addbits_and_close(void *cc,789unsigned ub, unsigned n, void *dst);790791/**792* Initialize the context for HAVAL-256/3.793*794* @param cc context to initialize (pointer to a795* <code>sph_haval256_3_context</code> structure)796*/797void sph_haval256_3_init(void *cc);798799/**800* Process some data bytes for HAVAL-256/3. If <code>len</code> is 0,801* then this function does nothing.802*803* @param cc the HAVAL-256/3 context804* @param data the input data805* @param len the input data length (in bytes)806*/807void sph_haval256_3(void *cc, const void *data, size_t len);808809/**810* Close a HAVAL-256/3 computation. The output buffer must be wide811* enough to accomodate the result (32 bytes). The context is automatically812* reinitialized.813*814* @param cc the HAVAL-256/3 context815* @param dst the output buffer816*/817void sph_haval256_3_close(void *cc, void *dst);818819/**820* Close a HAVAL-256/3 computation. Up to 7 extra input bits may be added821* to the input message; these are the <code>n</code> upper bits of822* the <code>ub</code> byte (i.e. the first extra bit has value 128 in823* <code>ub</code>, the second extra bit has value 64, and so on). Other824* bits in <code>ub</code> are ignored.825*826* The output buffer must be wide enough to accomodate the result (32827* bytes). The context is automatically reinitialized.828*829* @param cc the HAVAL-256/3 context830* @param ub the extra bits831* @param n the number of extra bits (0 to 7)832* @param dst the output buffer833*/834void sph_haval256_3_addbits_and_close(void *cc,835unsigned ub, unsigned n, void *dst);836837/**838* Initialize the context for HAVAL-256/4.839*840* @param cc context to initialize (pointer to a841* <code>sph_haval256_4_context</code> structure)842*/843void sph_haval256_4_init(void *cc);844845/**846* Process some data bytes for HAVAL-256/4. If <code>len</code> is 0,847* then this function does nothing.848*849* @param cc the HAVAL-256/4 context850* @param data the input data851* @param len the input data length (in bytes)852*/853void sph_haval256_4(void *cc, const void *data, size_t len);854855/**856* Close a HAVAL-256/4 computation. The output buffer must be wide857* enough to accomodate the result (32 bytes). The context is automatically858* reinitialized.859*860* @param cc the HAVAL-256/4 context861* @param dst the output buffer862*/863void sph_haval256_4_close(void *cc, void *dst);864865/**866* Close a HAVAL-256/4 computation. Up to 7 extra input bits may be added867* to the input message; these are the <code>n</code> upper bits of868* the <code>ub</code> byte (i.e. the first extra bit has value 128 in869* <code>ub</code>, the second extra bit has value 64, and so on). Other870* bits in <code>ub</code> are ignored.871*872* The output buffer must be wide enough to accomodate the result (32873* bytes). The context is automatically reinitialized.874*875* @param cc the HAVAL-256/4 context876* @param ub the extra bits877* @param n the number of extra bits (0 to 7)878* @param dst the output buffer879*/880void sph_haval256_4_addbits_and_close(void *cc,881unsigned ub, unsigned n, void *dst);882883/**884* Initialize the context for HAVAL-256/5.885*886* @param cc context to initialize (pointer to a887* <code>sph_haval256_5_context</code> structure)888*/889void sph_haval256_5_init(void *cc);890891/**892* Process some data bytes for HAVAL-256/5. If <code>len</code> is 0,893* then this function does nothing.894*895* @param cc the HAVAL-256/5 context896* @param data the input data897* @param len the input data length (in bytes)898*/899void sph_haval256_5(void *cc, const void *data, size_t len);900901/**902* Close a HAVAL-256/5 computation. The output buffer must be wide903* enough to accomodate the result (32 bytes). The context is automatically904* reinitialized.905*906* @param cc the HAVAL-256/5 context907* @param dst the output buffer908*/909void sph_haval256_5_close(void *cc, void *dst);910911/**912* Close a HAVAL-256/5 computation. Up to 7 extra input bits may be added913* to the input message; these are the <code>n</code> upper bits of914* the <code>ub</code> byte (i.e. the first extra bit has value 128 in915* <code>ub</code>, the second extra bit has value 64, and so on). Other916* bits in <code>ub</code> are ignored.917*918* The output buffer must be wide enough to accomodate the result (32919* bytes). The context is automatically reinitialized.920*921* @param cc the HAVAL-256/5 context922* @param ub the extra bits923* @param n the number of extra bits (0 to 7)924* @param dst the output buffer925*/926void sph_haval256_5_addbits_and_close(void *cc,927unsigned ub, unsigned n, void *dst);928929/**930* Apply the HAVAL compression function on the provided data. The931* <code>msg</code> parameter contains the 32 32-bit input blocks,932* as numerical values (hence after the little-endian decoding). The933* <code>val</code> parameter contains the 8 32-bit input blocks for934* the compression function; the output is written in place in this935* array. This function uses three internal passes.936*937* @param msg the message block (32 values)938* @param val the function 256-bit input and output939*/940void sph_haval_3_comp(const sph_u32 msg[32], sph_u32 val[8]);941942/**943* Apply the HAVAL compression function on the provided data. The944* <code>msg</code> parameter contains the 32 32-bit input blocks,945* as numerical values (hence after the little-endian decoding). The946* <code>val</code> parameter contains the 8 32-bit input blocks for947* the compression function; the output is written in place in this948* array. This function uses four internal passes.949*950* @param msg the message block (32 values)951* @param val the function 256-bit input and output952*/953void sph_haval_4_comp(const sph_u32 msg[32], sph_u32 val[8]);954955/**956* Apply the HAVAL compression function on the provided data. The957* <code>msg</code> parameter contains the 32 32-bit input blocks,958* as numerical values (hence after the little-endian decoding). The959* <code>val</code> parameter contains the 8 32-bit input blocks for960* the compression function; the output is written in place in this961* array. This function uses five internal passes.962*963* @param msg the message block (32 values)964* @param val the function 256-bit input and output965*/966void sph_haval_5_comp(const sph_u32 msg[32], sph_u32 val[8]);967968#endif969970971