Rename EVP_PKEY_METHOD to EVP_PKEY_CTX_METHOD

EVP_PKEY_ASN1_METHOD is really EVP_PKEY_METHOD and EVP_PKEY_METHOD is
really EVP_PKEY_CTX_METHOD.

Change-Id: I9445fd12dcf99634a906726d1a42586c1dc7146e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81527
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Lily Chen <chlily@google.com>
Commit-Queue: Lily Chen <chlily@google.com>
diff --git a/crypto/evp/evp_ctx.cc b/crypto/evp/evp_ctx.cc
index bb3ee6e..9814606 100644
--- a/crypto/evp/evp_ctx.cc
+++ b/crypto/evp/evp_ctx.cc
@@ -25,23 +25,23 @@
 #include "internal.h"
 
 
-static const EVP_PKEY_METHOD *const evp_methods[] = {
+static const EVP_PKEY_CTX_METHOD *const evp_methods[] = {
     &rsa_pkey_meth,    &ec_pkey_meth,   &ed25519_pkey_meth,
     &x25519_pkey_meth, &hkdf_pkey_meth,
 };
 
-static const EVP_PKEY_METHOD *evp_pkey_meth_find(int type) {
-  for (size_t i = 0; i < sizeof(evp_methods) / sizeof(EVP_PKEY_METHOD *); i++) {
-    if (evp_methods[i]->pkey_id == type) {
-      return evp_methods[i];
+static const EVP_PKEY_CTX_METHOD *evp_pkey_meth_find(int type) {
+  for (auto method : evp_methods) {
+    if (method->pkey_id == type) {
+      return method;
     }
   }
 
-  return NULL;
+  return nullptr;
 }
 
 static EVP_PKEY_CTX *evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *e,
-                                      const EVP_PKEY_METHOD *pmeth) {
+                                      const EVP_PKEY_CTX_METHOD *pmeth) {
   bssl::UniquePtr<EVP_PKEY_CTX> ret = bssl::MakeUnique<EVP_PKEY_CTX>();
   if (!ret) {
     return nullptr;
@@ -66,7 +66,7 @@
     return NULL;
   }
 
-  const EVP_PKEY_METHOD *pkey_method = pkey->ameth->pkey_method;
+  const EVP_PKEY_CTX_METHOD *pkey_method = pkey->ameth->pkey_method;
   if (pkey_method == NULL) {
     OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM);
     ERR_add_error_dataf("algorithm %d", pkey->ameth->pkey_id);
@@ -77,7 +77,7 @@
 }
 
 EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e) {
-  const EVP_PKEY_METHOD *pkey_method = evp_pkey_meth_find(id);
+  const EVP_PKEY_CTX_METHOD *pkey_method = evp_pkey_meth_find(id);
   if (pkey_method == NULL) {
     OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM);
     ERR_add_error_dataf("algorithm %d", id);
diff --git a/crypto/evp/internal.h b/crypto/evp/internal.h
index be213ae..f82f8ab 100644
--- a/crypto/evp/internal.h
+++ b/crypto/evp/internal.h
@@ -27,7 +27,7 @@
 
 
 typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
-typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
+typedef struct evp_pkey_ctx_method_st EVP_PKEY_CTX_METHOD;
 
 struct evp_pkey_asn1_method_st {
   // pkey_id contains one of the |EVP_PKEY_*| values and corresponds to the OID
@@ -36,7 +36,7 @@
   uint8_t oid[9];
   uint8_t oid_len;
 
-  const EVP_PKEY_METHOD *pkey_method;
+  const EVP_PKEY_CTX_METHOD *pkey_method;
 
   // pub_decode decodes |params| and |key| as a SubjectPublicKeyInfo
   // and writes the result into |out|. It returns one on success and zero on
@@ -177,7 +177,7 @@
   ~evp_pkey_ctx_st();
 
   // Method associated with this operation
-  const EVP_PKEY_METHOD *pmeth = nullptr;
+  const EVP_PKEY_CTX_METHOD *pmeth = nullptr;
   // Engine that implements this method or nullptr if builtin
   ENGINE *engine = nullptr;
   // Key: may be nullptr
@@ -193,7 +193,7 @@
   void *data = nullptr;
 } /* EVP_PKEY_CTX */;
 
-struct evp_pkey_method_st {
+struct evp_pkey_ctx_method_st {
   int pkey_id;
 
   int (*init)(EVP_PKEY_CTX *ctx);
@@ -228,7 +228,7 @@
   int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
 
   int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
-} /* EVP_PKEY_METHOD */;
+} /* EVP_PKEY_CTX_METHOD */;
 
 typedef struct {
   // key is the concatenation of the private seed and public key. It is stored
@@ -254,12 +254,12 @@
 extern const EVP_PKEY_ASN1_METHOD x25519_asn1_meth;
 extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth;
 
-extern const EVP_PKEY_METHOD rsa_pkey_meth;
-extern const EVP_PKEY_METHOD ec_pkey_meth;
-extern const EVP_PKEY_METHOD ed25519_pkey_meth;
-extern const EVP_PKEY_METHOD x25519_pkey_meth;
-extern const EVP_PKEY_METHOD hkdf_pkey_meth;
-extern const EVP_PKEY_METHOD dh_pkey_meth;
+extern const EVP_PKEY_CTX_METHOD rsa_pkey_meth;
+extern const EVP_PKEY_CTX_METHOD ec_pkey_meth;
+extern const EVP_PKEY_CTX_METHOD ed25519_pkey_meth;
+extern const EVP_PKEY_CTX_METHOD x25519_pkey_meth;
+extern const EVP_PKEY_CTX_METHOD hkdf_pkey_meth;
+extern const EVP_PKEY_CTX_METHOD dh_pkey_meth;
 
 // evp_pkey_set_method behaves like |EVP_PKEY_set_type|, but takes a pointer to
 // a method table. This avoids depending on every |EVP_PKEY_ASN1_METHOD|.
diff --git a/crypto/evp/p_dh.cc b/crypto/evp/p_dh.cc
index 8b53644..3cc877b 100644
--- a/crypto/evp/p_dh.cc
+++ b/crypto/evp/p_dh.cc
@@ -129,7 +129,7 @@
   }
 }
 
-const EVP_PKEY_METHOD dh_pkey_meth = {
+const EVP_PKEY_CTX_METHOD dh_pkey_meth = {
     /*pkey_id=*/EVP_PKEY_DH,
     /*init=*/pkey_dh_init,
     /*copy=*/pkey_dh_copy,
diff --git a/crypto/evp/p_ec.cc b/crypto/evp/p_ec.cc
index 310464c..2fd93cc 100644
--- a/crypto/evp/p_ec.cc
+++ b/crypto/evp/p_ec.cc
@@ -193,7 +193,7 @@
   return 1;
 }
 
-const EVP_PKEY_METHOD ec_pkey_meth = {
+const EVP_PKEY_CTX_METHOD ec_pkey_meth = {
     EVP_PKEY_EC,
     pkey_ec_init,
     pkey_ec_copy,
diff --git a/crypto/evp/p_ed25519.cc b/crypto/evp/p_ed25519.cc
index 204133d..d045148 100644
--- a/crypto/evp/p_ed25519.cc
+++ b/crypto/evp/p_ed25519.cc
@@ -84,7 +84,7 @@
   return 1;
 }
 
-const EVP_PKEY_METHOD ed25519_pkey_meth = {
+const EVP_PKEY_CTX_METHOD ed25519_pkey_meth = {
     /*pkey_id=*/EVP_PKEY_ED25519,
     /*init=*/nullptr,
     /*copy=*/pkey_ed25519_copy,
diff --git a/crypto/evp/p_hkdf.cc b/crypto/evp/p_hkdf.cc
index 0f816bb..2c7f6d8 100644
--- a/crypto/evp/p_hkdf.cc
+++ b/crypto/evp/p_hkdf.cc
@@ -183,7 +183,7 @@
   }
 }
 
-const EVP_PKEY_METHOD hkdf_pkey_meth = {
+const EVP_PKEY_CTX_METHOD hkdf_pkey_meth = {
     /*pkey_id=*/EVP_PKEY_HKDF,
     pkey_hkdf_init,
     pkey_hkdf_copy,
diff --git a/crypto/evp/p_rsa.cc b/crypto/evp/p_rsa.cc
index f2bb22b..36e057f 100644
--- a/crypto/evp/p_rsa.cc
+++ b/crypto/evp/p_rsa.cc
@@ -460,7 +460,7 @@
 
 }  // namespace
 
-const EVP_PKEY_METHOD rsa_pkey_meth = {
+const EVP_PKEY_CTX_METHOD rsa_pkey_meth = {
     EVP_PKEY_RSA,
     pkey_rsa_init,
     pkey_rsa_copy,
diff --git a/crypto/evp/p_x25519.cc b/crypto/evp/p_x25519.cc
index 1186e99..91e3975 100644
--- a/crypto/evp/p_x25519.cc
+++ b/crypto/evp/p_x25519.cc
@@ -90,7 +90,7 @@
   }
 }
 
-const EVP_PKEY_METHOD x25519_pkey_meth = {
+const EVP_PKEY_CTX_METHOD x25519_pkey_meth = {
     /*pkey_id=*/EVP_PKEY_X25519,
     /*init=*/NULL,
     /*copy=*/pkey_x25519_copy,