| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_exp.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | int i, bits, ret = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | BIGNUM *v, *rr; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | if (BN_get_flags(p, 0x04) != 0
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | || BN_get_flags(a, 0x04) != 0
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ERR_put_error(3,(123),((2|64)),__FILE__,49); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | rr = ((
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | v = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | if (rr ==
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ((void *)0)
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | || v ==
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ((void *)0)
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | if (BN_copy(v, a) ==
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ((void *)0)
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | if (BN_is_odd(p)
| 2-3 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | if (BN_copy(rr, a) ==
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } executed 2 times by 1 test: else {end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | if (!(BN_set_word((rr),1))
| 0-3 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | for (i = 1; i < bits
| 5-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | if (!BN_sqr(v, v, ctx)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | if (BN_is_bit_set(p, i)
| 5-10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | if (!BN_mul(rr, rr, v, ctx)
| 0-10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } executed 15 times by 1 test: end of blockExecuted by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | if (r != rr
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | err: code before this statement executed 5 times by 1 test: err:Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | return executed 5 times by 1 test: ret;return ret;Executed by:
executed 5 times by 1 test: return ret;Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | int ret; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | if (BN_is_odd(m)
| 279-8967 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | if (a->top == 1
| 92-6150 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | && (
| 0-2725 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | && (
| 0-2725 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | && (
| 0-2725 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | unsigned long A = a->d[0]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ret = BN_mod_exp_mont_word(r, A, p, m, ctx, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } executed 2725 times by 1 test: elseend of blockExecuted by:
| 2725 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ret = BN_mod_exp_mont(r, a, p, m, ctx, executed 6242 times by 1 test: ret = BN_mod_exp_mont(r, a, p, m, ctx, ((void *)0) );Executed by:
| 6242 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ((void *)0) executed 6242 times by 1 test: ret = BN_mod_exp_mont(r, a, p, m, ctx, ((void *)0) );Executed by:
| 6242 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); executed 6242 times by 1 test: ret = BN_mod_exp_mont(r, a, p, m, ctx, ((void *)0) );Executed by:
| 6242 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ret = BN_mod_exp_recp(r, a, p, m, ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } executed 279 times by 1 test: end of blockExecuted by:
| 279 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | return executed 9246 times by 1 test: ret;return ret;Executed by:
executed 9246 times by 1 test: return ret;Executed by:
| 9246 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | const BIGNUM *m, BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | int start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | BIGNUM *aa; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | BIGNUM *val[32]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | BN_RECP_CTX recp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | if (BN_get_flags(p, 0x04) != 0
| 0-582 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | || BN_get_flags(a, 0x04) != 0
| 0-582 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | || BN_get_flags(m, 0x04) != 0
| 0-582 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ERR_put_error(3,(125),((2|64)),__FILE__,175); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | if (bits == 0
| 5-577 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | if (BN_abs_is_word(m, 1)
| 2-3 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | (BN_set_word((r),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } executed 3 times by 1 test: else {end of blockExecuted by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ret = (BN_set_word((r),1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | return executed 5 times by 1 test: ret;return ret;Executed by:
executed 5 times by 1 test: return ret;Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | aa = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | val[0] = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | if (val[0] ==
| 0-577 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ((void *)0)
| 0-577 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | BN_RECP_CTX_init(&recp); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | if (m->neg
| 92-485 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | if (!BN_copy(aa, m)
| 0-92 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | aa->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0
| 0-92 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } executed 92 times by 1 test: else {end of blockExecuted by:
| 92 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | if (BN_RECP_CTX_set(&recp, m, ctx) <= 0
| 0-485 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } executed 485 times by 1 test: end of blockExecuted by:
| 485 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | if (!BN_nnmod(val[0], a, m, ctx)
| 1-576 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | goto executed 1 time by 1 test: err;goto err;Executed by:
executed 1 time by 1 test: goto err;Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | if (BN_is_zero(val[0])
| 4-572 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | (BN_set_word((r),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | goto executed 4 times by 1 test: err;goto err;Executed by:
executed 4 times by 1 test: goto err;Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | window = ((
| 13-559 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | if (window > 1
| 166-406 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx)
| 0-406 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | j = 1 << (window - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | for (i = 1; i < j
| 406-5422 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | if (((
| 0-5422 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ((void *)0)
| 0-5422 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | )
| 0-5422 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | !BN_mod_mul_reciprocal(val[i], val[i - 1], aa, &recp, ctx)
| 0-5422 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } executed 5422 times by 1 test: end of blockExecuted by:
| 5422 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } executed 406 times by 1 test: end of blockExecuted by:
| 406 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | wstart = bits - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | if (!(BN_set_word((r),1))
| 0-572 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | for (;;) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | if (BN_is_bit_set(p, wstart) == 0
| 23919-51529 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | if (!start
| 0-51529 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx)
| 0-51529 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | if (wstart == 0
| 320-51209 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | break; executed 320 times by 1 test: break;Executed by:
| 320 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | wstart--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | continue; executed 51209 times by 1 test: continue;Executed by:
| 51209 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | j = wstart; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | wvalue = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | for (i = 1; i < window
| 23754-91140 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | if (wstart - i < 0
| 165-90975 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | break; executed 165 times by 1 test: break;Executed by:
| 165 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | if (BN_is_bit_set(p, wstart - i)
| 43249-47726 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | wvalue <<= (i - wend); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | wvalue |= 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | wend = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } executed 47726 times by 1 test: end of blockExecuted by:
| 47726 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } executed 90975 times by 1 test: end of blockExecuted by:
| 90975 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | j = wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | if (!start
| 572-23347 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | for (i = 0; i < j
| 23347-91488 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx)
| 0-91488 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } executed 91488 times by 1 test: end of blockExecuted by:
| 91488 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | if (!BN_mod_mul_reciprocal(r, r, val[wvalue >> 1], &recp, ctx)
| 0-23919 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | wstart -= wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | start = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | if (wstart < 0
| 252-23667 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | break; executed 252 times by 1 test: break;Executed by:
| 252 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } executed 23667 times by 1 test: end of blockExecuted by:
| 23667 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | err: code before this statement executed 572 times by 1 test: err:Executed by:
| 572 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | BN_RECP_CTX_free(&recp); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | return executed 577 times by 1 test: ret;return ret;Executed by:
executed 577 times by 1 test: return ret;Executed by:
| 577 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | int start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | BIGNUM *d, *r; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | const BIGNUM *aa; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | BIGNUM *val[32]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | if (BN_get_flags(p, 0x04) != 0
| 592-17148 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | || BN_get_flags(a, 0x04) != 0
| 0-17148 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | || BN_get_flags(m, 0x04) != 0
| 5448-11700 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | return executed 6040 times by 1 test: BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont);return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont);Executed by:
executed 6040 times by 1 test: return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont);Executed by:
| 6040 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | if (!BN_is_odd(m)
| 2-11698 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | ERR_put_error(3,(109),(102),__FILE__,318); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | if (bits == 0
| 34-11664 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | if (BN_abs_is_word(m, 1)
| 8-26 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } executed 8 times by 1 test: else {end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ret = (BN_set_word((rr),1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | return executed 34 times by 1 test: ret;return ret;Executed by:
executed 34 times by 1 test: return ret;Executed by:
| 34 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | d = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | r = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | val[0] = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | if (val[0] ==
| 0-11664 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ((void *)0)
| 0-11664 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | if (in_mont !=
| 4715-6949 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ((void *)0)
| 4715-6949 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | mont = in_mont; executed 6949 times by 2 tests: mont = in_mont;Executed by:
| 6949 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | if ((
| 0-4715 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ((void *)0)
| 0-4715 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | if (!BN_MONT_CTX_set(mont, m, ctx)
| 0-4715 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } executed 4715 times by 1 test: end of blockExecuted by:
| 4715 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | if (a->neg
| 33-11561 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | if (!BN_nnmod(val[0], a, m, ctx)
| 0-136 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | aa = val[0]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } executed 136 times by 1 test: elseend of blockExecuted by:
| 136 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | aa = a; executed 11528 times by 2 tests: aa = a;Executed by:
| 11528 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | if (!bn_to_mont_fixed_top(val[0], aa, mont, ctx)
| 0-11664 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | window = ((
| 213-11451 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | if (window > 1
| 5631-6033 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | if (!bn_mul_mont_fixed_top(d, val[0], val[0], mont, ctx)
| 0-6033 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | j = 1 << (window - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | for (i = 1; i < j
| 6033-65607 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | if (((
| 0-65607 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ((void *)0)
| 0-65607 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | )
| 0-65607 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | !bn_mul_mont_fixed_top(val[i], val[i - 1], d, mont, ctx)
| 0-65607 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } executed 65607 times by 2 tests: end of blockExecuted by:
| 65607 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } executed 6033 times by 2 tests: end of blockExecuted by:
| 6033 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | wstart = bits - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | j = m->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | if (m->d[j - 1] & (((unsigned long)1) << ((8 * 8) - 1))
| 4856-6808 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | if (bn_wexpand(r, j) ==
| 0-6808 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | ((void *)0)
| 0-6808 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | r->d[0] = (0 - m->d[0]) & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | for (i = 1; i < j
| 6808-163595 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | r->d[i] = (~m->d[i]) & (0xffffffffffffffffL); executed 163595 times by 2 tests: r->d[i] = (~m->d[i]) & (0xffffffffffffffffL);Executed by:
| 163595 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | r->top = j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | r->flags |= 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } executed 6808 times by 2 tests: elseend of blockExecuted by:
| 6808 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | if (!bn_to_mont_fixed_top(r, BN_value_one(), mont, ctx)
| 0-4856 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | for (;;) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | if (BN_is_bit_set(p, wstart) == 0
| 246538-808705 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | if (!start
| 0-808705 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | if (!bn_mul_mont_fixed_top(r, r, r, mont, ctx)
| 0-808705 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } executed 808705 times by 2 tests: end of blockExecuted by:
| 808705 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | if (wstart == 0
| 1938-806767 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | break; executed 1938 times by 1 test: break;Executed by:
| 1938 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | wstart--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | continue; executed 806767 times by 2 tests: continue;Executed by:
| 806767 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | j = wstart; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | wvalue = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | for (i = 1; i < window
| 242914-861621 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | if (wstart - i < 0
| 3624-857997 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | break; executed 3624 times by 2 tests: break;Executed by:
| 3624 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | if (BN_is_bit_set(p, wstart - i)
| 211830-646167 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | wvalue <<= (i - wend); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | wvalue |= 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | wend = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } executed 646167 times by 2 tests: end of blockExecuted by:
| 646167 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } executed 857997 times by 2 tests: end of blockExecuted by:
| 857997 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | j = wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | if (!start
| 11664-234874 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | for (i = 0; i < j
| 234874-974897 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | if (!bn_mul_mont_fixed_top(r, r, r, mont, ctx)
| 0-974897 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } executed 974897 times by 2 tests: end of blockExecuted by:
| 974897 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | if (!bn_mul_mont_fixed_top(r, r, val[wvalue >> 1], mont, ctx)
| 0-246538 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | wstart -= wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | start = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | if (wstart < 0
| 9726-236812 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | break; executed 9726 times by 2 tests: break;Executed by:
| 9726 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } executed 236812 times by 2 tests: end of blockExecuted by:
| 236812 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | if (!BN_from_montgomery(rr, r, mont, ctx)
| 0-11664 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | err: code before this statement executed 11664 times by 2 tests: err:Executed by:
| 11664 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | if (in_mont ==
| 4715-6949 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | ((void *)0)
| 4715-6949 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | BN_MONT_CTX_free(mont); executed 4715 times by 1 test: BN_MONT_CTX_free(mont);Executed by:
| 4715 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | return executed 11664 times by 2 tests: ret;return ret;Executed by:
executed 11664 times by 2 tests: return ret;Executed by:
| 11664 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | static unsigned long bn_get_bits(const BIGNUM *a, int bitpos) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | unsigned long ret = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | int wordpos; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | wordpos = bitpos / (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | bitpos %= (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | if (wordpos >= 0
| 0-96938 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ret = a->d[wordpos] & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | if (bitpos
| 4896-92042 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | ret >>= bitpos; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | if (++
| 34740-57302 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ret |= a->d[wordpos] << ((8 * 8) - bitpos); executed 34740 times by 1 test: ret |= a->d[wordpos] << ((8 * 8) - bitpos);Executed by:
| 34740 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } executed 92042 times by 1 test: end of blockExecuted by:
| 92042 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } executed 96938 times by 1 test: end of blockExecuted by:
| 96938 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | return executed 96938 times by 1 test: ret & (0xffffffffffffffffL);return ret & (0xffffffffffffffffL);Executed by:
executed 96938 times by 1 test: return ret & (0xffffffffffffffffL);Executed by:
| 96938 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | static int MOD_EXP_CTIME_COPY_TO_PREBUF(const BIGNUM *b, int top, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | unsigned char *buf, int idx, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | int window) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | int i, j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | int width = 1 << window; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | unsigned long *table = (unsigned long *)buf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | if (top > b->top
| 0-26960 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | top = b->top; never executed: top = b->top; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | for (i = 0, j = idx; i < top
| 26960-528840 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | table[j] = b->d[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } executed 528840 times by 1 test: end of blockExecuted by:
| 528840 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | return executed 26960 times by 1 test: 1;return 1;Executed by:
executed 26960 times by 1 test: return 1;Executed by:
| 26960 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | unsigned char *buf, int idx, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | int window) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | int i, j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | int width = 1 << window; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | volatile unsigned long *table = (volatile unsigned long *)buf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | if (bn_wexpand(b, top) ==
| 0-89076 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | ((void *)0)
| 0-89076 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | if (window <= 3
| 39380-49696 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | for (i = 0; i < top
| 39380-1222738 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | unsigned long acc = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | for (j = 0; j < width
| 1222738-9781904 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | acc |= table[j] & | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ((unsigned long)0 - (constant_time_eq_int(j,idx)&1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } executed 9781904 times by 1 test: end of blockExecuted by:
| 9781904 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | b->d[i] = acc; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } executed 1222738 times by 1 test: end of blockExecuted by:
| 1222738 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } executed 39380 times by 1 test: else {end of blockExecuted by:
| 39380 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | int xstride = 1 << (window - 2); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | unsigned long y0, y1, y2, y3; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | i = idx >> (window - 2); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | idx &= xstride - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | y0 = (unsigned long)0 - (constant_time_eq_int(i,0)&1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | y1 = (unsigned long)0 - (constant_time_eq_int(i,1)&1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | y2 = (unsigned long)0 - (constant_time_eq_int(i,2)&1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | y3 = (unsigned long)0 - (constant_time_eq_int(i,3)&1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | for (i = 0; i < top
| 49696-323264 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | unsigned long acc = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | for (j = 0; j < xstride
| 323264-1293056 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | acc |= ( (table[j + 0 * xstride] & y0) | | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | (table[j + 1 * xstride] & y1) | | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | (table[j + 2 * xstride] & y2) | | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | (table[j + 3 * xstride] & y3) ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | & ((unsigned long)0 - (constant_time_eq_int(j,idx)&1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } executed 1293056 times by 1 test: end of blockExecuted by:
| 1293056 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | b->d[i] = acc; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } executed 323264 times by 1 test: end of blockExecuted by:
| 323264 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } executed 49696 times by 1 test: end of blockExecuted by:
| 49696 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | b->top = top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | b->flags |= 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | return executed 89076 times by 1 test: 1;return 1;Executed by:
executed 89076 times by 1 test: return 1;Executed by:
| 89076 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | const BIGNUM *m, BN_CTX *ctx, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | BN_MONT_CTX *in_mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | int i, bits, ret = 0, window, wvalue, wmask, window0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | int top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | int numPowers; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | unsigned char *powerbufFree = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | int powerbufLen = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | unsigned char *powerbuf = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | BIGNUM tmp, am; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | if (!BN_is_odd(m)
| 2-11073 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | ERR_put_error(3,(124),(102),__FILE__,614); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | top = m->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | bits = p->top * (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | if (bits == 0
| 15-11058 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | if (BN_abs_is_word(m, 1)
| 4-11 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } executed 4 times by 1 test: else {end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | ret = (BN_set_word((rr),1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } executed 11 times by 1 test: end of blockExecuted by:
| 11 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | return executed 15 times by 1 test: ret;return ret;Executed by:
executed 15 times by 1 test: return ret;Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | if (in_mont !=
| 2043-9015 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ((void *)0)
| 2043-9015 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | mont = in_mont; executed 9015 times by 1 test: mont = in_mont;Executed by:
| 9015 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | if ((
| 0-2043 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ((void *)0)
| 0-2043 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | if (!BN_MONT_CTX_set(mont, m, ctx)
| 0-2043 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } executed 2043 times by 1 test: end of blockExecuted by:
| 2043 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | if (!a->neg
| 0-11058 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | if ((
| 1-5759 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | && rsaz_avx2_eligible()
| 0-5174 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | if ( | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | ((
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | == bn_wexpand(rr, 16)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | RSAZ_1024_mod_exp_avx2(rr->d, a->d, p->d, m->d, mont->RR.d, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | mont->n0[0]); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | rr->top = 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | rr->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | bn_correct_top(rr); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } else if ((
| 19-10389 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | if ( | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | ((
| 0-616 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | == bn_wexpand(rr, 8)
| 0-616 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | RSAZ_512_mod_exp(rr->d, a->d, p->d, m->d, mont->n0[0], mont->RR.d); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | rr->top = 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | rr->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | bn_correct_top(rr); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | goto executed 616 times by 1 test: err;goto err;Executed by:
executed 616 times by 1 test: goto err;Executed by:
| 616 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } executed 10442 times by 1 test: end of blockExecuted by:
| 10442 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | window = ((
| 0-7269 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | if (window >= 5
| 2580-7862 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | window = 5; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | powerbufLen += top * sizeof(mont->N.d[0]); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } executed 7862 times by 1 test: end of blockExecuted by:
| 7862 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | (void)0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | numPowers = 1 << window; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | powerbufLen += sizeof(m->d[0]) * (top * numPowers + | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | ((2 * top) > | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | numPowers ? (2 * top) : numPowers)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | if (powerbufLen < 3072
| 2799-7643 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | powerbufFree = executed 2799 times by 1 test: powerbufFree = __builtin_alloca ( powerbufLen + ( 64 ) ) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | executed 2799 times by 1 test: powerbufFree = __builtin_alloca ( powerbufLen + ( 64 ) ) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | __builtin_alloca ( executed 2799 times by 1 test: powerbufFree = __builtin_alloca ( powerbufLen + ( 64 ) ) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | powerbufLen + ( 64 ) executed 2799 times by 1 test: powerbufFree = __builtin_alloca ( powerbufLen + ( 64 ) ) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | ) executed 2799 times by 1 test: powerbufFree = __builtin_alloca ( powerbufLen + ( 64 ) ) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | ; executed 2799 times by 1 test: powerbufFree = __builtin_alloca ( powerbufLen + ( 64 ) ) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | if ((
| 0-7643 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | CRYPTO_malloc(powerbufLen + ( 64 ), __FILE__, 716))
| 0-7643 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | ==
| 0-7643 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | ((void *)0)
| 0-7643 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | powerbuf = ((unsigned char*)(powerbufFree) + (( 64 ) - (((size_t)(powerbufFree)) & ((( 64 ) - 1))))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | memset(powerbuf, 0, powerbufLen); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | if (powerbufLen < 3072
| 2799-7643 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | powerbufFree = executed 2799 times by 1 test: powerbufFree = ((void *)0) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | ((void *)0) executed 2799 times by 1 test: powerbufFree = ((void *)0) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | ; executed 2799 times by 1 test: powerbufFree = ((void *)0) ;Executed by:
| 2799 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | tmp.d = (unsigned long *)(powerbuf + sizeof(m->d[0]) * top * numPowers); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | am.d = tmp.d + top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | tmp.top = am.top = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | tmp.dmax = am.dmax = top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | tmp.neg = am.neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | tmp.flags = am.flags = 0x02; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | if (m->d[top - 1] & (((unsigned long)1) << ((8 * 8) - 1))
| 2717-7725 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | tmp.d[0] = (0 - m->d[0]) & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | for (i = 1; i < top
| 7725-141477 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | tmp.d[i] = (~m->d[i]) & (0xffffffffffffffffL); executed 141477 times by 1 test: tmp.d[i] = (~m->d[i]) & (0xffffffffffffffffL);Executed by:
| 141477 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | tmp.top = top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } executed 7725 times by 1 test: elseend of blockExecuted by:
| 7725 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | if (!bn_to_mont_fixed_top(&tmp, BN_value_one(), mont, ctx)
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | if (a->neg
| 0-10442 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | if (!BN_nnmod(&am, a, m, ctx)
| 0-22 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | if (!bn_to_mont_fixed_top(&am, &am, mont, ctx)
| 0-22 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } executed 22 times by 1 test: else if (!bn_to_mont_fixed_top(&am, a, mont, ctx)end of blockExecuted by:
| 0-10420 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | if (window == 5
| 0-7862 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | void bn_mul_mont_gather5(unsigned long *rp, const unsigned long *ap, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | const void *table, const unsigned long *np, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | const unsigned long *n0, int num, int power); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | void bn_scatter5(const unsigned long *inp, size_t num, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | void *table, size_t power); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | void bn_gather5(unsigned long *out, size_t num, void *table, size_t power); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | void bn_power5(unsigned long *rp, const unsigned long *ap, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | const void *table, const unsigned long *np, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | const unsigned long *n0, int num, int power); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | int bn_get_bits5(const unsigned long *ap, int off); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | int bn_from_montgomery(unsigned long *rp, const unsigned long *ap, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | const unsigned long *not_used, const unsigned long *np, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | const unsigned long *n0, int num); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | unsigned long *n0 = mont->n0, *np; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | for (i = am.top; i < top
| 0-7862 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | am.d[i] = 0; never executed: am.d[i] = 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | for (i = tmp.top; i < top
| 0-7862 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | tmp.d[i] = 0; never executed: tmp.d[i] = 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | for (np = am.d + top, i = 0; i < top
| 7862-145430 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | np[i] = mont->N.d[i]; executed 145430 times by 1 test: np[i] = mont->N.d[i];Executed by:
| 145430 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | bn_scatter5(tmp.d, top, powerbuf, 0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | bn_scatter5(am.d, am.top, powerbuf, 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | bn_mul_mont(tmp.d, am.d, am.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | bn_scatter5(tmp.d, top, powerbuf, 2); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | for (i = 4; i < 32
| 7862-23586 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | bn_scatter5(tmp.d, top, powerbuf, i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } executed 23586 times by 1 test: end of blockExecuted by:
| 23586 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | for (i = 3; i < 8
| 7862-23586 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | int j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | bn_scatter5(tmp.d, top, powerbuf, i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | for (j = 2 * i; j < 32
| 23586-55034 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | bn_scatter5(tmp.d, top, powerbuf, j); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } executed 55034 times by 1 test: end of blockExecuted by:
| 55034 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } executed 23586 times by 1 test: end of blockExecuted by:
| 23586 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | for (; i < 16
| 7862-31448 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | bn_scatter5(tmp.d, top, powerbuf, i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | bn_scatter5(tmp.d, top, powerbuf, 2 * i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } executed 31448 times by 1 test: end of blockExecuted by:
| 31448 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | for (; i < 32
| 7862-62896 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | bn_scatter5(tmp.d, top, powerbuf, i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } executed 62896 times by 1 test: end of blockExecuted by:
| 62896 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | window0 = (bits - 1) % 5 + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | wmask = (1 << window0) - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | bits -= window0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | wvalue = bn_get_bits(p, bits) & wmask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | bn_gather5(tmp.d, top, powerbuf, wvalue); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | if (top & 7
| 2340-5522 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | while (bits > 0
| 2340-686189 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | bn_mul_mont_gather5(tmp.d, tmp.d, powerbuf, np, n0, top, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | bn_get_bits5(p->d, bits -= 5)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } executed 686189 times by 1 test: end of blockExecuted by:
| 686189 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } executed 2340 times by 1 test: else {end of blockExecuted by:
| 2340 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | while (bits > 0
| 5522-1135874 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | bn_power5(tmp.d, tmp.d, powerbuf, np, n0, top, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | bn_get_bits5(p->d, bits -= 5)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } executed 1135874 times by 1 test: end of blockExecuted by:
| 1135874 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } executed 5522 times by 1 test: end of blockExecuted by:
| 5522 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | ret = bn_from_montgomery(tmp.d, tmp.d, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | , np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | tmp.top = top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | bn_correct_top(&tmp); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | if (ret
| 2340-5522 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | if (!BN_copy(rr, &tmp)
| 0-5522 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | ret = 0; never executed: ret = 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | goto executed 5522 times by 1 test: err;goto err;Executed by:
executed 5522 times by 1 test: goto err;Executed by:
| 5522 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } executed 2340 times by 1 test: elseend of blockExecuted by:
| 2340 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 0, window)
| 0-2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&am, top, powerbuf, 1, window)
| 0-2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | if (window > 1
| 0-2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | if (!bn_mul_mont_fixed_top(&tmp, &am, &am, mont, ctx)
| 0-2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 2,
| 0-2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | window)
| 0-2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | for (i = 3; i < numPowers
| 2580-19220 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | if (!bn_mul_mont_fixed_top(&tmp, &am, &tmp, mont, ctx)
| 0-19220 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, i,
| 0-19220 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | window)
| 0-19220 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } executed 19220 times by 1 test: end of blockExecuted by:
| 19220 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } executed 2580 times by 1 test: end of blockExecuted by:
| 2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | window0 = (bits - 1) % window + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | wmask = (1 << window0) - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | bits -= window0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | wvalue = bn_get_bits(p, bits) & wmask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&tmp, top, powerbuf, wvalue,
| 0-2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | window)
| 0-2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | wmask = (1 << window) - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | while (bits > 0
| 2580-86496 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | for (i = 0; i < window
| 86496-308394 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | if (!bn_mul_mont_fixed_top(&tmp, &tmp, &tmp, mont, ctx)
| 0-308394 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | bits -= window; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | wvalue = bn_get_bits(p, bits) & wmask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&am, top, powerbuf, wvalue,
| 0-86496 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | window)
| 0-86496 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | if (!bn_mul_mont_fixed_top(&tmp, &tmp, &am, mont, ctx)
| 0-86496 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } executed 86496 times by 1 test: end of blockExecuted by:
| 86496 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } executed 2580 times by 1 test: end of blockExecuted by:
| 2580 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | if (!BN_from_montgomery(rr, &tmp, mont, ctx)
| 0-4920 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | err: code before this statement executed 4920 times by 1 test: err:Executed by:
| 4920 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | if (in_mont ==
| 2043-9015 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | ((void *)0)
| 2043-9015 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | BN_MONT_CTX_free(mont); executed 2043 times by 1 test: BN_MONT_CTX_free(mont);Executed by:
| 2043 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | if (powerbuf !=
| 616-10442 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | ((void *)0)
| 616-10442 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | OPENSSL_cleanse(powerbuf, powerbufLen); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | CRYPTO_free(powerbufFree, __FILE__, 1121); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } executed 10442 times by 1 test: end of blockExecuted by:
| 10442 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | return executed 11058 times by 1 test: ret;return ret;Executed by:
executed 11058 times by 1 test: return ret;Executed by:
| 11058 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | int BN_mod_exp_mont_word(BIGNUM *rr, unsigned long a, const BIGNUM *p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | int b, bits, ret = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | int r_is_one; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | unsigned long w, next_w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | BIGNUM *r, *t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | BIGNUM *swap_tmp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | if (BN_get_flags(p, 0x04) != 0
| 0-2729 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | || BN_get_flags(m, 0x04) != 0
| 0-2729 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | ERR_put_error(3,(117),((2|64)),__FILE__,1156); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | if (!BN_is_odd(m)
| 0-2729 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | ERR_put_error(3,(117),(102),__FILE__,1164); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | if (m->top == 1
| 112-2617 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | a %= m->d[0]; executed 112 times by 1 test: a %= m->d[0];Executed by:
| 112 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | if (bits == 0
| 10-2719 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | if (BN_abs_is_word(m, 1)
| 3-7 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } executed 7 times by 1 test: else {end of blockExecuted by:
| 7 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | ret = (BN_set_word((rr),1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | return executed 10 times by 1 test: ret;return ret;Executed by:
executed 10 times by 1 test: return ret;Executed by:
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | if (a == 0
| 2-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | return executed 2 times by 1 test: ret;return ret;Executed by:
executed 2 times by 1 test: return ret;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | r = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | t = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | if (t ==
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | ((void *)0)
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | if (in_mont !=
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | ((void *)0)
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | mont = in_mont; never executed: mont = in_mont; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | if ((
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | ((void *)0)
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | if (!BN_MONT_CTX_set(mont, m, ctx)
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | } executed 2717 times by 1 test: end of blockExecuted by:
| 2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | r_is_one = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | w = a; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | for (b = bits - 2; b >= 0
| 2717-373922 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | next_w = w * w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | if ((
| 83268-290654 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | if (r_is_one
| 2403-80865 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | if (!(BN_set_word(r, (w))
| 0-2403 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | r_is_one = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } executed 2403 times by 1 test: else {end of blockExecuted by:
| 2403 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | if (!(BN_mul_word(r, (w))
| 0-80865 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | ((void *)0)
| 0-80865 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | ,(t),(r),(m),(ctx))
| 0-80865 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } executed 80865 times by 1 test: end of blockExecuted by:
| 80865 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | next_w = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } executed 83268 times by 1 test: end of blockExecuted by:
| 83268 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | w = next_w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | if (!r_is_one
| 7308-366614 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)
| 0-366614 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } executed 366614 times by 1 test: end of blockExecuted by:
| 366614 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | if (BN_is_bit_set(p, b)
| 30032-343890 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | next_w = w * a; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | if ((
| 51661-292229 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | if (r_is_one
| 270-51391 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | if (!(BN_set_word(r, (w))
| 0-270 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | r_is_one = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } executed 270 times by 1 test: else {end of blockExecuted by:
| 270 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | if (!(BN_mul_word(r, (w))
| 0-51391 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | ((void *)0)
| 0-51391 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | ,(t),(r),(m),(ctx))
| 0-51391 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } executed 51391 times by 1 test: end of blockExecuted by:
| 51391 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | next_w = a; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } executed 51661 times by 1 test: end of blockExecuted by:
| 51661 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | w = next_w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } executed 343890 times by 1 test: end of blockExecuted by:
| 343890 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } executed 373922 times by 1 test: end of blockExecuted by:
| 373922 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | if (w != 1
| 157-2560 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | if (r_is_one
| 39-2521 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | if (!(BN_set_word(r, (w))
| 0-39 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | r_is_one = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | } executed 39 times by 1 test: else {end of blockExecuted by:
| 39 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | if (!(BN_mul_word(r, (w))
| 0-2521 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | ((void *)0)
| 0-2521 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | ,(t),(r),(m),(ctx))
| 0-2521 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | } executed 2521 times by 1 test: end of blockExecuted by:
| 2521 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | if (r_is_one
| 5-2712 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | if (!(BN_set_word((rr),1))
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | } executed 5 times by 1 test: else {end of blockExecuted by:
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | if (!BN_from_montgomery(rr, r, mont, ctx)
| 0-2712 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | } executed 2712 times by 1 test: end of blockExecuted by:
| 2712 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | err: code before this statement executed 2717 times by 1 test: err:Executed by:
| 2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | if (in_mont ==
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | ((void *)0)
| 0-2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | BN_MONT_CTX_free(mont); executed 2717 times by 1 test: BN_MONT_CTX_free(mont);Executed by:
| 2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | return executed 2717 times by 1 test: ret;return ret;Executed by:
executed 2717 times by 1 test: return ret;Executed by:
| 2717 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | const BIGNUM *m, BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | int start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | BIGNUM *d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | BIGNUM *val[32]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | if (BN_get_flags(p, 0x04) != 0
| 0-728 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | || BN_get_flags(a, 0x04) != 0
| 0-728 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | || BN_get_flags(m, 0x04) != 0
| 0-728 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | ERR_put_error(3,(126),((2|64)),__FILE__,1288); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | if (bits == 0
| 12-716 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | if (BN_abs_is_word(m, 1)
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | (BN_set_word((r),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } executed 6 times by 1 test: else {end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | ret = (BN_set_word((r),1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | return executed 12 times by 1 test: ret;return ret;Executed by:
executed 12 times by 1 test: return ret;Executed by:
| 12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | d = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | val[0] = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | if (val[0] ==
| 0-716 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | ((void *)0)
| 0-716 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | if (!BN_nnmod(val[0], a, m, ctx)
| 0-716 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | if (BN_is_zero(val[0])
| 56-660 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | (BN_set_word((r),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | goto executed 56 times by 1 test: err;goto err;Executed by:
executed 56 times by 1 test: goto err;Executed by:
| 56 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | window = ((
| 39-621 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | if (window > 1
| 247-413 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | if (!BN_mod_mul(d, val[0], val[0], m, ctx)
| 0-413 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | j = 1 << (window - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | for (i = 1; i < j
| 413-5343 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | if (((
| 0-5343 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | ((void *)0)
| 0-5343 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | )
| 0-5343 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | !BN_mod_mul(val[i], val[i - 1], d, m, ctx)
| 0-5343 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } executed 5343 times by 1 test: end of blockExecuted by:
| 5343 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | } executed 413 times by 1 test: end of blockExecuted by:
| 413 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | wstart = bits - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | if (!(BN_set_word((r),1))
| 0-660 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | for (;;) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | if (BN_is_bit_set(p, wstart) == 0
| 23776-64116 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | if (!start
| 0-64116 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | if (!BN_mod_mul(r, r, r, m, ctx)
| 0-64116 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | if (wstart == 0
| 298-63818 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | break; executed 298 times by 1 test: break;Executed by:
| 298 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | wstart--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | continue; executed 63818 times by 1 test: continue;Executed by:
| 63818 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | j = wstart; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | wvalue = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | for (i = 1; i < window
| 23547-93047 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | if (wstart - i < 0
| 229-92818 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | break; executed 229 times by 1 test: break;Executed by:
| 229 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | if (BN_is_bit_set(p, wstart - i)
| 40957-51861 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | wvalue <<= (i - wend); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | wvalue |= 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | wend = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | } executed 51861 times by 1 test: end of blockExecuted by:
| 51861 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } executed 92818 times by 1 test: end of blockExecuted by:
| 92818 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | j = wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | if (!start
| 660-23116 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | for (i = 0; i < j
| 23116-94651 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | if (!BN_mod_mul(r, r, r, m, ctx)
| 0-94651 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } executed 94651 times by 1 test: end of blockExecuted by:
| 94651 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | if (!BN_mod_mul(r, r, val[wvalue >> 1], m, ctx)
| 0-23776 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | wstart -= wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | start = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | if (wstart < 0
| 362-23414 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | break; executed 362 times by 1 test: break;Executed by:
| 362 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | } executed 23414 times by 1 test: end of blockExecuted by:
| 23414 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | err: code before this statement executed 660 times by 1 test: err:Executed by:
| 660 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | return executed 716 times by 1 test: ret;return ret;Executed by:
executed 716 times by 1 test: return ret;Executed by:
| 716 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |