Include-what-you-use ssl/internal.h.

The rest of ssl/ still includes things everywhere, but this at least fixes the
includes that were implicit from ssl/internal.h.

Change-Id: I7ed22590aca0fe78af84fd99a3e557f4b05f6782
Reviewed-on: https://boringssl-review.googlesource.com/4281
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/d1_clnt.c b/ssl/d1_clnt.c
index eeb8594..9e41618 100644
--- a/ssl/d1_clnt.c
+++ b/ssl/d1_clnt.c
@@ -114,11 +114,13 @@
 
 #include <assert.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <openssl/bn.h>
 #include <openssl/buf.h>
 #include <openssl/dh.h>
 #include <openssl/evp.h>
+#include <openssl/err.h>
 #include <openssl/md5.h>
 #include <openssl/mem.h>
 #include <openssl/obj.h>
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index 43a3f4a..3da70cf 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -58,6 +58,7 @@
 
 #include <limits.h>
 #include <stdio.h>
+#include <string.h>
 
 #if defined(OPENSSL_WINDOWS)
 #include <sys/timeb.h>
diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c
index c4f8f0c..5bb01da 100644
--- a/ssl/d1_pkt.c
+++ b/ssl/d1_pkt.c
@@ -109,9 +109,9 @@
  * copied and put under another distribution licence
  * [including the GNU Public Licence.] */
 
-#include <stdio.h>
-#include <errno.h>
 #include <assert.h>
+#include <stdio.h>
+#include <string.h>
 
 #include <openssl/buf.h>
 #include <openssl/mem.h>
diff --git a/ssl/d1_srtp.c b/ssl/d1_srtp.c
index 0ec006a..f8945e9 100644
--- a/ssl/d1_srtp.c
+++ b/ssl/d1_srtp.c
@@ -115,10 +115,11 @@
 */
 
 #include <stdio.h>
+#include <string.h>
 
 #include <openssl/bytestring.h>
-#include <openssl/obj.h>
 #include <openssl/err.h>
+#include <openssl/obj.h>
 
 #include "internal.h"
 #include <openssl/srtp.h>
diff --git a/ssl/d1_srvr.c b/ssl/d1_srvr.c
index 065f230..44d761b 100644
--- a/ssl/d1_srvr.c
+++ b/ssl/d1_srvr.c
@@ -118,6 +118,7 @@
 #include <openssl/bn.h>
 #include <openssl/buf.h>
 #include <openssl/dh.h>
+#include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/md5.h>
 #include <openssl/obj.h>
diff --git a/ssl/internal.h b/ssl/internal.h
index d137062..360a3d4 100644
--- a/ssl/internal.h
+++ b/ssl/internal.h
@@ -144,17 +144,7 @@
 
 #include <openssl/base.h>
 
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
 #include <openssl/aead.h>
-#include <openssl/bio.h>
-#include <openssl/buf.h>
-#include <openssl/dsa.h>
-#include <openssl/err.h>
-#include <openssl/rsa.h>
 #include <openssl/ssl.h>
 #include <openssl/stack.h>
 
diff --git a/ssl/s3_both.c b/ssl/s3_both.c
index 20c1084..9ab8e1b 100644
--- a/ssl/s3_both.c
+++ b/ssl/s3_both.c
@@ -116,6 +116,7 @@
 #include <string.h>
 
 #include <openssl/buf.h>
+#include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/mem.h>
 #include <openssl/md5.h>
diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c
index 81e76c4..eae6ff3 100644
--- a/ssl/s3_clnt.c
+++ b/ssl/s3_clnt.c
@@ -150,17 +150,18 @@
 
 #include <assert.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <openssl/buf.h>
 #include <openssl/bytestring.h>
 #include <openssl/rand.h>
 #include <openssl/obj.h>
+#include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/mem.h>
 #include <openssl/md5.h>
 #include <openssl/dh.h>
 #include <openssl/bn.h>
-#include <openssl/engine.h>
 #include <openssl/x509.h>
 
 #include "internal.h"
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index 8db0bd9..25ddbda 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -133,8 +133,9 @@
  * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
  * OTHERWISE. */
 
-#include <stdio.h>
 #include <assert.h>
+#include <stdio.h>
+#include <string.h>
 
 #include <openssl/err.h>
 #include <openssl/evp.h>
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index c0dab07..c9bc25b 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -148,9 +148,11 @@
 
 #include <assert.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <openssl/buf.h>
 #include <openssl/dh.h>
+#include <openssl/err.h>
 #include <openssl/md5.h>
 #include <openssl/mem.h>
 #include <openssl/obj.h>
diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c
index d7b7744..aa3c596 100644
--- a/ssl/s3_pkt.c
+++ b/ssl/s3_pkt.c
@@ -107,9 +107,9 @@
  * Hudson (tjh@cryptsoft.com). */
 
 #include <assert.h>
-#include <errno.h>
 #include <limits.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <openssl/buf.h>
 #include <openssl/err.h>
diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c
index cc7c6af..0ba1467 100644
--- a/ssl/s3_srvr.c
+++ b/ssl/s3_srvr.c
@@ -157,6 +157,7 @@
 #include <openssl/dh.h>
 #include <openssl/ec.h>
 #include <openssl/ecdsa.h>
+#include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 #include <openssl/md5.h>
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index cb3a039..14c5e31 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -112,7 +112,9 @@
  * ECC cipher suite support in OpenSSL originally developed by
  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */
 
+#include <errno.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <openssl/bio.h>
 #include <openssl/bn.h>
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
index 4df8a7b..7e5461c 100644
--- a/ssl/ssl_ciph.c
+++ b/ssl/ssl_ciph.c
@@ -138,10 +138,11 @@
  * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
  * OTHERWISE. */
 
-#include <stdio.h>
 #include <assert.h>
+#include <stdio.h>
+#include <string.h>
 
-#include <openssl/engine.h>
+#include <openssl/err.h>
 #include <openssl/md5.h>
 #include <openssl/mem.h>
 #include <openssl/obj.h>
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 8d28f38..4914924 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -138,12 +138,13 @@
  * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
  * OTHERWISE. */
 
-#include <stdio.h>
 #include <assert.h>
+#include <stdio.h>
+#include <string.h>
 
 #include <openssl/bytestring.h>
 #include <openssl/dh.h>
-#include <openssl/engine.h>
+#include <openssl/err.h>
 #include <openssl/lhash.h>
 #include <openssl/mem.h>
 #include <openssl/obj.h>
diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c
index 0129f29..2f8ca7f 100644
--- a/ssl/ssl_sess.c
+++ b/ssl/ssl_sess.c
@@ -134,8 +134,8 @@
  * OTHERWISE. */
 
 #include <stdio.h>
+#include <string.h>
 
-#include <openssl/engine.h>
 #include <openssl/err.h>
 #include <openssl/lhash.h>
 #include <openssl/mem.h>
diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
index 903020e..f3154cd 100644
--- a/ssl/t1_enc.c
+++ b/ssl/t1_enc.c
@@ -133,8 +133,9 @@
  * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
  * OTHERWISE. */
 
-#include <stdio.h>
 #include <assert.h>
+#include <stdio.h>
+#include <string.h>
 
 #include <openssl/err.h>
 #include <openssl/evp.h>
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index 8445f0e..5892c2c 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -106,11 +106,13 @@
  * (eay@cryptsoft.com).  This product includes software written by Tim
  * Hudson (tjh@cryptsoft.com). */
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
+#include <string.h>
 
 #include <openssl/bytestring.h>
+#include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 #include <openssl/mem.h>
diff --git a/ssl/t1_reneg.c b/ssl/t1_reneg.c
index 05a7836..d0009c1 100644
--- a/ssl/t1_reneg.c
+++ b/ssl/t1_reneg.c
@@ -106,11 +106,11 @@
  * (eay@cryptsoft.com).  This product includes software written by Tim
  * Hudson (tjh@cryptsoft.com). */
 
-#include <stdio.h>
 #include <assert.h>
+#include <stdio.h>
+#include <string.h>
 
 #include <openssl/bytestring.h>
-#include <openssl/obj.h>
 #include <openssl/err.h>
 
 #include "internal.h"
diff --git a/ssl/test/packeted_bio.cc b/ssl/test/packeted_bio.cc
index 3a1c49a..a2d1a5d 100644
--- a/ssl/test/packeted_bio.cc
+++ b/ssl/test/packeted_bio.cc
@@ -15,7 +15,6 @@
 #include "packeted_bio.h"
 
 #include <assert.h>
-#include <errno.h>
 #include <limits.h>
 #include <stdio.h>
 #include <string.h>