| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/dsa/dsa_ossl.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); | - | ||||||||||||||||||||||||
| 6 | static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, | - | ||||||||||||||||||||||||
| 7 | BIGNUM **rp); | - | ||||||||||||||||||||||||
| 8 | static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | - | ||||||||||||||||||||||||
| 9 | DSA *dsa); | - | ||||||||||||||||||||||||
| 10 | static int dsa_init(DSA *dsa); | - | ||||||||||||||||||||||||
| 11 | static int dsa_finish(DSA *dsa); | - | ||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | static DSA_METHOD openssl_dsa_meth = { | - | ||||||||||||||||||||||||
| 14 | .name = "OpenSSL DSA method", | - | ||||||||||||||||||||||||
| 15 | .dsa_do_sign = dsa_do_sign, | - | ||||||||||||||||||||||||
| 16 | .dsa_sign_setup = dsa_sign_setup, | - | ||||||||||||||||||||||||
| 17 | .dsa_do_verify = dsa_do_verify, | - | ||||||||||||||||||||||||
| 18 | .init = dsa_init, | - | ||||||||||||||||||||||||
| 19 | .finish = dsa_finish, | - | ||||||||||||||||||||||||
| 20 | }; | - | ||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | const DSA_METHOD * | - | ||||||||||||||||||||||||
| 23 | DSA_OpenSSL(void) | - | ||||||||||||||||||||||||
| 24 | { | - | ||||||||||||||||||||||||
| 25 | return executed 4 times by 2 tests: &openssl_dsa_meth;return &openssl_dsa_meth;Executed by:
executed 4 times by 2 tests: return &openssl_dsa_meth;Executed by:
| 4 | ||||||||||||||||||||||||
| 26 | } | - | ||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | static DSA_SIG * | - | ||||||||||||||||||||||||
| 29 | dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | - | ||||||||||||||||||||||||
| 30 | { | - | ||||||||||||||||||||||||
| 31 | BIGNUM b, bm, bxr, binv, m, *kinv = | - | ||||||||||||||||||||||||
| 32 | ((void *)0) | - | ||||||||||||||||||||||||
| 33 | , *r = | - | ||||||||||||||||||||||||
| 34 | ((void *)0) | - | ||||||||||||||||||||||||
| 35 | , *s = | - | ||||||||||||||||||||||||
| 36 | ((void *)0) | - | ||||||||||||||||||||||||
| 37 | ; | - | ||||||||||||||||||||||||
| 38 | BN_CTX *ctx = | - | ||||||||||||||||||||||||
| 39 | ((void *)0) | - | ||||||||||||||||||||||||
| 40 | ; | - | ||||||||||||||||||||||||
| 41 | int reason = 3; | - | ||||||||||||||||||||||||
| 42 | DSA_SIG *ret = | - | ||||||||||||||||||||||||
| 43 | ((void *)0) | - | ||||||||||||||||||||||||
| 44 | ; | - | ||||||||||||||||||||||||
| 45 | int noredo = 0; | - | ||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | BN_init(&b); | - | ||||||||||||||||||||||||
| 48 | BN_init(&binv); | - | ||||||||||||||||||||||||
| 49 | BN_init(&bm); | - | ||||||||||||||||||||||||
| 50 | BN_init(&bxr); | - | ||||||||||||||||||||||||
| 51 | BN_init(&m); | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | if (!dsa->p
| 0-2 | ||||||||||||||||||||||||
| 54 | reason = 101; | - | ||||||||||||||||||||||||
| 55 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 56 | } | - | ||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||
| 58 | s = BN_new(); | - | ||||||||||||||||||||||||
| 59 | if (s ==
| 0-2 | ||||||||||||||||||||||||
| 60 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 61 | ) | - | ||||||||||||||||||||||||
| 62 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 63 | ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||
| 64 | if (ctx ==
| 0-2 | ||||||||||||||||||||||||
| 65 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 66 | ) | - | ||||||||||||||||||||||||
| 67 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | if (dlen > ((BN_num_bits(dsa->q)+7)/8)
| 1 | ||||||||||||||||||||||||
| 75 | dlen = ((BN_num_bits(dsa->q)+7)/8); executed 1 time by 1 test: dlen = ((BN_num_bits(dsa->q)+7)/8);Executed by:
| 1 | ||||||||||||||||||||||||
| 76 | if (BN_bin2bn(dgst, dlen, &m) ==
| 0-2 | ||||||||||||||||||||||||
| 77 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 78 | ) | - | ||||||||||||||||||||||||
| 79 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||
| 81 | redo: code before this statement executed 2 times by 2 tests: redo:Executed by:
| 2 | ||||||||||||||||||||||||
| 82 | if (dsa->kinv ==
| 0-2 | ||||||||||||||||||||||||
| 83 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 84 | || dsa->r ==
| 0 | ||||||||||||||||||||||||
| 85 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 86 | ) { | - | ||||||||||||||||||||||||
| 87 | if (!DSA_sign_setup(dsa, ctx, &kinv, &r)
| 0-2 | ||||||||||||||||||||||||
| 88 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 89 | } executed 2 times by 2 tests: else {end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 90 | kinv = dsa->kinv; | - | ||||||||||||||||||||||||
| 91 | dsa->kinv = | - | ||||||||||||||||||||||||
| 92 | ((void *)0) | - | ||||||||||||||||||||||||
| 93 | ; | - | ||||||||||||||||||||||||
| 94 | r = dsa->r; | - | ||||||||||||||||||||||||
| 95 | dsa->r = | - | ||||||||||||||||||||||||
| 96 | ((void *)0) | - | ||||||||||||||||||||||||
| 97 | ; | - | ||||||||||||||||||||||||
| 98 | noredo = 1; | - | ||||||||||||||||||||||||
| 99 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 100 | if (!BN_sub(&bm, dsa->q, BN_value_one())
| 0-2 | ||||||||||||||||||||||||
| 101 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 102 | if (!BN_rand_range(&b, &bm)
| 0-2 | ||||||||||||||||||||||||
| 103 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 104 | if (!BN_add(&b, &b, BN_value_one())
| 0-2 | ||||||||||||||||||||||||
| 105 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 106 | if (BN_mod_inverse_ct(&binv, &b, dsa->q, ctx) ==
| 0-2 | ||||||||||||||||||||||||
| 107 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 108 | ) | - | ||||||||||||||||||||||||
| 109 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | if (!BN_mod_mul(&bxr, &b, dsa->priv_key, dsa->q, ctx)
| 0-2 | ||||||||||||||||||||||||
| 112 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 113 | if (!BN_mod_mul(&bxr, &bxr, r, dsa->q, ctx)
| 0-2 | ||||||||||||||||||||||||
| 114 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 115 | if (!BN_mod_mul(&bm, &b, &m, dsa->q, ctx)
| 0-2 | ||||||||||||||||||||||||
| 116 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 117 | if (!BN_mod_add(s, &bxr, &bm, dsa->q, ctx)
| 0-2 | ||||||||||||||||||||||||
| 118 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 119 | if (!BN_mod_mul(s, s, &binv, dsa->q, ctx)
| 0-2 | ||||||||||||||||||||||||
| 120 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 121 | if (!BN_mod_mul(s, s, kinv, dsa->q, ctx)
| 0-2 | ||||||||||||||||||||||||
| 122 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | if (((
| 0-2 | ||||||||||||||||||||||||
| 129 | if (noredo
| 0 | ||||||||||||||||||||||||
| 130 | reason = 110; | - | ||||||||||||||||||||||||
| 131 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 132 | } | - | ||||||||||||||||||||||||
| 133 | goto never executed: redo;goto redo;never executed: goto redo; | 0 | ||||||||||||||||||||||||
| 134 | } | - | ||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | if ((
| 0-2 | ||||||||||||||||||||||||
| 137 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 138 | ) { | - | ||||||||||||||||||||||||
| 139 | reason = (1|64); | - | ||||||||||||||||||||||||
| 140 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 141 | } | - | ||||||||||||||||||||||||
| 142 | ret->r = r; | - | ||||||||||||||||||||||||
| 143 | ret->s = s; | - | ||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 | err: code before this statement executed 2 times by 2 tests: err:Executed by:
| 2 | ||||||||||||||||||||||||
| 146 | if (!ret
| 0-2 | ||||||||||||||||||||||||
| 147 | ERR_put_error(10,(0xfff),(reason),__FILE__,198); | - | ||||||||||||||||||||||||
| 148 | BN_free(r); | - | ||||||||||||||||||||||||
| 149 | BN_free(s); | - | ||||||||||||||||||||||||
| 150 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 151 | BN_CTX_free(ctx); | - | ||||||||||||||||||||||||
| 152 | BN_clear_free(&b); | - | ||||||||||||||||||||||||
| 153 | BN_clear_free(&bm); | - | ||||||||||||||||||||||||
| 154 | BN_clear_free(&bxr); | - | ||||||||||||||||||||||||
| 155 | BN_clear_free(&binv); | - | ||||||||||||||||||||||||
| 156 | BN_clear_free(&m); | - | ||||||||||||||||||||||||
| 157 | BN_clear_free(kinv); | - | ||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | return executed 2 times by 2 tests: ret;return ret;Executed by:
executed 2 times by 2 tests: return ret;Executed by:
| 2 | ||||||||||||||||||||||||
| 160 | } | - | ||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | static int | - | ||||||||||||||||||||||||
| 163 | dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | - | ||||||||||||||||||||||||
| 164 | { | - | ||||||||||||||||||||||||
| 165 | BN_CTX *ctx; | - | ||||||||||||||||||||||||
| 166 | BIGNUM k, l, m, *kinv = | - | ||||||||||||||||||||||||
| 167 | ((void *)0) | - | ||||||||||||||||||||||||
| 168 | , *r = | - | ||||||||||||||||||||||||
| 169 | ((void *)0) | - | ||||||||||||||||||||||||
| 170 | ; | - | ||||||||||||||||||||||||
| 171 | int q_bits, ret = 0; | - | ||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||
| 173 | if (!dsa->p
| 0-2 | ||||||||||||||||||||||||
| 174 | ERR_put_error(10,(0xfff),(101),__FILE__,221); | - | ||||||||||||||||||||||||
| 175 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 176 | } | - | ||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | BN_init(&k); | - | ||||||||||||||||||||||||
| 179 | BN_init(&l); | - | ||||||||||||||||||||||||
| 180 | BN_init(&m); | - | ||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||
| 182 | if (ctx_in ==
| 0-2 | ||||||||||||||||||||||||
| 183 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 184 | ) { | - | ||||||||||||||||||||||||
| 185 | if ((
| 0 | ||||||||||||||||||||||||
| 186 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 187 | ) | - | ||||||||||||||||||||||||
| 188 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 189 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
| 190 | ctx = ctx_in; executed 2 times by 2 tests: ctx = ctx_in;Executed by:
| 2 | ||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||
| 192 | if ((
| 0-2 | ||||||||||||||||||||||||
| 193 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 194 | ) | - | ||||||||||||||||||||||||
| 195 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | q_bits = BN_num_bits(dsa->q); | - | ||||||||||||||||||||||||
| 199 | if (!BN_set_bit(&k, q_bits)
| 0-2 | ||||||||||||||||||||||||
| 200 | !BN_set_bit(&l, q_bits)
| 0-2 | ||||||||||||||||||||||||
| 201 | !BN_set_bit(&m, q_bits)
| 0-2 | ||||||||||||||||||||||||
| 202 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||
| 205 | do { | - | ||||||||||||||||||||||||
| 206 | if (!BN_rand_range(&k, dsa->q)
| 0-2 | ||||||||||||||||||||||||
| 207 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 208 | } executed 2 times by 2 tests: while (((end of blockExecuted by:
| 0-2 | ||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||
| 210 | ((&k)->flags|=(0x04)); | - | ||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | if (dsa->flags & 0x01
| 0-2 | ||||||||||||||||||||||||
| 213 | if (!BN_MONT_CTX_set_locked(&dsa->method_mont_p,
| 0-2 | ||||||||||||||||||||||||
| 214 | 8, dsa->p, ctx)
| 0-2 | ||||||||||||||||||||||||
| 215 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 216 | } executed 2 times by 2 tests: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 217 | if (!BN_add(&l, &k, dsa->q)
| 0-2 | ||||||||||||||||||||||||
| 218 | !BN_add(&m, &l, dsa->q)
| 0-2 | ||||||||||||||||||||||||
| 219 | !BN_copy(&k, BN_num_bits(&l) > q_bits ? &l : &m)
| 0-2 | ||||||||||||||||||||||||
| 220 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | if (dsa->meth->bn_mod_exp !=
| 0-2 | ||||||||||||||||||||||||
| 223 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 224 | ) { | - | ||||||||||||||||||||||||
| 225 | if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, &k, dsa->p, ctx,
| 0 | ||||||||||||||||||||||||
| 226 | dsa->method_mont_p)
| 0 | ||||||||||||||||||||||||
| 227 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 228 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 229 | if (!BN_mod_exp_mont_ct(r, dsa->g, &k, dsa->p, ctx,
| 0-2 | ||||||||||||||||||||||||
| 230 | dsa->method_mont_p)
| 0-2 | ||||||||||||||||||||||||
| 231 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 232 | } executed 2 times by 2 tests: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||
| 234 | if (!BN_div_ct(
| 0-2 | ||||||||||||||||||||||||
| 235 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 236 | ,(r),(r),(dsa->q),(ctx))
| 0-2 | ||||||||||||||||||||||||
| 237 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | if ((
| 0-2 | ||||||||||||||||||||||||
| 241 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 242 | , &k, dsa->q, ctx)) ==
| 0-2 | ||||||||||||||||||||||||
| 243 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 244 | ) | - | ||||||||||||||||||||||||
| 245 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 | BN_clear_free(*kinvp); | - | ||||||||||||||||||||||||
| 248 | *kinvp = kinv; | - | ||||||||||||||||||||||||
| 249 | kinv = | - | ||||||||||||||||||||||||
| 250 | ((void *)0) | - | ||||||||||||||||||||||||
| 251 | ; | - | ||||||||||||||||||||||||
| 252 | BN_clear_free(*rp); | - | ||||||||||||||||||||||||
| 253 | *rp = r; | - | ||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||
| 255 | ret = 1; | - | ||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||
| 257 | err: code before this statement executed 2 times by 2 tests: err:Executed by:
| 2 | ||||||||||||||||||||||||
| 258 | if (!ret
| 0-2 | ||||||||||||||||||||||||
| 259 | ERR_put_error(10,(0xfff),(3),__FILE__,306); | - | ||||||||||||||||||||||||
| 260 | BN_clear_free(r); | - | ||||||||||||||||||||||||
| 261 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 262 | if (ctx_in ==
| 0-2 | ||||||||||||||||||||||||
| 263 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 264 | ) | - | ||||||||||||||||||||||||
| 265 | BN_CTX_free(ctx); never executed: BN_CTX_free(ctx); | 0 | ||||||||||||||||||||||||
| 266 | BN_clear_free(&k); | - | ||||||||||||||||||||||||
| 267 | BN_clear_free(&l); | - | ||||||||||||||||||||||||
| 268 | BN_clear_free(&m); | - | ||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | return executed 2 times by 2 tests: ret;return ret;Executed by:
executed 2 times by 2 tests: return ret;Executed by:
| 2 | ||||||||||||||||||||||||
| 271 | } | - | ||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||
| 273 | static int | - | ||||||||||||||||||||||||
| 274 | dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) | - | ||||||||||||||||||||||||
| 275 | { | - | ||||||||||||||||||||||||
| 276 | BN_CTX *ctx; | - | ||||||||||||||||||||||||
| 277 | BIGNUM u1, u2, t1; | - | ||||||||||||||||||||||||
| 278 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||
| 279 | ((void *)0) | - | ||||||||||||||||||||||||
| 280 | ; | - | ||||||||||||||||||||||||
| 281 | int ret = -1, i; | - | ||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||
| 283 | if (!dsa->p
| 0-1 | ||||||||||||||||||||||||
| 284 | ERR_put_error(10,(0xfff),(101),__FILE__,327); | - | ||||||||||||||||||||||||
| 285 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 286 | } | - | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | i = BN_num_bits(dsa->q); | - | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | if (i != 160
| 0-1 | ||||||||||||||||||||||||
| 291 | ERR_put_error(10,(0xfff),(102),__FILE__,334); | - | ||||||||||||||||||||||||
| 292 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 293 | } | - | ||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | if (BN_num_bits(dsa->p) > 10000
| 0-1 | ||||||||||||||||||||||||
| 296 | ERR_put_error(10,(0xfff),(103),__FILE__,339); | - | ||||||||||||||||||||||||
| 297 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 298 | } | - | ||||||||||||||||||||||||
| 299 | BN_init(&u1); | - | ||||||||||||||||||||||||
| 300 | BN_init(&u2); | - | ||||||||||||||||||||||||
| 301 | BN_init(&t1); | - | ||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||
| 303 | if ((
| 0-1 | ||||||||||||||||||||||||
| 304 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 305 | ) | - | ||||||||||||||||||||||||
| 306 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||
| 308 | if (((
| 0-1 | ||||||||||||||||||||||||
| 309 | BN_ucmp(sig->r, dsa->q) >= 0
| 0-1 | ||||||||||||||||||||||||
| 310 | ret = 0; | - | ||||||||||||||||||||||||
| 311 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 312 | } | - | ||||||||||||||||||||||||
| 313 | if (((
| 0-1 | ||||||||||||||||||||||||
| 314 | BN_ucmp(sig->s, dsa->q) >= 0
| 0-1 | ||||||||||||||||||||||||
| 315 | ret = 0; | - | ||||||||||||||||||||||||
| 316 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 317 | } | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | if ((
| 0-1 | ||||||||||||||||||||||||
| 321 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 322 | ) | - | ||||||||||||||||||||||||
| 323 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | - | |||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 | if (dgst_len > (i >> 3)
| 0-1 | ||||||||||||||||||||||||
| 330 | dgst_len = (i >> 3); never executed: dgst_len = (i >> 3); | 0 | ||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | if (BN_bin2bn(dgst, dgst_len, &u1) ==
| 0-1 | ||||||||||||||||||||||||
| 334 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 335 | ) | - | ||||||||||||||||||||||||
| 336 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | if (!BN_mod_mul(&u1, &u1, &u2, dsa->q, ctx)
| 0-1 | ||||||||||||||||||||||||
| 340 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | if (!BN_mod_mul(&u2, sig->r, &u2, dsa->q, ctx)
| 0-1 | ||||||||||||||||||||||||
| 344 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||
| 346 | if (dsa->flags & 0x01
| 0-1 | ||||||||||||||||||||||||
| 347 | mont = BN_MONT_CTX_set_locked(&dsa->method_mont_p, | - | ||||||||||||||||||||||||
| 348 | 8, dsa->p, ctx); | - | ||||||||||||||||||||||||
| 349 | if (!mont
| 0-1 | ||||||||||||||||||||||||
| 350 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 351 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | if (dsa->meth->dsa_mod_exp !=
| 0-1 | ||||||||||||||||||||||||
| 354 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 355 | ) { | - | ||||||||||||||||||||||||
| 356 | if (!dsa->meth->dsa_mod_exp(dsa, &t1, dsa->g, &u1, dsa->pub_key,
| 0 | ||||||||||||||||||||||||
| 357 | &u2, dsa->p, ctx, mont)
| 0 | ||||||||||||||||||||||||
| 358 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 359 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 360 | if (!BN_mod_exp2_mont(&t1, dsa->g, &u1, dsa->pub_key, &u2,
| 0-1 | ||||||||||||||||||||||||
| 361 | dsa->p, ctx, mont)
| 0-1 | ||||||||||||||||||||||||
| 362 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 363 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||
| 367 | if (!BN_div_ct(
| 0-1 | ||||||||||||||||||||||||
| 368 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 369 | ,(&u1),(&t1),(dsa->q),(ctx))
| 0-1 | ||||||||||||||||||||||||
| 370 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | ret = BN_ucmp(&u1, sig->r) == 0; | - | ||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | err: code before this statement executed 1 time by 1 test: err:Executed by:
| 1 | ||||||||||||||||||||||||
| 376 | if (ret < 0
| 0-1 | ||||||||||||||||||||||||
| 377 | ERR_put_error(10,(0xfff),(3),__FILE__,410); never executed: ERR_put_error(10,(0xfff),(3),__FILE__,410); | 0 | ||||||||||||||||||||||||
| 378 | BN_CTX_free(ctx); | - | ||||||||||||||||||||||||
| 379 | BN_free(&u1); | - | ||||||||||||||||||||||||
| 380 | BN_free(&u2); | - | ||||||||||||||||||||||||
| 381 | BN_free(&t1); | - | ||||||||||||||||||||||||
| 382 | - | |||||||||||||||||||||||||
| 383 | return executed 1 time by 1 test: ret;return ret;Executed by:
executed 1 time by 1 test: return ret;Executed by:
| 1 | ||||||||||||||||||||||||
| 384 | } | - | ||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||
| 386 | static int | - | ||||||||||||||||||||||||
| 387 | dsa_init(DSA *dsa) | - | ||||||||||||||||||||||||
| 388 | { | - | ||||||||||||||||||||||||
| 389 | dsa->flags |= 0x01; | - | ||||||||||||||||||||||||
| 390 | return executed 6 times by 2 tests: 1;return 1;Executed by:
executed 6 times by 2 tests: return 1;Executed by:
| 6 | ||||||||||||||||||||||||
| 391 | } | - | ||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||
| 393 | static int | - | ||||||||||||||||||||||||
| 394 | dsa_finish(DSA *dsa) | - | ||||||||||||||||||||||||
| 395 | { | - | ||||||||||||||||||||||||
| 396 | BN_MONT_CTX_free(dsa->method_mont_p); | - | ||||||||||||||||||||||||
| 397 | return executed 6 times by 2 tests: 1;return 1;Executed by:
executed 6 times by 2 tests: return 1;Executed by:
| 6 | ||||||||||||||||||||||||
| 398 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |