]> git.tdb.fi Git - libs/crypto.git/blobdiff - source/md5.cpp
Use BlockHash as base class of MD5 as well
[libs/crypto.git] / source / md5.cpp
index 1fe700305bee89f5f801d4bbcda323e6aef7290e..fdf517f8678dcc16212a79cffff2e95c050238a6 100644 (file)
@@ -10,28 +10,28 @@ namespace Crypto {
 namespace {
 
 template<unsigned N>
-inline UInt32 func(UInt32, UInt32, UInt32);
+UInt32 func(UInt32, UInt32, UInt32);
 
 template<>
-UInt32 func<1>(UInt32 x, UInt32 y, UInt32 z)
+inline UInt32 func<1>(UInt32 x, UInt32 y, UInt32 z)
 {
        return (y&x) | (z&~x);
 }
 
 template<>
-UInt32 func<2>(UInt32 x, UInt32 y, UInt32 z)
+inline UInt32 func<2>(UInt32 x, UInt32 y, UInt32 z)
 {
        return (x&z) | (y&~z);
 }
 
 template<>
-UInt32 func<3>(UInt32 x, UInt32 y, UInt32 z)
+inline UInt32 func<3>(UInt32 x, UInt32 y, UInt32 z)
 {
        return x^y^z;
 }
 
 template<>
-UInt32 func<4>(UInt32 x, UInt32 y, UInt32 z)
+inline UInt32 func<4>(UInt32 x, UInt32 y, UInt32 z)
 {
        return y^(x|~z);
 }
@@ -77,39 +77,12 @@ void MD5::init()
        buffer[2] = 0x98badcfe;
        buffer[3] = 0x10325476;
        processed_bytes = 0;
-       unprocessed_bytes = 0;
 
        if(!sin_table[0])
                for(unsigned i=0; i<64; ++i)
                        sin_table[i] = 4294967296.0*abs(sin((i+1)*1.0));
 }
 
-void MD5::update(const char *data, unsigned len)
-{
-       if(unprocessed_bytes && unprocessed_bytes+len>=64)
-       {
-               unsigned needed = 64-unprocessed_bytes;
-               copy(data, data+needed, unprocessed+unprocessed_bytes);
-               process_block(unprocessed);
-               data += needed;
-               len -= needed;
-               unprocessed_bytes = 0;
-       }
-
-       while(len>=64)
-       {
-               process_block(data);
-               data += 64;
-               len -= 64;
-       }
-
-       if(len>0)
-       {
-               copy(data, data+len, unprocessed+unprocessed_bytes);
-               unprocessed_bytes += len;
-       }
-}
-
 unsigned MD5::get_digest(char *digest, unsigned len) const
 {
        if(len<16)