return ok;
}
-static void *dh_gen_init_base(void *provctx, int selection, int type)
+static void *dh_gen_init_base(void *provctx, int selection,
+ const OSSL_PARAM params[], int type)
{
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
struct dh_gen_ctx *gctx = NULL;
gctx->generator = DH_GENERATOR_2;
gctx->dh_type = type;
}
+ if (!dh_gen_set_params(gctx, params)) {
+ OPENSSL_free(gctx);
+ gctx = NULL;
+ }
return gctx;
}
-static void *dh_gen_init(void *provctx, int selection)
+static void *dh_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
- return dh_gen_init_base(provctx, selection, DH_FLAG_TYPE_DH);
+ return dh_gen_init_base(provctx, selection, params, DH_FLAG_TYPE_DH);
}
-static void *dhx_gen_init(void *provctx, int selection)
+static void *dhx_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
- return dh_gen_init_base(provctx, selection, DH_FLAG_TYPE_DHX);
+ return dh_gen_init_base(provctx, selection, params, DH_FLAG_TYPE_DHX);
}
static int dh_gen_set_template(void *genctx, void *templ)
if (gctx == NULL)
return 0;
+ if (params == NULL)
+ return 1;
+
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_TYPE);
if (p != NULL) {
return ok;
}
-static void *dsa_gen_init(void *provctx, int selection)
+static void *dsa_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
struct dsa_gen_ctx *gctx = NULL;
gctx->pcounter = -1;
gctx->hindex = 0;
}
+ if (!dsa_gen_set_params(gctx, params)) {
+ OPENSSL_free(gctx);
+ gctx = NULL;
+ }
return gctx;
}
if (gctx == NULL)
return 0;
+ if (params == NULL)
+ return 1;
+
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_TYPE);
if (p != NULL) {
if (key == NULL)
return 0;
+ if (params == NULL)
+ return 1;
+
if (!ossl_ec_group_set_params((EC_GROUP *)EC_KEY_get0_group(key), params))
return 0;
EC_GROUP *gen_group;
};
-static void *ec_gen_init(void *provctx, int selection)
+static void *ec_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
struct ec_gen_ctx *gctx = NULL;
gctx->selection = selection;
gctx->ecdh_mode = 0;
}
+ if (!ec_gen_set_params(gctx, params)) {
+ OPENSSL_free(gctx);
+ gctx = NULL;
+ }
return gctx;
}
static OSSL_FUNC_keymgmt_gen_fn ed25519_gen;
static OSSL_FUNC_keymgmt_gen_fn ed448_gen;
static OSSL_FUNC_keymgmt_gen_cleanup_fn ecx_gen_cleanup;
+static OSSL_FUNC_keymgmt_gen_set_params_fn ecx_gen_set_params;
+static OSSL_FUNC_keymgmt_gen_settable_params_fn ecx_gen_settable_params;
static OSSL_FUNC_keymgmt_load_fn ecx_load;
static OSSL_FUNC_keymgmt_get_params_fn x25519_get_params;
static OSSL_FUNC_keymgmt_get_params_fn x448_get_params;
ECX_KEY *ecxkey = key;
const OSSL_PARAM *p;
+ if (params == NULL)
+ return 1;
+
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY);
if (p != NULL) {
void *buf = ecxkey->pubkey;
return ed_settable_params;
}
-static void *ecx_gen_init(void *provctx, int selection, ECX_KEY_TYPE type)
+static void *ecx_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[], ECX_KEY_TYPE type)
{
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
struct ecx_gen_ctx *gctx = NULL;
gctx->type = type;
gctx->selection = selection;
}
+ if (!ecx_gen_set_params(gctx, params)) {
+ OPENSSL_free(gctx);
+ gctx = NULL;
+ }
return gctx;
}
-static void *x25519_gen_init(void *provctx, int selection)
+static void *x25519_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
- return ecx_gen_init(provctx, selection, ECX_KEY_TYPE_X25519);
+ return ecx_gen_init(provctx, selection, params, ECX_KEY_TYPE_X25519);
}
-static void *x448_gen_init(void *provctx, int selection)
+static void *x448_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
- return ecx_gen_init(provctx, selection, ECX_KEY_TYPE_X448);
+ return ecx_gen_init(provctx, selection, params, ECX_KEY_TYPE_X448);
}
-static void *ed25519_gen_init(void *provctx, int selection)
+static void *ed25519_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
- return ecx_gen_init(provctx, selection, ECX_KEY_TYPE_ED25519);
+ return ecx_gen_init(provctx, selection, params, ECX_KEY_TYPE_ED25519);
}
-static void *ed448_gen_init(void *provctx, int selection)
+static void *ed448_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
- return ecx_gen_init(provctx, selection, ECX_KEY_TYPE_ED448);
+ return ecx_gen_init(provctx, selection, params, ECX_KEY_TYPE_ED448);
}
static int ecx_gen_set_params(void *genctx, const OSSL_PARAM params[])
static OSSL_FUNC_keymgmt_gettable_params_fn cmac_gettable_params;
static OSSL_FUNC_keymgmt_import_types_fn cmac_imexport_types;
static OSSL_FUNC_keymgmt_export_types_fn cmac_imexport_types;
+static OSSL_FUNC_keymgmt_gen_init_fn cmac_gen_init;
static OSSL_FUNC_keymgmt_gen_set_params_fn cmac_gen_set_params;
static OSSL_FUNC_keymgmt_gen_settable_params_fn cmac_gen_settable_params;
return settable_params;
}
-static void *mac_gen_init(void *provctx, int selection)
+static void *mac_gen_init_common(void *provctx, int selection)
{
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
struct mac_gen_ctx *gctx = NULL;
return gctx;
}
+static void *mac_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
+{
+ struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
+
+ if (gctx != NULL && !mac_gen_set_params(gctx, params)) {
+ OPENSSL_free(gctx);
+ gctx = NULL;
+ }
+ return gctx;
+}
+
+static void *cmac_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
+{
+ struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection);
+
+ if (gctx != NULL && !cmac_gen_set_params(gctx, params)) {
+ OPENSSL_free(gctx);
+ gctx = NULL;
+ }
+ return gctx;
+}
+
static int mac_gen_set_params(void *genctx, const OSSL_PARAM params[])
{
struct mac_gen_ctx *gctx = genctx;
{ OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))cmac_imexport_types },
{ OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))mac_export },
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))cmac_imexport_types },
- { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))mac_gen_init },
+ { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))cmac_gen_init },
{ OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))cmac_gen_set_params },
{ OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
(void (*)(void))cmac_gen_settable_params },
return gctx->cb(params, gctx->cbarg);
}
-static void *gen_init(void *provctx, int selection, int rsa_type)
+static void *gen_init(void *provctx, int selection, int rsa_type,
+ const OSSL_PARAM params[])
{
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx);
struct rsa_gen_ctx *gctx = NULL;
gctx->rsa_type = rsa_type;
}
}
+ if (!rsa_gen_set_params(gctx, params)) {
+ OPENSSL_free(gctx);
+ gctx = NULL;
+ }
return gctx;
}
-static void *rsa_gen_init(void *provctx, int selection)
+static void *rsa_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
- return gen_init(provctx, selection, RSA_FLAG_TYPE_RSA);
+ return gen_init(provctx, selection, RSA_FLAG_TYPE_RSA, params);
}
-static void *rsapss_gen_init(void *provctx, int selection)
+static void *rsapss_gen_init(void *provctx, int selection,
+ const OSSL_PARAM params[])
{
- return gen_init(provctx, selection, RSA_FLAG_TYPE_RSASSAPSS);
+ return gen_init(provctx, selection, RSA_FLAG_TYPE_RSASSAPSS, params);
}
/*
struct rsa_gen_ctx *gctx = genctx;
const OSSL_PARAM *p;
+ if (params == NULL)
+ return 1;
+
if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_BITS)) != NULL
&& !OSSL_PARAM_get_size_t(p, &gctx->nbits))
return 0;