Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tpruvot
GitHub Repository: tpruvot/cpuminer-multi
Path: blob/linux/sha3/sph_haval.h
1201 views
1
/* $Id: sph_haval.h 218 2010-06-08 17:06:34Z tp $ */
2
/**
3
* HAVAL interface.
4
*
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
12
* padding data.
13
*
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.
18
*
19
* This paper, and a reference implementation, are available on the
20
* Calyptix web site: http://labs.calyptix.com/haval.php
21
*
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.
26
*
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;
30
* use only with care.
31
*
32
* ==========================(LICENSE BEGIN)============================
33
*
34
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
35
*
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:
43
*
44
* The above copyright notice and this permission notice shall be
45
* included in all copies or substantial portions of the Software.
46
*
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.
54
*
55
* ===========================(LICENSE END)=============================
56
*
57
* @file sph_haval.h
58
* @author Thomas Pornin <[email protected]>
59
*/
60
61
#ifndef SPH_HAVAL_H__
62
#define SPH_HAVAL_H__
63
64
#include <stddef.h>
65
#include "sph_types.h"
66
67
/**
68
* Output size (in bits) for HAVAL-128/3.
69
*/
70
#define SPH_SIZE_haval128_3 128
71
72
/**
73
* Output size (in bits) for HAVAL-128/4.
74
*/
75
#define SPH_SIZE_haval128_4 128
76
77
/**
78
* Output size (in bits) for HAVAL-128/5.
79
*/
80
#define SPH_SIZE_haval128_5 128
81
82
/**
83
* Output size (in bits) for HAVAL-160/3.
84
*/
85
#define SPH_SIZE_haval160_3 160
86
87
/**
88
* Output size (in bits) for HAVAL-160/4.
89
*/
90
#define SPH_SIZE_haval160_4 160
91
92
/**
93
* Output size (in bits) for HAVAL-160/5.
94
*/
95
#define SPH_SIZE_haval160_5 160
96
97
/**
98
* Output size (in bits) for HAVAL-192/3.
99
*/
100
#define SPH_SIZE_haval192_3 192
101
102
/**
103
* Output size (in bits) for HAVAL-192/4.
104
*/
105
#define SPH_SIZE_haval192_4 192
106
107
/**
108
* Output size (in bits) for HAVAL-192/5.
109
*/
110
#define SPH_SIZE_haval192_5 192
111
112
/**
113
* Output size (in bits) for HAVAL-224/3.
114
*/
115
#define SPH_SIZE_haval224_3 224
116
117
/**
118
* Output size (in bits) for HAVAL-224/4.
119
*/
120
#define SPH_SIZE_haval224_4 224
121
122
/**
123
* Output size (in bits) for HAVAL-224/5.
124
*/
125
#define SPH_SIZE_haval224_5 224
126
127
/**
128
* Output size (in bits) for HAVAL-256/3.
129
*/
130
#define SPH_SIZE_haval256_3 256
131
132
/**
133
* Output size (in bits) for HAVAL-256/4.
134
*/
135
#define SPH_SIZE_haval256_4 256
136
137
/**
138
* Output size (in bits) for HAVAL-256/5.
139
*/
140
#define SPH_SIZE_haval256_5 256
141
142
/**
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.
147
*
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>).
151
*/
152
typedef struct {
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;
157
#if SPH_64
158
sph_u64 count;
159
#else
160
sph_u32 count_high, count_low;
161
#endif
162
#endif
163
} sph_haval_context;
164
165
/**
166
* Type for a HAVAL-128/3 context (identical to the common context).
167
*/
168
typedef sph_haval_context sph_haval128_3_context;
169
170
/**
171
* Type for a HAVAL-128/4 context (identical to the common context).
172
*/
173
typedef sph_haval_context sph_haval128_4_context;
174
175
/**
176
* Type for a HAVAL-128/5 context (identical to the common context).
177
*/
178
typedef sph_haval_context sph_haval128_5_context;
179
180
/**
181
* Type for a HAVAL-160/3 context (identical to the common context).
182
*/
183
typedef sph_haval_context sph_haval160_3_context;
184
185
/**
186
* Type for a HAVAL-160/4 context (identical to the common context).
187
*/
188
typedef sph_haval_context sph_haval160_4_context;
189
190
/**
191
* Type for a HAVAL-160/5 context (identical to the common context).
192
*/
193
typedef sph_haval_context sph_haval160_5_context;
194
195
/**
196
* Type for a HAVAL-192/3 context (identical to the common context).
197
*/
198
typedef sph_haval_context sph_haval192_3_context;
199
200
/**
201
* Type for a HAVAL-192/4 context (identical to the common context).
202
*/
203
typedef sph_haval_context sph_haval192_4_context;
204
205
/**
206
* Type for a HAVAL-192/5 context (identical to the common context).
207
*/
208
typedef sph_haval_context sph_haval192_5_context;
209
210
/**
211
* Type for a HAVAL-224/3 context (identical to the common context).
212
*/
213
typedef sph_haval_context sph_haval224_3_context;
214
215
/**
216
* Type for a HAVAL-224/4 context (identical to the common context).
217
*/
218
typedef sph_haval_context sph_haval224_4_context;
219
220
/**
221
* Type for a HAVAL-224/5 context (identical to the common context).
222
*/
223
typedef sph_haval_context sph_haval224_5_context;
224
225
/**
226
* Type for a HAVAL-256/3 context (identical to the common context).
227
*/
228
typedef sph_haval_context sph_haval256_3_context;
229
230
/**
231
* Type for a HAVAL-256/4 context (identical to the common context).
232
*/
233
typedef sph_haval_context sph_haval256_4_context;
234
235
/**
236
* Type for a HAVAL-256/5 context (identical to the common context).
237
*/
238
typedef sph_haval_context sph_haval256_5_context;
239
240
/**
241
* Initialize the context for HAVAL-128/3.
242
*
243
* @param cc context to initialize (pointer to a
244
* <code>sph_haval128_3_context</code> structure)
245
*/
246
void sph_haval128_3_init(void *cc);
247
248
/**
249
* Process some data bytes for HAVAL-128/3. If <code>len</code> is 0,
250
* then this function does nothing.
251
*
252
* @param cc the HAVAL-128/3 context
253
* @param data the input data
254
* @param len the input data length (in bytes)
255
*/
256
void sph_haval128_3(void *cc, const void *data, size_t len);
257
258
/**
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
261
* reinitialized.
262
*
263
* @param cc the HAVAL-128/3 context
264
* @param dst the output buffer
265
*/
266
void sph_haval128_3_close(void *cc, void *dst);
267
268
/**
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.
274
*
275
* The output buffer must be wide enough to accomodate the result (16
276
* bytes). The context is automatically reinitialized.
277
*
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
282
*/
283
void sph_haval128_3_addbits_and_close(void *cc,
284
unsigned ub, unsigned n, void *dst);
285
286
/**
287
* Initialize the context for HAVAL-128/4.
288
*
289
* @param cc context to initialize (pointer to a
290
* <code>sph_haval128_4_context</code> structure)
291
*/
292
void sph_haval128_4_init(void *cc);
293
294
/**
295
* Process some data bytes for HAVAL-128/4. If <code>len</code> is 0,
296
* then this function does nothing.
297
*
298
* @param cc the HAVAL-128/4 context
299
* @param data the input data
300
* @param len the input data length (in bytes)
301
*/
302
void sph_haval128_4(void *cc, const void *data, size_t len);
303
304
/**
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
307
* reinitialized.
308
*
309
* @param cc the HAVAL-128/4 context
310
* @param dst the output buffer
311
*/
312
void sph_haval128_4_close(void *cc, void *dst);
313
314
/**
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.
320
*
321
* The output buffer must be wide enough to accomodate the result (16
322
* bytes). The context is automatically reinitialized.
323
*
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
328
*/
329
void sph_haval128_4_addbits_and_close(void *cc,
330
unsigned ub, unsigned n, void *dst);
331
332
/**
333
* Initialize the context for HAVAL-128/5.
334
*
335
* @param cc context to initialize (pointer to a
336
* <code>sph_haval128_5_context</code> structure)
337
*/
338
void sph_haval128_5_init(void *cc);
339
340
/**
341
* Process some data bytes for HAVAL-128/5. If <code>len</code> is 0,
342
* then this function does nothing.
343
*
344
* @param cc the HAVAL-128/5 context
345
* @param data the input data
346
* @param len the input data length (in bytes)
347
*/
348
void sph_haval128_5(void *cc, const void *data, size_t len);
349
350
/**
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
353
* reinitialized.
354
*
355
* @param cc the HAVAL-128/5 context
356
* @param dst the output buffer
357
*/
358
void sph_haval128_5_close(void *cc, void *dst);
359
360
/**
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.
366
*
367
* The output buffer must be wide enough to accomodate the result (16
368
* bytes). The context is automatically reinitialized.
369
*
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
374
*/
375
void sph_haval128_5_addbits_and_close(void *cc,
376
unsigned ub, unsigned n, void *dst);
377
378
/**
379
* Initialize the context for HAVAL-160/3.
380
*
381
* @param cc context to initialize (pointer to a
382
* <code>sph_haval160_3_context</code> structure)
383
*/
384
void sph_haval160_3_init(void *cc);
385
386
/**
387
* Process some data bytes for HAVAL-160/3. If <code>len</code> is 0,
388
* then this function does nothing.
389
*
390
* @param cc the HAVAL-160/3 context
391
* @param data the input data
392
* @param len the input data length (in bytes)
393
*/
394
void sph_haval160_3(void *cc, const void *data, size_t len);
395
396
/**
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
399
* reinitialized.
400
*
401
* @param cc the HAVAL-160/3 context
402
* @param dst the output buffer
403
*/
404
void sph_haval160_3_close(void *cc, void *dst);
405
406
/**
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.
412
*
413
* The output buffer must be wide enough to accomodate the result (20
414
* bytes). The context is automatically reinitialized.
415
*
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
420
*/
421
void sph_haval160_3_addbits_and_close(void *cc,
422
unsigned ub, unsigned n, void *dst);
423
424
/**
425
* Initialize the context for HAVAL-160/4.
426
*
427
* @param cc context to initialize (pointer to a
428
* <code>sph_haval160_4_context</code> structure)
429
*/
430
void sph_haval160_4_init(void *cc);
431
432
/**
433
* Process some data bytes for HAVAL-160/4. If <code>len</code> is 0,
434
* then this function does nothing.
435
*
436
* @param cc the HAVAL-160/4 context
437
* @param data the input data
438
* @param len the input data length (in bytes)
439
*/
440
void sph_haval160_4(void *cc, const void *data, size_t len);
441
442
/**
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
445
* reinitialized.
446
*
447
* @param cc the HAVAL-160/4 context
448
* @param dst the output buffer
449
*/
450
void sph_haval160_4_close(void *cc, void *dst);
451
452
/**
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.
458
*
459
* The output buffer must be wide enough to accomodate the result (20
460
* bytes). The context is automatically reinitialized.
461
*
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
466
*/
467
void sph_haval160_3_addbits_and_close(void *cc,
468
unsigned ub, unsigned n, void *dst);
469
470
/**
471
* Initialize the context for HAVAL-160/5.
472
*
473
* @param cc context to initialize (pointer to a
474
* <code>sph_haval160_5_context</code> structure)
475
*/
476
void sph_haval160_5_init(void *cc);
477
478
/**
479
* Process some data bytes for HAVAL-160/5. If <code>len</code> is 0,
480
* then this function does nothing.
481
*
482
* @param cc the HAVAL-160/5 context
483
* @param data the input data
484
* @param len the input data length (in bytes)
485
*/
486
void sph_haval160_5(void *cc, const void *data, size_t len);
487
488
/**
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
491
* reinitialized.
492
*
493
* @param cc the HAVAL-160/5 context
494
* @param dst the output buffer
495
*/
496
void sph_haval160_5_close(void *cc, void *dst);
497
498
/**
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.
504
*
505
* The output buffer must be wide enough to accomodate the result (20
506
* bytes). The context is automatically reinitialized.
507
*
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
512
*/
513
void sph_haval160_5_addbits_and_close(void *cc,
514
unsigned ub, unsigned n, void *dst);
515
516
/**
517
* Initialize the context for HAVAL-192/3.
518
*
519
* @param cc context to initialize (pointer to a
520
* <code>sph_haval192_3_context</code> structure)
521
*/
522
void sph_haval192_3_init(void *cc);
523
524
/**
525
* Process some data bytes for HAVAL-192/3. If <code>len</code> is 0,
526
* then this function does nothing.
527
*
528
* @param cc the HAVAL-192/3 context
529
* @param data the input data
530
* @param len the input data length (in bytes)
531
*/
532
void sph_haval192_3(void *cc, const void *data, size_t len);
533
534
/**
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
537
* reinitialized.
538
*
539
* @param cc the HAVAL-192/3 context
540
* @param dst the output buffer
541
*/
542
void sph_haval192_3_close(void *cc, void *dst);
543
544
/**
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.
550
*
551
* The output buffer must be wide enough to accomodate the result (24
552
* bytes). The context is automatically reinitialized.
553
*
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
558
*/
559
void sph_haval192_3_addbits_and_close(void *cc,
560
unsigned ub, unsigned n, void *dst);
561
562
/**
563
* Initialize the context for HAVAL-192/4.
564
*
565
* @param cc context to initialize (pointer to a
566
* <code>sph_haval192_4_context</code> structure)
567
*/
568
void sph_haval192_4_init(void *cc);
569
570
/**
571
* Process some data bytes for HAVAL-192/4. If <code>len</code> is 0,
572
* then this function does nothing.
573
*
574
* @param cc the HAVAL-192/4 context
575
* @param data the input data
576
* @param len the input data length (in bytes)
577
*/
578
void sph_haval192_4(void *cc, const void *data, size_t len);
579
580
/**
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
583
* reinitialized.
584
*
585
* @param cc the HAVAL-192/4 context
586
* @param dst the output buffer
587
*/
588
void sph_haval192_4_close(void *cc, void *dst);
589
590
/**
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.
596
*
597
* The output buffer must be wide enough to accomodate the result (24
598
* bytes). The context is automatically reinitialized.
599
*
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
604
*/
605
void sph_haval192_4_addbits_and_close(void *cc,
606
unsigned ub, unsigned n, void *dst);
607
608
/**
609
* Initialize the context for HAVAL-192/5.
610
*
611
* @param cc context to initialize (pointer to a
612
* <code>sph_haval192_5_context</code> structure)
613
*/
614
void sph_haval192_5_init(void *cc);
615
616
/**
617
* Process some data bytes for HAVAL-192/5. If <code>len</code> is 0,
618
* then this function does nothing.
619
*
620
* @param cc the HAVAL-192/5 context
621
* @param data the input data
622
* @param len the input data length (in bytes)
623
*/
624
void sph_haval192_5(void *cc, const void *data, size_t len);
625
626
/**
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
629
* reinitialized.
630
*
631
* @param cc the HAVAL-192/5 context
632
* @param dst the output buffer
633
*/
634
void sph_haval192_5_close(void *cc, void *dst);
635
636
/**
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.
642
*
643
* The output buffer must be wide enough to accomodate the result (24
644
* bytes). The context is automatically reinitialized.
645
*
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
650
*/
651
void sph_haval192_5_addbits_and_close(void *cc,
652
unsigned ub, unsigned n, void *dst);
653
654
/**
655
* Initialize the context for HAVAL-224/3.
656
*
657
* @param cc context to initialize (pointer to a
658
* <code>sph_haval224_3_context</code> structure)
659
*/
660
void sph_haval224_3_init(void *cc);
661
662
/**
663
* Process some data bytes for HAVAL-224/3. If <code>len</code> is 0,
664
* then this function does nothing.
665
*
666
* @param cc the HAVAL-224/3 context
667
* @param data the input data
668
* @param len the input data length (in bytes)
669
*/
670
void sph_haval224_3(void *cc, const void *data, size_t len);
671
672
/**
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
675
* reinitialized.
676
*
677
* @param cc the HAVAL-224/3 context
678
* @param dst the output buffer
679
*/
680
void sph_haval224_3_close(void *cc, void *dst);
681
682
/**
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.
688
*
689
* The output buffer must be wide enough to accomodate the result (28
690
* bytes). The context is automatically reinitialized.
691
*
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
696
*/
697
void sph_haval224_3_addbits_and_close(void *cc,
698
unsigned ub, unsigned n, void *dst);
699
700
/**
701
* Initialize the context for HAVAL-224/4.
702
*
703
* @param cc context to initialize (pointer to a
704
* <code>sph_haval224_4_context</code> structure)
705
*/
706
void sph_haval224_4_init(void *cc);
707
708
/**
709
* Process some data bytes for HAVAL-224/4. If <code>len</code> is 0,
710
* then this function does nothing.
711
*
712
* @param cc the HAVAL-224/4 context
713
* @param data the input data
714
* @param len the input data length (in bytes)
715
*/
716
void sph_haval224_4(void *cc, const void *data, size_t len);
717
718
/**
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
721
* reinitialized.
722
*
723
* @param cc the HAVAL-224/4 context
724
* @param dst the output buffer
725
*/
726
void sph_haval224_4_close(void *cc, void *dst);
727
728
/**
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.
734
*
735
* The output buffer must be wide enough to accomodate the result (28
736
* bytes). The context is automatically reinitialized.
737
*
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
742
*/
743
void sph_haval224_4_addbits_and_close(void *cc,
744
unsigned ub, unsigned n, void *dst);
745
746
/**
747
* Initialize the context for HAVAL-224/5.
748
*
749
* @param cc context to initialize (pointer to a
750
* <code>sph_haval224_5_context</code> structure)
751
*/
752
void sph_haval224_5_init(void *cc);
753
754
/**
755
* Process some data bytes for HAVAL-224/5. If <code>len</code> is 0,
756
* then this function does nothing.
757
*
758
* @param cc the HAVAL-224/5 context
759
* @param data the input data
760
* @param len the input data length (in bytes)
761
*/
762
void sph_haval224_5(void *cc, const void *data, size_t len);
763
764
/**
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
767
* reinitialized.
768
*
769
* @param cc the HAVAL-224/5 context
770
* @param dst the output buffer
771
*/
772
void sph_haval224_5_close(void *cc, void *dst);
773
774
/**
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.
780
*
781
* The output buffer must be wide enough to accomodate the result (28
782
* bytes). The context is automatically reinitialized.
783
*
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
788
*/
789
void sph_haval224_5_addbits_and_close(void *cc,
790
unsigned ub, unsigned n, void *dst);
791
792
/**
793
* Initialize the context for HAVAL-256/3.
794
*
795
* @param cc context to initialize (pointer to a
796
* <code>sph_haval256_3_context</code> structure)
797
*/
798
void sph_haval256_3_init(void *cc);
799
800
/**
801
* Process some data bytes for HAVAL-256/3. If <code>len</code> is 0,
802
* then this function does nothing.
803
*
804
* @param cc the HAVAL-256/3 context
805
* @param data the input data
806
* @param len the input data length (in bytes)
807
*/
808
void sph_haval256_3(void *cc, const void *data, size_t len);
809
810
/**
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
813
* reinitialized.
814
*
815
* @param cc the HAVAL-256/3 context
816
* @param dst the output buffer
817
*/
818
void sph_haval256_3_close(void *cc, void *dst);
819
820
/**
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.
826
*
827
* The output buffer must be wide enough to accomodate the result (32
828
* bytes). The context is automatically reinitialized.
829
*
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
834
*/
835
void sph_haval256_3_addbits_and_close(void *cc,
836
unsigned ub, unsigned n, void *dst);
837
838
/**
839
* Initialize the context for HAVAL-256/4.
840
*
841
* @param cc context to initialize (pointer to a
842
* <code>sph_haval256_4_context</code> structure)
843
*/
844
void sph_haval256_4_init(void *cc);
845
846
/**
847
* Process some data bytes for HAVAL-256/4. If <code>len</code> is 0,
848
* then this function does nothing.
849
*
850
* @param cc the HAVAL-256/4 context
851
* @param data the input data
852
* @param len the input data length (in bytes)
853
*/
854
void sph_haval256_4(void *cc, const void *data, size_t len);
855
856
/**
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
859
* reinitialized.
860
*
861
* @param cc the HAVAL-256/4 context
862
* @param dst the output buffer
863
*/
864
void sph_haval256_4_close(void *cc, void *dst);
865
866
/**
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.
872
*
873
* The output buffer must be wide enough to accomodate the result (32
874
* bytes). The context is automatically reinitialized.
875
*
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
880
*/
881
void sph_haval256_4_addbits_and_close(void *cc,
882
unsigned ub, unsigned n, void *dst);
883
884
/**
885
* Initialize the context for HAVAL-256/5.
886
*
887
* @param cc context to initialize (pointer to a
888
* <code>sph_haval256_5_context</code> structure)
889
*/
890
void sph_haval256_5_init(void *cc);
891
892
/**
893
* Process some data bytes for HAVAL-256/5. If <code>len</code> is 0,
894
* then this function does nothing.
895
*
896
* @param cc the HAVAL-256/5 context
897
* @param data the input data
898
* @param len the input data length (in bytes)
899
*/
900
void sph_haval256_5(void *cc, const void *data, size_t len);
901
902
/**
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
905
* reinitialized.
906
*
907
* @param cc the HAVAL-256/5 context
908
* @param dst the output buffer
909
*/
910
void sph_haval256_5_close(void *cc, void *dst);
911
912
/**
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.
918
*
919
* The output buffer must be wide enough to accomodate the result (32
920
* bytes). The context is automatically reinitialized.
921
*
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
926
*/
927
void sph_haval256_5_addbits_and_close(void *cc,
928
unsigned ub, unsigned n, void *dst);
929
930
/**
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.
937
*
938
* @param msg the message block (32 values)
939
* @param val the function 256-bit input and output
940
*/
941
void sph_haval_3_comp(const sph_u32 msg[32], sph_u32 val[8]);
942
943
/**
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.
950
*
951
* @param msg the message block (32 values)
952
* @param val the function 256-bit input and output
953
*/
954
void sph_haval_4_comp(const sph_u32 msg[32], sph_u32 val[8]);
955
956
/**
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.
963
*
964
* @param msg the message block (32 values)
965
* @param val the function 256-bit input and output
966
*/
967
void sph_haval_5_comp(const sph_u32 msg[32], sph_u32 val[8]);
968
969
#endif
970
971