[BACK]Return to sha1.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_ntl / crypt / sha1

Diff for /OpenXM/src/ox_ntl/crypt/sha1/sha1.c between version 1.1 and 1.2

version 1.1, 2004/01/12 13:16:28 version 1.2, 2004/03/25 13:34:19
Line 1 
Line 1 
 /* $OpenXM$ */  /* $OpenXM: OpenXM/src/ox_ntl/crypt/sha1/sha1.c,v 1.1 2004/01/12 13:16:28 iwane Exp $ */
 /* RFC 3174 */  /* RFC 3174 - SHA-1 (US Secure Hash Algorithm 1 (SHA1))*/
   
   #include "sha1.h"
   
 /* Global Constant */  /* Global Constant */
 static const unsigned int K[4] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};  static const unsigned int K[4] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
Line 72  f(unsigned int t, unsigned int b, unsigned int c, unsi
Line 73  f(unsigned int t, unsigned int b, unsigned int c, unsi
                 return ((b & c) | (b & d) | (c & d));                  return ((b & c) | (b & d) | (c & d));
         }          }
   
         // Invalid Parameter.          /* Invalid Parameter. */
         return (0);          return (0);
 }  }
   
Line 88  md(unsigned int *h, const unsigned char *msg)
Line 89  md(unsigned int *h, const unsigned char *msg)
         int i;          int i;
         unsigned int w[80];          unsigned int w[80];
   
         /* ....  */          /* ... */
         for (t = 0; t < 16; t++) {          for (t = 0; t < 16; t++) {
                 w[t] = 0;                  w[t] = 0;
                 for (i = 0; i < 4; i++) {                  for (i = 0; i < 4; i++) {
Line 124  md(unsigned int *h, const unsigned char *msg)
Line 125  md(unsigned int *h, const unsigned char *msg)
 }  }
   
 int  int
 sha1_h(unsigned char *Ph, const unsigned char *msg, int len, unsigned int *h)  sha1_h(unsigned char *Ph, const unsigned char *msg, int len, const unsigned int *hp)
 {  {
         int i, j, cnt, l = len;          int i, j, cnt, l = len;
         unsigned char buf[1024];          unsigned char buf[1024];
           unsigned int h[sizeof(H) / sizeof(H[0])];
   
           memcpy(h, hp, sizeof(h));
   
         while (l > BLOCK) {          while (l > BLOCK) {
                 md(h, msg);                  md(h, msg);
                 msg += BLOCK;                  msg += BLOCK;
Line 155  sha1_h(unsigned char *Ph, const unsigned char *msg, in
Line 159  sha1_h(unsigned char *Ph, const unsigned char *msg, in
 int  int
 sha1(unsigned char *Ph, const unsigned char *msg, int len)  sha1(unsigned char *Ph, const unsigned char *msg, int len)
 {  {
         unsigned int h[sizeof(H) / sizeof(H[0])];          return (sha1_h(Ph, msg, len, H));
   
         memcpy(h, H, sizeof(H));  
   
         return (sha1_h(Ph, msg, len, h));  
   
 }  }
   
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>