| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/m_sigver.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | static int update(EVP_MD_CTX *ctx, const void *data, size_t datalen) | - | ||||||||||||
| 4 | { | - | ||||||||||||
| 5 | ERR_put_error(6,(173),(177),__FILE__,20); | - | ||||||||||||
| 6 | return executed 4 times by 1 test: 0;return 0;Executed by:
executed 4 times by 1 test: return 0;Executed by:
| 4 | ||||||||||||
| 7 | } | - | ||||||||||||
| 8 | - | |||||||||||||
| 9 | static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, | - | ||||||||||||
| 10 | const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey, | - | ||||||||||||
| 11 | int ver) | - | ||||||||||||
| 12 | { | - | ||||||||||||
| 13 | if (ctx->pctx ==
| 3-24489 | ||||||||||||
| 14 | ((void *)0)
| 3-24489 | ||||||||||||
| 15 | ) | - | ||||||||||||
| 16 | ctx->pctx = EVP_PKEY_CTX_new(pkey, e); executed 24489 times by 1 test: ctx->pctx = EVP_PKEY_CTX_new(pkey, e);Executed by:
| 24489 | ||||||||||||
| 17 | if (ctx->pctx ==
| 0-24492 | ||||||||||||
| 18 | ((void *)0)
| 0-24492 | ||||||||||||
| 19 | ) | - | ||||||||||||
| 20 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 21 | - | |||||||||||||
| 22 | if (!(ctx->pctx->pmeth->flags & 4)
| 122-24370 | ||||||||||||
| 23 | - | |||||||||||||
| 24 | if (type ==
| 2-24368 | ||||||||||||
| 25 | ((void *)0)
| 2-24368 | ||||||||||||
| 26 | ) { | - | ||||||||||||
| 27 | int def_nid; | - | ||||||||||||
| 28 | if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) > 0
| 0-2 | ||||||||||||
| 29 | type = EVP_get_digestbyname(OBJ_nid2sn(def_nid)); executed 2 times by 1 test: type = EVP_get_digestbyname(OBJ_nid2sn(def_nid));Executed by:
| 2 | ||||||||||||
| 30 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 31 | - | |||||||||||||
| 32 | if (type ==
| 0-24370 | ||||||||||||
| 33 | ((void *)0)
| 0-24370 | ||||||||||||
| 34 | ) { | - | ||||||||||||
| 35 | ERR_put_error(6,(161),(158),__FILE__,42); | - | ||||||||||||
| 36 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 37 | } | - | ||||||||||||
| 38 | } executed 24370 times by 1 test: end of blockExecuted by:
| 24370 | ||||||||||||
| 39 | - | |||||||||||||
| 40 | if (ver
| 3194-21298 | ||||||||||||
| 41 | if (ctx->pctx->pmeth->verifyctx_init
| 0-3194 | ||||||||||||
| 42 | if (ctx->pctx->pmeth->verifyctx_init(ctx->pctx, ctx) <= 0
| 0 | ||||||||||||
| 43 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 44 | ctx->pctx->operation = (1<<7); | - | ||||||||||||
| 45 | } never executed: else if (ctx->pctx->pmeth->digestverify != 0end of block
| 0-3173 | ||||||||||||
| 46 | ctx->pctx->operation = (1<<4); | - | ||||||||||||
| 47 | ctx->update = update; | - | ||||||||||||
| 48 | } executed 21 times by 1 test: else if (EVP_PKEY_verify_init(ctx->pctx) <= 0end of blockExecuted by:
| 0-3173 | ||||||||||||
| 49 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 50 | } | - | ||||||||||||
| 51 | } executed 3194 times by 1 test: else {end of blockExecuted by:
| 3194 | ||||||||||||
| 52 | if (ctx->pctx->pmeth->signctx_init
| 2020-19278 | ||||||||||||
| 53 | if (ctx->pctx->pmeth->signctx_init(ctx->pctx, ctx) <= 0
| 0-19278 | ||||||||||||
| 54 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 55 | ctx->pctx->operation = (1<<6); | - | ||||||||||||
| 56 | } executed 19278 times by 1 test: else if (ctx->pctx->pmeth->digestsign != 0end of blockExecuted by:
| 29-19278 | ||||||||||||
| 57 | ctx->pctx->operation = (1<<3); | - | ||||||||||||
| 58 | ctx->update = update; | - | ||||||||||||
| 59 | } executed 29 times by 1 test: else if (EVP_PKEY_sign_init(ctx->pctx) <= 0end of blockExecuted by:
| 0-1991 | ||||||||||||
| 60 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 61 | } | - | ||||||||||||
| 62 | } executed 21298 times by 1 test: end of blockExecuted by:
| 21298 | ||||||||||||
| 63 | if (EVP_PKEY_CTX_ctrl(ctx->pctx, -1, ((1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)), 1, 0, (void *)(type)) <= 0
| 3-24489 | ||||||||||||
| 64 | return executed 3 times by 1 test: 0;return 0;Executed by:
executed 3 times by 1 test: return 0;Executed by:
| 3 | ||||||||||||
| 65 | if (pctx
| 3930-20559 | ||||||||||||
| 66 | * executed 3930 times by 1 test: pctx = ctx->pctx;*pctx = ctx->pctx;Executed by:
executed 3930 times by 1 test: *pctx = ctx->pctx;Executed by:
| 3930 | ||||||||||||
| 67 | if (ctx->pctx->pmeth->flags & 4
| 120-24369 | ||||||||||||
| 68 | return executed 120 times by 1 test: 1;return 1;Executed by:
executed 120 times by 1 test: return 1;Executed by:
| 120 | ||||||||||||
| 69 | if (!EVP_DigestInit_ex(ctx, type, e)
| 0-24369 | ||||||||||||
| 70 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | - | |||||||||||||
| 73 | - | |||||||||||||
| 74 | - | |||||||||||||
| 75 | if (ctx->pctx->pmeth->digest_custom !=
| 3-24366 | ||||||||||||
| 76 | ((void *)0)
| 3-24366 | ||||||||||||
| 77 | ) | - | ||||||||||||
| 78 | return executed 3 times by 1 test: ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx);return ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx);Executed by:
executed 3 times by 1 test: return ctx->pctx->pmeth->digest_custom(ctx->pctx, ctx);Executed by:
| 3 | ||||||||||||
| 79 | - | |||||||||||||
| 80 | return executed 24366 times by 1 test: 1;return 1;Executed by:
executed 24366 times by 1 test: return 1;Executed by:
| 24366 | ||||||||||||
| 81 | } | - | ||||||||||||
| 82 | - | |||||||||||||
| 83 | int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, | - | ||||||||||||
| 84 | const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey) | - | ||||||||||||
| 85 | { | - | ||||||||||||
| 86 | return executed 21298 times by 1 test: do_sigver_init(ctx, pctx, type, e, pkey, 0);return do_sigver_init(ctx, pctx, type, e, pkey, 0);Executed by:
executed 21298 times by 1 test: return do_sigver_init(ctx, pctx, type, e, pkey, 0);Executed by:
| 21298 | ||||||||||||
| 87 | } | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, | - | ||||||||||||
| 90 | const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey) | - | ||||||||||||
| 91 | { | - | ||||||||||||
| 92 | return executed 3194 times by 1 test: do_sigver_init(ctx, pctx, type, e, pkey, 1);return do_sigver_init(ctx, pctx, type, e, pkey, 1);Executed by:
executed 3194 times by 1 test: return do_sigver_init(ctx, pctx, type, e, pkey, 1);Executed by:
| 3194 | ||||||||||||
| 93 | } | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, | - | ||||||||||||
| 96 | size_t *siglen) | - | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 | int sctx = 0, r = 0; | - | ||||||||||||
| 99 | EVP_PKEY_CTX *pctx = ctx->pctx; | - | ||||||||||||
| 100 | if (pctx->pmeth->flags & 4
| 144-83271 | ||||||||||||
| 101 | if (!sigret
| 72 | ||||||||||||
| 102 | return executed 72 times by 1 test: pctx->pmeth->signctx(pctx, sigret, siglen, ctx);return pctx->pmeth->signctx(pctx, sigret, siglen, ctx);Executed by:
executed 72 times by 1 test: return pctx->pmeth->signctx(pctx, sigret, siglen, ctx);Executed by:
| 72 | ||||||||||||
| 103 | if (ctx->flags & 0x0200
| 0-72 | ||||||||||||
| 104 | r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx); never executed: r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx); | 0 | ||||||||||||
| 105 | else { | - | ||||||||||||
| 106 | EVP_PKEY_CTX *dctx = EVP_PKEY_CTX_dup(ctx->pctx); | - | ||||||||||||
| 107 | if (!dctx
| 0-72 | ||||||||||||
| 108 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 109 | r = dctx->pmeth->signctx(dctx, sigret, siglen, ctx); | - | ||||||||||||
| 110 | EVP_PKEY_CTX_free(dctx); | - | ||||||||||||
| 111 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||
| 112 | return executed 72 times by 1 test: r;return r;Executed by:
executed 72 times by 1 test: return r;Executed by:
| 72 | ||||||||||||
| 113 | } | - | ||||||||||||
| 114 | if (pctx->pmeth->signctx
| 2070-81201 | ||||||||||||
| 115 | sctx = 1; executed 81201 times by 1 test: sctx = 1;Executed by:
| 81201 | ||||||||||||
| 116 | else | - | ||||||||||||
| 117 | sctx = 0; executed 2070 times by 1 test: sctx = 0;Executed by:
| 2070 | ||||||||||||
| 118 | if (sigret
| 109-83162 | ||||||||||||
| 119 | unsigned char md[64]; | - | ||||||||||||
| 120 | unsigned int mdlen = 0; | - | ||||||||||||
| 121 | if (ctx->flags & 0x0200
| 0-83162 | ||||||||||||
| 122 | if (sctx
| 0 | ||||||||||||
| 123 | r = ctx->pctx->pmeth->signctx(ctx->pctx, sigret, siglen, ctx); never executed: r = ctx->pctx->pmeth->signctx(ctx->pctx, sigret, siglen, ctx); | 0 | ||||||||||||
| 124 | else | - | ||||||||||||
| 125 | r = EVP_DigestFinal_ex(ctx, md, &mdlen); never executed: r = EVP_DigestFinal_ex(ctx, md, &mdlen); | 0 | ||||||||||||
| 126 | } else { | - | ||||||||||||
| 127 | EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new(); | - | ||||||||||||
| 128 | if (tmp_ctx ==
| 0-83162 | ||||||||||||
| 129 | ((void *)0)
| 0-83162 | ||||||||||||
| 130 | ) | - | ||||||||||||
| 131 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 132 | if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)
| 0-83162 | ||||||||||||
| 133 | EVP_MD_CTX_free(tmp_ctx); | - | ||||||||||||
| 134 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 135 | } | - | ||||||||||||
| 136 | if (sctx
| 1991-81171 | ||||||||||||
| 137 | r = tmp_ctx->pctx->pmeth->signctx(tmp_ctx->pctx, executed 81171 times by 1 test: r = tmp_ctx->pctx->pmeth->signctx(tmp_ctx->pctx, sigret, siglen, tmp_ctx);Executed by:
| 81171 | ||||||||||||
| 138 | sigret, siglen, tmp_ctx); executed 81171 times by 1 test: r = tmp_ctx->pctx->pmeth->signctx(tmp_ctx->pctx, sigret, siglen, tmp_ctx);Executed by:
| 81171 | ||||||||||||
| 139 | else | - | ||||||||||||
| 140 | r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen); executed 1991 times by 1 test: r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen);Executed by:
| 1991 | ||||||||||||
| 141 | EVP_MD_CTX_free(tmp_ctx); | - | ||||||||||||
| 142 | } executed 83162 times by 1 test: end of blockExecuted by:
| 83162 | ||||||||||||
| 143 | if (sctx
| 0-81171 | ||||||||||||
| 144 | return executed 81171 times by 1 test: r;return r;Executed by:
executed 81171 times by 1 test: return r;Executed by:
| 81171 | ||||||||||||
| 145 | if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0
| 2-1989 | ||||||||||||
| 146 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||
| 147 | } executed 1989 times by 1 test: else {end of blockExecuted by:
| 1989 | ||||||||||||
| 148 | if (sctx
| 30-79 | ||||||||||||
| 149 | if (pctx->pmeth->signctx(pctx, sigret, siglen, ctx) <= 0
| 0-30 | ||||||||||||
| 150 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 151 | } executed 30 times by 1 test: else {end of blockExecuted by:
| 30 | ||||||||||||
| 152 | int s = EVP_MD_size(ctx->digest); | - | ||||||||||||
| 153 | if (s < 0
| 0-79 | ||||||||||||
| 154 | ((void *)0)
| 0-79 | ||||||||||||
| 155 | , s) <= 0
| 0-79 | ||||||||||||
| 156 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 157 | } executed 79 times by 1 test: end of blockExecuted by:
| 79 | ||||||||||||
| 158 | } | - | ||||||||||||
| 159 | return executed 2098 times by 1 test: 1;return 1;Executed by:
executed 2098 times by 1 test: return 1;Executed by:
| 2098 | ||||||||||||
| 160 | } | - | ||||||||||||
| 161 | - | |||||||||||||
| 162 | int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen, | - | ||||||||||||
| 163 | const unsigned char *tbs, size_t tbslen) | - | ||||||||||||
| 164 | { | - | ||||||||||||
| 165 | if (ctx->pctx->pmeth->digestsign !=
| 40-1914 | ||||||||||||
| 166 | ((void *)0)
| 40-1914 | ||||||||||||
| 167 | ) | - | ||||||||||||
| 168 | return executed 40 times by 1 test: ctx->pctx->pmeth->digestsign(ctx, sigret, siglen, tbs, tbslen);return ctx->pctx->pmeth->digestsign(ctx, sigret, siglen, tbs, tbslen);Executed by:
executed 40 times by 1 test: return ctx->pctx->pmeth->digestsign(ctx, sigret, siglen, tbs, tbslen);Executed by:
| 40 | ||||||||||||
| 169 | if (sigret !=
| 1-1913 | ||||||||||||
| 170 | ((void *)0)
| 1-1913 | ||||||||||||
| 171 | && EVP_DigestUpdate(ctx,tbs,tbslen) <= 0
| 0-1913 | ||||||||||||
| 172 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 173 | return executed 1914 times by 1 test: EVP_DigestSignFinal(ctx, sigret, siglen);return EVP_DigestSignFinal(ctx, sigret, siglen);Executed by:
executed 1914 times by 1 test: return EVP_DigestSignFinal(ctx, sigret, siglen);Executed by:
| 1914 | ||||||||||||
| 174 | } | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, | - | ||||||||||||
| 177 | size_t siglen) | - | ||||||||||||
| 178 | { | - | ||||||||||||
| 179 | unsigned char md[64]; | - | ||||||||||||
| 180 | int r = 0; | - | ||||||||||||
| 181 | unsigned int mdlen = 0; | - | ||||||||||||
| 182 | int vctx = 0; | - | ||||||||||||
| 183 | - | |||||||||||||
| 184 | if (ctx->pctx->pmeth->verifyctx
| 0-3170 | ||||||||||||
| 185 | vctx = 1; never executed: vctx = 1; | 0 | ||||||||||||
| 186 | else | - | ||||||||||||
| 187 | vctx = 0; executed 3170 times by 1 test: vctx = 0;Executed by:
| 3170 | ||||||||||||
| 188 | if (ctx->flags & 0x0200
| 0-3170 | ||||||||||||
| 189 | if (vctx
| 0 | ||||||||||||
| 190 | r = ctx->pctx->pmeth->verifyctx(ctx->pctx, sig, siglen, ctx); never executed: r = ctx->pctx->pmeth->verifyctx(ctx->pctx, sig, siglen, ctx); | 0 | ||||||||||||
| 191 | else | - | ||||||||||||
| 192 | r = EVP_DigestFinal_ex(ctx, md, &mdlen); never executed: r = EVP_DigestFinal_ex(ctx, md, &mdlen); | 0 | ||||||||||||
| 193 | } else { | - | ||||||||||||
| 194 | EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new(); | - | ||||||||||||
| 195 | if (tmp_ctx ==
| 0-3170 | ||||||||||||
| 196 | ((void *)0)
| 0-3170 | ||||||||||||
| 197 | ) | - | ||||||||||||
| 198 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 199 | if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)
| 0-3170 | ||||||||||||
| 200 | EVP_MD_CTX_free(tmp_ctx); | - | ||||||||||||
| 201 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 202 | } | - | ||||||||||||
| 203 | if (vctx
| 0-3170 | ||||||||||||
| 204 | r = tmp_ctx->pctx->pmeth->verifyctx(tmp_ctx->pctx, never executed: r = tmp_ctx->pctx->pmeth->verifyctx(tmp_ctx->pctx, sig, siglen, tmp_ctx); | 0 | ||||||||||||
| 205 | sig, siglen, tmp_ctx); never executed: r = tmp_ctx->pctx->pmeth->verifyctx(tmp_ctx->pctx, sig, siglen, tmp_ctx); | 0 | ||||||||||||
| 206 | else | - | ||||||||||||
| 207 | r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen); executed 3170 times by 1 test: r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen);Executed by:
| 3170 | ||||||||||||
| 208 | EVP_MD_CTX_free(tmp_ctx); | - | ||||||||||||
| 209 | } executed 3170 times by 1 test: end of blockExecuted by:
| 3170 | ||||||||||||
| 210 | if (vctx
| 0-3170 | ||||||||||||
| 211 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||
| 212 | return executed 3170 times by 1 test: EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen);return EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen);Executed by:
executed 3170 times by 1 test: return EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen);Executed by:
| 3170 | ||||||||||||
| 213 | } | - | ||||||||||||
| 214 | - | |||||||||||||
| 215 | int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, | - | ||||||||||||
| 216 | size_t siglen, const unsigned char *tbs, size_t tbslen) | - | ||||||||||||
| 217 | { | - | ||||||||||||
| 218 | if (ctx->pctx->pmeth->digestverify !=
| 19-3098 | ||||||||||||
| 219 | ((void *)0)
| 19-3098 | ||||||||||||
| 220 | ) | - | ||||||||||||
| 221 | return executed 19 times by 1 test: ctx->pctx->pmeth->digestverify(ctx, sigret, siglen, tbs, tbslen);return ctx->pctx->pmeth->digestverify(ctx, sigret, siglen, tbs, tbslen);Executed by:
executed 19 times by 1 test: return ctx->pctx->pmeth->digestverify(ctx, sigret, siglen, tbs, tbslen);Executed by:
| 19 | ||||||||||||
| 222 | if (EVP_DigestUpdate(ctx,tbs,tbslen) <= 0
| 0-3098 | ||||||||||||
| 223 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 224 | return executed 3098 times by 1 test: EVP_DigestVerifyFinal(ctx, sigret, siglen);return EVP_DigestVerifyFinal(ctx, sigret, siglen);Executed by:
executed 3098 times by 1 test: return EVP_DigestVerifyFinal(ctx, sigret, siglen);Executed by:
| 3098 | ||||||||||||
| 225 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |