OpenCoverage

bn_word.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_word.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2unsigned long BN_mod_word(const BIGNUM *a, unsigned long w)-
3{-
4-
5 unsigned long ret = 0;-
6-
7-
8-
9 int i;-
10-
11 if (w == 0
w == 0Description
TRUEnever evaluated
FALSEevaluated 7022607 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-7022607
12 return
never executed: return (unsigned long)-1;
(unsigned long)-1;
never executed: return (unsigned long)-1;
0
13-
14-
15-
16-
17-
18-
19 if (w > ((unsigned long)1 << 32)
w > ((unsigned long)1 << 32)Description
TRUEevaluated 103 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7022504 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
103-7022504
20 BIGNUM *tmp = BN_dup(a);-
21 if (tmp ==
tmp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 103 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-103
22 ((void *)0)
tmp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 103 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-103
23 )-
24 return
never executed: return (unsigned long)-1;
(unsigned long)-1;
never executed: return (unsigned long)-1;
0
25-
26 ret = BN_div_word(tmp, w);-
27 BN_free(tmp);-
28-
29 return
executed 103 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 103 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
103
30 }-
31-
32-
33 ;-
34 w &= (0xffffffffffffffffL);-
35 for (i = a->top - 1; i >= 0
i >= 0Description
TRUEevaluated 141244951 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7022504 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i--) {
7022504-141244951
36-
37-
38-
39-
40-
41-
42 ret = ((ret << 32) | ((a->d[i] >> 32) & (0xffffffffL))) % w;-
43 ret = ((ret << 32) | (a->d[i] & (0xffffffffL))) % w;-
44-
45-
46-
47-
48 }
executed 141244951 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
141244951
49 return
executed 7022504 times by 1 test: return (unsigned long)ret;
Executed by:
  • libcrypto.so.1.1
(unsigned long)ret;
executed 7022504 times by 1 test: return (unsigned long)ret;
Executed by:
  • libcrypto.so.1.1
7022504
50}-
51-
52unsigned long BN_div_word(BIGNUM *a, unsigned long w)-
53{-
54 unsigned long ret = 0;-
55 int i, j;-
56-
57 ;-
58 w &= (0xffffffffffffffffL);-
59-
60 if (!w
!wDescription
TRUEnever evaluated
FALSEevaluated 35819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-35819
61-
62 return
never executed: return (unsigned long)-1;
(unsigned long)-1;
never executed: return (unsigned long)-1;
0
63 if (a->top == 0
a->top == 0Description
TRUEnever evaluated
FALSEevaluated 35819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-35819
64 return
never executed: return 0;
0;
never executed: return 0;
0
65-
66-
67 j = (8 * 8) - BN_num_bits_word(w);-
68 w <<= j;-
69 if (!BN_lshift(a, a, j)
!BN_lshift(a, a, j)Description
TRUEnever evaluated
FALSEevaluated 35819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-35819
70 return
never executed: return (unsigned long)-1;
(unsigned long)-1;
never executed: return (unsigned long)-1;
0
71-
72 for (i = a->top - 1; i >= 0
i >= 0Description
TRUEevaluated 95669 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 35819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i--) {
35819-95669
73 unsigned long l, d;-
74-
75 l = a->d[i];-
76 d = bn_div_words(ret, l, w);-
77 ret = (l - ((d * w) & (0xffffffffffffffffL))) & (0xffffffffffffffffL);-
78 a->d[i] = d;-
79 }
executed 95669 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
95669
80 if ((
(a->top > 0)Description
TRUEevaluated 35819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
a->top > 0)
(a->top > 0)Description
TRUEevaluated 35819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
&& (
(a->d[a->top - 1] == 0)Description
TRUEevaluated 34752 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1067 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a->d[a->top - 1] == 0)
(a->d[a->top - 1] == 0)Description
TRUEevaluated 34752 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1067 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-35819
81 a->top--;
executed 34752 times by 1 test: a->top--;
Executed by:
  • libcrypto.so.1.1
34752
82 ret >>= j;-
83 if (!a->top
!a->topDescription
TRUEevaluated 17143 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18676 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
17143-18676
84 a->neg = 0;
executed 17143 times by 1 test: a->neg = 0;
Executed by:
  • libcrypto.so.1.1
17143
85 ;-
86 return
executed 35819 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 35819 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
35819
87}-
88-
89int BN_add_word(BIGNUM *a, unsigned long w)-
90{-
91 unsigned long l;-
92 int i;-
93-
94 ;-
95 w &= (0xffffffffffffffffL);-
96-
97-
98 if (!w
!wDescription
TRUEevaluated 48980 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 208788 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
48980-208788
99 return
executed 48980 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 48980 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
48980
100-
101 if (BN_is_zero(a)
BN_is_zero(a)Description
TRUEevaluated 1305 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 207483 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
1305-207483
102 return
executed 1305 times by 1 test: return BN_set_word(a, w);
Executed by:
  • libcrypto.so.1.1
BN_set_word(a, w);
executed 1305 times by 1 test: return BN_set_word(a, w);
Executed by:
  • libcrypto.so.1.1
1305
103-
104 if (a->neg
a->negDescription
TRUEnever evaluated
FALSEevaluated 207483 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-207483
105 a->neg = 0;-
106 i = BN_sub_word(a, w);-
107 if (!BN_is_zero(a)
!BN_is_zero(a)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
108 a->neg = !(a->neg);
never executed: a->neg = !(a->neg);
0
109 return
never executed: return i;
i;
never executed: return i;
0
110 }-
111 for (i = 0; w != 0
w != 0Description
TRUEevaluated 217503 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 207214 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
&& i < a->top
i < a->topDescription
TRUEevaluated 217234 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 269 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++) {
269-217503
112 a->d[i] = l = (a->d[i] + w) & (0xffffffffffffffffL);-
113 w = (
(w > l)Description
TRUEevaluated 10020 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 207214 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
w > l)
(w > l)Description
TRUEevaluated 10020 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 207214 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
? 1 : 0;
10020-207214
114 }
executed 217234 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
217234
115 if (w
wDescription
TRUEevaluated 269 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 207214 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
&& i == a->top
i == a->topDescription
TRUEevaluated 269 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-207214
116 if (bn_wexpand(a, a->top + 1) ==
bn_wexpand(a, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 269 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-269
117 ((void *)0)
bn_wexpand(a, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 269 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-269
118 )-
119 return
never executed: return 0;
0;
never executed: return 0;
0
120 a->top++;-
121 a->d[i] = w;-
122 }
executed 269 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
269
123 ;-
124 return
executed 207483 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 207483 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
207483
125}-
126-
127int BN_sub_word(BIGNUM *a, unsigned long w)-
128{-
129 int i;-
130-
131 ;-
132 w &= (0xffffffffffffffffL);-
133-
134-
135 if (!w
!wDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 88354 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
3-88354
136 return
executed 3 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 3 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
3
137-
138 if (BN_is_zero(a)
BN_is_zero(a)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 88348 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
6-88348
139 i = BN_set_word(a, w);-
140 if (i != 0
i != 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-6
141 BN_set_negative(a, 1);
executed 6 times by 1 test: BN_set_negative(a, 1);
Executed by:
  • libcrypto.so.1.1
6
142 return
executed 6 times by 1 test: return i;
Executed by:
  • libcrypto.so.1.1
i;
executed 6 times by 1 test: return i;
Executed by:
  • libcrypto.so.1.1
6
143 }-
144-
145 if (a->neg
a->negDescription
TRUEnever evaluated
FALSEevaluated 88348 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-88348
146 a->neg = 0;-
147 i = BN_add_word(a, w);-
148 a->neg = 1;-
149 return
never executed: return i;
i;
never executed: return i;
0
150 }-
151-
152 if ((
(a->top == 1)Description
TRUEevaluated 501 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 87847 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
a->top == 1)
(a->top == 1)Description
TRUEevaluated 501 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 87847 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
&& (
(a->d[0] < w)Description
TRUEnever evaluated
FALSEevaluated 501 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a->d[0] < w)
(a->d[0] < w)Description
TRUEnever evaluated
FALSEevaluated 501 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-87847
153 a->d[0] = w - a->d[0];-
154 a->neg = 1;-
155 return
never executed: return 1;
1;
never executed: return 1;
0
156 }-
157 i = 0;-
158 for (;;) {-
159 if (a->d[i] >= w
a->d[i] >= wDescription
TRUEevaluated 88348 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 80712 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
80712-88348
160 a->d[i] -= w;-
161 break;
executed 88348 times by 2 tests: break;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
88348
162 } else {-
163 a->d[i] = (a->d[i] - w) & (0xffffffffffffffffL);-
164 i++;-
165 w = 1;-
166 }
executed 80712 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
80712
167 }-
168 if ((
(a->d[i] == 0)Description
TRUEevaluated 24803 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 63545 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
a->d[i] == 0)
(a->d[i] == 0)Description
TRUEevaluated 24803 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 63545 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
&& (
(i == (a->top - 1))Description
TRUEevaluated 23812 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
i == (a->top - 1))
(i == (a->top - 1))Description
TRUEevaluated 23812 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
991-63545
169 a->top--;
executed 23812 times by 1 test: a->top--;
Executed by:
  • libcrypto.so.1.1
23812
170 ;-
171 return
executed 88348 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 88348 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
88348
172}-
173-
174int BN_mul_word(BIGNUM *a, unsigned long w)-
175{-
176 unsigned long ll;-
177-
178 ;-
179 w &= (0xffffffffffffffffL);-
180 if (a->top
a->topDescription
TRUEevaluated 142222 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 590 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
590-142222
181 if (w == 0
w == 0Description
TRUEnever evaluated
FALSEevaluated 142222 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-142222
182 (
never executed: (BN_set_word((a),0));
BN_set_word((a),0));
never executed: (BN_set_word((a),0));
0
183 else {-
184 ll = bn_mul_words(a->d, a->d, a->top, w);-
185 if (ll
llDescription
TRUEevaluated 131406 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10816 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
10816-131406
186 if (bn_wexpand(a, a->top + 1) ==
bn_wexpand(a, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 131406 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-131406
187 ((void *)0)
bn_wexpand(a, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 131406 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-131406
188 )-
189 return
never executed: return 0;
0;
never executed: return 0;
0
190 a->d[a->top++] = ll;-
191 }
executed 131406 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
131406
192 }
executed 142222 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
142222
193 }-
194 ;-
195 return
executed 142812 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 142812 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
142812
196}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2