Remove some easy obj.h dependencies.

A lot of consumers of obj.h only want the NID values. Others didn't need
it at all. This also removes some OBJ_nid2sn and OBJ_nid2ln calls in EVP
error paths which isn't worth pulling a large table in for.

BUG=chromium:499653

Change-Id: Id6dff578f993012e35b740a13b8e4f9c2edc0744
Reviewed-on: https://boringssl-review.googlesource.com/7563
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/crypto/cipher/cipher.c b/crypto/cipher/cipher.c
index 4401867..341516a 100644
--- a/crypto/cipher/cipher.c
+++ b/crypto/cipher/cipher.c
@@ -61,7 +61,7 @@
 
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 
diff --git a/crypto/cipher/e_aes.c b/crypto/cipher/e_aes.c
index 1412be1..aa652eb 100644
--- a/crypto/cipher/e_aes.c
+++ b/crypto/cipher/e_aes.c
@@ -54,7 +54,7 @@
 #include <openssl/cpu.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rand.h>
 #include <openssl/sha.h>
 
diff --git a/crypto/cipher/e_des.c b/crypto/cipher/e_des.c
index b1d312c..2ba2bed 100644
--- a/crypto/cipher/e_des.c
+++ b/crypto/cipher/e_des.c
@@ -56,7 +56,7 @@
 
 #include <openssl/cipher.h>
 #include <openssl/des.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 
diff --git a/crypto/cipher/e_null.c b/crypto/cipher/e_null.c
index cfe1d1b..3d6a24c 100644
--- a/crypto/cipher/e_null.c
+++ b/crypto/cipher/e_null.c
@@ -58,7 +58,7 @@
 
 #include <string.h>
 
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 
diff --git a/crypto/cipher/e_rc2.c b/crypto/cipher/e_rc2.c
index 8ca7bba..67418d5 100644
--- a/crypto/cipher/e_rc2.c
+++ b/crypto/cipher/e_rc2.c
@@ -55,7 +55,7 @@
  * [including the GNU Public Licence.] */
 
 #include <openssl/cipher.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 
diff --git a/crypto/cipher/e_rc4.c b/crypto/cipher/e_rc4.c
index 3a2c166..e7c2cca 100644
--- a/crypto/cipher/e_rc4.c
+++ b/crypto/cipher/e_rc4.c
@@ -58,7 +58,7 @@
 #include <string.h>
 
 #include <openssl/cipher.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rc4.h>
 
 
diff --git a/crypto/cipher/tls_cbc.c b/crypto/cipher/tls_cbc.c
index c0d566d..510b4c7 100644
--- a/crypto/cipher/tls_cbc.c
+++ b/crypto/cipher/tls_cbc.c
@@ -54,7 +54,7 @@
 #include <string.h>
 
 #include <openssl/digest.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/sha.h>
 
 #include "../internal.h"
diff --git a/crypto/digest/digest.c b/crypto/digest/digest.c
index f47cd0a..dfa40bd 100644
--- a/crypto/digest/digest.c
+++ b/crypto/digest/digest.c
@@ -60,7 +60,6 @@
 #include <string.h>
 
 #include <openssl/err.h>
-#include <openssl/obj.h>
 #include <openssl/mem.h>
 
 #include "internal.h"
diff --git a/crypto/ec/ec.c b/crypto/ec/ec.c
index ec44cef..478e80e 100644
--- a/crypto/ec/ec.c
+++ b/crypto/ec/ec.c
@@ -73,7 +73,7 @@
 #include <openssl/bn.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 #include "../internal.h"
diff --git a/crypto/ec/example_mul.c b/crypto/ec/example_mul.c
index 9db97d6..a2bdd52 100644
--- a/crypto/ec/example_mul.c
+++ b/crypto/ec/example_mul.c
@@ -70,7 +70,7 @@
 #include <openssl/bn.h>
 #include <openssl/crypto.h>
 #include <openssl/ec.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 
 static int example_EC_POINT_mul(void) {
diff --git a/crypto/ec/p224-64.c b/crypto/ec/p224-64.c
index 47e8943..7bf889c 100644
--- a/crypto/ec/p224-64.c
+++ b/crypto/ec/p224-64.c
@@ -26,7 +26,6 @@
 #include <openssl/ec.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
 
 #include <string.h>
 
diff --git a/crypto/ec/p256-64.c b/crypto/ec/p256-64.c
index 3b1d791..70c0608 100644
--- a/crypto/ec/p256-64.c
+++ b/crypto/ec/p256-64.c
@@ -27,7 +27,6 @@
 #include <openssl/ec.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
 
 #include <string.h>
 
diff --git a/crypto/ecdsa/ecdsa_test.cc b/crypto/ecdsa/ecdsa_test.cc
index bef91c9..8d7827d 100644
--- a/crypto/ecdsa/ecdsa_test.cc
+++ b/crypto/ecdsa/ecdsa_test.cc
@@ -59,7 +59,7 @@
 #include <openssl/ec.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rand.h>
 
 #include "../test/scoped_types.h"
diff --git a/crypto/evp/evp.c b/crypto/evp/evp.c
index 22d262c..79993aa 100644
--- a/crypto/evp/evp.c
+++ b/crypto/evp/evp.c
@@ -63,7 +63,7 @@
 #include <openssl/ec.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rsa.h>
 #include <openssl/thread.h>
 
@@ -320,7 +320,7 @@
   ameth = evp_pkey_asn1_find(type);
   if (ameth == NULL) {
     OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM);
-    ERR_add_error_dataf("algorithm %d (%s)", type, OBJ_nid2sn(type));
+    ERR_add_error_dataf("algorithm %d", type);
     return 0;
   }
 
diff --git a/crypto/evp/evp_ctx.c b/crypto/evp/evp_ctx.c
index 491b13e..f510f6c 100644
--- a/crypto/evp/evp_ctx.c
+++ b/crypto/evp/evp_ctx.c
@@ -60,7 +60,6 @@
 
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
 
 #include "internal.h"
 
@@ -97,8 +96,7 @@
 
   if (pmeth == NULL) {
     OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM);
-    const char *name = OBJ_nid2sn(id);
-    ERR_add_error_dataf("algorithm %d (%s)", id, name);
+    ERR_add_error_dataf("algorithm %d", id);
     return NULL;
   }
 
diff --git a/crypto/evp/p_ec.c b/crypto/evp/p_ec.c
index 4952182..f92c87c 100644
--- a/crypto/evp/p_ec.c
+++ b/crypto/evp/p_ec.c
@@ -66,7 +66,7 @@
 #include <openssl/ecdsa.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 #include "../ec/internal.h"
diff --git a/crypto/evp/p_rsa.c b/crypto/evp/p_rsa.c
index 629c33a..a210657 100644
--- a/crypto/evp/p_rsa.c
+++ b/crypto/evp/p_rsa.c
@@ -64,7 +64,7 @@
 #include <openssl/digest.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rsa.h>
 
 #include "../rsa/internal.h"
diff --git a/crypto/evp/print.c b/crypto/evp/print.c
index b637c70..56521ec 100644
--- a/crypto/evp/print.c
+++ b/crypto/evp/print.c
@@ -495,8 +495,7 @@
 static int print_unsupported(BIO *out, const EVP_PKEY *pkey, int indent,
                              const char *kstr) {
   BIO_indent(out, indent, 128);
-  BIO_printf(out, "%s algorithm \"%s\" unsupported\n", kstr,
-             OBJ_nid2ln(pkey->type));
+  BIO_printf(out, "%s algorithm unsupported\n", kstr);
   return 1;
 }
 
diff --git a/crypto/pkcs8/p5_pbe.c b/crypto/pkcs8/p5_pbe.c
index 653cabf..8e56d41 100644
--- a/crypto/pkcs8/p5_pbe.c
+++ b/crypto/pkcs8/p5_pbe.c
@@ -57,6 +57,7 @@
 
 #include <openssl/asn1t.h>
 #include <openssl/err.h>
+#include <openssl/obj.h>
 #include <openssl/pkcs8.h>
 #include <openssl/rand.h>
 #include <openssl/x509.h>
diff --git a/crypto/pkcs8/p5_pbev2.c b/crypto/pkcs8/p5_pbev2.c
index fec0d86..3799b39 100644
--- a/crypto/pkcs8/p5_pbev2.c
+++ b/crypto/pkcs8/p5_pbev2.c
@@ -61,6 +61,7 @@
 #include <openssl/cipher.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
+#include <openssl/obj.h>
 #include <openssl/pkcs8.h>
 #include <openssl/rand.h>
 #include <openssl/x509.h>
diff --git a/crypto/pkcs8/pkcs8.c b/crypto/pkcs8/pkcs8.c
index 175a885..3825522 100644
--- a/crypto/pkcs8/pkcs8.c
+++ b/crypto/pkcs8/pkcs8.c
@@ -68,6 +68,7 @@
 #include <openssl/err.h>
 #include <openssl/hmac.h>
 #include <openssl/mem.h>
+#include <openssl/obj.h>
 #include <openssl/x509.h>
 
 #include "internal.h"
diff --git a/crypto/rsa/rsa.c b/crypto/rsa/rsa.c
index 9ffea1f..0b29893 100644
--- a/crypto/rsa/rsa.c
+++ b/crypto/rsa/rsa.c
@@ -64,7 +64,7 @@
 #include <openssl/err.h>
 #include <openssl/ex_data.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/thread.h>
 
 #include "internal.h"
diff --git a/crypto/rsa/rsa_test.cc b/crypto/rsa/rsa_test.cc
index 3f0dff5..62177a4 100644
--- a/crypto/rsa/rsa_test.cc
+++ b/crypto/rsa/rsa_test.cc
@@ -63,7 +63,7 @@
 #include <openssl/bytestring.h>
 #include <openssl/crypto.h>
 #include <openssl/err.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "../test/scoped_types.h"
 
diff --git a/crypto/test/scoped_types.h b/crypto/test/scoped_types.h
index eef30e7..5c49a7e 100644
--- a/crypto/test/scoped_types.h
+++ b/crypto/test/scoped_types.h
@@ -24,6 +24,7 @@
 #include <openssl/asn1.h>
 #include <openssl/bio.h>
 #include <openssl/bn.h>
+#include <openssl/bytestring.h>
 #include <openssl/cmac.h>
 #include <openssl/curve25519.h>
 #include <openssl/dh.h>
diff --git a/crypto/x509v3/tab_test.c b/crypto/x509v3/tab_test.c
index 7994043..1900547 100644
--- a/crypto/x509v3/tab_test.c
+++ b/crypto/x509v3/tab_test.c
@@ -66,6 +66,7 @@
 
 #include <openssl/base.h>
 #include <openssl/crypto.h>
+#include <openssl/obj.h>
 #include <openssl/x509v3.h>
 
 #if !defined(BORINGSSL_SHARED_LIBRARY)
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index b52d2d4..398c741 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -69,7 +69,7 @@
 #include <openssl/base64.h>
 #include <openssl/cipher.h>
 #include <openssl/digest.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #if defined(__cplusplus)
 extern "C" {
diff --git a/include/openssl/x509.h b/include/openssl/x509.h
index 752191d..4b977b9 100644
--- a/include/openssl/x509.h
+++ b/include/openssl/x509.h
@@ -76,6 +76,7 @@
 #include <openssl/ecdsa.h>
 #include <openssl/ec.h>
 #include <openssl/evp.h>
+#include <openssl/obj.h>
 #include <openssl/rsa.h>
 #include <openssl/sha.h>
 #include <openssl/stack.h>
diff --git a/ssl/d1_both.c b/ssl/d1_both.c
index 6ba49d7..8596f32 100644
--- a/ssl/d1_both.c
+++ b/ssl/d1_both.c
@@ -121,7 +121,6 @@
 #include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
 #include <openssl/rand.h>
 #include <openssl/x509.h>
 
diff --git a/ssl/d1_clnt.c b/ssl/d1_clnt.c
index c6a2b13..b29d56c 100644
--- a/ssl/d1_clnt.c
+++ b/ssl/d1_clnt.c
@@ -124,7 +124,6 @@
 #include <openssl/err.h>
 #include <openssl/md5.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
 #include <openssl/rand.h>
 
 #include "internal.h"
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index 76498cc..4298580 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -61,7 +61,7 @@
 
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 
diff --git a/ssl/d1_srtp.c b/ssl/d1_srtp.c
index ce15ee2..e7b1607 100644
--- a/ssl/d1_srtp.c
+++ b/ssl/d1_srtp.c
@@ -120,7 +120,6 @@
 
 #include <openssl/bytestring.h>
 #include <openssl/err.h>
-#include <openssl/obj.h>
 
 #include "internal.h"
 
diff --git a/ssl/d1_srvr.c b/ssl/d1_srvr.c
index 579d5a2..fef8541 100644
--- a/ssl/d1_srvr.c
+++ b/ssl/d1_srvr.c
@@ -122,7 +122,6 @@
 #include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/md5.h>
-#include <openssl/obj.h>
 #include <openssl/rand.h>
 #include <openssl/x509.h>
 
diff --git a/ssl/s3_both.c b/ssl/s3_both.c
index c289a7c..7bb31de 100644
--- a/ssl/s3_both.c
+++ b/ssl/s3_both.c
@@ -121,7 +121,7 @@
 #include <openssl/evp.h>
 #include <openssl/mem.h>
 #include <openssl/md5.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rand.h>
 #include <openssl/sha.h>
 #include <openssl/x509.h>
diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c
index 0b9e458..8dd4abd 100644
--- a/ssl/s3_clnt.c
+++ b/ssl/s3_clnt.c
@@ -162,7 +162,6 @@
 #include <openssl/evp.h>
 #include <openssl/md5.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
 #include <openssl/rand.h>
 #include <openssl/x509.h>
 #include <openssl/x509v3.h>
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index 8bbf23d..04aa08c 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -142,7 +142,7 @@
 #include <openssl/evp.h>
 #include <openssl/mem.h>
 #include <openssl/md5.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index 620e1ca..7df046f 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -157,7 +157,7 @@
 #include <openssl/err.h>
 #include <openssl/md5.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 
diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c
index eb92edb..bc874c7 100644
--- a/ssl/s3_srvr.c
+++ b/ssl/s3_srvr.c
@@ -163,7 +163,7 @@
 #include <openssl/hmac.h>
 #include <openssl/md5.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rand.h>
 #include <openssl/sha.h>
 #include <openssl/x509.h>
diff --git a/ssl/ssl_ecdh.c b/ssl/ssl_ecdh.c
index 6abd0ba..d48c93f 100644
--- a/ssl/ssl_ecdh.c
+++ b/ssl/ssl_ecdh.c
@@ -23,7 +23,7 @@
 #include <openssl/ec.h>
 #include <openssl/err.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 
 #include "internal.h"
 
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index a1179fe..1d4ccb7 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -149,7 +149,6 @@
 #include <openssl/err.h>
 #include <openssl/lhash.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
 #include <openssl/rand.h>
 #include <openssl/x509v3.h>
 
diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
index 231bb1b..b599207 100644
--- a/ssl/t1_enc.c
+++ b/ssl/t1_enc.c
@@ -143,7 +143,7 @@
 #include <openssl/hmac.h>
 #include <openssl/md5.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rand.h>
 
 #include "internal.h"
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index 1d4565f..916ec4d 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -119,7 +119,7 @@
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 #include <openssl/mem.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rand.h>
 #include <openssl/type_check.h>
 
diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc
index 391cb67..5effa58 100644
--- a/ssl/test/bssl_shim.cc
+++ b/ssl/test/bssl_shim.cc
@@ -46,7 +46,7 @@
 #include <openssl/crypto.h>
 #include <openssl/err.h>
 #include <openssl/hmac.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rand.h>
 #include <openssl/ssl.h>
 
diff --git a/tool/speed.cc b/tool/speed.cc
index 9f426e2..63cb0e2 100644
--- a/tool/speed.cc
+++ b/tool/speed.cc
@@ -24,7 +24,7 @@
 #include <openssl/curve25519.h>
 #include <openssl/digest.h>
 #include <openssl/err.h>
-#include <openssl/obj.h>
+#include <openssl/nid.h>
 #include <openssl/rand.h>
 #include <openssl/rsa.h>