aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-13 00:16:41 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-13 00:16:41 +0000
commitd8fe3868996c80cd3de775584fde730c32c309c9 (patch)
tree2b0c265adc6241809aecb784b4ddbabbb90f38c4 /src
parent1effc94df7e558de6319082e390803911cf45c24 (diff)
downloadlibbu++-d8fe3868996c80cd3de775584fde730c32c309c9.tar.gz
libbu++-d8fe3868996c80cd3de775584fde730c32c309c9.tar.bz2
libbu++-d8fe3868996c80cd3de775584fde730c32c309c9.tar.xz
libbu++-d8fe3868996c80cd3de775584fde730c32c309c9.zip
md5...is...broken...I'm...fixing it...
Diffstat (limited to 'src')
-rw-r--r--src/md5.cpp32
-rw-r--r--src/md5.h10
2 files changed, 10 insertions, 32 deletions
diff --git a/src/md5.cpp b/src/md5.cpp
index abf4bfa..46ee769 100644
--- a/src/md5.cpp
+++ b/src/md5.cpp
@@ -13,29 +13,7 @@
13 13
14 14
15// This performs a wrapping bitwise shift, kinda' fun! 15// This performs a wrapping bitwise shift, kinda' fun!
16 16#define bitRoll( val, amnt ) ((val<<(amnt)) | (val>>(32-(amnt))))
17#define bit_roll( num, cnt ) \
18 (((num) << (cnt)) | (((num) >> (32 - (cnt))) & ~(-1<<(cnt))))
19
20//#define md5_cmn( q, a, b, x, s, t ) (bit_roll((a + q + x + t), s) + b)
21
22// The following are handy wrappers for the cmn function
23#define md5_ff( a, b, c, d, x, s, t ) \
24 (md5_cmn((b & c) | ((~b) & d), a, b, x, s, t))
25
26#define md5_gg( a, b, c, d, x, s, t ) \
27 (md5_cmn((b & d) | (c & (~d)), a, b, x, s, t))
28
29#define md5_hh( a, b, c, d, x, s, t ) \
30 (md5_cmn(b ^ c ^ d, a, b, x, s, t))
31
32#define md5_ii( a, b, c, d, x, s, t ) \
33 (md5_cmn(c ^ (b | (~d)), a, b, x, s, t))
34
35inline long md5_cmn( long q, long a, long b, long x, long s, long t )
36{
37 return bit_roll((a + q + x + t), s) + b;
38}
39 17
40Bu::Md5::Md5() 18Bu::Md5::Md5()
41{ 19{
@@ -50,10 +28,10 @@ void Bu::Md5::reset()
50{ 28{
51 // These are the magic seed numbers... 29 // These are the magic seed numbers...
52 30
53 sum[0] = 1732584193; 31 sum[0] = 0x67452301U;
54 sum[1] = -271733879; 32 sum[1] = 0xEFCDAB89U;
55 sum[2] = -1732584194; 33 sum[2] = 0x98BADCFEU;
56 sum[3] = 271733878; 34 sum[3] = 0x10325476U;
57 35
58 iBytes = 0; 36 iBytes = 0;
59 memset( inbuf, 0, 4*16 ); 37 memset( inbuf, 0, 4*16 );
diff --git a/src/md5.h b/src/md5.h
index 79b1d09..0be65fd 100644
--- a/src/md5.h
+++ b/src/md5.h
@@ -36,12 +36,12 @@ namespace Bu
36 /** 36 /**
37 * Compute one block of input data. 37 * Compute one block of input data.
38 */ 38 */
39 void compBlock( long *x, long *lsum ); 39 void compBlock( long *x, uint32_t *lsum );
40 void compCap( long *sumout ); 40 void compCap( uint32_t *sumout );
41 41
42 long inbuf[16]; 42 uint32_t inbuf[16];
43 long iFill; 43 uint32_t iFill;
44 long sum[4]; 44 uint32_t sum[4];
45 uint64_t iBytes; 45 uint64_t iBytes;
46 }; 46 };
47}; 47};