1 /********************************************************************\
3 * CONTENTS: Header file for a sample C-implementation of the
4 * RIPEMD-160 hash-function.
5 * AUTHOR: Antoon Bosselaers, Dept. Electrical Eng.-ESAT/COSIC
6 * DATE: 1 March 1996 VERSION: 1.0
7 \********************************************************************/
9 #ifndef RMD160H /* make sure this file is read only once */
12 /********************************************************************/
13 /* Type definitions of an 8 and a 32-bit integer type, respectively.
14 Adapt these, if necessary, for your operating system and compiler
16 typedef unsigned char byte
; /* unsigned 8-bit integer */
17 typedef unsigned long word
; /* unsigned 32-bit integer */
19 /********************************************************************/
20 /* Macro definitions */
22 /* ROL(x, n) cyclically rotates x over n bits to the left
23 x must be of an unsigned 32 bits type and 0 <= n < 32.
25 #define ROL(x, n) (((x) << (n)) | ((x) >> (32-(n))))
27 /* The five basic RIPEMD-160 functions F1(), F2(), F3(), F4(), and F5()
29 #define F1(x, y, z) ((x) ^ (y) ^ (z))
30 #define F2(x, y, z) (((x) & (y)) | (~(x) & (z)))
31 #define F3(x, y, z) (((x) | ~(y)) ^ (z))
32 #define F4(x, y, z) (((x) & (z)) | ((y) & ~(z)))
33 #define F5(x, y, z) ((x) ^ ((y) | ~(z)))
35 /* The ten basic RIPEMD-160 transformations FF1() through FFF5()
37 #define FF1(a, b, c, d, e, x, s) {\
38 (a) += F1((b), (c), (d)) + (x);\
39 (a) = ROL((a), (s)) + (e);\
42 #define FF2(a, b, c, d, e, x, s) {\
43 (a) += F2((b), (c), (d)) + (x) + 0x5a827999UL;\
44 (a) = ROL((a), (s)) + (e);\
47 #define FF3(a, b, c, d, e, x, s) {\
48 (a) += F3((b), (c), (d)) + (x) + 0x6ed9eba1UL;\
49 (a) = ROL((a), (s)) + (e);\
52 #define FF4(a, b, c, d, e, x, s) {\
53 (a) += F4((b), (c), (d)) + (x) + 0x8f1bbcdcUL;\
54 (a) = ROL((a), (s)) + (e);\
57 #define FF5(a, b, c, d, e, x, s) {\
58 (a) += F5((b), (c), (d)) + (x) + 0xa953fd4eUL;\
59 (a) = ROL((a), (s)) + (e);\
62 #define FFF1(a, b, c, d, e, x, s) {\
63 (a) += F1((b), (c), (d)) + (x);\
64 (a) = ROL((a), (s)) + (e);\
67 #define FFF2(a, b, c, d, e, x, s) {\
68 (a) += F2((b), (c), (d)) + (x) + 0x7a6d76e9UL;\
69 (a) = ROL((a), (s)) + (e);\
72 #define FFF3(a, b, c, d, e, x, s) {\
73 (a) += F3((b), (c), (d)) + (x) + 0x6d703ef3UL;\
74 (a) = ROL((a), (s)) + (e);\
77 #define FFF4(a, b, c, d, e, x, s) {\
78 (a) += F4((b), (c), (d)) + (x) + 0x5c4dd124UL;\
79 (a) = ROL((a), (s)) + (e);\
82 #define FFF5(a, b, c, d, e, x, s) {\
83 (a) += F5((b), (c), (d)) + (x) + 0x50a28be6UL;\
84 (a) = ROL((a), (s)) + (e);\
88 /********************************************************************/
89 /* Function prototypes */
91 void MDinit(word
*MDbuf
);
92 void MDcompress(word
*MDbuf
, word
*X
);
93 void MDfinish(word
*MDbuf
, byte
*string
, word lswlen
, word mswlen
);
97 /*********************** end of file rmd160.h ***********************/