Lines Matching refs:pctx

39 static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,  in do_sigver_init()  argument
64 if (ctx->pctx == NULL) { in do_sigver_init()
67 ctx->pctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, props); in do_sigver_init()
69 ctx->pctx = EVP_PKEY_CTX_new(pkey, e); in do_sigver_init()
71 if (ctx->pctx == NULL) in do_sigver_init()
74 locpctx = ctx->pctx; in do_sigver_init()
213 if (pctx != NULL) in do_sigver_init()
214 *pctx = locpctx; in do_sigver_init()
304 if (ctx->pctx->pmeth == NULL) { in do_sigver_init()
309 if (!(ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM)) { in do_sigver_init()
324 if (ctx->pctx->pmeth->verifyctx_init) { in do_sigver_init()
325 if (ctx->pctx->pmeth->verifyctx_init(ctx->pctx, ctx) <= 0) in do_sigver_init()
327 ctx->pctx->operation = EVP_PKEY_OP_VERIFYCTX; in do_sigver_init()
328 } else if (ctx->pctx->pmeth->digestverify != 0) { in do_sigver_init()
329 ctx->pctx->operation = EVP_PKEY_OP_VERIFY; in do_sigver_init()
331 } else if (EVP_PKEY_verify_init(ctx->pctx) <= 0) { in do_sigver_init()
335 if (ctx->pctx->pmeth->signctx_init) { in do_sigver_init()
336 if (ctx->pctx->pmeth->signctx_init(ctx->pctx, ctx) <= 0) in do_sigver_init()
338 ctx->pctx->operation = EVP_PKEY_OP_SIGNCTX; in do_sigver_init()
339 } else if (ctx->pctx->pmeth->digestsign != 0) { in do_sigver_init()
340 ctx->pctx->operation = EVP_PKEY_OP_SIGN; in do_sigver_init()
342 } else if (EVP_PKEY_sign_init(ctx->pctx) <= 0) { in do_sigver_init()
346 if (EVP_PKEY_CTX_set_signature_md(ctx->pctx, type) <= 0) in do_sigver_init()
348 if (pctx) in do_sigver_init()
349 *pctx = ctx->pctx; in do_sigver_init()
350 if (ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) in do_sigver_init()
358 ctx->pctx->flag_call_digest_custom = 0; in do_sigver_init()
359 if (ctx->pctx->pmeth->digest_custom != NULL) in do_sigver_init()
360 ctx->pctx->flag_call_digest_custom = 1; in do_sigver_init()
374 int EVP_DigestSignInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, in EVP_DigestSignInit_ex() argument
379 return do_sigver_init(ctx, pctx, NULL, mdname, libctx, props, NULL, pkey, 0, in EVP_DigestSignInit_ex()
383 int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, in EVP_DigestSignInit() argument
386 return do_sigver_init(ctx, pctx, type, NULL, NULL, NULL, e, pkey, 0, in EVP_DigestSignInit()
390 int EVP_DigestVerifyInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, in EVP_DigestVerifyInit_ex() argument
395 return do_sigver_init(ctx, pctx, NULL, mdname, libctx, props, NULL, pkey, 1, in EVP_DigestVerifyInit_ex()
399 int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, in EVP_DigestVerifyInit() argument
402 return do_sigver_init(ctx, pctx, type, NULL, NULL, NULL, e, pkey, 1, in EVP_DigestVerifyInit()
409 EVP_PKEY_CTX *pctx = ctx->pctx; in EVP_DigestSignUpdate() local
411 if (pctx == NULL in EVP_DigestSignUpdate()
412 || pctx->operation != EVP_PKEY_OP_SIGNCTX in EVP_DigestSignUpdate()
413 || pctx->op.sig.algctx == NULL in EVP_DigestSignUpdate()
414 || pctx->op.sig.signature == NULL) in EVP_DigestSignUpdate()
417 if (pctx->op.sig.signature->digest_sign_update == NULL) { in EVP_DigestSignUpdate()
422 return pctx->op.sig.signature->digest_sign_update(pctx->op.sig.algctx, in EVP_DigestSignUpdate()
426 if (pctx != NULL) { in EVP_DigestSignUpdate()
428 if (pctx->flag_call_digest_custom in EVP_DigestSignUpdate()
429 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx)) in EVP_DigestSignUpdate()
431 pctx->flag_call_digest_custom = 0; in EVP_DigestSignUpdate()
439 EVP_PKEY_CTX *pctx = ctx->pctx; in EVP_DigestVerifyUpdate() local
441 if (pctx == NULL in EVP_DigestVerifyUpdate()
442 || pctx->operation != EVP_PKEY_OP_VERIFYCTX in EVP_DigestVerifyUpdate()
443 || pctx->op.sig.algctx == NULL in EVP_DigestVerifyUpdate()
444 || pctx->op.sig.signature == NULL) in EVP_DigestVerifyUpdate()
447 if (pctx->op.sig.signature->digest_verify_update == NULL) { in EVP_DigestVerifyUpdate()
452 return pctx->op.sig.signature->digest_verify_update(pctx->op.sig.algctx, in EVP_DigestVerifyUpdate()
456 if (pctx != NULL) { in EVP_DigestVerifyUpdate()
458 if (pctx->flag_call_digest_custom in EVP_DigestVerifyUpdate()
459 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx)) in EVP_DigestVerifyUpdate()
461 pctx->flag_call_digest_custom = 0; in EVP_DigestVerifyUpdate()
472 EVP_PKEY_CTX *dctx, *pctx = ctx->pctx; in EVP_DigestSignFinal() local
474 if (pctx == NULL in EVP_DigestSignFinal()
475 || pctx->operation != EVP_PKEY_OP_SIGNCTX in EVP_DigestSignFinal()
476 || pctx->op.sig.algctx == NULL in EVP_DigestSignFinal()
477 || pctx->op.sig.signature == NULL) in EVP_DigestSignFinal()
481 return pctx->op.sig.signature->digest_sign_final(pctx->op.sig.algctx, in EVP_DigestSignFinal()
484 dctx = EVP_PKEY_CTX_dup(pctx); in EVP_DigestSignFinal()
495 if (pctx == NULL || pctx->pmeth == NULL) { in EVP_DigestSignFinal()
501 if (pctx->flag_call_digest_custom in EVP_DigestSignFinal()
502 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx)) in EVP_DigestSignFinal()
504 pctx->flag_call_digest_custom = 0; in EVP_DigestSignFinal()
506 if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) { in EVP_DigestSignFinal()
508 return pctx->pmeth->signctx(pctx, sigret, siglen, ctx); in EVP_DigestSignFinal()
510 r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx); in EVP_DigestSignFinal()
512 dctx = EVP_PKEY_CTX_dup(pctx); in EVP_DigestSignFinal()
520 if (pctx->pmeth->signctx != NULL) in EVP_DigestSignFinal()
530 r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx); in EVP_DigestSignFinal()
543 r = tmp_ctx->pctx->pmeth->signctx(tmp_ctx->pctx, in EVP_DigestSignFinal()
551 if (EVP_PKEY_sign(pctx, sigret, siglen, md, mdlen) <= 0) in EVP_DigestSignFinal()
555 if (pctx->pmeth->signctx(pctx, sigret, siglen, ctx) <= 0) in EVP_DigestSignFinal()
560 if (s < 0 || EVP_PKEY_sign(pctx, sigret, siglen, NULL, s) <= 0) in EVP_DigestSignFinal()
570 EVP_PKEY_CTX *pctx = ctx->pctx; in EVP_DigestSign() local
572 if (pctx != NULL in EVP_DigestSign()
573 && pctx->operation == EVP_PKEY_OP_SIGNCTX in EVP_DigestSign()
574 && pctx->op.sig.algctx != NULL in EVP_DigestSign()
575 && pctx->op.sig.signature != NULL) { in EVP_DigestSign()
576 if (pctx->op.sig.signature->digest_sign != NULL) in EVP_DigestSign()
577 return pctx->op.sig.signature->digest_sign(pctx->op.sig.algctx, in EVP_DigestSign()
583 if (ctx->pctx->pmeth != NULL && ctx->pctx->pmeth->digestsign != NULL) in EVP_DigestSign()
584 return ctx->pctx->pmeth->digestsign(ctx, sigret, siglen, tbs, tbslen); in EVP_DigestSign()
599 EVP_PKEY_CTX *dctx, *pctx = ctx->pctx; in EVP_DigestVerifyFinal() local
601 if (pctx == NULL in EVP_DigestVerifyFinal()
602 || pctx->operation != EVP_PKEY_OP_VERIFYCTX in EVP_DigestVerifyFinal()
603 || pctx->op.sig.algctx == NULL in EVP_DigestVerifyFinal()
604 || pctx->op.sig.signature == NULL) in EVP_DigestVerifyFinal()
608 return pctx->op.sig.signature->digest_verify_final(pctx->op.sig.algctx, in EVP_DigestVerifyFinal()
610 dctx = EVP_PKEY_CTX_dup(pctx); in EVP_DigestVerifyFinal()
620 if (pctx == NULL || pctx->pmeth == NULL) { in EVP_DigestVerifyFinal()
626 if (pctx->flag_call_digest_custom in EVP_DigestVerifyFinal()
627 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx)) in EVP_DigestVerifyFinal()
629 pctx->flag_call_digest_custom = 0; in EVP_DigestVerifyFinal()
631 if (pctx->pmeth->verifyctx != NULL) in EVP_DigestVerifyFinal()
637 r = pctx->pmeth->verifyctx(pctx, sig, siglen, ctx); in EVP_DigestVerifyFinal()
649 r = tmp_ctx->pctx->pmeth->verifyctx(tmp_ctx->pctx, in EVP_DigestVerifyFinal()
657 return EVP_PKEY_verify(pctx, sig, siglen, md, mdlen); in EVP_DigestVerifyFinal()
663 EVP_PKEY_CTX *pctx = ctx->pctx; in EVP_DigestVerify() local
665 if (pctx != NULL in EVP_DigestVerify()
666 && pctx->operation == EVP_PKEY_OP_VERIFYCTX in EVP_DigestVerify()
667 && pctx->op.sig.algctx != NULL in EVP_DigestVerify()
668 && pctx->op.sig.signature != NULL) { in EVP_DigestVerify()
669 if (pctx->op.sig.signature->digest_verify != NULL) in EVP_DigestVerify()
670 return pctx->op.sig.signature->digest_verify(pctx->op.sig.algctx, in EVP_DigestVerify()
675 if (ctx->pctx->pmeth != NULL && ctx->pctx->pmeth->digestverify != NULL) in EVP_DigestVerify()
676 return ctx->pctx->pmeth->digestverify(ctx, sigret, siglen, tbs, tbslen); in EVP_DigestVerify()