Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/bn/bn_mod.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | int | - | ||||||||||||
4 | BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) | - | ||||||||||||
5 | { | - | ||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | if (!(BN_div_ct(
| 5-112872 | ||||||||||||
10 | ((void *)0)
| 5-112872 | ||||||||||||
11 | ,(r),(m),(d),(ctx)))
| 5-112872 | ||||||||||||
12 | return executed 5 times by 1 test: 0;return 0; Executed by:
executed 5 times by 1 test: return 0; Executed by:
| 5 | ||||||||||||
13 | if (!r->neg
| 243-112629 | ||||||||||||
14 | return executed 112629 times by 14 tests: 1;return 1; Executed by:
executed 112629 times by 14 tests: return 1; Executed by:
| 112629 | ||||||||||||
15 | - | |||||||||||||
16 | if (d->neg
| 0-243 | ||||||||||||
17 | return never executed: BN_sub(r, r, d);return BN_sub(r, r, d); never executed: return BN_sub(r, r, d); | 0 | ||||||||||||
18 | else | - | ||||||||||||
19 | return executed 243 times by 2 tests: BN_add(r, r, d);return BN_add(r, r, d); Executed by:
executed 243 times by 2 tests: return BN_add(r, r, d); Executed by:
| 243 | ||||||||||||
20 | } | - | ||||||||||||
21 | - | |||||||||||||
22 | int | - | ||||||||||||
23 | BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | - | ||||||||||||
24 | BN_CTX *ctx) | - | ||||||||||||
25 | { | - | ||||||||||||
26 | if (!BN_add(r, a, b)
| 0-120 | ||||||||||||
27 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
28 | return executed 120 times by 4 tests: BN_nnmod(r, r, m, ctx);return BN_nnmod(r, r, m, ctx); Executed by:
executed 120 times by 4 tests: return BN_nnmod(r, r, m, ctx); Executed by:
| 120 | ||||||||||||
29 | } | - | ||||||||||||
30 | - | |||||||||||||
31 | - | |||||||||||||
32 | - | |||||||||||||
33 | int | - | ||||||||||||
34 | BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m) | - | ||||||||||||
35 | { | - | ||||||||||||
36 | if (!BN_uadd(r, a, b)
| 0-585006 | ||||||||||||
37 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
38 | if (BN_ucmp(r, m) >= 0
| 287369-297637 | ||||||||||||
39 | return executed 287369 times by 4 tests: BN_usub(r, r, m);return BN_usub(r, r, m); Executed by:
executed 287369 times by 4 tests: return BN_usub(r, r, m); Executed by:
| 287369 | ||||||||||||
40 | return executed 297637 times by 4 tests: 1;return 1; Executed by:
executed 297637 times by 4 tests: return 1; Executed by:
| 297637 | ||||||||||||
41 | } | - | ||||||||||||
42 | - | |||||||||||||
43 | int | - | ||||||||||||
44 | BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | - | ||||||||||||
45 | BN_CTX *ctx) | - | ||||||||||||
46 | { | - | ||||||||||||
47 | if (!BN_sub(r, a, b)
| 0 | ||||||||||||
48 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
49 | return never executed: BN_nnmod(r, r, m, ctx);return BN_nnmod(r, r, m, ctx); never executed: return BN_nnmod(r, r, m, ctx); | 0 | ||||||||||||
50 | } | - | ||||||||||||
51 | - | |||||||||||||
52 | - | |||||||||||||
53 | - | |||||||||||||
54 | int | - | ||||||||||||
55 | BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m) | - | ||||||||||||
56 | { | - | ||||||||||||
57 | if (!BN_sub(r, a, b)
| 0-1256535 | ||||||||||||
58 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
59 | if (r->neg
| 628051-628484 | ||||||||||||
60 | return executed 628484 times by 4 tests: BN_add(r, r, m);return BN_add(r, r, m); Executed by:
executed 628484 times by 4 tests: return BN_add(r, r, m); Executed by:
| 628484 | ||||||||||||
61 | return executed 628051 times by 4 tests: 1;return 1; Executed by:
executed 628051 times by 4 tests: return 1; Executed by:
| 628051 | ||||||||||||
62 | } | - | ||||||||||||
63 | - | |||||||||||||
64 | - | |||||||||||||
65 | int | - | ||||||||||||
66 | BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | - | ||||||||||||
67 | BN_CTX *ctx) | - | ||||||||||||
68 | { | - | ||||||||||||
69 | BIGNUM *t; | - | ||||||||||||
70 | int ret = 0; | - | ||||||||||||
71 | - | |||||||||||||
72 | ; | - | ||||||||||||
73 | ; | - | ||||||||||||
74 | ; | - | ||||||||||||
75 | - | |||||||||||||
76 | BN_CTX_start(ctx); | - | ||||||||||||
77 | if ((
| 0-88348 | ||||||||||||
78 | ((void *)0)
| 0-88348 | ||||||||||||
79 | ) | - | ||||||||||||
80 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
81 | if (a == b
| 17056-71292 | ||||||||||||
82 | if (!BN_sqr(t, a, ctx)
| 0-71292 | ||||||||||||
83 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
84 | } executed 71292 times by 9 tests: else {end of block Executed by:
| 71292 | ||||||||||||
85 | if (!BN_mul(t, a,b, ctx)
| 0-17056 | ||||||||||||
86 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
87 | } executed 17056 times by 12 tests: end of block Executed by:
| 17056 | ||||||||||||
88 | if (!BN_nnmod(r, t,m, ctx)
| 1-88347 | ||||||||||||
89 | goto executed 1 time by 1 test: err;goto err; Executed by:
executed 1 time by 1 test: goto err; Executed by:
| 1 | ||||||||||||
90 | ; | - | ||||||||||||
91 | ret = 1; | - | ||||||||||||
92 | - | |||||||||||||
93 | err: code before this statement executed 88347 times by 14 tests: err: Executed by:
| 88347 | ||||||||||||
94 | BN_CTX_end(ctx); | - | ||||||||||||
95 | return executed 88348 times by 14 tests: (ret);return (ret); Executed by:
executed 88348 times by 14 tests: return (ret); Executed by:
| 88348 | ||||||||||||
96 | } | - | ||||||||||||
97 | - | |||||||||||||
98 | int | - | ||||||||||||
99 | BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) | - | ||||||||||||
100 | { | - | ||||||||||||
101 | if (!BN_sqr(r, a, ctx)
| 0-934 | ||||||||||||
102 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
103 | - | |||||||||||||
104 | return executed 934 times by 5 tests: BN_div_ct(return BN_div_ct( ((void *)0) ,(r),(r),(m),(ctx)); Executed by:
executed 934 times by 5 tests: return BN_div_ct( ((void *)0) ,(r),(r),(m),(ctx)); Executed by:
| 934 | ||||||||||||
105 | ((void *)0) executed 934 times by 5 tests: return BN_div_ct( ((void *)0) ,(r),(r),(m),(ctx)); Executed by:
| 934 | ||||||||||||
106 | ,(r),(r),(m),(ctx)); executed 934 times by 5 tests: return BN_div_ct( ((void *)0) ,(r),(r),(m),(ctx)); Executed by:
| 934 | ||||||||||||
107 | } | - | ||||||||||||
108 | - | |||||||||||||
109 | int | - | ||||||||||||
110 | BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) | - | ||||||||||||
111 | { | - | ||||||||||||
112 | if (!BN_lshift1(r, a)
| 0 | ||||||||||||
113 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
114 | ; | - | ||||||||||||
115 | return never executed: BN_nnmod(r, r, m, ctx);return BN_nnmod(r, r, m, ctx); never executed: return BN_nnmod(r, r, m, ctx); | 0 | ||||||||||||
116 | } | - | ||||||||||||
117 | - | |||||||||||||
118 | - | |||||||||||||
119 | - | |||||||||||||
120 | int | - | ||||||||||||
121 | BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m) | - | ||||||||||||
122 | { | - | ||||||||||||
123 | if (!BN_lshift1(r, a)
| 0-618748 | ||||||||||||
124 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
125 | ; | - | ||||||||||||
126 | if (BN_cmp(r, m) >= 0
| 309036-309712 | ||||||||||||
127 | return executed 309036 times by 5 tests: BN_sub(r, r, m);return BN_sub(r, r, m); Executed by:
executed 309036 times by 5 tests: return BN_sub(r, r, m); Executed by:
| 309036 | ||||||||||||
128 | return executed 309712 times by 5 tests: 1;return 1; Executed by:
executed 309712 times by 5 tests: return 1; Executed by:
| 309712 | ||||||||||||
129 | } | - | ||||||||||||
130 | - | |||||||||||||
131 | int | - | ||||||||||||
132 | BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx) | - | ||||||||||||
133 | { | - | ||||||||||||
134 | BIGNUM *abs_m = | - | ||||||||||||
135 | ((void *)0) | - | ||||||||||||
136 | ; | - | ||||||||||||
137 | int ret; | - | ||||||||||||
138 | - | |||||||||||||
139 | if (!BN_nnmod(r, a, m, ctx)
| 0 | ||||||||||||
140 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
141 | - | |||||||||||||
142 | if (m->neg
| 0 | ||||||||||||
143 | abs_m = BN_dup(m); | - | ||||||||||||
144 | if (abs_m ==
| 0 | ||||||||||||
145 | ((void *)0)
| 0 | ||||||||||||
146 | ) | - | ||||||||||||
147 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
148 | abs_m->neg = 0; | - | ||||||||||||
149 | } never executed: end of block | 0 | ||||||||||||
150 | - | |||||||||||||
151 | ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m)); | - | ||||||||||||
152 | ; | - | ||||||||||||
153 | - | |||||||||||||
154 | BN_free(abs_m); | - | ||||||||||||
155 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||
156 | } | - | ||||||||||||
157 | - | |||||||||||||
158 | - | |||||||||||||
159 | - | |||||||||||||
160 | int | - | ||||||||||||
161 | BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m) | - | ||||||||||||
162 | { | - | ||||||||||||
163 | if (r != a
| 163199 | ||||||||||||
164 | if (BN_copy(r, a) ==
| 0-163199 | ||||||||||||
165 | ((void *)0)
| 0-163199 | ||||||||||||
166 | ) | - | ||||||||||||
167 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
168 | } executed 163199 times by 4 tests: end of block Executed by:
| 163199 | ||||||||||||
169 | - | |||||||||||||
170 | while (n > 0
| 326398-664617 | ||||||||||||
171 | int max_shift; | - | ||||||||||||
172 | - | |||||||||||||
173 | - | |||||||||||||
174 | max_shift = BN_num_bits(m) - BN_num_bits(r); | - | ||||||||||||
175 | - | |||||||||||||
176 | - | |||||||||||||
177 | if (max_shift < 0
| 0-664617 | ||||||||||||
178 | ERR_put_error(3,(0xfff),(110),__FILE__,281); | - | ||||||||||||
179 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
180 | } | - | ||||||||||||
181 | - | |||||||||||||
182 | if (max_shift > n
| 100868-563749 | ||||||||||||
183 | max_shift = n; executed 100868 times by 4 tests: max_shift = n; Executed by:
| 100868 | ||||||||||||
184 | - | |||||||||||||
185 | if (max_shift
| 313521-351096 | ||||||||||||
186 | if (!BN_lshift(r, r, max_shift)
| 0-351096 | ||||||||||||
187 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
188 | n -= max_shift; | - | ||||||||||||
189 | } executed 351096 times by 4 tests: else {end of block Executed by:
| 351096 | ||||||||||||
190 | if (!BN_lshift1(r, r)
| 0-313521 | ||||||||||||
191 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
192 | --n; | - | ||||||||||||
193 | } executed 313521 times by 4 tests: end of block Executed by:
| 313521 | ||||||||||||
194 | - | |||||||||||||
195 | - | |||||||||||||
196 | - | |||||||||||||
197 | if (BN_cmp(r, m) >= 0
| 257533-407084 | ||||||||||||
198 | if (!BN_sub(r, r, m)
| 0-407084 | ||||||||||||
199 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
200 | } executed 407084 times by 4 tests: end of block Executed by:
| 407084 | ||||||||||||
201 | } executed 664617 times by 4 tests: end of block Executed by:
| 664617 | ||||||||||||
202 | ; | - | ||||||||||||
203 | - | |||||||||||||
204 | return executed 326398 times by 4 tests: 1;return 1; Executed by:
executed 326398 times by 4 tests: return 1; Executed by:
| 326398 | ||||||||||||
205 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |