diff options
author | Richard Levitte <levitte@openssl.org> | 2020-02-04 17:49:28 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-02-07 09:37:56 +0100 |
commit | 273a67e345567e4dc95bd962605a3e34532f2649 (patch) | |
tree | dd082d42dc40251b1f0553242f9fc214c8fbe1d6 /crypto/evp/keymgmt_meth.c | |
parent | 32b0645cf9f1e5c11ed1cb0fc1ff1dcd47541a93 (diff) |
KEYMGMT: Require both get_params and gettable_params, or none
The same go for the pairs import + import_types and export + export_types.
This required some additional changes in our KEYMGMT implementations.
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11006)
Diffstat (limited to 'crypto/evp/keymgmt_meth.c')
-rw-r--r-- | crypto/evp/keymgmt_meth.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/crypto/evp/keymgmt_meth.c b/crypto/evp/keymgmt_meth.c index bb059140d3..b2395815c8 100644 --- a/crypto/evp/keymgmt_meth.c +++ b/crypto/evp/keymgmt_meth.c @@ -38,6 +38,7 @@ static void *keymgmt_from_dispatch(int name_id, OSSL_PROVIDER *prov) { EVP_KEYMGMT *keymgmt = NULL; + int paramfncnt = 0, importfncnt = 0, exportfncnt = 0; if ((keymgmt = keymgmt_new()) == NULL) { EVP_KEYMGMT_free(keymgmt); @@ -56,13 +57,17 @@ static void *keymgmt_from_dispatch(int name_id, keymgmt->free = OSSL_get_OP_keymgmt_free(fns); break; case OSSL_FUNC_KEYMGMT_GET_PARAMS: - if (keymgmt->get_params == NULL) + if (keymgmt->get_params == NULL) { + paramfncnt++; keymgmt->get_params = OSSL_get_OP_keymgmt_get_params(fns); + } break; case OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS: - if (keymgmt->gettable_params == NULL) + if (keymgmt->gettable_params == NULL) { + paramfncnt++; keymgmt->gettable_params = OSSL_get_OP_keymgmt_gettable_params(fns); + } break; case OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME: if (keymgmt->query_operation_name == NULL) @@ -78,20 +83,28 @@ static void *keymgmt_from_dispatch(int name_id, keymgmt->validate = OSSL_get_OP_keymgmt_validate(fns); break; case OSSL_FUNC_KEYMGMT_IMPORT: - if (keymgmt->import == NULL) + if (keymgmt->import == NULL) { + importfncnt++; keymgmt->import = OSSL_get_OP_keymgmt_import(fns); + } break; case OSSL_FUNC_KEYMGMT_IMPORT_TYPES: - if (keymgmt->import_types == NULL) + if (keymgmt->import_types == NULL) { + importfncnt++; keymgmt->import_types = OSSL_get_OP_keymgmt_import_types(fns); + } break; case OSSL_FUNC_KEYMGMT_EXPORT: - if (keymgmt->export == NULL) + if (keymgmt->export == NULL) { + exportfncnt++; keymgmt->export = OSSL_get_OP_keymgmt_export(fns); + } break; case OSSL_FUNC_KEYMGMT_EXPORT_TYPES: - if (keymgmt->export_types == NULL) + if (keymgmt->export_types == NULL) { + exportfncnt++; keymgmt->export_types = OSSL_get_OP_keymgmt_export_types(fns); + } break; } } @@ -106,12 +119,9 @@ static void *keymgmt_from_dispatch(int name_id, if (keymgmt->free == NULL || keymgmt->new == NULL || keymgmt->has == NULL - || (keymgmt->gettable_params != NULL - && keymgmt->get_params == NULL) - || (keymgmt->import_types != NULL - && keymgmt->import == NULL) - || (keymgmt->export_types != NULL - && keymgmt->export == NULL)) { + || (paramfncnt != 0 && paramfncnt != 2) + || (importfncnt != 0 && importfncnt != 2) + || (exportfncnt != 0 && exportfncnt != 2)) { EVP_KEYMGMT_free(keymgmt); EVPerr(0, EVP_R_INVALID_PROVIDER_FUNCTIONS); return NULL; |