Remove EVP_PKEY_CTRL_DIGESTINIT -2 special-case in md_begin_digest.

All EVP_PKEY types return 1 on that. (It can go away entirely when
EVP_PKEY_HMAC is gone.) This removes a place internally where we're sensitive
to the failure code.

Change-Id: Ic6cda2da9337ba7ef1c66a18e40c5dcc44fcf840
Reviewed-on: https://boringssl-review.googlesource.com/3871
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/evp/digestsign.c b/crypto/evp/digestsign.c
index c86b805..508fda8 100644
--- a/crypto/evp/digestsign.c
+++ b/crypto/evp/digestsign.c
@@ -65,9 +65,8 @@
 /* md_begin_digset is a callback from the |EVP_MD_CTX| code that is called when
  * a new digest is begun. */
 static int md_begin_digest(EVP_MD_CTX *ctx) {
-  int r = EVP_PKEY_CTX_ctrl(ctx->pctx, -1, EVP_PKEY_OP_TYPE_SIG,
-                            EVP_PKEY_CTRL_DIGESTINIT, 0, ctx);
-  return r > 0 || r == -2;
+  return EVP_PKEY_CTX_ctrl(ctx->pctx, -1, EVP_PKEY_OP_TYPE_SIG,
+                           EVP_PKEY_CTRL_DIGESTINIT, 0, ctx) == 1;
 }
 
 static const struct evp_md_pctx_ops md_pctx_ops = {
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index 396624a..49cf03b 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -590,7 +590,10 @@
 
 /* EVP_PKEY_CTRL_DIGESTINIT is an internal value. It's called by
  * EVP_DigestInit_ex to signal the |EVP_PKEY| that a digest operation is
- * starting. */
+ * starting.
+ *
+ * TODO(davidben): This is only needed to support the deprecated HMAC |EVP_PKEY|
+ * types. */
 #define EVP_PKEY_CTRL_DIGESTINIT 3
 
 /* EVP_PKEY_CTRL_PEER_KEY is called with different values of |p1|: