Lines Matching refs:ctx

66 #define M_check_autoarg(ctx, arg, arglen, err) \
67 if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) \
69 size_t pksize = (size_t)EVP_PKEY_size(ctx->pkey); \
82 int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx)
85 if (!ctx || !ctx->pmeth || !ctx->pmeth->sign)
91 ctx->operation = EVP_PKEY_OP_SIGN;
92 if (!ctx->pmeth->sign_init)
94 ret = ctx->pmeth->sign_init(ctx);
96 ctx->operation = EVP_PKEY_OP_UNDEFINED;
100 int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
104 if (!ctx || !ctx->pmeth || !ctx->pmeth->sign)
110 if (ctx->operation != EVP_PKEY_OP_SIGN)
115 M_check_autoarg(ctx, sig, siglen, EVP_F_EVP_PKEY_SIGN)
116 return ctx->pmeth->sign(ctx, sig, siglen, tbs, tbslen);
119 int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx)
122 if (!ctx || !ctx->pmeth || !ctx->pmeth->verify)
128 ctx->operation = EVP_PKEY_OP_VERIFY;
129 if (!ctx->pmeth->verify_init)
131 ret = ctx->pmeth->verify_init(ctx);
133 ctx->operation = EVP_PKEY_OP_UNDEFINED;
137 int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
141 if (!ctx || !ctx->pmeth || !ctx->pmeth->verify)
147 if (ctx->operation != EVP_PKEY_OP_VERIFY)
152 return ctx->pmeth->verify(ctx, sig, siglen, tbs, tbslen);
155 int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx)
158 if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover)
164 ctx->operation = EVP_PKEY_OP_VERIFYRECOVER;
165 if (!ctx->pmeth->verify_recover_init)
167 ret = ctx->pmeth->verify_recover_init(ctx);
169 ctx->operation = EVP_PKEY_OP_UNDEFINED;
173 int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
177 if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover)
183 if (ctx->operation != EVP_PKEY_OP_VERIFYRECOVER)
188 M_check_autoarg(ctx, rout, routlen, EVP_F_EVP_PKEY_VERIFY_RECOVER)
189 return ctx->pmeth->verify_recover(ctx, rout, routlen, sig, siglen);
192 int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx)
195 if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt)
201 ctx->operation = EVP_PKEY_OP_ENCRYPT;
202 if (!ctx->pmeth->encrypt_init)
204 ret = ctx->pmeth->encrypt_init(ctx);
206 ctx->operation = EVP_PKEY_OP_UNDEFINED;
210 int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
214 if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt)
220 if (ctx->operation != EVP_PKEY_OP_ENCRYPT)
225 M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_ENCRYPT)
226 return ctx->pmeth->encrypt(ctx, out, outlen, in, inlen);
229 int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx)
232 if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt)
238 ctx->operation = EVP_PKEY_OP_DECRYPT;
239 if (!ctx->pmeth->decrypt_init)
241 ret = ctx->pmeth->decrypt_init(ctx);
243 ctx->operation = EVP_PKEY_OP_UNDEFINED;
247 int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
251 if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt)
257 if (ctx->operation != EVP_PKEY_OP_DECRYPT)
262 M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_DECRYPT)
263 return ctx->pmeth->decrypt(ctx, out, outlen, in, inlen);
267 int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
270 if (!ctx || !ctx->pmeth || !ctx->pmeth->derive)
276 ctx->operation = EVP_PKEY_OP_DERIVE;
277 if (!ctx->pmeth->derive_init)
279 ret = ctx->pmeth->derive_init(ctx);
281 ctx->operation = EVP_PKEY_OP_UNDEFINED;
285 int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer)
288 if (!ctx || !ctx->pmeth || !(ctx->pmeth->derive||ctx->pmeth->encrypt||ctx->pmeth->decrypt) || !ctx->pmeth->ctrl)
294 if (ctx->operation != EVP_PKEY_OP_DERIVE && ctx->operation != EVP_PKEY_OP_ENCRYPT && ctx->operation != EVP_PKEY_OP_DECRYPT)
301 ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 0, peer);
309 if (!ctx->pkey)
315 if (ctx->pkey->type != peer->type)
328 !EVP_PKEY_cmp_parameters(ctx->pkey, peer))
335 if (ctx->peerkey)
336 EVP_PKEY_free(ctx->peerkey);
337 ctx->peerkey = peer;
339 ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 1, peer);
343 ctx->peerkey = NULL;
352 int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen)
354 if (!ctx || !ctx->pmeth || !ctx->pmeth->derive)
360 if (ctx->operation != EVP_PKEY_OP_DERIVE)
365 M_check_autoarg(ctx, key, pkeylen, EVP_F_EVP_PKEY_DERIVE)
366 return ctx->pmeth->derive(ctx, key, pkeylen);