[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.4 and 1.5

version 1.4, 2004/06/20 10:59:01 version 1.5, 2004/07/04 02:31:51
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/ox_ntl/crypt/sha1/sha1.c,v 1.3 2004/05/16 15:02:39 iwane Exp $ */  /* $OpenXM: OpenXM/src/ox_ntl/crypt/sha1/sha1.c,v 1.4 2004/06/20 10:59:01 iwane Exp $ */
 /* RFC 3174 - SHA-1 (US Secure Hash Algorithm 1 (SHA1))*/  /* RFC 3174 - SHA-1 (US Secure Hash Algorithm 1 (SHA1))*/
   
 #include <stdio.h>  #include <stdio.h>
   #include <string.h>
   
 #include "sha1.h"  #include "sha1.h"
   
Line 9 
Line 10 
 #include <errno.h>  #include <errno.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   
   #ifdef lint
   #define inline
   #endif
   
   
 /* Global Constant */  /* Global Constant */
 static const uint32_t K[4] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};  static const uint32_t K[4] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
 static const uint32_t H[5] = {0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0};  static const uint32_t H[5] = {0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0};
Line 19  static const uint32_t H[5] = {0x67452301, 0xefcdab89, 
Line 25  static const uint32_t H[5] = {0x67452301, 0xefcdab89, 
 static inline uint32_t lshift32(uint32_t x, int n)  static inline uint32_t lshift32(uint32_t x, int n)
 {  {
         return ((x << n) | (x >> (32 - n)));          return ((x << n) | (x >> (32 - n)));
 };  }
   
   
   
Line 173  int
Line 179  int
 fsha1_h(unsigned char *Ph, int fd, const uint32_t *hp)  fsha1_h(unsigned char *Ph, int fd, const uint32_t *hp)
 {  {
         int i, j, cnt, ret;          int i, j, cnt, ret;
         size_t l;          int l;
         off_t len;          off_t len;
         unsigned char buf[1024], *msg, msgbuf[1024];          unsigned char buf[1024], *msg, msgbuf[1024];
         uint32_t h[sizeof(H) / sizeof(H[0])];          uint32_t h[sizeof(H) / sizeof(H[0])];
         int pad = 0;  
         struct stat stbuf;          struct stat stbuf;
   
         if (hp == NULL)          if (hp == NULL)
Line 186  fsha1_h(unsigned char *Ph, int fd, const uint32_t *hp)
Line 191  fsha1_h(unsigned char *Ph, int fd, const uint32_t *hp)
                 memcpy(h, hp, sizeof(h));                  memcpy(h, hp, sizeof(h));
   
         ret = fstat(fd, &stbuf);          ret = fstat(fd, &stbuf);
           if (ret != 0) {
                   return (errno);
           }
   
   
           msg = msgbuf;
         len = stbuf.st_size;          len = stbuf.st_size;
         if (len == 0)          if (len == 0)
                 goto _PADDING;                  goto _PADDING;
Line 209  fsha1_h(unsigned char *Ph, int fd, const uint32_t *hp)
Line 220  fsha1_h(unsigned char *Ph, int fd, const uint32_t *hp)
   
                 if (len == 0) {                  if (len == 0) {
 _PADDING:  _PADDING:
                         cnt = padding(buf, msg, stbuf.st_size);                          cnt = padding(buf, msg, (size_t)(stbuf.st_size % BLOCK));
                         for (i = 0; i < cnt; i++) {                          for (i = 0; i < cnt; i++) {
                                 sha1_md(h, buf + BLOCK * i);                                  sha1_md(h, buf + BLOCK * i);
                         }                          }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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