OpenCoverage

bn_sqr.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_sqr.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)-
7{-
8 int ret = bn_sqr_fixed_top(r, a, ctx);-
9-
10 bn_correct_top(r);-
11 ;-
12-
13 return
executed 3893302 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 3893302 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3893302
14}-
15-
16int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)-
17{-
18 int max, al;-
19 int ret = 0;-
20 BIGNUM *tmp, *rr;-
21-
22 ;-
23-
24 al = a->top;-
25 if (al <= 0
al <= 0Description
TRUEevaluated 13300 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3946758 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
13300-3946758
26 r->top = 0;-
27 r->neg = 0;-
28 return
executed 13300 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 13300 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
13300
29 }-
30-
31 BN_CTX_start(ctx);-
32 rr = (
(a != r)Description
TRUEevaluated 3883324 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 63434 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a != r)
(a != r)Description
TRUEevaluated 3883324 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 63434 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
? r : BN_CTX_get(ctx);
63434-3883324
33 tmp = BN_CTX_get(ctx);-
34 if (rr ==
rr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3946758 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-3946758
35 ((void *)0)
rr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3946758 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-3946758
36 || tmp ==
tmp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3946758 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-3946758
37 ((void *)0)
tmp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3946758 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-3946758
38 )-
39 goto
never executed: goto err;
err;
never executed: goto err;
0
40-
41 max = 2 * al;-
42 if (bn_wexpand(rr, max) ==
bn_wexpand(rr,...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3946758 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-3946758
43 ((void *)0)
bn_wexpand(rr,...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3946758 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-3946758
44 )-
45 goto
never executed: goto err;
err;
never executed: goto err;
0
46-
47 if (al == 4
al == 4Description
TRUEevaluated 3585515 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 361243 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
361243-3585515
48-
49-
50-
51-
52 bn_sqr_comba4(rr->d, a->d);-
53-
54 }
executed 3585515 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else if (al == 8
al == 8Description
TRUEevaluated 126176 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 235067 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
126176-3585515
55-
56-
57-
58-
59 bn_sqr_comba8(rr->d, a->d);-
60-
61 }
executed 126176 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
126176
62-
63 if (al < (16)
al < (16)Description
TRUEevaluated 181157 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 53910 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
53910-181157
64 unsigned long t[(16) * 2];-
65 bn_sqr_normal(rr->d, a->d, al, t);-
66 }
executed 181157 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
181157
67 int j, k;-
68-
69 j = BN_num_bits_word((unsigned long)al);-
70 j = 1 << (j - 1);-
71 k = j + j;-
72 if (al == j
al == jDescription
TRUEevaluated 21270 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 32640 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
21270-32640
73 if (bn_wexpand(tmp, k * 2) ==
bn_wexpand(tmp...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 21270 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-21270
74 ((void *)0)
bn_wexpand(tmp...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 21270 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-21270
75 )-
76 goto
never executed: goto err;
err;
never executed: goto err;
0
77 bn_sqr_recursive(rr->d, a->d, al, tmp->d);-
78 }
executed 21270 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
21270
79 if (bn_wexpand(tmp, max) ==
bn_wexpand(tmp...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 32640 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-32640
80 ((void *)0)
bn_wexpand(tmp...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 32640 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-32640
81 )-
82 goto
never executed: goto err;
err;
never executed: goto err;
0
83 bn_sqr_normal(rr->d, a->d, al, tmp->d);-
84 }
executed 32640 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
32640
85 }-
86-
87-
88-
89-
90-
91 }-
92-
93 rr->neg = 0;-
94 rr->top = max;-
95 rr->flags |= 0;-
96 if (r != rr
r != rrDescription
TRUEevaluated 63434 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3883324 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
&& BN_copy(r, rr) ==
BN_copy(r, rr) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 63434 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3883324
97 ((void *)0)
BN_copy(r, rr) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 63434 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-63434
98 )-
99 goto
never executed: goto err;
err;
never executed: goto err;
0
100-
101 ret = 1;-
102 err:
code before this statement executed 3946758 times by 2 tests: err:
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3946758
103 ;-
104 ;-
105 BN_CTX_end(ctx);-
106 return
executed 3946758 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 3946758 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3946758
107}-
108-
109-
110void bn_sqr_normal(unsigned long *r, const unsigned long *a, int n, unsigned long *tmp)-
111{-
112 int i, j, max;-
113 const unsigned long *ap;-
114 unsigned long *rp;-
115-
116 max = n * 2;-
117 ap = a;-
118 rp = r;-
119 rp[0] = rp[max - 1] = 0;-
120 rp++;-
121 j = n;-
122-
123 if (--
--j > 0Description
TRUEevaluated 117136 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 96661 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
j > 0
--j > 0Description
TRUEevaluated 117136 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 96661 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
96661-117136
124 ap++;-
125 rp[j] = bn_mul_words(rp, ap, j, ap[-1]);-
126 rp += 2;-
127 }
executed 117136 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
117136
128-
129 for (i = n - 2; i > 0
i > 0Description
TRUEevaluated 1646505 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 213797 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i--) {
213797-1646505
130 j--;-
131 ap++;-
132 rp[j] = bn_mul_add_words(rp, ap, j, ap[-1]);-
133 rp += 2;-
134 }
executed 1646505 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1646505
135-
136 bn_add_words(r, r, r, max);-
137-
138-
139-
140 bn_sqr_words(tmp, a, n);-
141-
142 bn_add_words(r, r, tmp, max);-
143}
executed 213797 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
213797
144void bn_sqr_recursive(unsigned long *r, const unsigned long *a, int n2, unsigned long *t)-
145{-
146 int n = n2 / 2;-
147 int zero, c1;-
148 unsigned long ln, lo, *p;-
149-
150 if (n2 == 4
n2 == 4Description
TRUEnever evaluated
FALSEevaluated 155914 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-155914
151-
152-
153-
154 bn_sqr_comba4(r, a);-
155-
156 return;
never executed: return;
0
157 } else if (n2 == 8
n2 == 8Description
TRUEevaluated 110942 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 44972 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
44972-110942
158-
159-
160-
161 bn_sqr_comba8(r, a);-
162-
163 return;
executed 110942 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
110942
164 }-
165 if (n2 < (16)
n2 < (16)Description
TRUEnever evaluated
FALSEevaluated 44972 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-44972
166 bn_sqr_normal(r, a, n2, t);-
167 return;
never executed: return;
0
168 }-
169-
170 c1 = bn_cmp_words(a, &(a[n]), n);-
171 zero = 0;-
172 if (c1 > 0
c1 > 0Description
TRUEevaluated 29402 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 15570 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
15570-29402
173 bn_sub_words(t, a, &(a[n]), n);
executed 29402 times by 1 test: bn_sub_words(t, a, &(a[n]), n);
Executed by:
  • libcrypto.so.1.1
29402
174 else if (c1 < 0
c1 < 0Description
TRUEevaluated 15298 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 272 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
272-15298
175 bn_sub_words(t, &(a[n]), a, n);
executed 15298 times by 1 test: bn_sub_words(t, &(a[n]), a, n);
Executed by:
  • libcrypto.so.1.1
15298
176 else-
177 zero = 1;
executed 272 times by 1 test: zero = 1;
Executed by:
  • libcrypto.so.1.1
272
178-
179-
180 p = &(t[n2 * 2]);-
181-
182 if (!zero
!zeroDescription
TRUEevaluated 44700 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 272 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
272-44700
183 bn_sqr_recursive(&(t[n2]), t, n, p);
executed 44700 times by 1 test: bn_sqr_recursive(&(t[n2]), t, n, p);
Executed by:
  • libcrypto.so.1.1
44700
184 else-
185 memset(&t[n2], 0, sizeof(*t) * n2);
executed 272 times by 1 test: memset(&t[n2], 0, sizeof(*t) * n2);
Executed by:
  • libcrypto.so.1.1
272
186 bn_sqr_recursive(r, a, n, p);-
187 bn_sqr_recursive(&(r[n2]), &(a[n]), n, p);-
188-
189-
190-
191-
192-
193-
194-
195 c1 = (int)(bn_add_words(t, r, &(r[n2]), n2));-
196-
197-
198 c1 -= (int)(bn_sub_words(&(t[n2]), t, &(t[n2]), n2));-
199-
200-
201-
202-
203-
204-
205-
206 c1 += (int)(bn_add_words(&(r[n]), &(r[n]), &(t[n2]), n2));-
207 if (c1
c1Description
TRUEevaluated 12652 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 32320 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
12652-32320
208 p = &(r[n + n2]);-
209 lo = *p;-
210 ln = (lo + c1) & (0xffffffffffffffffL);-
211 *p = ln;-
212-
213-
214-
215-
216-
217 if (ln < (unsigned long)c1
ln < (unsigned long)c1Description
TRUEevaluated 321 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12331 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
321-12331
218 do {-
219 p++;-
220 lo = *p;-
221 ln = (lo + 1) & (0xffffffffffffffffL);-
222 *p = ln;-
223 }
executed 644 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
while (ln == 0
ln == 0Description
TRUEevaluated 323 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 321 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
);
321-644
224 }
executed 321 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
321
225 }
executed 12652 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
12652
226}
executed 44972 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
44972
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2