]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mdfour.c
Improve debug logging for render modules
[xonotic/darkplaces.git] / mdfour.c
index 36180c6e74b957392a69391c938f20924da9599c..ae92e3758af2ac487f1b732662fe731a6d1cda79 100644 (file)
--- a/mdfour.c
+++ b/mdfour.c
@@ -27,9 +27,8 @@
        $Id$
 */
 
-#include "quakedef.h"
+#include "darkplaces.h"
 
-#include <string.h>            /* XoXus: needed for memset call */
 #include "mdfour.h"
 
 /* NOTE: This code makes no attempt to be fast!
 #define F(X,Y,Z) (((X)&(Y)) | ((~(X))&(Z)))
 #define G(X,Y,Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))
 #define H(X,Y,Z) ((X)^(Y)^(Z))
-#ifdef LARGE_INT32
-#define lshift(x,s) ((((x)<<(s))&0xFFFFFFFF) | (((x)>>(32-(s)))&0xFFFFFFFF))
-#else
 #define lshift(x,s) (((x)<<(s)) | ((x)>>(32-(s))))
-#endif
 
 #define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
 #define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + 0x5A827999,s)
 #define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1,s)
 
 /* this applies md4 to 64 byte chunks */
-static void mdfour64(struct mdfour *md, uint32 *M)
+static void mdfour64(struct mdfour_s *md, uint32_t *M)
 {
        int j;
-       uint32 AA, BB, CC, DD;
-       uint32 X[16];
-       uint32 A,B,C,D;
+       uint32_t AA, BB, CC, DD;
+       uint32_t X[16];
+       uint32_t A,B,C,D;
 
        for (j=0;j<16;j++)
                X[j] = M[j];
@@ -93,18 +88,13 @@ static void mdfour64(struct mdfour *md, uint32 *M)
 
        A += AA; B += BB; C += CC; D += DD;
 
-#ifdef LARGE_INT32
-       A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
-       C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
-#endif
-
        for (j=0;j<16;j++)
                X[j] = 0;
 
        md->A = A; md->B = B; md->C = C; md->D = D;
 }
 
-static void copy64(uint32 *M, const unsigned char *in)
+static void copy64(uint32_t *M, const unsigned char *in)
 {
        int i;
 
@@ -113,7 +103,7 @@ static void copy64(uint32 *M, const unsigned char *in)
                        (in[i*4+1]<<8) | (in[i*4+0]<<0);
 }
 
-static void copy4(unsigned char *out,uint32 x)
+static void copy4(unsigned char *out,uint32_t x)
 {
        out[0] = x&0xFF;
        out[1] = (x>>8)&0xFF;
@@ -121,7 +111,7 @@ static void copy4(unsigned char *out,uint32 x)
        out[3] = (x>>24)&0xFF;
 }
 
-void mdfour_begin(struct mdfour *md)
+void mdfour_begin(struct mdfour_s *md)
 {
        md->A = 0x67452301;
        md->B = 0xefcdab89;
@@ -131,11 +121,11 @@ void mdfour_begin(struct mdfour *md)
 }
 
 
-static void mdfour_tail(struct mdfour *md, const unsigned char *in, int n)
+static void mdfour_tail(struct mdfour_s *md, const unsigned char *in, int n)
 {
        unsigned char buf[128];
-       uint32 M[16];
-       uint32 b;
+       uint32_t M[16];
+       uint32_t b;
 
        md->totalN += n;
 
@@ -158,14 +148,14 @@ static void mdfour_tail(struct mdfour *md, const unsigned char *in, int n)
        }
 }
 
-void mdfour_update(struct mdfour *md, const unsigned char *in, int n)
+void mdfour_update(struct mdfour_s *md, const unsigned char *in, int n)
 {
-       uint32 M[16];
+       uint32_t M[16];
 
-// start of edit by Forest 'LordHavoc' Hale
+// start of edit by Ashley Rose Hale (LadyHavoc)
 // commented out to prevent crashing when length is 0
 //     if (n == 0) mdfour_tail(in, n);
-// end of edit by Forest 'LordHavoc' Hale
+// end of edit by Ashley Rose Hale (LadyHavoc)
 
        while (n >= 64) {
                copy64(M, in);
@@ -179,7 +169,7 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n)
 }
 
 
-void mdfour_result(struct mdfour *md, unsigned char *out)
+void mdfour_result(struct mdfour_s *md, unsigned char *out)
 {
        copy4(out, md->A);
        copy4(out+4, md->B);
@@ -190,7 +180,7 @@ void mdfour_result(struct mdfour *md, unsigned char *out)
 
 void mdfour(unsigned char *out, const unsigned char *in, int n)
 {
-       struct mdfour md;
+       struct mdfour_s md;
        mdfour_begin(&md);
        mdfour_update(&md, in, n);
        mdfour_result(&md, out);