-
Notifications
You must be signed in to change notification settings - Fork 32
feat: route configurable devId through key init calls #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ static const OSSL_PARAM wolfssl_param_types[] = { | |
| OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0), | ||
| OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0), | ||
| OSSL_PARAM_DEFN(OSSL_PROV_PARAM_STATUS, OSSL_PARAM_INTEGER, NULL, 0), | ||
| OSSL_PARAM_int("wolfprovider_devid", NULL), | ||
|
||
| OSSL_PARAM_END | ||
| }; | ||
|
|
||
|
|
@@ -218,6 +219,9 @@ static WOLFPROV_CTX* wolfssl_prov_ctx_new(void) | |
| WP_CHECK_FIPS_ALGO_PTR(WP_CAST_ALGO_DRBG); | ||
|
|
||
| ctx = (WOLFPROV_CTX*)OPENSSL_zalloc(sizeof(*ctx)); | ||
| if (ctx != NULL) { | ||
| ctx->devId = INVALID_DEVID; | ||
| } | ||
| if ((ctx != NULL) && (wc_InitRng(&ctx->rng) != 0)) { | ||
| OPENSSL_free(ctx); | ||
| ctx = NULL; | ||
|
|
@@ -372,6 +376,49 @@ static int wolfprov_get_params(void* provCtx, OSSL_PARAM params[]) | |
| return ok; | ||
| } | ||
|
|
||
| /* | ||
| * Get the table of parameters that can be set on wolfProv. | ||
| * | ||
| * @param [in] provCtx Unused. | ||
| * @return Table of settable parameters. | ||
| */ | ||
| static const OSSL_PARAM* wolfprov_settable_params(void* provCtx) | ||
| { | ||
| static const OSSL_PARAM settable[] = { | ||
| OSSL_PARAM_int("wolfprovider_devid", NULL), | ||
|
||
| OSSL_PARAM_END | ||
| }; | ||
| (void)provCtx; | ||
| return settable; | ||
| } | ||
|
|
||
| /* | ||
| * Set parameters on the provider context. | ||
| * | ||
| * @param [in] provCtx Provider context. | ||
| * @param [in] params Parameters to set. | ||
| * @return 1 on success. | ||
| * @return 0 on failure. | ||
| */ | ||
| static int wolfprov_set_params(void* provCtx, const OSSL_PARAM params[]) | ||
| { | ||
| int ok = 1; | ||
| const OSSL_PARAM* p; | ||
| WOLFPROV_CTX* ctx = (WOLFPROV_CTX*)provCtx; | ||
|
Comment on lines
+403
to
+407
|
||
|
|
||
| WOLFPROV_ENTER(WP_LOG_COMP_PROVIDER, "wolfprov_set_params"); | ||
|
|
||
| p = OSSL_PARAM_locate_const(params, "wolfprovider_devid"); | ||
|
||
| if (p != NULL) { | ||
| if (!OSSL_PARAM_get_int(p, &ctx->devId)) { | ||
| ok = 0; | ||
| } | ||
| } | ||
|
Comment on lines
+411
to
+416
|
||
|
|
||
| WOLFPROV_LEAVE(WP_LOG_COMP_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok); | ||
| return ok; | ||
| } | ||
|
|
||
| #ifdef HAVE_FIPS | ||
| /* Properties of wolfSSL provider: name and FIPS wolfSSL. */ | ||
| #define WOLFPROV_PROPERTIES "provider=wolfprov,fips=yes" | ||
|
|
@@ -1214,6 +1261,8 @@ static const OSSL_DISPATCH wolfprov_dispatch_table[] = { | |
| { OSSL_FUNC_PROVIDER_TEARDOWN, (DFUNC)wolfprov_teardown }, | ||
| { OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (DFUNC)wolfprov_gettable_params }, | ||
| { OSSL_FUNC_PROVIDER_GET_PARAMS, (DFUNC)wolfprov_get_params }, | ||
| { OSSL_FUNC_PROVIDER_SETTABLE_PARAMS, (DFUNC)wolfprov_settable_params }, | ||
| { OSSL_FUNC_PROVIDER_SET_PARAMS, (DFUNC)wolfprov_set_params }, | ||
| { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (DFUNC)wolfprov_query }, | ||
| { OSSL_FUNC_PROVIDER_GET_CAPABILITIES, | ||
| (DFUNC)wolfssl_prov_get_capabilities }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wolfprovider_devidis being advertised as a gettable provider parameter viawolfssl_param_types, but this PR only adds support for setting it (wolfprov_set_params). This is an API contract mismatch: either implement returning the current value inwolfprov_get_params, or remove it from the gettable table and keep it only inwolfprov_settable_params.