Lines Matching refs:gctx
1003 struct ec_gen_ctx *gctx = NULL; in ec_gen_init() local
1008 if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) { in ec_gen_init()
1009 gctx->libctx = libctx; in ec_gen_init()
1010 gctx->selection = selection; in ec_gen_init()
1011 gctx->ecdh_mode = 0; in ec_gen_init()
1012 OSSL_FIPS_IND_INIT(gctx) in ec_gen_init()
1013 if (!ec_gen_set_params(gctx, params)) { in ec_gen_init()
1014 OPENSSL_free(gctx); in ec_gen_init()
1015 gctx = NULL; in ec_gen_init()
1018 return gctx; in ec_gen_init()
1026 struct ec_gen_ctx *gctx = ec_gen_init(provctx, selection, params); in sm2_gen_init() local
1028 if (gctx != NULL) { in sm2_gen_init()
1029 if (gctx->group_name != NULL) in sm2_gen_init()
1030 return gctx; in sm2_gen_init()
1031 if ((gctx->group_name = OPENSSL_strdup("sm2")) != NULL) in sm2_gen_init()
1032 return gctx; in sm2_gen_init()
1033 ec_gen_cleanup(gctx); in sm2_gen_init()
1042 struct ec_gen_ctx *gctx = genctx; in ec_gen_set_group() local
1050 EC_GROUP_free(gctx->gen_group); in ec_gen_set_group()
1051 gctx->gen_group = group; in ec_gen_set_group()
1057 struct ec_gen_ctx *gctx = genctx; in ec_gen_set_template() local
1061 if (!ossl_prov_is_running() || gctx == NULL || ec == NULL) in ec_gen_set_template()
1065 return ec_gen_set_group(gctx, ec_group); in ec_gen_set_template()
1108 struct ec_gen_ctx *gctx = genctx; in ec_gen_set_params() local
1112 if (!OSSL_FIPS_IND_SET_CTX_PARAM(gctx, OSSL_FIPS_IND_SETTABLE0, params, in ec_gen_set_params()
1116 COPY_INT_PARAM(params, OSSL_PKEY_PARAM_USE_COFACTOR_ECDH, gctx->ecdh_mode); in ec_gen_set_params()
1118 COPY_UTF8_PARAM(params, OSSL_PKEY_PARAM_GROUP_NAME, gctx->group_name); in ec_gen_set_params()
1119 COPY_UTF8_PARAM(params, OSSL_PKEY_PARAM_EC_FIELD_TYPE, gctx->field_type); in ec_gen_set_params()
1120 COPY_UTF8_PARAM(params, OSSL_PKEY_PARAM_EC_ENCODING, gctx->encoding); in ec_gen_set_params()
1121 COPY_UTF8_PARAM(params, OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT, gctx->pt_format); in ec_gen_set_params()
1122 COPY_UTF8_PARAM(params, OSSL_PKEY_PARAM_EC_GROUP_CHECK_TYPE, gctx->group_check); in ec_gen_set_params()
1124 COPY_BN_PARAM(params, OSSL_PKEY_PARAM_EC_P, gctx->p); in ec_gen_set_params()
1125 COPY_BN_PARAM(params, OSSL_PKEY_PARAM_EC_A, gctx->a); in ec_gen_set_params()
1126 COPY_BN_PARAM(params, OSSL_PKEY_PARAM_EC_B, gctx->b); in ec_gen_set_params()
1127 COPY_BN_PARAM(params, OSSL_PKEY_PARAM_EC_ORDER, gctx->order); in ec_gen_set_params()
1128 COPY_BN_PARAM(params, OSSL_PKEY_PARAM_EC_COFACTOR, gctx->cofactor); in ec_gen_set_params()
1130 COPY_OCTET_PARAM(params, OSSL_PKEY_PARAM_EC_SEED, gctx->seed, gctx->seed_len); in ec_gen_set_params()
1131 COPY_OCTET_PARAM(params, OSSL_PKEY_PARAM_EC_GENERATOR, gctx->gen, in ec_gen_set_params()
1132 gctx->gen_len); in ec_gen_set_params()
1134 COPY_OCTET_PARAM(params, OSSL_PKEY_PARAM_DHKEM_IKM, gctx->dhkem_ikm, in ec_gen_set_params()
1135 gctx->dhkem_ikmlen); in ec_gen_set_params()
1143 static int ec_gen_set_group_from_params(struct ec_gen_ctx *gctx) in ec_gen_set_group_from_params() argument
1154 if (gctx->encoding != NULL in ec_gen_set_group_from_params()
1156 gctx->encoding, 0)) in ec_gen_set_group_from_params()
1159 if (gctx->pt_format != NULL in ec_gen_set_group_from_params()
1162 gctx->pt_format, 0)) in ec_gen_set_group_from_params()
1165 if (gctx->group_name != NULL) { in ec_gen_set_group_from_params()
1167 gctx->group_name, 0)) in ec_gen_set_group_from_params()
1171 } else if (gctx->field_type != NULL) { in ec_gen_set_group_from_params()
1173 gctx->field_type, 0)) in ec_gen_set_group_from_params()
1178 if (gctx->p == NULL in ec_gen_set_group_from_params()
1179 || gctx->a == NULL in ec_gen_set_group_from_params()
1180 || gctx->b == NULL in ec_gen_set_group_from_params()
1181 || gctx->order == NULL in ec_gen_set_group_from_params()
1182 || !OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_P, gctx->p) in ec_gen_set_group_from_params()
1183 || !OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_A, gctx->a) in ec_gen_set_group_from_params()
1184 || !OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_B, gctx->b) in ec_gen_set_group_from_params()
1185 || !OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_EC_ORDER, gctx->order)) in ec_gen_set_group_from_params()
1188 if (gctx->cofactor != NULL in ec_gen_set_group_from_params()
1190 gctx->cofactor)) in ec_gen_set_group_from_params()
1193 if (gctx->seed != NULL in ec_gen_set_group_from_params()
1195 gctx->seed, gctx->seed_len)) in ec_gen_set_group_from_params()
1198 if (gctx->gen == NULL in ec_gen_set_group_from_params()
1200 gctx->gen, gctx->gen_len)) in ec_gen_set_group_from_params()
1206 group = EC_GROUP_new_from_params(params, gctx->libctx, NULL); in ec_gen_set_group_from_params()
1210 EC_GROUP_free(gctx->gen_group); in ec_gen_set_group_from_params()
1211 gctx->gen_group = group; in ec_gen_set_group_from_params()
1255 struct ec_gen_ctx *gctx = genctx; in ec_gen_get_params() local
1257 if (gctx == NULL) in ec_gen_get_params()
1260 if (!OSSL_FIPS_IND_GET_CTX_PARAM(gctx, params)) in ec_gen_get_params()
1280 struct ec_gen_ctx *gctx = genctx; in ec_gen() local
1285 || gctx == NULL in ec_gen()
1286 || (ec = EC_KEY_new_ex(gctx->libctx, NULL)) == NULL) in ec_gen()
1289 if (gctx->gen_group == NULL) { in ec_gen()
1290 if (!ec_gen_set_group_from_params(gctx)) in ec_gen()
1293 if (gctx->encoding != NULL) { in ec_gen()
1294 int flags = ossl_ec_encoding_name2id(gctx->encoding); in ec_gen()
1298 EC_GROUP_set_asn1_flag(gctx->gen_group, flags); in ec_gen()
1300 if (gctx->pt_format != NULL) { in ec_gen()
1301 int format = ossl_ec_pt_format_name2id(gctx->pt_format); in ec_gen()
1305 EC_GROUP_set_point_conversion_form(gctx->gen_group, format); in ec_gen()
1309 if (!ossl_ec_check_security_strength(gctx->gen_group, 1)) { in ec_gen()
1310 if (!OSSL_FIPS_IND_ON_UNAPPROVED(gctx, OSSL_FIPS_IND_SETTABLE0, in ec_gen()
1311 gctx->libctx, "EC KeyGen", "key size", in ec_gen()
1320 ret = ec_gen_assign_group(ec, gctx->gen_group); in ec_gen()
1323 if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) { in ec_gen()
1325 if (gctx->dhkem_ikm != NULL && gctx->dhkem_ikmlen != 0) in ec_gen()
1326 ret = ret && ossl_ec_generate_key_dhkem(ec, gctx->dhkem_ikm, in ec_gen()
1327 gctx->dhkem_ikmlen); in ec_gen()
1333 if (gctx->ecdh_mode != -1) in ec_gen()
1334 ret = ret && ossl_ec_set_ecdh_cofactor_mode(ec, gctx->ecdh_mode); in ec_gen()
1336 if (gctx->group_check != NULL) in ec_gen()
1338 gctx->group_check); in ec_gen()
1354 struct ec_gen_ctx *gctx = genctx; in sm2_gen() local
1358 if (gctx == NULL in sm2_gen()
1359 || (ec = EC_KEY_new_ex(gctx->libctx, NULL)) == NULL) in sm2_gen()
1362 if (gctx->gen_group == NULL) { in sm2_gen()
1363 if (!ec_gen_set_group_from_params(gctx)) in sm2_gen()
1366 if (gctx->encoding) { in sm2_gen()
1367 int flags = ossl_ec_encoding_name2id(gctx->encoding); in sm2_gen()
1371 EC_GROUP_set_asn1_flag(gctx->gen_group, flags); in sm2_gen()
1373 if (gctx->pt_format != NULL) { in sm2_gen()
1374 int format = ossl_ec_pt_format_name2id(gctx->pt_format); in sm2_gen()
1378 EC_GROUP_set_point_conversion_form(gctx->gen_group, format); in sm2_gen()
1383 ret = ec_gen_assign_group(ec, gctx->gen_group); in sm2_gen()
1386 if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) in sm2_gen()
1401 struct ec_gen_ctx *gctx = genctx; in ec_gen_cleanup() local
1403 if (gctx == NULL) in ec_gen_cleanup()
1406 OPENSSL_clear_free(gctx->dhkem_ikm, gctx->dhkem_ikmlen); in ec_gen_cleanup()
1407 EC_GROUP_free(gctx->gen_group); in ec_gen_cleanup()
1408 BN_free(gctx->p); in ec_gen_cleanup()
1409 BN_free(gctx->a); in ec_gen_cleanup()
1410 BN_free(gctx->b); in ec_gen_cleanup()
1411 BN_free(gctx->order); in ec_gen_cleanup()
1412 BN_free(gctx->cofactor); in ec_gen_cleanup()
1413 OPENSSL_free(gctx->group_name); in ec_gen_cleanup()
1414 OPENSSL_free(gctx->field_type); in ec_gen_cleanup()
1415 OPENSSL_free(gctx->pt_format); in ec_gen_cleanup()
1416 OPENSSL_free(gctx->encoding); in ec_gen_cleanup()
1417 OPENSSL_free(gctx->seed); in ec_gen_cleanup()
1418 OPENSSL_free(gctx->gen); in ec_gen_cleanup()
1419 OPENSSL_free(gctx); in ec_gen_cleanup()