nfsd4: don't check ip address in setclientid
[safe/jmp/linux-2.6] / fs / cifs / md5.c
index ccebf9b..98b66a5 100644 (file)
  * with every copy.
  *
  * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
+ * MD5Context structure, pass it to cifs_MD5_init, call cifs_MD5_update as
+ * needed on buffers full of bytes, and then call cifs_MD5_final, which
  * will fill a supplied 16-byte array with the digest.
  */
 
-/* This code slightly modified to fit into Samba by 
-   abartlet@samba.org Jun 2001 
-   and to fit the cifs vfs by 
+/* This code slightly modified to fit into Samba by
+   abartlet@samba.org Jun 2001
+   and to fit the cifs vfs by
    Steve French sfrench@us.ibm.com */
 
 #include <linux/string.h>
@@ -45,7 +45,7 @@ byteReverse(unsigned char *buf, unsigned longs)
  * initialization constants.
  */
 void
-MD5Init(struct MD5Context *ctx)
+cifs_MD5_init(struct MD5Context *ctx)
 {
        ctx->buf[0] = 0x67452301;
        ctx->buf[1] = 0xefcdab89;
@@ -61,7 +61,7 @@ MD5Init(struct MD5Context *ctx)
  * of bytes.
  */
 void
-MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
+cifs_MD5_update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
 {
        register __u32 t;
 
@@ -106,11 +106,11 @@ MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
 }
 
 /*
- * Final wrapup - pad to 64-byte boundary with the bit pattern 
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
  * 1 0* (64-bit count of bits processed, MSB-first)
  */
 void
-MD5Final(unsigned char digest[16], struct MD5Context *ctx)
+cifs_MD5_final(unsigned char digest[16], struct MD5Context *ctx)
 {
        unsigned int count;
        unsigned char *p;
@@ -161,11 +161,11 @@ MD5Final(unsigned char digest[16], struct MD5Context *ctx)
 
 /* This is the central step in the MD5 algorithm. */
 #define MD5STEP(f, w, x, y, z, data, s) \
-       ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
+       (w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x)
 
 /*
  * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data.  MD5Update blocks
+ * reflect the addition of 16 longwords of new data.  cifs_MD5_update blocks
  * the data and converts bytes into longwords for this routine.
  */
 static void
@@ -267,17 +267,17 @@ hmac_md5_init_rfc2104(unsigned char *key, int key_len,
                unsigned char tk[16];
                struct MD5Context tctx;
 
-               MD5Init(&tctx);
-               MD5Update(&tctx, key, key_len);
-               MD5Final(tk, &tctx);
+               cifs_MD5_init(&tctx);
+               cifs_MD5_update(&tctx, key, key_len);
+               cifs_MD5_final(tk, &tctx);
 
                key = tk;
                key_len = 16;
        }
 
        /* start out by storing key in pads */
-       memset(ctx->k_ipad, 0, sizeof (ctx->k_ipad));
-       memset(ctx->k_opad, 0, sizeof (ctx->k_opad));
+       memset(ctx->k_ipad, 0, sizeof(ctx->k_ipad));
+       memset(ctx->k_opad, 0, sizeof(ctx->k_opad));
        memcpy(ctx->k_ipad, key, key_len);
        memcpy(ctx->k_opad, key, key_len);
 
@@ -287,8 +287,8 @@ hmac_md5_init_rfc2104(unsigned char *key, int key_len,
                ctx->k_opad[i] ^= 0x5c;
        }
 
-       MD5Init(&ctx->ctx);
-       MD5Update(&ctx->ctx, ctx->k_ipad, 64);
+       cifs_MD5_init(&ctx->ctx);
+       cifs_MD5_update(&ctx->ctx, ctx->k_ipad, 64);
 }
 #endif
 
@@ -302,13 +302,12 @@ hmac_md5_init_limK_to_64(const unsigned char *key, int key_len,
        int i;
 
        /* if key is longer than 64 bytes truncate it */
-       if (key_len > 64) {
+       if (key_len > 64)
                key_len = 64;
-       }
 
        /* start out by storing key in pads */
-       memset(ctx->k_ipad, 0, sizeof (ctx->k_ipad));
-       memset(ctx->k_opad, 0, sizeof (ctx->k_opad));
+       memset(ctx->k_ipad, 0, sizeof(ctx->k_ipad));
+       memset(ctx->k_opad, 0, sizeof(ctx->k_opad));
        memcpy(ctx->k_ipad, key, key_len);
        memcpy(ctx->k_opad, key, key_len);
 
@@ -318,8 +317,8 @@ hmac_md5_init_limK_to_64(const unsigned char *key, int key_len,
                ctx->k_opad[i] ^= 0x5c;
        }
 
-       MD5Init(&ctx->ctx);
-       MD5Update(&ctx->ctx, ctx->k_ipad, 64);
+       cifs_MD5_init(&ctx->ctx);
+       cifs_MD5_update(&ctx->ctx, ctx->k_ipad, 64);
 }
 
 /***********************************************************************
@@ -329,7 +328,7 @@ void
 hmac_md5_update(const unsigned char *text, int text_len,
                struct HMACMD5Context *ctx)
 {
-       MD5Update(&ctx->ctx, text, text_len);   /* then text of datagram */
+       cifs_MD5_update(&ctx->ctx, text, text_len);     /* then text of datagram */
 }
 
 /***********************************************************************
@@ -340,12 +339,12 @@ hmac_md5_final(unsigned char *digest, struct HMACMD5Context *ctx)
 {
        struct MD5Context ctx_o;
 
-       MD5Final(digest, &ctx->ctx);
+       cifs_MD5_final(digest, &ctx->ctx);
 
-       MD5Init(&ctx_o);
-       MD5Update(&ctx_o, ctx->k_opad, 64);
-       MD5Update(&ctx_o, digest, 16);
-       MD5Final(digest, &ctx_o);
+       cifs_MD5_init(&ctx_o);
+       cifs_MD5_update(&ctx_o, ctx->k_opad, 64);
+       cifs_MD5_update(&ctx_o, digest, 16);
+       cifs_MD5_final(digest, &ctx_o);
 }
 
 /***********************************************************
@@ -359,9 +358,9 @@ hmac_md5(unsigned char key[16], unsigned char *data, int data_len,
 {
        struct HMACMD5Context ctx;
        hmac_md5_init_limK_to_64(key, 16, &ctx);
-       if (data_len != 0) {
+       if (data_len != 0)
                hmac_md5_update(data, data_len, &ctx);
-       }
+
        hmac_md5_final(digest, &ctx);
 }
 #endif