Discuss http://www.shoup.net/papers/oaep.ps.Z
[openssl.git] / crypto / sha / sha.h
index ba40aafc135b58368913c88a05b13fff17430c5b..77f6d9695e77bd9220f4c04f18b2c6c4dcc57f34 100644 (file)
 extern "C" {
 #endif
 
-#ifdef NO_SHA
+#if defined(NO_SHA) || (defined(NO_SHA0) && defined(NO_SHA1))
 #error SHA is disabled.
 #endif
 
-#define SHA_CBLOCK     64
-#define SHA_LBLOCK     16
-#define SHA_BLOCK      16
-#define SHA_LAST_BLOCK  56
-#define SHA_LENGTH_BLOCK 8
-#define SHA_DIGEST_LENGTH 20
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !
+ * ! SHA_LONG_LOG2 has to be defined along.                        !
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ */
 
-#ifdef WIN16
+#if defined(WIN16) || defined(__LP32__)
+#define SHA_LONG unsigned long
+#elif defined(_CRAY) || defined(__ILP64__)
 #define SHA_LONG unsigned long
+#define SHA_LONG_LOG2 3
 #else
 #define SHA_LONG unsigned int
-#endif 
+#endif
+
+#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 20
 
 typedef struct SHAstate_st
        {
@@ -90,17 +100,17 @@ typedef struct SHAstate_st
 
 #ifndef NO_SHA0
 void SHA_Init(SHA_CTX *c);
-void SHA_Update(SHA_CTX *c, const unsigned char *data, unsigned long len);
+void SHA_Update(SHA_CTX *c, const void *data, unsigned long len);
 void SHA_Final(unsigned char *md, SHA_CTX *c);
 unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md);
-void SHA_Transform(SHA_CTX *c, unsigned char *data);
+void SHA_Transform(SHA_CTX *c, const unsigned char *data);
 #endif
 #ifndef NO_SHA1
 void SHA1_Init(SHA_CTX *c);
-void SHA1_Update(SHA_CTX *c, const unsigned char *data, unsigned long len);
+void SHA1_Update(SHA_CTX *c, const void *data, unsigned long len);
 void SHA1_Final(unsigned char *md, SHA_CTX *c);
 unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md);
-void SHA1_Transform(SHA_CTX *c, unsigned char *data);
+void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
 #endif
 #ifdef  __cplusplus
 }