Message digest stuff.
diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c
index 9ea53d4..c2661c1 100644
--- a/crypto/dsa/dsa_gen.c
+++ b/crypto/dsa/dsa_gen.c
@@ -64,6 +64,7 @@
 #define HASH    SHA1
 #endif 
 
+#ifndef NO_SHA
 #include <stdio.h>
 #include <time.h>
 #include "cryptlib.h"
@@ -328,4 +329,4 @@
 	
 	return(ok);
 	}
-
+#endif
diff --git a/crypto/dsa/dsa_key.c b/crypto/dsa/dsa_key.c
index e974861..ab7f38f 100644
--- a/crypto/dsa/dsa_key.c
+++ b/crypto/dsa/dsa_key.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_SHA
 #include <stdio.h>
 #include <time.h>
 #include "cryptlib.h"
@@ -108,4 +109,4 @@
 	if (ctx != NULL) BN_CTX_free(ctx);
 	return(ok);
 	}
-
+#endif
diff --git a/crypto/evp/e_cbc_3d.c b/crypto/evp/e_cbc_3d.c
index 58a2276..9b95554 100644
--- a/crypto/evp/e_cbc_3d.c
+++ b/crypto/evp/e_cbc_3d.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -143,3 +144,4 @@
 		&(ctx->iv[0]),
 		ctx->encrypt);
 	}
+#endif
diff --git a/crypto/evp/e_cbc_d.c b/crypto/evp/e_cbc_d.c
index a20497a..1507dbb 100644
--- a/crypto/evp/e_cbc_d.c
+++ b/crypto/evp/e_cbc_d.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -98,3 +99,4 @@
 	{
 	des_ncbc_encrypt(in,out,inl,ctx->c.des_ks,&(ctx->iv[0]),ctx->encrypt);
 	}
+#endif
diff --git a/crypto/evp/e_cfb_3d.c b/crypto/evp/e_cfb_3d.c
index 803bb47..7a6a65b 100644
--- a/crypto/evp/e_cfb_3d.c
+++ b/crypto/evp/e_cfb_3d.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -146,3 +147,4 @@
 			       ctx->c.des_ede.ks3,
 			       &(ctx->iv[0]),&ctx->num,ctx->encrypt);
 	}
+#endif
diff --git a/crypto/evp/e_cfb_d.c b/crypto/evp/e_cfb_d.c
index 59ae819..8b77430 100644
--- a/crypto/evp/e_cfb_d.c
+++ b/crypto/evp/e_cfb_d.c
@@ -61,6 +61,7 @@
 #include <openssl/evp.h>
 #include <openssl/objects.h>
 
+#ifndef NO_DES
 static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
 	unsigned char *iv,int enc);
 static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
@@ -104,3 +105,4 @@
 		&(ctx->iv[0]),
 		&ctx->num,ctx->encrypt);
 	}
+#endif
diff --git a/crypto/evp/e_ecb_3d.c b/crypto/evp/e_ecb_3d.c
index a6db815..7bcecee 100644
--- a/crypto/evp/e_ecb_3d.c
+++ b/crypto/evp/e_ecb_3d.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -142,3 +143,4 @@
 			ctx->encrypt);
 		}
 	}
+#endif
diff --git a/crypto/evp/e_ecb_d.c b/crypto/evp/e_ecb_d.c
index 2c9f8e3..3496ca5 100644
--- a/crypto/evp/e_ecb_d.c
+++ b/crypto/evp/e_ecb_d.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -102,3 +103,4 @@
 		des_ecb_encrypt(&(in[i]),&(out[i]),ctx->c.des_ks,ctx->encrypt);
 		}
 	}
+#endif
diff --git a/crypto/evp/e_ofb_3d.c b/crypto/evp/e_ofb_3d.c
index e0ea647..dba58c1 100644
--- a/crypto/evp/e_ofb_3d.c
+++ b/crypto/evp/e_ofb_3d.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -144,3 +145,4 @@
 			       ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
 			       &(ctx->iv[0]),&ctx->num);
 	}
+#endif
diff --git a/crypto/evp/e_ofb_d.c b/crypto/evp/e_ofb_d.c
index f91e93e..fd75b73 100644
--- a/crypto/evp/e_ofb_d.c
+++ b/crypto/evp/e_ofb_d.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -100,3 +101,4 @@
 	{
 	des_ofb64_encrypt(in,out,inl,ctx->c.des_ks,&(ctx->iv[0]),&ctx->num);
 	}
+#endif
diff --git a/crypto/evp/e_xcbc_d.c b/crypto/evp/e_xcbc_d.c
index 01e15ae..3238de0 100644
--- a/crypto/evp/e_xcbc_d.c
+++ b/crypto/evp/e_xcbc_d.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DES
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -106,3 +107,4 @@
 		&(ctx->c.desx_cbc.outw[0]),
 		ctx->encrypt);
 	}
+#endif
diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c
index 28398bc..21eda41 100644
--- a/crypto/evp/evp_key.c
+++ b/crypto/evp/evp_key.c
@@ -82,7 +82,7 @@
 	}
 
 #ifdef NO_DES
-int des_read_pw_string(char *buf,int len,char *prompt,int verify);
+int des_read_pw_string(char *buf,int len,const char *prompt,int verify);
 #endif
 
 int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
diff --git a/crypto/evp/m_dss.c b/crypto/evp/m_dss.c
index 356b936..8ea8268 100644
--- a/crypto/evp/m_dss.c
+++ b/crypto/evp/m_dss.c
@@ -62,6 +62,7 @@
 #include <openssl/objects.h>
 #include <openssl/x509.h>
 
+#ifndef NO_SHA
 static EVP_MD dsa_md=
 	{
 	NID_dsaWithSHA,
@@ -79,4 +80,4 @@
 	{
 	return(&dsa_md);
 	}
-
+#endif
diff --git a/crypto/evp/m_dss1.c b/crypto/evp/m_dss1.c
index 4315086..9d8d1ce 100644
--- a/crypto/evp/m_dss1.c
+++ b/crypto/evp/m_dss1.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_SHA
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -79,3 +80,4 @@
 	{
 	return(&dss1_md);
 	}
+#endif
diff --git a/crypto/evp/m_md2.c b/crypto/evp/m_md2.c
index 4b84238..3281e91 100644
--- a/crypto/evp/m_md2.c
+++ b/crypto/evp/m_md2.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_MD2
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -79,4 +80,4 @@
 	{
 	return(&md2_md);
 	}
-
+#endif
diff --git a/crypto/evp/m_md5.c b/crypto/evp/m_md5.c
index 18531b6..9fc9530 100644
--- a/crypto/evp/m_md5.c
+++ b/crypto/evp/m_md5.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_MD5
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -79,3 +80,4 @@
 	{
 	return(&md5_md);
 	}
+#endif
diff --git a/crypto/evp/m_mdc2.c b/crypto/evp/m_mdc2.c
index 2e59628..2c7f1ae 100644
--- a/crypto/evp/m_mdc2.c
+++ b/crypto/evp/m_mdc2.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_MDC2
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -79,3 +80,4 @@
 	{
 	return(&mdc2_md);
 	}
+#endif
diff --git a/crypto/evp/m_sha.c b/crypto/evp/m_sha.c
index 8213c36..6d35b71 100644
--- a/crypto/evp/m_sha.c
+++ b/crypto/evp/m_sha.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_SHA
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -79,4 +80,4 @@
 	{
 	return(&sha_md);
 	}
-
+#endif
diff --git a/crypto/evp/m_sha1.c b/crypto/evp/m_sha1.c
index 5d54806..57a1ab0 100644
--- a/crypto/evp/m_sha1.c
+++ b/crypto/evp/m_sha1.c
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_SHA
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
@@ -79,3 +80,4 @@
 	{
 	return(&sha1_md);
 	}
+#endif
diff --git a/crypto/rand/Makefile.ssl b/crypto/rand/Makefile.ssl
index 17591e0..e78d585 100644
--- a/crypto/rand/Makefile.ssl
+++ b/crypto/rand/Makefile.ssl
@@ -77,7 +77,7 @@
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 md_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
-md_rand.o: ../../include/openssl/md5.h ../../include/openssl/opensslv.h
-md_rand.o: ../../include/openssl/rand.h ../../include/openssl/stack.h
+md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
+md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
 rand_lib.o: ../../include/openssl/rand.h
 randfile.o: ../../include/openssl/e_os.h ../../include/openssl/rand.h
diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c
index ab7e41c..8ab8608 100644
--- a/crypto/rand/md_rand.c
+++ b/crypto/rand/md_rand.c
@@ -64,16 +64,16 @@
 #include <openssl/crypto.h>
 
 #if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
-#ifndef NO_MD5
-#define USE_MD5_RAND
-#elif !defined(NO_SHA1)
+#if !defined(NO_SHA) && !defined(NO_SHA1)
 #define USE_SHA1_RAND
-#elif !defined(NO_MDC2)
+#elif !defined(NO_MD5)
+#define USE_MD5_RAND
+#elif !defined(NO_MDC2) && !defined(NO_DES)
 #define USE_MDC2_RAND
 #elif !defined(NO_MD2)
 #define USE_MD2_RAND
 #else
-We need a message digest of some type 
+#error No message digest algorithm available
 #endif
 #endif
 
diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c
index e3c7444..5637a31 100644
--- a/crypto/rsa/rsa_oaep.c
+++ b/crypto/rsa/rsa_oaep.c
@@ -4,7 +4,7 @@
 
 /* EME_OAEP as defined in RFC 2437 (PKCS #1 v2.0) */
 
-#ifndef NO_SHA
+#if !defined(NO_SHA) && !defined(NO_SHA1)
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/bn.h>
diff --git a/crypto/sha/sha.h b/crypto/sha/sha.h
index 105d4c8..ba40aaf 100644
--- a/crypto/sha/sha.h
+++ b/crypto/sha/sha.h
@@ -90,16 +90,16 @@
 
 #ifndef NO_SHA0
 void SHA_Init(SHA_CTX *c);
-void SHA_Update(SHA_CTX *c, unsigned char *data, unsigned long len);
+void SHA_Update(SHA_CTX *c, const unsigned char *data, unsigned long len);
 void SHA_Final(unsigned char *md, SHA_CTX *c);
-unsigned char *SHA(unsigned char *d, unsigned long n,unsigned char *md);
+unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md);
 void SHA_Transform(SHA_CTX *c, unsigned char *data);
 #endif
 #ifndef NO_SHA1
 void SHA1_Init(SHA_CTX *c);
-void SHA1_Update(SHA_CTX *c, unsigned char *data, unsigned long len);
+void SHA1_Update(SHA_CTX *c, const unsigned char *data, unsigned long len);
 void SHA1_Final(unsigned char *md, SHA_CTX *c);
-unsigned char *SHA1(unsigned char *d, unsigned long n,unsigned char *md);
+unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md);
 void SHA1_Transform(SHA_CTX *c, unsigned char *data);
 #endif
 #ifdef  __cplusplus
diff --git a/crypto/sha/sha1_one.c b/crypto/sha/sha1_one.c
index 864e2a8..861752e 100644
--- a/crypto/sha/sha1_one.c
+++ b/crypto/sha/sha1_one.c
@@ -61,7 +61,7 @@
 #include <openssl/sha.h>
 
 #ifndef NO_SHA1
-unsigned char *SHA1(unsigned char *d, unsigned long n, unsigned char *md)
+unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md)
 	{
 	SHA_CTX c;
 	static unsigned char m[SHA_DIGEST_LENGTH];
diff --git a/crypto/sha/sha1dgst.c b/crypto/sha/sha1dgst.c
index 532f53b..f4a47f3 100644
--- a/crypto/sha/sha1dgst.c
+++ b/crypto/sha/sha1dgst.c
@@ -114,7 +114,7 @@
 	c->num=0;
 	}
 
-void SHA1_Update(SHA_CTX *c, register unsigned char *data,
+void SHA1_Update(SHA_CTX *c, const register unsigned char *data,
 	     unsigned long len)
 	{
 	register SHA_LONG *p;
diff --git a/crypto/sha/sha_dgst.c b/crypto/sha/sha_dgst.c
index e75c66c..5827c73 100644
--- a/crypto/sha/sha_dgst.c
+++ b/crypto/sha/sha_dgst.c
@@ -100,7 +100,8 @@
 	c->num=0;
 	}
 
-void SHA_Update(SHA_CTX *c, register unsigned char *data, unsigned long len)
+void SHA_Update(SHA_CTX *c, const register unsigned char *data,
+		unsigned long len)
 	{
 	register SHA_LONG *p;
 	int ew,ec,sw,sc;
diff --git a/crypto/sha/sha_one.c b/crypto/sha/sha_one.c
index 6ef3f06..2d955de 100644
--- a/crypto/sha/sha_one.c
+++ b/crypto/sha/sha_one.c
@@ -61,7 +61,7 @@
 #include <openssl/sha.h>
 
 #ifndef NO_SHA0
-unsigned char *SHA(unsigned char *d, unsigned long n, unsigned char *md)
+unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md)
 	{
 	SHA_CTX c;
 	static unsigned char m[SHA_DIGEST_LENGTH];
diff --git a/ssl/s2_lib.c b/ssl/s2_lib.c
index e56901b..39ab1b6 100644
--- a/ssl/s2_lib.c
+++ b/ssl/s2_lib.c
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include <openssl/rsa.h>
 #include <openssl/objects.h>
+#include <openssl/md5.h>
 #include "ssl_locl.h"
 
 static long ssl2_default_timeout(void );
diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c
index 327c4dd..e0871c4 100644
--- a/ssl/s3_clnt.c
+++ b/ssl/s3_clnt.c
@@ -60,6 +60,8 @@
 #include <openssl/buffer.h>
 #include <openssl/rand.h>
 #include <openssl/objects.h>
+#include <openssl/md5.h>
+#include <openssl/sha.h>
 #include <openssl/evp.h>
 #include "ssl_locl.h"
 
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index 2113ff3..3ef8676 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -57,6 +57,8 @@
  */
 
 #include <stdio.h>
+#include <openssl/md5.h>
+#include <openssl/sha.h>
 #include <openssl/evp.h>
 #include "ssl_locl.h"
 
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index d21772e..c41e254 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -57,6 +57,8 @@
  */
 
 #include <stdio.h>
+#include <openssl/md5.h>
+#include <openssl/sha.h>
 #include <openssl/objects.h>
 #include "ssl_locl.h"
 
diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c
index 0379cc5..154b6ad 100644
--- a/ssl/s3_srvr.c
+++ b/ssl/s3_srvr.c
@@ -62,6 +62,8 @@
 #include <openssl/buffer.h>
 #include <openssl/rand.h>
 #include <openssl/objects.h>
+#include <openssl/md5.h>
+#include <openssl/sha.h>
 #include <openssl/evp.h>
 #include <openssl/x509.h>
 #include "ssl_locl.h"
diff --git a/ssl/ssl_algs.c b/ssl/ssl_algs.c
index 6e198ec..726289a 100644
--- a/ssl/ssl_algs.c
+++ b/ssl/ssl_algs.c
@@ -85,11 +85,11 @@
 	EVP_add_digest_alias(SN_md5,"ssl2-md5");
 	EVP_add_digest_alias(SN_md5,"ssl3-md5");
 #endif
-#ifndef NO_SHA1
+#ifndef NO_SHA
 	EVP_add_digest(EVP_sha1()); /* RSA with sha1 */
 	EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
 #endif
-#if !defined(NO_SHA1) && !defined(NO_DSA)
+#if !defined(NO_SHA) && !defined(NO_DSA)
 	EVP_add_digest(EVP_dss1()); /* DSA with sha1 */
 #endif
 
diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
index 05a3382..914b743 100644
--- a/ssl/t1_enc.c
+++ b/ssl/t1_enc.c
@@ -58,6 +58,8 @@
 
 #include <stdio.h>
 #include <openssl/comp.h>
+#include <openssl/md5.h>
+#include <openssl/sha.h>
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 #include "ssl_locl.h"