Lines Matching refs:ctx
20 static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation,
31 if (ctx == NULL) {
36 evp_pkey_ctx_free_old_ops(ctx);
37 ctx->operation = operation;
41 if (evp_pkey_ctx_is_legacy(ctx))
44 if (ctx->pkey == NULL) {
51 * Try to derive the supported asym cipher from |ctx->keymgmt|.
53 if (!ossl_assert(ctx->pkey->keymgmt == NULL
54 || ctx->pkey->keymgmt == ctx->keymgmt)) {
60 = evp_keymgmt_util_query_operation_name(ctx->keymgmt,
74 * as |ctx->keymgmt|
77 * asym cipher, and try to export |ctx->pkey| to that keymgmt (when
78 * this keymgmt happens to be the same as |ctx->keymgmt|, the export
98 cipher = EVP_ASYM_CIPHER_fetch(ctx->libctx, supported_ciph,
99 ctx->propquery);
104 tmp_prov = EVP_KEYMGMT_get0_provider(ctx->keymgmt);
107 supported_ciph, ctx->propquery);
118 * |ctx->pkey|, but from the provider of the asym cipher method, using
120 * With the keymgmt we found (if we did), we try to export |ctx->pkey|
122 * export it if |tmp_keymgmt| is different from |ctx->pkey|'s keymgmt)
126 EVP_KEYMGMT_get0_name(ctx->keymgmt),
127 ctx->propquery);
129 provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
130 &tmp_keymgmt, ctx->propquery);
144 ctx->op.ciph.cipher = cipher;
145 ctx->op.ciph.algctx = cipher->newctx(ossl_provider_ctx(cipher->prov));
146 if (ctx->op.ciph.algctx == NULL) {
159 ret = cipher->encrypt_init(ctx->op.ciph.algctx, provkey, params);
167 ret = cipher->decrypt_init(ctx->op.ciph.algctx, provkey, params);
188 if (ctx->pmeth == NULL || ctx->pmeth->encrypt == NULL) {
192 switch(ctx->operation) {
194 if (ctx->pmeth->encrypt_init == NULL)
196 ret = ctx->pmeth->encrypt_init(ctx);
199 if (ctx->pmeth->decrypt_init == NULL)
201 ret = ctx->pmeth->decrypt_init(ctx);
210 evp_pkey_ctx_free_old_ops(ctx);
211 ctx->operation = EVP_PKEY_OP_UNDEFINED;
217 int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx)
219 return evp_pkey_asym_cipher_init(ctx, EVP_PKEY_OP_ENCRYPT, NULL);
222 int EVP_PKEY_encrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
224 return evp_pkey_asym_cipher_init(ctx, EVP_PKEY_OP_ENCRYPT, params);
227 int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
233 if (ctx == NULL) {
238 if (ctx->operation != EVP_PKEY_OP_ENCRYPT) {
243 if (ctx->op.ciph.algctx == NULL)
246 ret = ctx->op.ciph.cipher->encrypt(ctx->op.ciph.algctx, out, outlen,
251 if (ctx->pmeth == NULL || ctx->pmeth->encrypt == NULL) {
255 M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_ENCRYPT)
256 return ctx->pmeth->encrypt(ctx, out, outlen, in, inlen);
259 int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx)
261 return evp_pkey_asym_cipher_init(ctx, EVP_PKEY_OP_DECRYPT, NULL);
264 int EVP_PKEY_decrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
266 return evp_pkey_asym_cipher_init(ctx, EVP_PKEY_OP_DECRYPT, params);
269 int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
275 if (ctx == NULL) {
280 if (ctx->operation != EVP_PKEY_OP_DECRYPT) {
285 if (ctx->op.ciph.algctx == NULL)
288 ret = ctx->op.ciph.cipher->decrypt(ctx->op.ciph.algctx, out, outlen,
293 if (ctx->pmeth == NULL || ctx->pmeth->decrypt == NULL) {
297 M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_DECRYPT)
298 return ctx->pmeth->decrypt(ctx, out, outlen, in, inlen);
469 EVP_ASYM_CIPHER *EVP_ASYM_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
472 return evp_generic_fetch(ctx, OSSL_OP_ASYM_CIPHER, algorithm, properties,