Add EVP_PKEY_base_id.

OpenSSL has two notions of key type because it supports multiple OIDs
for the same algorithm: NID_rsa vs NID_rsaEncryption and five distinct
spelling of DSA. We do not support these, so the base ID is simply the
ID.

Bug: 280
Change-Id: I966530901405a29a0cc35a2bea67304dda336e8a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36844
Reviewed-by: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/evp/evp.c b/crypto/evp/evp.c
index 838353a..0e90b6f 100644
--- a/crypto/evp/evp.c
+++ b/crypto/evp/evp.c
@@ -429,3 +429,10 @@
 void OpenSSL_add_all_digests(void) {}
 
 void EVP_cleanup(void) {}
+
+int EVP_PKEY_base_id(const EVP_PKEY *pkey) {
+  // OpenSSL has two notions of key type because it supports multiple OIDs for
+  // the same algorithm: NID_rsa vs NID_rsaEncryption and five distinct spelling
+  // of DSA. We do not support these, so the base ID is simply the ID.
+  return EVP_PKEY_id(pkey);
+}
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index a7b4fcf..999e19d 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -924,6 +924,9 @@
 OPENSSL_EXPORT size_t EVP_PKEY_get1_tls_encodedpoint(const EVP_PKEY *pkey,
                                                      uint8_t **out_ptr);
 
+// EVP_PKEY_base_id calls |EVP_PKEY_id|.
+OPENSSL_EXPORT int EVP_PKEY_base_id(const EVP_PKEY *pkey);
+
 
 // Preprocessor compatibility section (hidden).
 //