Remove string.h from base.h.

Including string.h in base.h causes any file that includes a BoringSSL
header to include string.h. Generally this wouldn't be a problem,
although string.h might slow down the compile if it wasn't otherwise
needed. However, it also causes problems for ipsec-tools in Android
because OpenSSL didn't have this behaviour.

This change removes string.h from base.h and, instead, adds it to each
.c file that requires it.

Change-Id: I5968e50b0e230fd3adf9b72dd2836e6f52d6fb37
Reviewed-on: https://boringssl-review.googlesource.com/3200
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/x509/a_strex.c b/crypto/x509/a_strex.c
index 0d5dd9f..b194d18 100644
--- a/crypto/x509/a_strex.c
+++ b/crypto/x509/a_strex.c
@@ -56,6 +56,8 @@
 
 #include <openssl/x509.h>
 
+#include <string.h>
+
 #include <openssl/asn1.h>
 #include <openssl/mem.h>
 #include <openssl/obj.h>
diff --git a/crypto/x509/asn1_gen.c b/crypto/x509/asn1_gen.c
index 9246b93..750701e 100644
--- a/crypto/x509/asn1_gen.c
+++ b/crypto/x509/asn1_gen.c
@@ -56,6 +56,8 @@
 
 #include <openssl/x509.h>
 
+#include <string.h>
+
 #include <openssl/asn1.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index 659bc44..5a77b81 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -55,8 +55,9 @@
  * copied and put under another distribution licence
  * [including the GNU Public Licence.] */
 
-#include <sys/types.h>
+#include <string.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 
 #include <openssl/buf.h>
 #include <openssl/err.h>
diff --git a/crypto/x509/pkcs7_test.c b/crypto/x509/pkcs7_test.c
index 2e20c40..4283022 100644
--- a/crypto/x509/pkcs7_test.c
+++ b/crypto/x509/pkcs7_test.c
@@ -14,6 +14,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <openssl/bytestring.h>
 #include <openssl/crypto.h>
diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c
index 0974ef6..712e36b 100644
--- a/crypto/x509/x509_cmp.c
+++ b/crypto/x509/x509_cmp.c
@@ -55,6 +55,8 @@
  * copied and put under another distribution licence
  * [including the GNU Public Licence.] */
 
+#include <string.h>
+
 #include <openssl/asn1.h>
 #include <openssl/buf.h>
 #include <openssl/digest.h>
diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c
index 05d1598..090d341 100644
--- a/crypto/x509/x509_lu.c
+++ b/crypto/x509/x509_lu.c
@@ -55,6 +55,8 @@
  * copied and put under another distribution licence
  * [including the GNU Public Licence.] */
 
+#include <string.h>
+
 #include <openssl/err.h>
 #include <openssl/lhash.h>
 #include <openssl/mem.h>
diff --git a/crypto/x509/x509_obj.c b/crypto/x509/x509_obj.c
index 5f539ab..914e0de 100644
--- a/crypto/x509/x509_obj.c
+++ b/crypto/x509/x509_obj.c
@@ -55,6 +55,8 @@
  * copied and put under another distribution licence
  * [including the GNU Public Licence.] */
 
+#include <string.h>
+
 #include <openssl/buf.h>
 #include <openssl/err.h>
 #include <openssl/lhash.h>
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
index 99d55bc..285bcaf 100644
--- a/crypto/x509/x509_vfy.c
+++ b/crypto/x509/x509_vfy.c
@@ -54,6 +54,7 @@
  * copied and put under another distribution licence
  * [including the GNU Public Licence.] */
 
+#include <string.h>
 #include <time.h>
 
 #include <openssl/asn1.h>
diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c
index 442e070..3daaf61 100644
--- a/crypto/x509/x509_vpm.c
+++ b/crypto/x509/x509_vpm.c
@@ -52,6 +52,8 @@
  * (eay@cryptsoft.com).  This product includes software written by Tim
  * Hudson (tjh@cryptsoft.com). */
 
+#include <string.h>
+
 #include <openssl/buf.h>
 #include <openssl/lhash.h>
 #include <openssl/mem.h>
@@ -61,6 +63,7 @@
 
 #include "vpm_int.h"
 
+
 /* X509_VERIFY_PARAM functions */
 
 static void x509_verify_param_zero(X509_VERIFY_PARAM *param)
diff --git a/crypto/x509/x509name.c b/crypto/x509/x509name.c
index 4a5ea17..042d18b 100644
--- a/crypto/x509/x509name.c
+++ b/crypto/x509/x509name.c
@@ -54,6 +54,8 @@
  * copied and put under another distribution licence
  * [including the GNU Public Licence.] */
 
+#include <string.h>
+
 #include <openssl/asn1.h>
 #include <openssl/err.h>
 #include <openssl/evp.h>
diff --git a/crypto/x509/x509spki.c b/crypto/x509/x509spki.c
index 03823b7..9bab957 100644
--- a/crypto/x509/x509spki.c
+++ b/crypto/x509/x509spki.c
@@ -52,6 +52,8 @@
  * (eay@cryptsoft.com).  This product includes software written by Tim
  * Hudson (tjh@cryptsoft.com). */
 
+#include <string.h>
+
 #include <openssl/base64.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c
index 6e108f5..211f68f 100644
--- a/crypto/x509/x_name.c
+++ b/crypto/x509/x_name.c
@@ -55,6 +55,7 @@
  * [including the GNU Public Licence.] */
 
 #include <ctype.h>
+#include <string.h>
 
 #include <openssl/asn1.h>
 #include <openssl/asn1t.h>
diff --git a/crypto/x509/x_pkey.c b/crypto/x509/x_pkey.c
index 9fc9e3d..550078b 100644
--- a/crypto/x509/x_pkey.c
+++ b/crypto/x509/x_pkey.c
@@ -56,6 +56,8 @@
 
 #include <openssl/x509.h>
 
+#include <string.h>
+
 #include <openssl/asn1.h>
 #include <openssl/mem.h>
 #include <openssl/err.h>