]> git.sesse.net Git - freerainbowtables/blobdiff - Client Applications/rcracki_mt/fast_md5.cpp
Merge branch 'master' of git@gitorious.org:freerainbowtables-applications/freerainbow...
[freerainbowtables] / Client Applications / rcracki_mt / fast_md5.cpp
index 8d60aee2736417ac3f81c7482e44ae4b3f05c025..934e9c6b8b62ea69322e1e90d742230a6f760341 100644 (file)
@@ -9,11 +9,30 @@
  *  - For lengths < 16, transformation steps are "unrolled" using macros/defines
  *  - Constants used whenever possible, it's the compiler's job to sort them out
  *  - Padding is done on 4-byte words, and memory copied as last resort.
+ *
+ * rcracki_mt is a multithreaded implementation and fork of the original 
+ * RainbowCrack
+ *
+ * Copyright 2009, 2010 DaniĆ«l Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * This file is part of rcracki_mt.
+ *
+ * rcracki_mt is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * rcracki_mt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with rcracki_mt.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-
-typedef unsigned int UINT4;
-
+#include "fast_md5.h"
 
 /* MD5 defines as per RFC reference implementation */
 
@@ -115,9 +134,9 @@ typedef unsigned int UINT4;
 
 // md5 step
 #define MD5STEP(f, a, b, c, d, AC, x, s) {     \
-    (a) += f ((b), (c), (d));          \
+       (a) += f ((b), (c), (d));               \
        (a) += (AC) + (x);                              \
-    (a) = ROTATE_LEFT ((a), (s));      \
+       (a) = ROTATE_LEFT ((a), (s));   \
        (a) += (b);                                             \
 }
 
@@ -226,8 +245,9 @@ typedef unsigned int UINT4;
 
 
 #ifndef MD5_pad_w1
-static inline UINT4 MD5_pad_w1(UINT4 data)
+static inline uint32 MD5_pad_w1(uint32 data)
 {
+// XXX x86 specific
        __asm__ (
                "movb   %%al,   %%cl    \n\t"
                "xorl   %1,             %1              \n\t"
@@ -243,8 +263,9 @@ static inline UINT4 MD5_pad_w1(UINT4 data)
 #endif
 
 #ifndef MD5_pad_w3
-static inline UINT4 MD5_pad_w3(UINT4 data)
+static inline uint32 MD5_pad_w3(uint32 data)
 {
+// XXX x86 specific
        __asm__ (
                "roll   $8,             %1              \n\t"
                "movb   $128,   %%al    \n\t"
@@ -258,7 +279,7 @@ static inline UINT4 MD5_pad_w3(UINT4 data)
 #endif
 
 
-static inline void MD5_copy_pad_block(UINT4 *dData, UINT4 *wIn, int blocklen, int len)
+static inline void MD5_copy_pad_block(uint32 *dData, uint32 *wIn, int blocklen, int len)
 {
        register int cl;
 
@@ -292,7 +313,7 @@ static inline void MD5_copy_pad_block(UINT4 *dData, UINT4 *wIn, int blocklen, in
 // fast initializer array
 //__attribute__((aligned(16)))
 //__declspec(align(16))
-static const UINT4 CC[4] = {Ca, Cb, Cc, Cd};
+static const uint32 CC[4] = {Ca, Cb, Cc, Cd};
 
 
 
@@ -302,13 +323,13 @@ static const UINT4 CC[4] = {Ca, Cb, Cc, Cd};
  */
 void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest)
 {
-       #define wIn             ((UINT4 *)pData)
-       #define wOut    ((UINT4 *)pDigest)
+       #define wIn             ((uint32 *)pData)
+       #define wOut    ((uint32 *)pDigest)
 
-       register UINT4 a;
-       register UINT4 b;
-       register UINT4 c;
-       register UINT4 d;
+       register uint32 a;
+       register uint32 b;
+       register uint32 c;
+       register uint32 d;
 
        switch (len) {
                case 0:
@@ -362,7 +383,7 @@ void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest)
        }
 
        // data block used for padding
-       UINT4 dData[16];
+       uint32 dData[16];
 
        if (len < 56) {
                // 16 < length < 56
@@ -383,7 +404,7 @@ void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest)
        } else {
                // len >= 56
 
-               #define wIn             ((UINT4 *)pData)
+               #define wIn             ((uint32 *)pData)
 
                // original len
                int tlen = len;
@@ -458,7 +479,7 @@ void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest)
                        );
 
                        #undef  wIn
-                       #define wIn             ((UINT4 *)pData)
+                       #define wIn             ((uint32 *)pData)
                        return;
                }
        }