Move EVP_R_COMMAND_NOT_SUPPORTED into individual EVP_PKEY ctrl hooks.
This removes another place where we're internally sensitive to the
success/failure conditions.
Change-Id: I18fecf6457e841ba0afb718397b9b5fd3bbdfe4c
Reviewed-on: https://boringssl-review.googlesource.com/3872
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/err/evp.errordata b/crypto/err/evp.errordata
index b85ee39..8cb7b1e 100644
--- a/crypto/err/evp.errordata
+++ b/crypto/err/evp.errordata
@@ -45,6 +45,7 @@
EVP,function,144,pkey_ec_keygen
EVP,function,145,pkey_ec_paramgen
EVP,function,146,pkey_ec_sign
+EVP,function,158,pkey_hmac_ctrl
EVP,function,147,pkey_rsa_ctrl
EVP,function,148,pkey_rsa_decrypt
EVP,function,149,pkey_rsa_encrypt
diff --git a/crypto/evp/evp_ctx.c b/crypto/evp/evp_ctx.c
index a383725..daf1a28 100644
--- a/crypto/evp/evp_ctx.c
+++ b/crypto/evp/evp_ctx.c
@@ -212,7 +212,6 @@
int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd,
int p1, void *p2) {
- int ret;
if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl) {
OPENSSL_PUT_ERROR(EVP, EVP_PKEY_CTX_ctrl, EVP_R_COMMAND_NOT_SUPPORTED);
return -2;
@@ -231,13 +230,7 @@
return -1;
}
- ret = ctx->pmeth->ctrl(ctx, cmd, p1, p2);
-
- if (ret == -2) {
- OPENSSL_PUT_ERROR(EVP, EVP_PKEY_CTX_ctrl, EVP_R_COMMAND_NOT_SUPPORTED);
- }
-
- return ret;
+ return ctx->pmeth->ctrl(ctx, cmd, p1, p2);
}
int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx) {
diff --git a/crypto/evp/p_ec.c b/crypto/evp/p_ec.c
index f45989a..0fe805d 100644
--- a/crypto/evp/p_ec.c
+++ b/crypto/evp/p_ec.c
@@ -241,6 +241,7 @@
return 1;
default:
+ OPENSSL_PUT_ERROR(EVP, pkey_ec_ctrl, EVP_R_COMMAND_NOT_SUPPORTED);
return -2;
}
}
diff --git a/crypto/evp/p_hmac.c b/crypto/evp/p_hmac.c
index 6d9a909..89859b4 100644
--- a/crypto/evp/p_hmac.c
+++ b/crypto/evp/p_hmac.c
@@ -204,6 +204,7 @@
break;
default:
+ OPENSSL_PUT_ERROR(EVP, pkey_hmac_ctrl, EVP_R_COMMAND_NOT_SUPPORTED);
return -2;
}
return 1;
diff --git a/crypto/evp/p_rsa.c b/crypto/evp/p_rsa.c
index ff294ae..615f6f8 100644
--- a/crypto/evp/p_rsa.c
+++ b/crypto/evp/p_rsa.c
@@ -487,6 +487,7 @@
return 1;
default:
+ OPENSSL_PUT_ERROR(EVP, pkey_rsa_ctrl, EVP_R_COMMAND_NOT_SUPPORTED);
return -2;
}
}
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index 49cf03b..26e4f2f 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -823,6 +823,7 @@
#define EVP_F_rsa_priv_encode 155
#define EVP_F_rsa_pss_to_ctx 156
#define EVP_F_rsa_pub_decode 157
+#define EVP_F_pkey_hmac_ctrl 158
#define EVP_R_BUFFER_TOO_SMALL 100
#define EVP_R_COMMAND_NOT_SUPPORTED 101
#define EVP_R_CONTEXT_NOT_INITIALISED 102