PR: 2632
[oweals/openssl.git] / crypto / sha / sha.h
index f4dd5277c2f78e68dd8f82ad7bdc58965eaaff87..16cacf9fc01b2733e337493864769ec11e16478f 100644 (file)
@@ -60,6 +60,7 @@
 #define HEADER_SHA_H
 
 #include <openssl/e_os2.h>
+#include <stddef.h>
 
 #ifdef  __cplusplus
 extern "C" {
@@ -80,7 +81,7 @@ extern "C" {
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  */
 
-#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
+#if defined(__LP32__)
 #define SHA_LONG unsigned long
 #elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
 #define SHA_LONG unsigned long
@@ -89,19 +90,19 @@ extern "C" {
 #define SHA_LONG unsigned int
 #endif
 
-#define SHA_LBLOCK     16U
+#define SHA_LBLOCK     16
 #define SHA_CBLOCK     (SHA_LBLOCK*4)  /* SHA treats input data as a
                                         * contiguous array of 32 bit
                                         * wide big-endian values. */
 #define SHA_LAST_BLOCK  (SHA_CBLOCK-8)
-#define SHA_DIGEST_LENGTH 20U
+#define SHA_DIGEST_LENGTH 20
 
 typedef struct SHAstate_st
        {
        SHA_LONG h0,h1,h2,h3,h4;
        SHA_LONG Nl,Nh;
        SHA_LONG data[SHA_LBLOCK];
-       int num;
+       unsigned int num;
        } SHA_CTX;
 
 #ifndef OPENSSL_NO_SHA0
@@ -130,18 +131,13 @@ typedef struct SHA256state_st
        SHA_LONG h[8];
        SHA_LONG Nl,Nh;
        SHA_LONG data[SHA_LBLOCK];
-       int num;
+       unsigned int num,md_len;
        } SHA256_CTX;
 
 #ifndef OPENSSL_NO_SHA256
 int SHA224_Init(SHA256_CTX *c);
-#if 0
 int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
 int SHA224_Final(unsigned char *md, SHA256_CTX *c);
-#else
-#define SHA224_Update(c,data,len)      SHA256_Update((c),(data),(len))
-#define SHA224_Final(md,c)     SHA256_Final((md),(c))
-#endif
 unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md);
 int SHA256_Init(SHA256_CTX *c);
 int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
@@ -153,6 +149,7 @@ void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
 #define SHA384_DIGEST_LENGTH   48
 #define SHA512_DIGEST_LENGTH   64
 
+#ifndef OPENSSL_NO_SHA512
 /*
  * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64
  * being exactly 64-bit wide. See Implementation Notes in sha512.c
@@ -164,6 +161,9 @@ void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
 #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
 #define SHA_LONG64 unsigned __int64
 #define U64(C)     C##UI64
+#elif defined(__arch64__)
+#define SHA_LONG64 unsigned long
+#define U64(C)     C##UL
 #else
 #define SHA_LONG64 unsigned long long
 #define U64(C)     C##ULL
@@ -177,8 +177,9 @@ typedef struct SHA512state_st
                SHA_LONG64      d[SHA_LBLOCK];
                unsigned char   p[SHA512_CBLOCK];
        } u;
-       int num;
+       unsigned int num,md_len;
        } SHA512_CTX;
+#endif
 
 #ifndef OPENSSL_NO_SHA512
 int SHA384_Init(SHA512_CTX *c);