|
1 |
|
2 #include <ruby.h> |
|
3 |
|
4 static VALUE rb_mEzmlm; |
|
5 static VALUE rb_cEZHash; |
|
6 |
|
7 |
|
8 #ifndef SURF_H |
|
9 #define SURF_H |
|
10 |
|
11 #define ROTATE(x,b) (((x) << (b)) | ((x) >> (32 - (b)))) |
|
12 #define MUSH(i,b) x = t[i] += (((x ^ seed[i]) + sum) ^ ROTATE(x,b)); |
|
13 |
|
14 typedef struct { |
|
15 unsigned int seed[32]; |
|
16 unsigned int sum[8]; |
|
17 unsigned int out[8]; |
|
18 unsigned int in[12]; |
|
19 int todo; |
|
20 } surfpcs; |
|
21 |
|
22 static const unsigned int littleendian[8] = { |
|
23 0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c, |
|
24 0x13121110, 0x17161514, 0x1b1a1918, 0x1f1e1d1c |
|
25 } ; |
|
26 #define end ((unsigned char *) &littleendian) |
|
27 #define data ((unsigned char *) s->in) |
|
28 #define outdata ((unsigned char *) s->out) |
|
29 |
|
30 extern void surf( unsigned int out[8], const unsigned int in[12], const unsigned int seed[32] ); |
|
31 extern void surfpcs_init( surfpcs *s, const unsigned int k[32] ); |
|
32 extern void surfpcs_add( surfpcs *s, const char *x,unsigned int n ); |
|
33 extern void surfpcs_addlc( surfpcs *s, const char *x,unsigned int n ); |
|
34 extern void surfpcs_out( surfpcs *s, unsigned char h[32] ); |
|
35 #endif |
|
36 |
|
37 |
|
38 #ifndef SUBHASH_H |
|
39 #define SUBHASH_H |
|
40 |
|
41 unsigned int subhashs(const char *s); |
|
42 unsigned int subhashb(const char *s,long len); |
|
43 #define subhashsa(SA) subhashb((SA)->s,(SA)->len) |
|
44 |
|
45 #endif |
|
46 |