| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/evp/m_sigver.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | static int | - | ||||||||||||
| 6 | do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, | - | ||||||||||||
| 7 | ENGINE *e, EVP_PKEY *pkey, int ver) | - | ||||||||||||
| 8 | { | - | ||||||||||||
| 9 | if (ctx->pctx ==
| 1888-6992 | ||||||||||||
| 10 | ((void *)0)
| 1888-6992 | ||||||||||||
| 11 | ) | - | ||||||||||||
| 12 | ctx->pctx = EVP_PKEY_CTX_new(pkey, e); executed 1888 times by 6 tests: ctx->pctx = EVP_PKEY_CTX_new(pkey, e);Executed by:
| 1888 | ||||||||||||
| 13 | if (ctx->pctx ==
| 0-8880 | ||||||||||||
| 14 | ((void *)0)
| 0-8880 | ||||||||||||
| 15 | ) | - | ||||||||||||
| 16 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 17 | - | |||||||||||||
| 18 | if (type ==
| 0-8880 | ||||||||||||
| 19 | ((void *)0)
| 0-8880 | ||||||||||||
| 20 | ) { | - | ||||||||||||
| 21 | int def_nid; | - | ||||||||||||
| 22 | if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) > 0
| 0 | ||||||||||||
| 23 | type = EVP_get_digestbyname(OBJ_nid2sn(def_nid)); never executed: type = EVP_get_digestbyname(OBJ_nid2sn(def_nid)); | 0 | ||||||||||||
| 24 | } never executed: end of block | 0 | ||||||||||||
| 25 | - | |||||||||||||
| 26 | if (type ==
| 0-8880 | ||||||||||||
| 27 | ((void *)0)
| 0-8880 | ||||||||||||
| 28 | ) { | - | ||||||||||||
| 29 | ERR_put_error(6,(0xfff),(158),__FILE__,84); | - | ||||||||||||
| 30 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 31 | } | - | ||||||||||||
| 32 | - | |||||||||||||
| 33 | if (ver
| 72-8808 | ||||||||||||
| 34 | if (ctx->pctx->pmeth->verifyctx_init
| 0-72 | ||||||||||||
| 35 | if (ctx->pctx->pmeth->verifyctx_init(ctx->pctx,
| 0 | ||||||||||||
| 36 | ctx) <=0
| 0 | ||||||||||||
| 37 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 38 | ctx->pctx->operation = (1<<7); | - | ||||||||||||
| 39 | } never executed: else if (EVP_PKEY_verify_init(ctx->pctx) <= 0end of block
| 0-72 | ||||||||||||
| 40 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 41 | } executed 72 times by 2 tests: else {end of blockExecuted by:
| 72 | ||||||||||||
| 42 | if (ctx->pctx->pmeth->signctx_init
| 4-8804 | ||||||||||||
| 43 | if (ctx->pctx->pmeth->signctx_init(ctx->pctx, ctx) <= 0
| 0-8804 | ||||||||||||
| 44 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 45 | ctx->pctx->operation = (1<<6); | - | ||||||||||||
| 46 | } executed 8804 times by 4 tests: else if (EVP_PKEY_sign_init(ctx->pctx) <= 0end of blockExecuted by:
| 0-8804 | ||||||||||||
| 47 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 48 | } executed 8808 times by 6 tests: end of blockExecuted by:
| 8808 | ||||||||||||
| 49 | if (EVP_PKEY_CTX_ctrl(ctx->pctx, -1, ((1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)), 1, 0, (void *)type) <= 0
| 0-8880 | ||||||||||||
| 50 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 51 | if (pctx
| 4-8876 | ||||||||||||
| 52 | * executed 4 times by 2 tests: pctx = ctx->pctx;*pctx = ctx->pctx;Executed by:
executed 4 times by 2 tests: *pctx = ctx->pctx;Executed by:
| 4 | ||||||||||||
| 53 | if (!EVP_DigestInit_ex(ctx, type, e)
| 0-8880 | ||||||||||||
| 54 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 55 | return executed 8880 times by 6 tests: 1;return 1;Executed by:
executed 8880 times by 6 tests: return 1;Executed by:
| 8880 | ||||||||||||
| 56 | } | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | int | - | ||||||||||||
| 59 | EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, | - | ||||||||||||
| 60 | ENGINE *e, EVP_PKEY *pkey) | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | return executed 8808 times by 6 tests: do_sigver_init(ctx, pctx, type, e, pkey, 0);return do_sigver_init(ctx, pctx, type, e, pkey, 0);Executed by:
executed 8808 times by 6 tests: return do_sigver_init(ctx, pctx, type, e, pkey, 0);Executed by:
| 8808 | ||||||||||||
| 63 | } | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | int | - | ||||||||||||
| 66 | EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, | - | ||||||||||||
| 67 | ENGINE *e, EVP_PKEY *pkey) | - | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 | return executed 72 times by 2 tests: do_sigver_init(ctx, pctx, type, e, pkey, 1);return do_sigver_init(ctx, pctx, type, e, pkey, 1);Executed by:
executed 72 times by 2 tests: return do_sigver_init(ctx, pctx, type, e, pkey, 1);Executed by:
| 72 | ||||||||||||
| 70 | } | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | int | - | ||||||||||||
| 73 | EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) | - | ||||||||||||
| 74 | { | - | ||||||||||||
| 75 | int sctx, r = 0; | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | if (ctx->pctx->pmeth->signctx
| 6-8932 | ||||||||||||
| 78 | sctx = 1; executed 8932 times by 4 tests: sctx = 1;Executed by:
| 8932 | ||||||||||||
| 79 | else | - | ||||||||||||
| 80 | sctx = 0; executed 6 times by 2 tests: sctx = 0;Executed by:
| 6 | ||||||||||||
| 81 | if (sigret
| 2-8936 | ||||||||||||
| 82 | EVP_MD_CTX tmp_ctx; | - | ||||||||||||
| 83 | unsigned char md[64]; | - | ||||||||||||
| 84 | unsigned int mdlen = 0; | - | ||||||||||||
| 85 | EVP_MD_CTX_init(&tmp_ctx); | - | ||||||||||||
| 86 | if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)
| 0-8936 | ||||||||||||
| 87 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 88 | if (sctx
| 4-8932 | ||||||||||||
| 89 | r = tmp_ctx.pctx->pmeth->signctx(tmp_ctx.pctx, executed 8932 times by 4 tests: r = tmp_ctx.pctx->pmeth->signctx(tmp_ctx.pctx, sigret, siglen, &tmp_ctx);Executed by:
| 8932 | ||||||||||||
| 90 | sigret, siglen, &tmp_ctx); executed 8932 times by 4 tests: r = tmp_ctx.pctx->pmeth->signctx(tmp_ctx.pctx, sigret, siglen, &tmp_ctx);Executed by:
| 8932 | ||||||||||||
| 91 | else | - | ||||||||||||
| 92 | r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen); executed 4 times by 2 tests: r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen);Executed by:
| 4 | ||||||||||||
| 93 | EVP_MD_CTX_cleanup(&tmp_ctx); | - | ||||||||||||
| 94 | if (sctx
| 0-8932 | ||||||||||||
| 95 | return executed 8932 times by 4 tests: r;return r;Executed by:
executed 8932 times by 4 tests: return r;Executed by:
| 8932 | ||||||||||||
| 96 | if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0
| 0-4 | ||||||||||||
| 97 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 98 | } executed 4 times by 2 tests: else {end of blockExecuted by:
| 4 | ||||||||||||
| 99 | if (sctx
| 0-2 | ||||||||||||
| 100 | if (ctx->pctx->pmeth->signctx(ctx->pctx, sigret,
| 0 | ||||||||||||
| 101 | siglen, ctx) <= 0
| 0 | ||||||||||||
| 102 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 103 | } never executed: else {end of block | 0 | ||||||||||||
| 104 | int s = EVP_MD_size(ctx->digest); | - | ||||||||||||
| 105 | if (s < 0
| 0-2 | ||||||||||||
| 106 |
| 0-2 | ||||||||||||
| 107 | ((void *)0)
| 0-2 | ||||||||||||
| 108 | , s) <= 0
| 0-2 | ||||||||||||
| 109 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 110 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 111 | } | - | ||||||||||||
| 112 | return executed 6 times by 2 tests: 1;return 1;Executed by:
executed 6 times by 2 tests: return 1;Executed by:
| 6 | ||||||||||||
| 113 | } | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | int | - | ||||||||||||
| 116 | EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, size_t siglen) | - | ||||||||||||
| 117 | { | - | ||||||||||||
| 118 | EVP_MD_CTX tmp_ctx; | - | ||||||||||||
| 119 | unsigned char md[64]; | - | ||||||||||||
| 120 | int r; | - | ||||||||||||
| 121 | unsigned int mdlen = 0; | - | ||||||||||||
| 122 | int vctx; | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | if (ctx->pctx->pmeth->verifyctx
| 0-72 | ||||||||||||
| 125 | vctx = 1; never executed: vctx = 1; | 0 | ||||||||||||
| 126 | else | - | ||||||||||||
| 127 | vctx = 0; executed 72 times by 2 tests: vctx = 0;Executed by:
| 72 | ||||||||||||
| 128 | EVP_MD_CTX_init(&tmp_ctx); | - | ||||||||||||
| 129 | if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)
| 0-72 | ||||||||||||
| 130 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 131 | if (vctx
| 0-72 | ||||||||||||
| 132 | r = tmp_ctx.pctx->pmeth->verifyctx(tmp_ctx.pctx, sig, | - | ||||||||||||
| 133 | siglen, &tmp_ctx); | - | ||||||||||||
| 134 | } never executed: elseend of block | 0 | ||||||||||||
| 135 | r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen); executed 72 times by 2 tests: r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen);Executed by:
| 72 | ||||||||||||
| 136 | EVP_MD_CTX_cleanup(&tmp_ctx); | - | ||||||||||||
| 137 | if (vctx
| 0-72 | ||||||||||||
| 138 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||
| 139 | return executed 72 times by 2 tests: EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen);return EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen);Executed by:
executed 72 times by 2 tests: return EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen);Executed by:
| 72 | ||||||||||||
| 140 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |