Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/bn/bn_exp.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
8 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
9 | BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
10 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
11 | int i, bits, ret = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
12 | BIGNUM *v, *rr; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
14 | if (((
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
16 | ERR_put_error(3,(0xfff),((2|64)),__FILE__,132); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
17 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
18 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
20 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
21 | if ((
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
22 | rr = BN_CTX_get(ctx); never executed: rr = BN_CTX_get(ctx); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
23 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
24 | rr = r; executed 25 times by 1 test: rr = r; Executed by:
| 25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
25 | v = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
26 | if (rr ==
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
27 | ((void *)0)
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
28 | || v ==
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
29 | ((void *)0)
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
30 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
31 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
32 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
33 | if (BN_copy(v, a) ==
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
34 | ((void *)0)
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
35 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
36 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
37 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
39 | if ((((
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
40 | if (BN_copy(rr, a) ==
| 0-16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
41 | ((void *)0)
| 0-16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
42 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
43 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
44 | } executed 16 times by 1 test: else {end of block Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
45 | if (!(BN_set_word((rr),1))
| 0-9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
46 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
47 | } executed 9 times by 1 test: end of block Executed by:
| 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
49 | for (i = 1; i < bits
| 25-75 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
50 | if (!BN_sqr(v, v, ctx)
| 0-75 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
51 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
52 | if (BN_is_bit_set(p, i)
| 30-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
53 | if (!BN_mul(rr, rr, v, ctx)
| 0-45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
54 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
55 | } executed 45 times by 1 test: end of block Executed by:
| 45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
56 | } executed 75 times by 1 test: end of block Executed by:
| 75 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
57 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
59 | err: code before this statement executed 25 times by 1 test: err: Executed by:
| 25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
60 | if (r != rr
| 0-25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
61 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
62 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
63 | BN_copy(r, rr); never executed: BN_copy(r, rr); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
64 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
65 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
66 | return executed 25 times by 1 test: (ret);return (ret); Executed by:
executed 25 times by 1 test: return (ret); Executed by:
| 25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
67 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
69 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
70 | BN_mod_exp_internal(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | BN_CTX *ctx, int ct) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
72 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
73 | int ret; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
75 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
76 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
77 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
78 | if ((((
| 0-294 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
79 | if (a->top == 1
| 0-233 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
80 | unsigned long A = a->d[0]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
81 | ret = BN_mod_exp_mont_word(r, A,p, m,ctx, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
82 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
83 | ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
84 | } executed 15 times by 1 test: elseend of block Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
85 | ret = BN_mod_exp_mont_ct(r, a,p, m,ctx, executed 279 times by 9 tests: ret = BN_mod_exp_mont_ct(r, a,p, m,ctx, ((void *)0) ); Executed by:
| 279 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
86 | ((void *)0) executed 279 times by 9 tests: ret = BN_mod_exp_mont_ct(r, a,p, m,ctx, ((void *)0) ); Executed by:
| 279 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
87 | ); executed 279 times by 9 tests: ret = BN_mod_exp_mont_ct(r, a,p, m,ctx, ((void *)0) ); Executed by:
| 279 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
88 | } else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
89 | ret = BN_mod_exp_recp(r, a,p, m, ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
90 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
91 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
92 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
93 | return executed 297 times by 9 tests: (ret);return (ret); Executed by:
executed 297 times by 9 tests: return (ret); Executed by:
| 297 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
94 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
96 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
97 | BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
98 | BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
99 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
100 | return executed 131 times by 2 tests: BN_mod_exp_internal(r, a, p, m, ctx,return BN_mod_exp_internal(r, a, p, m, ctx, (((p)->flags&(0x04)) != 0)); Executed by:
executed 131 times by 2 tests: return BN_mod_exp_internal(r, a, p, m, ctx, (((p)->flags&(0x04)) != 0)); Executed by:
| 131 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
101 | (((p)->flags&(0x04)) != 0)); executed 131 times by 2 tests: return BN_mod_exp_internal(r, a, p, m, ctx, (((p)->flags&(0x04)) != 0)); Executed by:
| 131 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
102 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
104 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
105 | BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
106 | BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
107 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
108 | return executed 159 times by 9 tests: BN_mod_exp_internal(r, a, p, m, ctx, 1);return BN_mod_exp_internal(r, a, p, m, ctx, 1); Executed by:
executed 159 times by 9 tests: return BN_mod_exp_internal(r, a, p, m, ctx, 1); Executed by:
| 159 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
109 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
112 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
113 | BN_mod_exp_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
114 | BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
115 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
116 | return executed 7 times by 2 tests: BN_mod_exp_internal(r, a, p, m, ctx, 0);return BN_mod_exp_internal(r, a, p, m, ctx, 0); Executed by:
executed 7 times by 2 tests: return BN_mod_exp_internal(r, a, p, m, ctx, 0); Executed by:
| 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
117 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
120 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
121 | BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
122 | BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
123 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
124 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
125 | int start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
126 | BIGNUM *aa; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
128 | BIGNUM *val[32]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
129 | BN_RECP_CTX recp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
131 | if (((
| 0-304 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
133 | ERR_put_error(3,(0xfff),((2|64)),__FILE__,266); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
134 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
135 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
136 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
137 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
138 | if (bits == 0
| 1-303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
140 | if (((((((
| 0-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
141 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
142 | (BN_set_word((r),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
143 | } executed 1 time by 1 test: elseend of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
144 | ret = (BN_set_word((r),1)); never executed: ret = (BN_set_word((r),1)); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
145 | return executed 1 time by 1 test: ret;return ret; Executed by:
executed 1 time by 1 test: return ret; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
146 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
148 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
149 | if ((
| 0-303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
150 | ((void *)0)
| 0-303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
151 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
152 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
153 | if ((
| 0-303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
154 | ((void *)0)
| 0-303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
155 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
156 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
158 | BN_RECP_CTX_init(&recp); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
159 | if (m->neg
| 0-303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
161 | if (!BN_copy(aa, m)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
162 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
163 | aa->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
164 | if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
165 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
166 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
167 | if (BN_RECP_CTX_set(&recp, m, ctx) <= 0
| 0-303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
168 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
169 | } executed 303 times by 2 tests: end of block Executed by:
| 303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
170 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
171 | if (!BN_nnmod(val[0], a, m, ctx)
| 3-300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
172 | goto executed 3 times by 1 test: err;goto err; Executed by:
executed 3 times by 1 test: goto err; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
173 | if (((
| 0-300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
174 | (BN_set_word((r),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
175 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
176 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
177 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
179 | window = ((
| 0-300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
180 | if (window > 1
| 0-300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
181 | if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx)
| 0-300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
182 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
183 | j = 1 << (window - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
184 | for (i = 1; i < j
| 300-4500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
185 | if (((
| 0-4500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
186 | ((void *)0)
| 0-4500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
187 | )
| 0-4500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
188 | !BN_mod_mul_reciprocal(val[i], val[i - 1],
| 0-4500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
189 | aa, &recp, ctx)
| 0-4500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
190 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
191 | } executed 4500 times by 2 tests: end of block Executed by:
| 4500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
192 | } executed 300 times by 2 tests: end of block Executed by:
| 300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
194 | start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
197 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
198 | wstart = bits - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
199 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
201 | if (!(BN_set_word((r),1))
| 0-300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
202 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
204 | for (;;) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
205 | if (BN_is_bit_set(p, wstart) == 0
| 19232-37574 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
206 | if (!start
| 0-37574 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
207 | if (!BN_mod_mul_reciprocal(r, r,r, &recp, ctx)
| 0-37574 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
208 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
209 | if (wstart == 0
| 210-37364 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
210 | break; executed 210 times by 2 tests: break; Executed by:
| 210 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
211 | wstart--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
212 | continue; executed 37364 times by 2 tests: continue; Executed by:
| 37364 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
213 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
217 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
218 | j = wstart; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
219 | wvalue = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
220 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
221 | for (i = 1; i < window
| 19096-76732 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
222 | if (wstart - i < 0
| 136-76596 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
223 | break; executed 136 times by 1 test: break; Executed by:
| 136 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
224 | if (BN_is_bit_set(p, wstart - i)
| 36780-39816 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
225 | wvalue <<= (i - wend); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
226 | wvalue |= 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
227 | wend = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
228 | } executed 39816 times by 2 tests: end of block Executed by:
| 39816 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
229 | } executed 76596 times by 2 tests: end of block Executed by:
| 76596 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
230 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
232 | j = wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
234 | if (!start
| 300-18932 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
235 | for (i = 0; i < j
| 18932-76610 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
236 | if (!BN_mod_mul_reciprocal(r, r,r, &recp, ctx)
| 0-76610 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
237 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
238 | } executed 76610 times by 2 tests: end of block Executed by:
| 76610 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
239 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
241 | if (!BN_mod_mul_reciprocal(r, r,val[wvalue >> 1], &recp, ctx)
| 0-19232 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
242 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
245 | wstart -= wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
246 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
247 | start = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
248 | if (wstart < 0
| 90-19142 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
249 | break; executed 90 times by 1 test: break; Executed by:
| 90 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
250 | } executed 19142 times by 2 tests: end of block Executed by:
| 19142 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
251 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
253 | err: code before this statement executed 300 times by 2 tests: err: Executed by:
| 300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
254 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
255 | BN_RECP_CTX_free(&recp); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
256 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
257 | return executed 303 times by 2 tests: (ret);return (ret); Executed by:
executed 303 times by 2 tests: return (ret); Executed by:
| 303 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
258 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
259 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
260 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
261 | BN_mod_exp_mont_internal(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
262 | BN_CTX *ctx, BN_MONT_CTX *in_mont, int ct) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
263 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
264 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
265 | int start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
266 | BIGNUM *d, *r; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
267 | const BIGNUM *aa; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
269 | BIGNUM *val[32]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
270 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
271 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
272 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
274 | if (ct
| 402-4014 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
275 | return executed 4014 times by 12 tests: 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 4014 times by 12 tests: return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont); Executed by:
| 4014 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
276 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
277 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
278 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
279 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
280 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
282 | if (!(((
| 0-402 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
283 | ERR_put_error(3,(0xfff),(102),__FILE__,408); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
284 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
285 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
286 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
287 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
288 | if (bits == 0
| 2-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
290 | if (((((((
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
291 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
292 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
293 | } executed 2 times by 1 test: elseend of block Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
294 | ret = (BN_set_word((rr),1)); never executed: ret = (BN_set_word((rr),1)); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
295 | return executed 2 times by 1 test: ret;return ret; Executed by:
executed 2 times by 1 test: return ret; Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
296 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
297 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
298 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
299 | if ((
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
300 | ((void *)0)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
301 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
302 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
303 | if ((
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
304 | ((void *)0)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
305 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
306 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
307 | if ((
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
308 | ((void *)0)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
309 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
310 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
311 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
312 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
313 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
314 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
315 | if (in_mont !=
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
316 | ((void *)0)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
317 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
318 | mont = in_mont; never executed: mont = in_mont; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
319 | else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
320 | if ((
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
321 | ((void *)0)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
322 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
323 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
324 | if (!BN_MONT_CTX_set(mont, m, ctx)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
325 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
326 | } executed 400 times by 1 test: end of block Executed by:
| 400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
328 | if (a->neg
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
329 | if (!BN_nnmod(val[0], a,m, ctx)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
330 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
331 | aa = val[0]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
332 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
333 | aa = a; executed 400 times by 1 test: aa = a; Executed by:
| 400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
334 | if (((
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
335 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
336 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
337 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
338 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
339 | if (!BN_mod_mul_montgomery( (val[0]),(aa),&((mont)->RR),(mont),(ctx))
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
340 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
342 | window = ((
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
343 | if (window > 1
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
344 | if (!BN_mod_mul_montgomery(d, val[0], val[0], mont, ctx)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
345 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
346 | j = 1 << (window - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
347 | for (i = 1; i < j
| 400-6000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
348 | if (((
| 0-6000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
349 | ((void *)0)
| 0-6000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
350 | )
| 0-6000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
351 | !BN_mod_mul_montgomery(val[i], val[i - 1],
| 0-6000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
352 | d, mont, ctx)
| 0-6000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
353 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
354 | } executed 6000 times by 1 test: end of block Executed by:
| 6000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
355 | } executed 400 times by 1 test: end of block Executed by:
| 400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
356 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
357 | start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
358 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
359 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
360 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
361 | wstart = bits - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
362 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
364 | if (!BN_mod_mul_montgomery( (r),(BN_value_one()),&((mont)->RR),(mont),(ctx))
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
365 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
366 | for (;;) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
367 | if (BN_is_bit_set(p, wstart) == 0
| 21664-41348 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
368 | if (!start
| 0-41348 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
369 | if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)
| 0-41348 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
370 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
371 | } executed 41348 times by 1 test: end of block Executed by:
| 41348 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
372 | if (wstart == 0
| 220-41128 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
373 | break; executed 220 times by 1 test: break; Executed by:
| 220 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
374 | wstart--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
375 | continue; executed 41128 times by 1 test: continue; Executed by:
| 41128 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
376 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
378 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
381 | j = wstart; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
382 | wvalue = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
383 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
384 | for (i = 1; i < window
| 21392-86264 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
385 | if (wstart - i < 0
| 272-85992 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
386 | break; executed 272 times by 1 test: break; Executed by:
| 272 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
387 | if (BN_is_bit_set(p, wstart - i)
| 42960-43032 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
388 | wvalue <<= (i - wend); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
389 | wvalue |= 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
390 | wend = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
391 | } executed 43032 times by 1 test: end of block Executed by:
| 43032 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
392 | } executed 85992 times by 1 test: end of block Executed by:
| 85992 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
393 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
395 | j = wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
396 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
397 | if (!start
| 400-21264 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
398 | for (i = 0; i < j
| 21264-85820 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
399 | if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)
| 0-85820 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
400 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
401 | } executed 85820 times by 1 test: end of block Executed by:
| 85820 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
402 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
403 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
404 | if (!BN_mod_mul_montgomery(r, r, val[wvalue >> 1], mont, ctx)
| 0-21664 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
405 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
406 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
408 | wstart -= wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
409 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
410 | start = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
411 | if (wstart < 0
| 180-21484 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
412 | break; executed 180 times by 1 test: break; Executed by:
| 180 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
413 | } executed 21484 times by 1 test: end of block Executed by:
| 21484 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
414 | if (!BN_from_montgomery(rr, r,mont, ctx)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
415 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
416 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
417 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
418 | err: code before this statement executed 400 times by 1 test: err: Executed by:
| 400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
419 | if ((
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
420 | ((void *)0)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
421 | )
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
422 | ((void *)0)
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
423 | )
| 0-400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
424 | BN_MONT_CTX_free(mont); executed 400 times by 1 test: BN_MONT_CTX_free(mont); Executed by:
| 400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
425 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
426 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
427 | return executed 400 times by 1 test: (ret);return (ret); Executed by:
executed 400 times by 1 test: return (ret); Executed by:
| 400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
428 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
430 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
431 | BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
432 | BN_CTX *ctx, BN_MONT_CTX *in_mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
433 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
434 | return executed 201 times by 1 test: BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont,return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, (((p)->flags&(0x04)) != 0)); Executed by:
executed 201 times by 1 test: return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, (((p)->flags&(0x04)) != 0)); Executed by:
| 201 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
435 | (((p)->flags&(0x04)) != 0)); executed 201 times by 1 test: return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, (((p)->flags&(0x04)) != 0)); Executed by:
| 201 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
436 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
438 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
439 | BN_mod_exp_mont_ct(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
440 | BN_CTX *ctx, BN_MONT_CTX *in_mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
441 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
442 | return executed 4014 times by 12 tests: BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 1);return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 1); Executed by:
executed 4014 times by 12 tests: return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 1); Executed by:
| 4014 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
443 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
444 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
445 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
446 | BN_mod_exp_mont_nonct(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
447 | BN_CTX *ctx, BN_MONT_CTX *in_mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
448 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
449 | return executed 201 times by 1 test: BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 0);return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 0); Executed by:
executed 201 times by 1 test: return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 0); Executed by:
| 201 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
450 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
451 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
453 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
454 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
455 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
456 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
457 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
458 | MOD_EXP_CTIME_COPY_TO_PREBUF(const BIGNUM *b, int top, unsigned char *buf, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
459 | int idx, int window) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
460 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
461 | int i, j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
462 | int width = 1 << window; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
463 | unsigned long *table = (unsigned long *)buf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
464 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
465 | if (top > b->top
| 258-36468 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
466 | top = b->top; executed 258 times by 4 tests: top = b->top; Executed by:
| 258 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
467 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
468 | for (i = 0, j = idx; i < top
| 36726-131835 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
469 | table[j] = b->d[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
470 | } executed 131835 times by 12 tests: end of block Executed by:
| 131835 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
472 | return executed 36726 times by 12 tests: 1;return 1; Executed by:
executed 36726 times by 12 tests: return 1; Executed by:
| 36726 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
473 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
475 | static int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
476 | MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
477 | int window) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
478 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
479 | int i, j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
480 | int width = 1 << window; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
481 | volatile unsigned long *table = (volatile unsigned long *)buf; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
482 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
483 | if ((((
| 0-118300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
484 | ((void *)0)
| 0-118300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
485 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
486 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
487 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
488 | if (window <= 3
| 19482-98818 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
489 | for (i = 0; i < top
| 19482-185525 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
490 | unsigned long acc = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
491 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
492 | for (j = 0; j < width
| 185525-446830 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
493 | acc |= table[j] & | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
494 | ((unsigned long)0 - (constant_time_eq_int(j,idx)&1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
495 | } executed 446830 times by 10 tests: end of block Executed by:
| 446830 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
496 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
497 | b->d[i] = acc; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
498 | } executed 185525 times by 10 tests: end of block Executed by:
| 185525 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
499 | } executed 19482 times by 10 tests: else {end of block Executed by:
| 19482 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
500 | int xstride = 1 << (window - 2); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
501 | unsigned long y0, y1, y2, y3; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
502 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
503 | i = idx >> (window - 2); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
504 | idx &= xstride - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
505 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
506 | y0 = (unsigned long)0 - (constant_time_eq_int(i,0)&1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
507 | y1 = (unsigned long)0 - (constant_time_eq_int(i,1)&1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
508 | y2 = (unsigned long)0 - (constant_time_eq_int(i,2)&1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
509 | y3 = (unsigned long)0 - (constant_time_eq_int(i,3)&1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
510 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
511 | for (i = 0; i < top
| 98818-356568 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
512 | unsigned long acc = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
513 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
514 | for (j = 0; j < xstride
| 356568-1815488 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
515 | acc |= ( (table[j + 0 * xstride] & y0) | | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
516 | (table[j + 1 * xstride] & y1) | | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
517 | (table[j + 2 * xstride] & y2) | | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
518 | (table[j + 3 * xstride] & y3) ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
519 | & ((unsigned long)0 - (constant_time_eq_int(j,idx)&1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
520 | } executed 1815488 times by 9 tests: end of block Executed by:
| 1815488 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
521 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
522 | b->d[i] = acc; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
523 | } executed 356568 times by 9 tests: end of block Executed by:
| 356568 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
524 | } executed 98818 times by 9 tests: end of block Executed by:
| 98818 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
525 | b->top = top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
526 | { unsigned long *ftl; int tmp_top = (b)->top; if (tmp_top > 0
executed 118084 times by 12 tests: (b)->top = tmp_top; }break; Executed by:
executed 118300 times by 12 tests: ; };end of block Executed by:
| 0-119516 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
527 | return executed 118300 times by 12 tests: 1;return 1; Executed by:
executed 118300 times by 12 tests: return 1; Executed by:
| 118300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
528 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
529 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
530 | BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
531 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
532 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
533 | int i, bits, ret = 0, window, wvalue; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
534 | int top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
535 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
536 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
537 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
538 | int numPowers; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
539 | unsigned char *powerbufFree = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
540 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
541 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
542 | int powerbufLen = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
543 | unsigned char *powerbuf = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
544 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
545 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
546 | BIGNUM tmp, am; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
547 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
548 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
549 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
550 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
551 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
552 | if (!(((
| 1-4349 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
553 | ERR_put_error(3,(0xfff),(102),__FILE__,665); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
554 | return executed 2 times by 1 test: (0);return (0); Executed by:
executed 2 times by 1 test: return (0); Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
555 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
556 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
557 | top = m->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
559 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
560 | if (bits == 0
| 9-4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
561 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
562 | if (((((((
| 0-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
563 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
564 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
565 | } executed 5 times by 1 test: elseend of block Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
566 | ret = (BN_set_word((rr),1)); executed 4 times by 1 test: ret = (BN_set_word((rr),1)); Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
567 | return executed 9 times by 2 tests: ret;return ret; Executed by:
executed 9 times by 2 tests: return ret; Executed by:
| 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
568 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
569 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
570 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
571 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
572 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
574 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
575 | if (in_mont !=
| 681-3658 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
576 | ((void *)0)
| 681-3658 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
577 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
578 | mont = in_mont; executed 3658 times by 11 tests: mont = in_mont; Executed by:
| 3658 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
579 | else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
580 | if ((
| 0-681 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
581 | ((void *)0)
| 0-681 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
582 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
583 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
584 | if (!BN_MONT_CTX_set(mont, m, ctx)
| 0-681 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
585 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
586 | } executed 681 times by 9 tests: end of block Executed by:
| 681 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
587 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
588 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
589 | window = ((
| 243-4096 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
590 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
591 | if (window == 6
| 10-4096 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
592 | window = 5; executed 233 times by 7 tests: window = 5; Executed by:
| 233 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
594 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
596 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
598 | numPowers = 1 << window; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
599 | powerbufLen = sizeof(m->d[0]) * (top * numPowers + | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
600 | ((2*top) > numPowers ? (2*top) : numPowers)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
601 | if ((
| 0-4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
602 | ( 64 ), 1)) ==
| 0-4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
603 | ((void *)0)
| 0-4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
604 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
605 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
606 | powerbuf = ((unsigned char*)(powerbufFree) + (( 64 ) - (((size_t)(powerbufFree)) & ((( 64 ) - 1))))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
607 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
608 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
609 | tmp.d = (unsigned long *)(powerbuf + sizeof(m->d[0]) * top * numPowers); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
610 | am.d = tmp.d + top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
611 | tmp.top = am.top = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
612 | tmp.dmax = am.dmax = top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
613 | tmp.neg = am.neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
614 | tmp.flags = am.flags = 0x02; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
615 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
616 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
617 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
618 | if (!BN_mod_mul_montgomery( (&tmp),(BN_value_one()),&((mont)->RR),(mont),(ctx))
| 0-4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
619 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
620 | if (a->neg
| 0-4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
621 | if (!BN_div_ct(
| 0-253 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
622 | ((void *)0)
| 0-253 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
623 | ,(&am),(a),(m),(ctx))
| 0-253 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
624 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
625 | if (!BN_mod_mul_montgomery( (&am),(&am),&((mont)->RR),(mont),(ctx))
| 0-253 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
626 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
627 | } executed 253 times by 1 test: else if (!BN_mod_mul_montgomery( (&am),(a),&((mont)->RR),(mont),(ctx))end of block Executed by:
| 0-4086 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
628 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
629 | if (window == 5
| 202-3125 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
630 | void bn_mul_mont_gather5(unsigned long *rp, const unsigned long *ap, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
631 | const void *table, const unsigned long *np, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
632 | const unsigned long *n0, int num, int power); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
633 | void bn_scatter5(const unsigned long *inp, size_t num, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
634 | void *table, size_t power); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
635 | void bn_gather5(unsigned long *out, size_t num, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
636 | void *table, size_t power); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
637 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
638 | unsigned long *np = mont->N.d, *n0 = mont->n0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
639 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
640 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
641 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
642 | for (i = am.top; i < top
| 47-1012 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
643 | am.d[i] = 0; executed 47 times by 2 tests: am.d[i] = 0; Executed by:
| 47 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
644 | for (i = tmp.top; i < top
| 83-1012 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
645 | tmp.d[i] = 0; executed 83 times by 1 test: tmp.d[i] = 0; Executed by:
| 83 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
646 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
647 | bn_scatter5(tmp.d, top, powerbuf, 0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
648 | bn_scatter5(am.d, am.top, powerbuf, 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
649 | bn_mul_mont(tmp.d, am.d, am.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
650 | bn_scatter5(tmp.d, top, powerbuf, 2); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
651 | for (i = 4; i < 32
| 1012-3036 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
652 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
653 | bn_scatter5(tmp.d, top, powerbuf, i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
654 | } executed 3036 times by 10 tests: end of block Executed by:
| 3036 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
655 | for (i = 3; i < 8
| 1012-3036 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
656 | int j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
657 | bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
658 | n0, top, i - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
659 | bn_scatter5(tmp.d, top, powerbuf, i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
660 | for (j = 2 * i; j < 32
| 3036-7084 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
661 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
662 | bn_scatter5(tmp.d, top, powerbuf, j); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
663 | } executed 7084 times by 10 tests: end of block Executed by:
| 7084 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
664 | } executed 3036 times by 10 tests: end of block Executed by:
| 3036 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
665 | for (; i < 16
| 1012-4048 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
666 | bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
667 | n0, top, i - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
668 | bn_scatter5(tmp.d, top, powerbuf, i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
669 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
670 | bn_scatter5(tmp.d, top, powerbuf, 2*i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
671 | } executed 4048 times by 10 tests: end of block Executed by:
| 4048 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
672 | for (; i < 32
| 1012-8096 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
673 | bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
674 | n0, top, i - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
675 | bn_scatter5(tmp.d, top, powerbuf, i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
676 | } executed 8096 times by 10 tests: end of block Executed by:
| 8096 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
677 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
678 | bits--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
679 | for (wvalue = 0, i = bits % 5; i >= 0
| 1012-1902 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
680 | wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); executed 1902 times by 10 tests: wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); Executed by:
| 1902 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
681 | bn_gather5(tmp.d, top, powerbuf, wvalue); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
682 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
684 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
685 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
686 | while (bits >= 0
| 1012-121377 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
687 | for (wvalue = 0, i = 0; i < 5
| 121377-606885 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
688 | wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); executed 606885 times by 10 tests: wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); Executed by:
| 606885 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
689 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
690 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
691 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
692 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
693 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
694 | bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
695 | bn_mul_mont_gather5(tmp.d, tmp.d, powerbuf, np, n0, top, wvalue); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
696 | } executed 121377 times by 10 tests: end of block Executed by:
| 121377 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
697 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
698 | tmp.top = top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
699 | { unsigned long *ftl; int tmp_top = (&tmp)->top; if (tmp_top > 0
executed 1009 times by 10 tests: (&tmp)->top = tmp_top; }break; Executed by:
executed 1012 times by 10 tests: ; };end of block Executed by:
| 0-1082 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
700 | } executed 1012 times by 10 tests: elseend of block Executed by:
| 1012 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
701 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
702 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
703 | if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 0,
| 0-3327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
704 | window)
| 0-3327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
705 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
706 | if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&am, top, powerbuf, 1,
| 0-3327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
707 | window)
| 0-3327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
708 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
709 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
710 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
712 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
713 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
714 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
715 | if (window > 1
| 819-2508 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
716 | if (!BN_mod_mul_montgomery(&tmp, &am, &am, mont, ctx)
| 0-2508 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
717 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
718 | if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf,
| 0-2508 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
719 | 2, window)
| 0-2508 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
720 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
721 | for (i = 3; i < numPowers
| 2508-27564 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
722 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
723 | if (!BN_mod_mul_montgomery(&tmp, &am, &tmp,
| 0-27564 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
724 | mont, ctx)
| 0-27564 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
725 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
726 | if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top,
| 0-27564 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
727 | powerbuf, i, window)
| 0-27564 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
728 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
729 | } executed 27564 times by 10 tests: end of block Executed by:
| 27564 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
730 | } executed 2508 times by 10 tests: end of block Executed by:
| 2508 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
732 | bits--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
733 | for (wvalue = 0, i = bits % window; i >= 0
| 3327-7001 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
734 | wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); executed 7001 times by 12 tests: wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); Executed by:
| 7001 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
735 | if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&tmp, top, powerbuf,
| 0-3327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
736 | wvalue, window)
| 0-3327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
737 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
739 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
740 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
741 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
742 | while (bits >= 0
| 3327-114973 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
743 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
744 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
745 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
746 | for (i = 0; i < window
| 114973-461461 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
747 | if (!BN_mod_mul_montgomery(&tmp, &tmp, &tmp,
| 0-461461 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
748 | mont, ctx)
| 0-461461 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
749 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
750 | wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
751 | } executed 461461 times by 12 tests: end of block Executed by:
| 461461 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
752 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
753 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
754 | if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&am, top, powerbuf,
| 0-114973 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
755 | wvalue, window)
| 0-114973 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
756 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
757 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
758 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
759 | if (!BN_mod_mul_montgomery(&tmp, &tmp, &am, mont, ctx)
| 0-114973 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
760 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
761 | } executed 114973 times by 12 tests: end of block Executed by:
| 114973 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
762 | } executed 3327 times by 12 tests: end of block Executed by:
| 3327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
763 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
764 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
765 | if (!BN_from_montgomery(rr, &tmp, mont, ctx)
| 0-4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
766 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
767 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
768 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
769 | err: code before this statement executed 4339 times by 12 tests: err: Executed by:
| 4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
770 | if ((
| 681-3658 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
771 | ((void *)0)
| 681-3658 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
772 | )
| 0-3658 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
773 | ((void *)0)
| 0-681 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
774 | )
| 0-681 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
775 | BN_MONT_CTX_free(mont); executed 681 times by 9 tests: BN_MONT_CTX_free(mont); Executed by:
| 681 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
776 | freezero(powerbufFree, powerbufLen + ( 64 )); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
777 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
778 | return executed 4339 times by 12 tests: (ret);return (ret); Executed by:
executed 4339 times by 12 tests: return (ret); Executed by:
| 4339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
779 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
780 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
781 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
782 | BN_mod_exp_mont_word(BIGNUM *rr, unsigned long a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
783 | BN_CTX *ctx, BN_MONT_CTX *in_mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
784 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
785 | BN_MONT_CTX *mont = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
786 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
787 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
788 | int b, bits, ret = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
789 | int r_is_one; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
790 | unsigned long w, next_w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
791 | BIGNUM *d, *r, *t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
792 | BIGNUM *swap_tmp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
793 | if (((
| 0-16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
794 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
795 | ERR_put_error(3,(0xfff),((2|64)),__FILE__,935); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
796 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
797 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
798 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
799 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
800 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
801 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
802 | if (!(((
| 0-16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
803 | ERR_put_error(3,(0xfff),(102),__FILE__,943); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
804 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
805 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
806 | if (m->top == 1
| 0-16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
807 | a %= m->d[0]; executed 16 times by 2 tests: a %= m->d[0]; Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
809 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
810 | if (bits == 0
| 1-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
811 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
812 | if (((((((
| 0-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
813 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
814 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
815 | } executed 1 time by 1 test: elseend of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
816 | ret = (BN_set_word((rr),1)); never executed: ret = (BN_set_word((rr),1)); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
817 | return executed 1 time by 1 test: ret;return ret; Executed by:
executed 1 time by 1 test: return ret; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
818 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
819 | if (a == 0
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
820 | (BN_set_word((rr),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
821 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
822 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
823 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
824 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
825 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
826 | if ((
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
827 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
828 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
829 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
830 | if ((
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
831 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
832 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
833 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
834 | if ((
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
835 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
836 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
837 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
838 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
839 | if (in_mont !=
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
840 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
841 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
842 | mont = in_mont; never executed: mont = in_mont; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
843 | else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
844 | if ((
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
845 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
846 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
847 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
848 | if (!BN_MONT_CTX_set(mont, m, ctx)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
849 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
850 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
851 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
852 | r_is_one = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
853 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
854 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
857 | w = a; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
858 | for (b = bits - 2; b >= 0
| 15-259 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
859 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
860 | next_w = w * w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
861 | if ((
| 69-190 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
862 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
863 | if (r_is_one
| 5-64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
864 | if (!(BN_set_word(r, (w))
| 0-5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
865 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
866 | r_is_one = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
867 | } executed 5 times by 1 test: else {end of block Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
868 | if (!(BN_mul_word(r, (w))
| 0-64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
869 | ((void *)0)
| 0-64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
870 | ,(t),(r),(m),(ctx))
| 0-64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
871 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
872 | } executed 64 times by 1 test: end of block Executed by:
| 64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
873 | next_w = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
874 | } executed 69 times by 1 test: end of block Executed by:
| 69 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
875 | w = next_w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
876 | if (!r_is_one
| 16-243 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
877 | if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)
| 0-243 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
878 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
879 | } executed 243 times by 1 test: end of block Executed by:
| 243 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
880 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
881 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
882 | if (BN_is_bit_set(p, b)
| 129-130 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
883 | next_w = w * a; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
884 | if ((
| 61-69 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
885 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
886 | if (r_is_one
| 8-53 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
887 | if (!(BN_set_word(r, (w))
| 0-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
888 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
889 | r_is_one = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
890 | } executed 8 times by 1 test: else {end of block Executed by:
| 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
891 | if (!(BN_mul_word(r, (w))
| 0-53 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
892 | ((void *)0)
| 0-53 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
893 | ,(t),(r),(m),(ctx))
| 0-53 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
894 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
895 | } executed 53 times by 1 test: end of block Executed by:
| 53 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
896 | next_w = a; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
897 | } executed 61 times by 1 test: end of block Executed by:
| 61 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
898 | w = next_w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
899 | } executed 130 times by 1 test: end of block Executed by:
| 130 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
900 | } executed 259 times by 1 test: end of block Executed by:
| 259 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
902 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
903 | if (w != 1
| 2-13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
904 | if (r_is_one
| 2-11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
905 | if (!(BN_set_word(r, (w))
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
906 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
907 | r_is_one = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
908 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
909 | if (!(BN_mul_word(r, (w))
| 0-11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
910 | ((void *)0)
| 0-11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
911 | ,(t),(r),(m),(ctx))
| 0-11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
912 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
913 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
914 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
915 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
916 | if (r_is_one
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
917 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
918 | if (!(BN_set_word((rr),1))
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
919 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
920 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
921 | if (!BN_from_montgomery(rr, r, mont, ctx)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
922 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
923 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
924 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
925 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
926 | err: code before this statement executed 15 times by 1 test: err: Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
927 | if ((
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
928 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
929 | )
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
930 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
931 | )
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
932 | BN_MONT_CTX_free(mont); executed 15 times by 1 test: BN_MONT_CTX_free(mont); Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
933 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
934 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
935 | return executed 15 times by 1 test: (ret);return (ret); Executed by:
executed 15 times by 1 test: return (ret); Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
936 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
937 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
938 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
939 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
940 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
941 | BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
942 | BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
943 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
944 | int i, j, bits, ret = 0, wstart, wend, window, wvalue; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
945 | int start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
946 | BIGNUM *d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
947 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
948 | BIGNUM *val[32]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
949 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
950 | if (((
| 0-203 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
951 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
952 | ERR_put_error(3,(0xfff),((2|64)),__FILE__,1072); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
953 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
954 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
955 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
956 | bits = BN_num_bits(p); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
957 | if (bits == 0
| 1-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
958 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
959 | if (((((((
| 0-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
960 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
961 | (BN_set_word((r),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
962 | } executed 1 time by 1 test: elseend of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
963 | ret = (BN_set_word((r),1)); never executed: ret = (BN_set_word((r),1)); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
964 | return executed 1 time by 1 test: ret;return ret; Executed by:
executed 1 time by 1 test: return ret; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
965 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
966 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
967 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
968 | if ((
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
969 | ((void *)0)
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
970 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
971 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
972 | if ((
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
973 | ((void *)0)
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
974 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
975 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
976 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
977 | if (!BN_nnmod(val[0],a,m,ctx)
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
978 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
979 | if (((
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
980 | (BN_set_word((r),0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
981 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
982 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
983 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
984 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
985 | window = ((
| 0-200 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
986 | if (window > 1
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
987 | if (!BN_mod_mul(d, val[0], val[0], m, ctx)
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
988 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
989 | j = 1 << (window - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
990 | for (i = 1; i < j
| 202-3062 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
991 | if (((
| 0-3062 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
992 | ((void *)0)
| 0-3062 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
993 | )
| 0-3062 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
994 | !BN_mod_mul(val[i], val[i - 1], d,m, ctx)
| 0-3062 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
995 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
996 | } executed 3062 times by 2 tests: end of block Executed by:
| 3062 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
997 | } executed 202 times by 2 tests: end of block Executed by:
| 202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
998 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
999 | start = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1000 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1002 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1003 | wstart = bits - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1004 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1005 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1006 | if (!(BN_set_word((r),1))
| 0-202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1007 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1008 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1009 | for (;;) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1010 | if (BN_is_bit_set(p, wstart) == 0
| 11048-21572 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1011 | if (!start
| 0-21572 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1012 | if (!BN_mod_mul(r, r, r, m, ctx)
| 0-21572 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1013 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1014 | if (wstart == 0
| 110-21462 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1015 | break; executed 110 times by 1 test: break; Executed by:
| 110 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1016 | wstart--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1017 | continue; executed 21462 times by 2 tests: continue; Executed by:
| 21462 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1018 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1019 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1020 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1021 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1022 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1023 | j = wstart; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1024 | wvalue = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1025 | wend = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1026 | for (i = 1; i < window
| 10910-44208 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1027 | if (wstart - i < 0
| 138-44070 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1028 | break; executed 138 times by 2 tests: break; Executed by:
| 138 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1029 | if (BN_is_bit_set(p, wstart - i)
| 21766-22304 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1030 | wvalue <<= (i - wend); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1031 | wvalue |= 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1032 | wend = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1033 | } executed 22304 times by 2 tests: end of block Executed by:
| 22304 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1034 | } executed 44070 times by 2 tests: end of block Executed by:
| 44070 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1035 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1036 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1037 | j = wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1038 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1039 | if (!start
| 202-10846 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1040 | for (i = 0; i < j
| 10846-44048 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1041 | if (!BN_mod_mul(r, r, r, m, ctx)
| 0-44048 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1042 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1043 | } executed 44048 times by 2 tests: end of block Executed by:
| 44048 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1044 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1045 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1046 | if (!BN_mod_mul(r, r, val[wvalue >> 1], m, ctx)
| 0-11048 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1047 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1049 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1050 | wstart -= wend + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1051 | wvalue = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1052 | start = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1053 | if (wstart < 0
| 92-10956 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1054 | break; executed 92 times by 2 tests: break; Executed by:
| 92 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1055 | } executed 10956 times by 2 tests: end of block Executed by:
| 10956 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1056 | ret = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1057 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
1058 | err: code before this statement executed 202 times by 2 tests: err: Executed by:
| 202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1059 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1060 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1061 | return executed 202 times by 2 tests: (ret);return (ret); Executed by:
executed 202 times by 2 tests: return (ret); Executed by:
| 202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
1062 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |