Lines Matching refs:pctx

39 static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,  in do_sigver_init()  argument
57 if (ctx->pctx == NULL) { in do_sigver_init()
60 ctx->pctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, props); in do_sigver_init()
62 ctx->pctx = EVP_PKEY_CTX_new(pkey, e); in do_sigver_init()
64 if (ctx->pctx == NULL) in do_sigver_init()
69 locpctx = ctx->pctx; in do_sigver_init()
208 if (pctx != NULL) in do_sigver_init()
209 *pctx = locpctx; in do_sigver_init()
299 if (ctx->pctx->pmeth == NULL) { in do_sigver_init()
304 if (!(ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM)) { in do_sigver_init()
319 if (ctx->pctx->pmeth->verifyctx_init) { in do_sigver_init()
320 if (ctx->pctx->pmeth->verifyctx_init(ctx->pctx, ctx) <= 0) in do_sigver_init()
322 ctx->pctx->operation = EVP_PKEY_OP_VERIFYCTX; in do_sigver_init()
323 } else if (ctx->pctx->pmeth->digestverify != 0) { in do_sigver_init()
324 ctx->pctx->operation = EVP_PKEY_OP_VERIFY; in do_sigver_init()
326 } else if (EVP_PKEY_verify_init(ctx->pctx) <= 0) { in do_sigver_init()
330 if (ctx->pctx->pmeth->signctx_init) { in do_sigver_init()
331 if (ctx->pctx->pmeth->signctx_init(ctx->pctx, ctx) <= 0) in do_sigver_init()
333 ctx->pctx->operation = EVP_PKEY_OP_SIGNCTX; in do_sigver_init()
334 } else if (ctx->pctx->pmeth->digestsign != 0) { in do_sigver_init()
335 ctx->pctx->operation = EVP_PKEY_OP_SIGN; in do_sigver_init()
337 } else if (EVP_PKEY_sign_init(ctx->pctx) <= 0) { in do_sigver_init()
341 if (EVP_PKEY_CTX_set_signature_md(ctx->pctx, type) <= 0) in do_sigver_init()
343 if (pctx) in do_sigver_init()
344 *pctx = ctx->pctx; in do_sigver_init()
345 if (ctx->pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) in do_sigver_init()
353 ctx->pctx->flag_call_digest_custom = 0; in do_sigver_init()
354 if (ctx->pctx->pmeth->digest_custom != NULL) in do_sigver_init()
355 ctx->pctx->flag_call_digest_custom = 1; in do_sigver_init()
369 int EVP_DigestSignInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, in EVP_DigestSignInit_ex() argument
374 return do_sigver_init(ctx, pctx, NULL, mdname, libctx, props, NULL, pkey, 0, in EVP_DigestSignInit_ex()
378 int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, in EVP_DigestSignInit() argument
381 return do_sigver_init(ctx, pctx, type, NULL, NULL, NULL, e, pkey, 0, in EVP_DigestSignInit()
385 int EVP_DigestVerifyInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, in EVP_DigestVerifyInit_ex() argument
390 return do_sigver_init(ctx, pctx, NULL, mdname, libctx, props, NULL, pkey, 1, in EVP_DigestVerifyInit_ex()
394 int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, in EVP_DigestVerifyInit() argument
397 return do_sigver_init(ctx, pctx, type, NULL, NULL, NULL, e, pkey, 1, in EVP_DigestVerifyInit()
404 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
446 if (pctx == NULL in EVP_DigestVerifyUpdate()
447 || pctx->operation != EVP_PKEY_OP_VERIFYCTX in EVP_DigestVerifyUpdate()
448 || pctx->op.sig.algctx == NULL in EVP_DigestVerifyUpdate()
449 || pctx->op.sig.signature == NULL) in EVP_DigestVerifyUpdate()
452 if (pctx->op.sig.signature->digest_verify_update == NULL) { in EVP_DigestVerifyUpdate()
457 return pctx->op.sig.signature->digest_verify_update(pctx->op.sig.algctx, in EVP_DigestVerifyUpdate()
461 if (pctx != NULL) { in EVP_DigestVerifyUpdate()
463 if (pctx->flag_call_digest_custom in EVP_DigestVerifyUpdate()
464 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx)) in EVP_DigestVerifyUpdate()
466 pctx->flag_call_digest_custom = 0; in EVP_DigestVerifyUpdate()
477 EVP_PKEY_CTX *dctx = NULL, *pctx = ctx->pctx; in EVP_DigestSignFinal() local
484 if (pctx == NULL in EVP_DigestSignFinal()
485 || pctx->operation != EVP_PKEY_OP_SIGNCTX in EVP_DigestSignFinal()
486 || pctx->op.sig.algctx == NULL in EVP_DigestSignFinal()
487 || pctx->op.sig.signature == NULL) in EVP_DigestSignFinal()
492 dctx = EVP_PKEY_CTX_dup(pctx); in EVP_DigestSignFinal()
494 pctx = dctx; in EVP_DigestSignFinal()
496 r = pctx->op.sig.signature->digest_sign_final(pctx->op.sig.algctx, in EVP_DigestSignFinal()
506 if (pctx == NULL || pctx->pmeth == NULL) { in EVP_DigestSignFinal()
512 if (pctx->flag_call_digest_custom in EVP_DigestSignFinal()
513 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx)) in EVP_DigestSignFinal()
515 pctx->flag_call_digest_custom = 0; in EVP_DigestSignFinal()
517 if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) { in EVP_DigestSignFinal()
519 return pctx->pmeth->signctx(pctx, sigret, siglen, ctx); in EVP_DigestSignFinal()
521 r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx); in EVP_DigestSignFinal()
524 dctx = EVP_PKEY_CTX_dup(pctx); in EVP_DigestSignFinal()
532 if (pctx->pmeth->signctx != NULL) in EVP_DigestSignFinal()
542 r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx); in EVP_DigestSignFinal()
555 r = tmp_ctx->pctx->pmeth->signctx(tmp_ctx->pctx, in EVP_DigestSignFinal()
563 if (EVP_PKEY_sign(pctx, sigret, siglen, md, mdlen) <= 0) in EVP_DigestSignFinal()
567 if (pctx->pmeth->signctx(pctx, sigret, siglen, ctx) <= 0) in EVP_DigestSignFinal()
572 if (s < 0 || EVP_PKEY_sign(pctx, sigret, siglen, NULL, s) <= 0) in EVP_DigestSignFinal()
582 EVP_PKEY_CTX *pctx = ctx->pctx; in EVP_DigestSign() local
589 if (pctx != NULL in EVP_DigestSign()
590 && pctx->operation == EVP_PKEY_OP_SIGNCTX in EVP_DigestSign()
591 && pctx->op.sig.algctx != NULL in EVP_DigestSign()
592 && pctx->op.sig.signature != NULL) { in EVP_DigestSign()
593 if (pctx->op.sig.signature->digest_sign != NULL) { in EVP_DigestSign()
596 return pctx->op.sig.signature->digest_sign(pctx->op.sig.algctx, in EVP_DigestSign()
603 if (ctx->pctx->pmeth != NULL && ctx->pctx->pmeth->digestsign != NULL) in EVP_DigestSign()
604 return ctx->pctx->pmeth->digestsign(ctx, sigret, siglen, tbs, tbslen); in EVP_DigestSign()
619 EVP_PKEY_CTX *dctx = NULL, *pctx = ctx->pctx; in EVP_DigestVerifyFinal() local
626 if (pctx == NULL in EVP_DigestVerifyFinal()
627 || pctx->operation != EVP_PKEY_OP_VERIFYCTX in EVP_DigestVerifyFinal()
628 || pctx->op.sig.algctx == NULL in EVP_DigestVerifyFinal()
629 || pctx->op.sig.signature == NULL) in EVP_DigestVerifyFinal()
634 dctx = EVP_PKEY_CTX_dup(pctx); in EVP_DigestVerifyFinal()
636 pctx = dctx; in EVP_DigestVerifyFinal()
638 r = pctx->op.sig.signature->digest_verify_final(pctx->op.sig.algctx, in EVP_DigestVerifyFinal()
647 if (pctx == NULL || pctx->pmeth == NULL) { in EVP_DigestVerifyFinal()
653 if (pctx->flag_call_digest_custom in EVP_DigestVerifyFinal()
654 && !ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx)) in EVP_DigestVerifyFinal()
656 pctx->flag_call_digest_custom = 0; in EVP_DigestVerifyFinal()
658 if (pctx->pmeth->verifyctx != NULL) in EVP_DigestVerifyFinal()
664 r = pctx->pmeth->verifyctx(pctx, sig, siglen, ctx); in EVP_DigestVerifyFinal()
677 r = tmp_ctx->pctx->pmeth->verifyctx(tmp_ctx->pctx, in EVP_DigestVerifyFinal()
685 return EVP_PKEY_verify(pctx, sig, siglen, md, mdlen); in EVP_DigestVerifyFinal()
691 EVP_PKEY_CTX *pctx = ctx->pctx; in EVP_DigestVerify() local
698 if (pctx != NULL in EVP_DigestVerify()
699 && pctx->operation == EVP_PKEY_OP_VERIFYCTX in EVP_DigestVerify()
700 && pctx->op.sig.algctx != NULL in EVP_DigestVerify()
701 && pctx->op.sig.signature != NULL) { in EVP_DigestVerify()
702 if (pctx->op.sig.signature->digest_verify != NULL) { in EVP_DigestVerify()
704 return pctx->op.sig.signature->digest_verify(pctx->op.sig.algctx, in EVP_DigestVerify()
710 if (ctx->pctx->pmeth != NULL && ctx->pctx->pmeth->digestverify != NULL) in EVP_DigestVerify()
711 return ctx->pctx->pmeth->digestverify(ctx, sigret, siglen, tbs, tbslen); in EVP_DigestVerify()