Lines Matching refs:kem
24 EVP_KEM *kem = NULL; in evp_kem_init() local
89 EVP_KEM_free(kem); in evp_kem_init()
94 kem = EVP_KEM_fetch(ctx->libctx, supported_kem, ctx->propquery); in evp_kem_init()
95 if (kem != NULL) in evp_kem_init()
96 tmp_prov = EVP_KEM_get0_provider(kem); in evp_kem_init()
100 kem = evp_kem_fetch_from_prov((OSSL_PROVIDER *)tmp_prov, in evp_kem_init()
103 if (kem == NULL) { in evp_kem_init()
110 if (kem == NULL) in evp_kem_init()
134 EVP_KEM_free(kem); in evp_kem_init()
145 EVP_KEM_free(kem); in evp_kem_init()
150 ctx->op.encap.kem = kem; in evp_kem_init()
151 ctx->op.encap.algctx = kem->newctx(ossl_provider_ctx(kem->prov)); in evp_kem_init()
160 if (provauthkey != NULL && kem->auth_encapsulate_init != NULL) { in evp_kem_init()
161 ret = kem->auth_encapsulate_init(ctx->op.encap.algctx, provkey, in evp_kem_init()
163 } else if (provauthkey == NULL && kem->encapsulate_init != NULL) { in evp_kem_init()
164 ret = kem->encapsulate_init(ctx->op.encap.algctx, provkey, params); in evp_kem_init()
172 if (provauthkey != NULL && kem->auth_decapsulate_init != NULL) { in evp_kem_init()
173 ret = kem->auth_decapsulate_init(ctx->op.encap.algctx, provkey, in evp_kem_init()
175 } else if (provauthkey == NULL && kem->encapsulate_init != NULL) { in evp_kem_init()
176 ret = kem->decapsulate_init(ctx->op.encap.algctx, provkey, params); in evp_kem_init()
235 return ctx->op.encap.kem->encapsulate(ctx->op.encap.algctx, in EVP_PKEY_encapsulate()
270 return ctx->op.encap.kem->decapsulate(ctx->op.encap.algctx, in EVP_PKEY_decapsulate()
276 EVP_KEM *kem = OPENSSL_zalloc(sizeof(EVP_KEM)); in evp_kem_new() local
278 if (kem == NULL) in evp_kem_new()
281 if (!CRYPTO_NEW_REF(&kem->refcnt, 1)) { in evp_kem_new()
282 OPENSSL_free(kem); in evp_kem_new()
285 kem->prov = prov; in evp_kem_new()
288 return kem; in evp_kem_new()
295 EVP_KEM *kem = NULL; in evp_kem_from_algorithm() local
299 if ((kem = evp_kem_new(prov)) == NULL) { in evp_kem_from_algorithm()
304 kem->name_id = name_id; in evp_kem_from_algorithm()
305 if ((kem->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL) in evp_kem_from_algorithm()
307 kem->description = algodef->algorithm_description; in evp_kem_from_algorithm()
312 if (kem->newctx != NULL) in evp_kem_from_algorithm()
314 kem->newctx = OSSL_FUNC_kem_newctx(fns); in evp_kem_from_algorithm()
318 if (kem->encapsulate_init != NULL) in evp_kem_from_algorithm()
320 kem->encapsulate_init = OSSL_FUNC_kem_encapsulate_init(fns); in evp_kem_from_algorithm()
324 if (kem->auth_encapsulate_init != NULL) in evp_kem_from_algorithm()
326 kem->auth_encapsulate_init = OSSL_FUNC_kem_auth_encapsulate_init(fns); in evp_kem_from_algorithm()
330 if (kem->encapsulate != NULL) in evp_kem_from_algorithm()
332 kem->encapsulate = OSSL_FUNC_kem_encapsulate(fns); in evp_kem_from_algorithm()
336 if (kem->decapsulate_init != NULL) in evp_kem_from_algorithm()
338 kem->decapsulate_init = OSSL_FUNC_kem_decapsulate_init(fns); in evp_kem_from_algorithm()
342 if (kem->auth_decapsulate_init != NULL) in evp_kem_from_algorithm()
344 kem->auth_decapsulate_init = OSSL_FUNC_kem_auth_decapsulate_init(fns); in evp_kem_from_algorithm()
348 if (kem->decapsulate != NULL) in evp_kem_from_algorithm()
350 kem->decapsulate = OSSL_FUNC_kem_decapsulate(fns); in evp_kem_from_algorithm()
354 if (kem->freectx != NULL) in evp_kem_from_algorithm()
356 kem->freectx = OSSL_FUNC_kem_freectx(fns); in evp_kem_from_algorithm()
360 if (kem->dupctx != NULL) in evp_kem_from_algorithm()
362 kem->dupctx = OSSL_FUNC_kem_dupctx(fns); in evp_kem_from_algorithm()
365 if (kem->get_ctx_params != NULL) in evp_kem_from_algorithm()
367 kem->get_ctx_params in evp_kem_from_algorithm()
372 if (kem->gettable_ctx_params != NULL) in evp_kem_from_algorithm()
374 kem->gettable_ctx_params in evp_kem_from_algorithm()
379 if (kem->set_ctx_params != NULL) in evp_kem_from_algorithm()
381 kem->set_ctx_params in evp_kem_from_algorithm()
386 if (kem->settable_ctx_params != NULL) in evp_kem_from_algorithm()
388 kem->settable_ctx_params in evp_kem_from_algorithm()
415 return kem; in evp_kem_from_algorithm()
417 EVP_KEM_free(kem); in evp_kem_from_algorithm()
421 void EVP_KEM_free(EVP_KEM *kem) in EVP_KEM_free() argument
425 if (kem == NULL) in EVP_KEM_free()
428 CRYPTO_DOWN_REF(&kem->refcnt, &i); in EVP_KEM_free()
431 OPENSSL_free(kem->type_name); in EVP_KEM_free()
432 ossl_provider_free(kem->prov); in EVP_KEM_free()
433 CRYPTO_FREE_REF(&kem->refcnt); in EVP_KEM_free()
434 OPENSSL_free(kem); in EVP_KEM_free()
437 int EVP_KEM_up_ref(EVP_KEM *kem) in EVP_KEM_up_ref() argument
441 CRYPTO_UP_REF(&kem->refcnt, &ref); in EVP_KEM_up_ref()
445 OSSL_PROVIDER *EVP_KEM_get0_provider(const EVP_KEM *kem) in EVP_KEM_get0_provider() argument
447 return kem->prov; in EVP_KEM_get0_provider()
468 int EVP_KEM_is_a(const EVP_KEM *kem, const char *name) in EVP_KEM_is_a() argument
470 return kem != NULL && evp_is_a(kem->prov, kem->name_id, NULL, name); in EVP_KEM_is_a()
473 int evp_kem_get_number(const EVP_KEM *kem) in evp_kem_get_number() argument
475 return kem->name_id; in evp_kem_get_number()
478 const char *EVP_KEM_get0_name(const EVP_KEM *kem) in EVP_KEM_get0_name() argument
480 return kem->type_name; in EVP_KEM_get0_name()
483 const char *EVP_KEM_get0_description(const EVP_KEM *kem) in EVP_KEM_get0_description() argument
485 return kem->description; in EVP_KEM_get0_description()
489 void (*fn)(EVP_KEM *kem, void *arg), in EVP_KEM_do_all_provided() argument
498 int EVP_KEM_names_do_all(const EVP_KEM *kem, in EVP_KEM_names_do_all() argument
502 if (kem->prov != NULL) in EVP_KEM_names_do_all()
503 return evp_names_do_all(kem->prov, kem->name_id, fn, data); in EVP_KEM_names_do_all()
508 const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem) in EVP_KEM_gettable_ctx_params() argument
512 if (kem == NULL || kem->gettable_ctx_params == NULL) in EVP_KEM_gettable_ctx_params()
515 provctx = ossl_provider_ctx(EVP_KEM_get0_provider(kem)); in EVP_KEM_gettable_ctx_params()
516 return kem->gettable_ctx_params(NULL, provctx); in EVP_KEM_gettable_ctx_params()
519 const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem) in EVP_KEM_settable_ctx_params() argument
523 if (kem == NULL || kem->settable_ctx_params == NULL) in EVP_KEM_settable_ctx_params()
526 provctx = ossl_provider_ctx(EVP_KEM_get0_provider(kem)); in EVP_KEM_settable_ctx_params()
527 return kem->settable_ctx_params(NULL, provctx); in EVP_KEM_settable_ctx_params()