Remove all .cvsignore files
[openssl.git] / crypto / whrlpool / wp_dgst.c
index 1d33eb6..ee5c5c1 100644 (file)
 #include "wp_locl.h"
 #include <string.h>
 
-void WHIRLPOOL_Init    (WHIRLPOOL_CTX *c) { memset (c,0,sizeof(*c)); }
+int WHIRLPOOL_Init     (WHIRLPOOL_CTX *c)
+       {
+       memset (c,0,sizeof(*c));
+       return(1);
+       }
 
-void WHIRLPOOL_Update  (WHIRLPOOL_CTX *c,const void *_inp,size_t bytes)
+int WHIRLPOOL_Update   (WHIRLPOOL_CTX *c,const void *_inp,size_t bytes)
        {
        /* Well, largest suitable chunk size actually is
         * (1<<(sizeof(size_t)*8-3))-64, but below number
@@ -73,6 +77,8 @@ void WHIRLPOOL_Update (WHIRLPOOL_CTX *c,const void *_inp,size_t bytes)
                }
        if (bytes)
                WHIRLPOOL_BitUpdate(c,inp,bytes*8);
+
+       return(1);
        }
 
 void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *_inp,size_t bits)
@@ -124,7 +130,7 @@ void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *_inp,size_t bits)
                                else
                                        {
                                        memcpy(c->data+byteoff,inp,bits/8);
-                                       bitoff += bits;
+                                       bitoff += (unsigned int)bits;
                                        bits = 0;
                                        }
                                c->bitoff = bitoff;
@@ -191,7 +197,7 @@ void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *_inp,size_t bits)
                                b = (inp[0]<<inpgap)&0xff;
                                if (bitrem)     c->data[byteoff++] |= b>>bitrem;
                                else            c->data[byteoff++]  = b;
-                               bitoff += bits;
+                               bitoff += (unsigned int)bits;
                                if (bitoff==WHIRLPOOL_BBLOCK)
                                        {
                                        whirlpool_block(c,c->data,1);
@@ -206,12 +212,11 @@ void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *_inp,size_t bits)
                }
        }
 
-void WHIRLPOOL_Final   (unsigned char *md,WHIRLPOOL_CTX *c)
+int WHIRLPOOL_Final    (unsigned char *md,WHIRLPOOL_CTX *c)
        {
        unsigned int    bitoff  = c->bitoff,
                        byteoff = bitoff/8;
-       int             i,j;
-       size_t          v;
+       size_t          i,j,v;
        unsigned char  *p;
 
        bitoff %= 8;
@@ -238,8 +243,12 @@ void WHIRLPOOL_Final       (unsigned char *md,WHIRLPOOL_CTX *c)
 
        whirlpool_block(c,c->data,1);
 
-       memcpy(md,c->H.c,WHIRLPOOL_DIGEST_LENGTH);
-       memset(c,0,sizeof(*c));
+       if (md) {
+               memcpy(md,c->H.c,WHIRLPOOL_DIGEST_LENGTH);
+               memset(c,0,sizeof(*c));
+               return(1);
+               }
+       return(0);
        }
 
 unsigned char *WHIRLPOOL(const void *inp, size_t bytes,unsigned char *md)