diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2019-08-24 18:56:34 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2019-08-24 18:56:34 +1000 |
commit | 95214b434fe969e9508b6b9f38d0ea931d7e6415 (patch) | |
tree | 96a0684ba1c18233a9bf12f03a8177852c343523 /apps/apps.c | |
parent | e1f8584d47a499301fba781086af6885fcf21fec (diff) |
Add app for fips installation
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9634)
Diffstat (limited to 'apps/apps.c')
-rw-r--r-- | apps/apps.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/apps.c b/apps/apps.c index 274a387a3d..5038817750 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -2566,3 +2566,53 @@ int opt_printf_stderr(const char *fmt, ...) va_end(ap); return ret; } + +OSSL_PARAM *app_params_new_from_opts(STACK_OF(OPENSSL_STRING) *opts, + const OSSL_PARAM *paramdefs) +{ + OSSL_PARAM *params = NULL; + size_t sz = (size_t)sk_OPENSSL_STRING_num(opts); + size_t params_n; + char *opt = "", *stmp, *vtmp = NULL; + + if (opts == NULL) + return NULL; + + params = OPENSSL_zalloc(sizeof(OSSL_PARAM) * (sz + 1)); + if (params == NULL) + return NULL; + + for (params_n = 0; params_n < sz; params_n++) { + opt = sk_OPENSSL_STRING_value(opts, (int)params_n); + if ((stmp = OPENSSL_strdup(opt)) == NULL + || (vtmp = strchr(stmp, ':')) == NULL) + goto err; + /* Replace ':' with 0 to terminate the string pointed to by stmp */ + *vtmp = 0; + /* Skip over the separator so that vmtp points to the value */ + vtmp++; + if (!OSSL_PARAM_allocate_from_text(¶ms[params_n], paramdefs, + stmp, vtmp, strlen(vtmp))) + goto err; + OPENSSL_free(stmp); + } + params[params_n] = OSSL_PARAM_construct_end(); + return params; +err: + OPENSSL_free(stmp); + BIO_printf(bio_err, "Parameter error '%s'\n", opt); + ERR_print_errors(bio_err); + app_params_free(params); + return NULL; +} + +void app_params_free(OSSL_PARAM *params) +{ + int i; + + if (params != NULL) { + for (i = 0; params[i].key != NULL; ++i) + OPENSSL_free(params[i].data); + OPENSSL_free(params); + } +} |