Lines Matching defs:ctx
21 static int update(EVP_MD_CTX *ctx, const void *data, size_t datalen)
39 static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
54 if (ctx->algctx != NULL) {
55 if (!ossl_assert(ctx->digest != NULL)) {
59 if (ctx->digest->freectx != NULL)
60 ctx->digest->freectx(ctx->algctx);
61 ctx->algctx = NULL;
64 if (ctx->pctx == NULL) {
67 ctx->pctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, props);
69 ctx->pctx = EVP_PKEY_CTX_new(pkey, e);
71 if (ctx->pctx == NULL)
74 locpctx = ctx->pctx;
102 mdname = canon_mdname(EVP_MD_get0_name(ctx->reqdigest));
129 * as |ctx->keymgmt|
132 * signature, and try to export |ctx->pkey| to that keymgmt (when
133 * this keymgmt happens to be the same as |ctx->keymgmt|, the export
217 ctx->reqdigest = type;
234 evp_md_ctx_clear_digest(ctx, 1, 0);
245 ctx->fetched_digest = EVP_MD_fetch(locpctx->libctx, mdname, props);
246 if (ctx->fetched_digest != NULL) {
247 ctx->digest = ctx->reqdigest = ctx->fetched_digest;
250 ctx->reqdigest = ctx->digest = EVP_get_digestbyname(mdname);
251 if (ctx->digest == NULL) {
304 if (ctx->pctx->pmeth == NULL) {
309 if (!(ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM)) {
324 if (ctx->pctx->pmeth->verifyctx_init) {
325 if (ctx->pctx->pmeth->verifyctx_init(ctx->pctx, ctx) <= 0)
327 ctx->pctx->operation = EVP_PKEY_OP_VERIFYCTX;
328 } else if (ctx->pctx->pmeth->digestverify != 0) {
329 ctx->pctx->operation = EVP_PKEY_OP_VERIFY;
330 ctx->update = update;
331 } else if (EVP_PKEY_verify_init(ctx->pctx) <= 0) {
335 if (ctx->pctx->pmeth->signctx_init) {
336 if (ctx->pctx->pmeth->signctx_init(ctx->pctx, ctx) <= 0)
338 ctx->pctx->operation = EVP_PKEY_OP_SIGNCTX;
339 } else if (ctx->pctx->pmeth->digestsign != 0) {
340 ctx->pctx->operation = EVP_PKEY_OP_SIGN;
341 ctx->update = update;
342 } else if (EVP_PKEY_sign_init(ctx->pctx) <= 0) {
346 if (EVP_PKEY_CTX_set_signature_md(ctx->pctx, type) <= 0)
349 *pctx = ctx->pctx;
350 if (ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM)
352 if (!EVP_DigestInit_ex(ctx, type, e))
358 ctx->pctx->flag_call_digest_custom = 0;
359 if (ctx->pctx->pmeth->digest_custom != NULL)
360 ctx->pctx->flag_call_digest_custom = 1;
374 int EVP_DigestSignInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
379 return do_sigver_init(ctx, pctx, NULL, mdname, libctx, props, NULL, pkey, 0,
383 int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
386 return do_sigver_init(ctx, pctx, type, NULL, NULL, NULL, e, pkey, 0,
390 int EVP_DigestVerifyInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
395 return do_sigver_init(ctx, pctx, NULL, mdname, libctx, props, NULL, pkey, 1,
399 int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
402 return do_sigver_init(ctx, pctx, type, NULL, NULL, NULL, e, pkey, 1,
407 int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize)
409 EVP_PKEY_CTX *pctx = ctx->pctx;
429 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx))
434 return EVP_DigestUpdate(ctx, data, dsize);
437 int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize)
439 EVP_PKEY_CTX *pctx = ctx->pctx;
459 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx))
464 return EVP_DigestUpdate(ctx, data, dsize);
468 int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
472 EVP_PKEY_CTX *dctx, *pctx = ctx->pctx;
480 if (sigret == NULL || (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) != 0)
502 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx))
508 return pctx->pmeth->signctx(pctx, sigret, siglen, ctx);
509 if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE)
510 r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx);
515 r = dctx->pmeth->signctx(dctx, sigret, siglen, ctx);
528 if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
530 r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx);
532 r = EVP_DigestFinal_ex(ctx, md, &mdlen);
538 if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)) {
555 if (pctx->pmeth->signctx(pctx, sigret, siglen, ctx) <= 0)
558 int s = EVP_MD_get_size(ctx->digest);
567 int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen,
570 EVP_PKEY_CTX *pctx = ctx->pctx;
583 if (ctx->pctx->pmeth != NULL && ctx->pctx->pmeth->digestsign != NULL)
584 return ctx->pctx->pmeth->digestsign(ctx, sigret, siglen, tbs, tbslen);
587 if (sigret != NULL && EVP_DigestSignUpdate(ctx, tbs, tbslen) <= 0)
589 return EVP_DigestSignFinal(ctx, sigret, siglen);
592 int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
599 EVP_PKEY_CTX *dctx, *pctx = ctx->pctx;
607 if ((ctx->flags & EVP_MD_CTX_FLAG_FINALISE) != 0)
627 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx))
635 if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
637 r = pctx->pmeth->verifyctx(pctx, sig, siglen, ctx);
639 r = EVP_DigestFinal_ex(ctx, md, &mdlen);
644 if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)) {
660 int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,
663 EVP_PKEY_CTX *pctx = ctx->pctx;
675 if (ctx->pctx->pmeth != NULL && ctx->pctx->pmeth->digestverify != NULL)
676 return ctx->pctx->pmeth->digestverify(ctx, sigret, siglen, tbs, tbslen);
679 if (EVP_DigestVerifyUpdate(ctx, tbs, tbslen) <= 0)
681 return EVP_DigestVerifyFinal(ctx, sigret, siglen);