- if (sigret == NULL || (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) != 0)
- return pctx->op.sig.signature->digest_sign_final(pctx->op.sig.algctx,
- sigret, siglen,
- sigret == NULL ? 0 : *siglen);
- dctx = EVP_PKEY_CTX_dup(pctx);
- if (dctx == NULL)
- return 0;
-
- r = dctx->op.sig.signature->digest_sign_final(dctx->op.sig.algctx,
+ if (sigret != NULL && (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) == 0) {
+ /* try dup */
+ dctx = EVP_PKEY_CTX_dup(pctx);
+ if (dctx != NULL)
+ pctx = dctx;
+ }
+ r = pctx->op.sig.signature->digest_sign_final(pctx->op.sig.algctx,