OpenCoverage

bn_shift.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_shift.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2int BN_lshift1(BIGNUM *r, const BIGNUM *a)-
3{-
4 register unsigned long *ap, *rp, t, c;-
5 int i;-
6-
7 ;-
8 ;-
9-
10 if (r != a
r != aDescription
TRUEevaluated 515226 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1968061 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
515226-1968061
11 r->neg = a->neg;-
12 if (bn_wexpand(r, a->top + 1) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 515226 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-515226
13 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 515226 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-515226
14 )-
15 return
never executed: return 0;
0;
never executed: return 0;
0
16 r->top = a->top;-
17 }
executed 515226 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else {
515226
18 if (bn_wexpand(r, a->top + 1) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1968061 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-1968061
19 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1968061 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-1968061
20 )-
21 return
never executed: return 0;
0;
never executed: return 0;
0
22 }
executed 1968061 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1968061
23 ap = a->d;-
24 rp = r->d;-
25 c = 0;-
26 for (i = 0; i < a->top
i < a->topDescription
TRUEevaluated 14493324 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 2483287 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i++) {
2483287-14493324
27 t = *(ap++);-
28 *(rp++) = ((t << 1) | c) & (0xffffffffffffffffL);-
29 c = (
(t & ((unsigne...(8 * 8) - 1)))Description
TRUEevaluated 6873524 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 7619800 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
t & ((unsigned long)1 << ((8 * 8) - 1)))
(t & ((unsigne...(8 * 8) - 1)))Description
TRUEevaluated 6873524 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 7619800 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
? 1 : 0;
6873524-7619800
30 }
executed 14493324 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
14493324
31 if (c
cDescription
TRUEevaluated 795961 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1687326 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
795961-1687326
32 *rp = 1;-
33 r->top++;-
34 }
executed 795961 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
795961
35 ;-
36 return
executed 2483287 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 2483287 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
2483287
37}-
38-
39int BN_rshift1(BIGNUM *r, const BIGNUM *a)-
40{-
41 unsigned long *ap, *rp, t, c;-
42 int i, j;-
43-
44 ;-
45 ;-
46-
47 if (BN_is_zero(a)
BN_is_zero(a)Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5356044 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
27-5356044
48 (BN_set_word((r),0));-
49 return
executed 27 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 27 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
27
50 }-
51 i = a->top;-
52 ap = a->d;-
53 j = i - (ap[i - 1] == 1);-
54 if (a != r
a != rDescription
TRUEevaluated 56338 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 5299706 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
56338-5299706
55 if (bn_wexpand(r, j) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 56338 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-56338
56 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 56338 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-56338
57 )-
58 return
never executed: return 0;
0;
never executed: return 0;
0
59 r->neg = a->neg;-
60 }
executed 56338 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
56338
61 rp = r->d;-
62 t = ap[--i];-
63 c = (
(t & 1)Description
TRUEevaluated 3236349 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 2119695 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
t & 1)
(t & 1)Description
TRUEevaluated 3236349 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 2119695 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
? ((unsigned long)1 << ((8 * 8) - 1)) : 0;
2119695-3236349
64 if (t >>= 1
t >>= 1Description
TRUEevaluated 3516924 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1839120 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
1839120-3516924
65 rp[i] = t;
executed 3516924 times by 2 tests: rp[i] = t;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3516924
66 while (i > 0
i > 0Description
TRUEevaluated 10396202 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 5356044 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
5356044-10396202
67 t = ap[--i];-
68 rp[i] = ((t >> 1) & (0xffffffffffffffffL)) | c;-
69 c = (
(t & 1)Description
TRUEevaluated 2358710 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 8037492 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
t & 1)
(t & 1)Description
TRUEevaluated 2358710 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 8037492 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
? ((unsigned long)1 << ((8 * 8) - 1)) : 0;
2358710-8037492
70 }
executed 10396202 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
10396202
71 r->top = j;-
72 if (!r->top
!r->topDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5356037 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
7-5356037
73 r->neg = 0;
executed 7 times by 1 test: r->neg = 0;
Executed by:
  • libcrypto.so.1.1
7
74 ;-
75 return
executed 5356044 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 5356044 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
5356044
76}-
77-
78int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)-
79{-
80 int i, nw, lb, rb;-
81 unsigned long *t, *f;-
82 unsigned long l;-
83-
84 ;-
85 ;-
86-
87 if (n < 0
n < 0Description
TRUEnever evaluated
FALSEevaluated 14793446 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-14793446
88 ERR_put_error(3,(145),(119),__FILE__,93);-
89 return
never executed: return 0;
0;
never executed: return 0;
0
90 }-
91-
92 nw = n / (8 * 8);-
93 if (bn_wexpand(r, a->top + nw + 1) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 14793446 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-14793446
94 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 14793446 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-14793446
95 )-
96 return
never executed: return 0;
0;
never executed: return 0;
0
97 r->neg = a->neg;-
98 lb = n % (8 * 8);-
99 rb = (8 * 8) - lb;-
100 f = a->d;-
101 t = r->d;-
102 t[a->top + nw] = 0;-
103 if (lb == 0
lb == 0Description
TRUEevaluated 653604 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 14139842 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
653604-14139842
104 for (i = a->top - 1; i >= 0
i >= 0Description
TRUEevaluated 5503450 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 653604 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i--)
653604-5503450
105 t[nw + i] = f[i];
executed 5503450 times by 2 tests: t[nw + i] = f[i];
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
5503450
106 else-
107 for (i = a->top - 1; i >= 0
i >= 0Description
TRUEevaluated 122548139 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 14139842 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i--) {
14139842-122548139
108 l = f[i];-
109 t[nw + i + 1] |= (l >> rb) & (0xffffffffffffffffL);-
110 t[nw + i] = (l << lb) & (0xffffffffffffffffL);-
111 }
executed 122548139 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
122548139
112 memset(t, 0, sizeof(*t) * nw);-
113 r->top = a->top + nw + 1;-
114 bn_correct_top(r);-
115 ;-
116 return
executed 14793446 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 14793446 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
14793446
117}-
118-
119int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)-
120{-
121 int i, j, nw, lb, rb;-
122 unsigned long *t, *f;-
123 unsigned long l, tmp;-
124-
125 ;-
126 ;-
127-
128 if (n < 0
n < 0Description
TRUEnever evaluated
FALSEevaluated 11958314 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-11958314
129 ERR_put_error(3,(146),(119),__FILE__,132);-
130 return
never executed: return 0;
0;
never executed: return 0;
0
131 }-
132-
133 nw = n / (8 * 8);-
134 rb = n % (8 * 8);-
135 lb = (8 * 8) - rb;-
136 if (nw >= a->top
nw >= a->topDescription
TRUEevaluated 33371 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11924943 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
|| a->top == 0
a->top == 0Description
TRUEnever evaluated
FALSEevaluated 11924943 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-11924943
137 (BN_set_word((r),0));-
138 return
executed 33371 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 33371 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
33371
139 }-
140 i = (BN_num_bits(a) - n + ((8 * 8) - 1)) / (8 * 8);-
141 if (r != a
r != aDescription
TRUEevaluated 7084646 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 4840297 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
4840297-7084646
142 if (bn_wexpand(r, i) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7084646 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-7084646
143 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7084646 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-7084646
144 )-
145 return
never executed: return 0;
0;
never executed: return 0;
0
146 r->neg = a->neg;-
147 }
executed 7084646 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else {
7084646
148 if (n == 0
n == 0Description
TRUEevaluated 70216 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4770081 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
70216-4770081
149 return
executed 70216 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 70216 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
70216
150 }
executed 4770081 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4770081
151-
152 f = &(a->d[nw]);-
153 t = r->d;-
154 j = a->top - nw;-
155 r->top = i;-
156-
157 if (rb == 0
rb == 0Description
TRUEevaluated 340750 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 11513977 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
340750-11513977
158 for (i = j; i != 0
i != 0Description
TRUEevaluated 3128235 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 340750 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i--)
340750-3128235
159 *(
executed 3128235 times by 2 tests: *(t++) = *(f++);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
t++) = *(f++);
executed 3128235 times by 2 tests: *(t++) = *(f++);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3128235
160 }
executed 340750 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else {
340750
161 l = *(f++);-
162 for (i = j - 1; i != 0
i != 0Description
TRUEevaluated 48326049 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 11513977 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i--) {
11513977-48326049
163 tmp = (l >> rb) & (0xffffffffffffffffL);-
164 l = *(f++);-
165 *(t++) = (tmp | (l << lb)) & (0xffffffffffffffffL);-
166 }
executed 48326049 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
48326049
167 if ((
(l = (l >> rb)...fffffffffffL))Description
TRUEevaluated 11344942 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 169035 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
l = (l >> rb) & (0xffffffffffffffffL))
(l = (l >> rb)...fffffffffffL))Description
TRUEevaluated 11344942 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 169035 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
169035-11344942
168 *(
executed 11344942 times by 2 tests: *(t) = l;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
t) = l;
executed 11344942 times by 2 tests: *(t) = l;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
11344942
169 }
executed 11513977 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
11513977
170 if (!r->top
!r->topDescription
TRUEevaluated 464 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11854263 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
464-11854263
171 r->neg = 0;
executed 464 times by 1 test: r->neg = 0;
Executed by:
  • libcrypto.so.1.1
464
172 ;-
173 return
executed 11854727 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 11854727 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
11854727
174}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2