OpenCoverage

bn_add.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_add.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)-
4{-
5 int ret, r_neg, cmp_res;-
6-
7 ;-
8 ;-
9-
10 if (a->neg == b->neg
a->neg == b->negDescription
TRUEevaluated 2479515 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 2356233 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
2356233-2479515
11 r_neg = a->neg;-
12 ret = BN_uadd(r, a, b);-
13 }
executed 2479515 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else {
2479515
14 cmp_res = BN_ucmp(a, b);-
15 if (cmp_res > 0
cmp_res > 0Description
TRUEevaluated 217 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2356016 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
217-2356016
16 r_neg = a->neg;-
17 ret = BN_usub(r, a, b);-
18 }
executed 217 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else if (cmp_res < 0
cmp_res < 0Description
TRUEevaluated 2356012 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
4-2356012
19 r_neg = b->neg;-
20 ret = BN_usub(r, b, a);-
21 }
executed 2356012 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else {
2356012
22 r_neg = 0;-
23 (BN_set_word((r),0));-
24 ret = 1;-
25 }
executed 4 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4
26 }-
27-
28 r->neg = r_neg;-
29 ;-
30 return
executed 4835748 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 4835748 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4835748
31}-
32-
33-
34int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)-
35{-
36 int ret, r_neg, cmp_res;-
37-
38 ;-
39 ;-
40-
41 if (a->neg != b->neg
a->neg != b->negDescription
TRUEevaluated 413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6458150 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
413-6458150
42 r_neg = a->neg;-
43 ret = BN_uadd(r, a, b);-
44 }
executed 413 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
413
45 cmp_res = BN_ucmp(a, b);-
46 if (cmp_res > 0
cmp_res > 0Description
TRUEevaluated 4096900 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 2361250 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
2361250-4096900
47 r_neg = a->neg;-
48 ret = BN_usub(r, a, b);-
49 }
executed 4096900 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else if (cmp_res < 0
cmp_res < 0Description
TRUEevaluated 2355348 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 5902 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
5902-4096900
50 r_neg = !b->neg;-
51 ret = BN_usub(r, b, a);-
52 }
executed 2355348 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else {
2355348
53 r_neg = 0;-
54 (BN_set_word((r),0));-
55 ret = 1;-
56 }
executed 5902 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5902
57 }-
58-
59 r->neg = r_neg;-
60 ;-
61 return
executed 6458563 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 6458563 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
6458563
62}-
63-
64-
65int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)-
66{-
67 int max, min, dif;-
68 const unsigned long *ap, *bp;-
69 unsigned long *rp, carry, t1, t2;-
70-
71 ;-
72 ;-
73-
74 if (a->top < b->top
a->top < b->topDescription
TRUEevaluated 150607 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 10317130 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
150607-10317130
75 const BIGNUM *tmp;-
76-
77 tmp = a;-
78 a = b;-
79 b = tmp;-
80 }
executed 150607 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
150607
81 max = a->top;-
82 min = b->top;-
83 dif = max - min;-
84-
85 if (bn_wexpand(r, max + 1) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10467737 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-10467737
86 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10467737 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-10467737
87 )-
88 return
never executed: return 0;
0;
never executed: return 0;
0
89-
90 r->top = max;-
91-
92 ap = a->d;-
93 bp = b->d;-
94 rp = r->d;-
95-
96 carry = bn_add_words(rp, ap, bp, min);-
97 rp += min;-
98 ap += min;-
99-
100 while (dif
difDescription
TRUEevaluated 1667428 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 10467737 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
1667428-10467737
101 dif--;-
102 t1 = *(ap++);-
103 t2 = (t1 + carry) & (0xffffffffffffffffL);-
104 *(rp++) = t2;-
105 carry &= (t2 == 0);-
106 }
executed 1667428 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1667428
107 *rp = carry;-
108 r->top += carry;-
109-
110 r->neg = 0;-
111 ;-
112 return
executed 10467737 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 10467737 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
10467737
113}-
114-
115-
116int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)-
117{-
118 int max, min, dif;-
119 unsigned long t1, t2, borrow, *rp;-
120 const unsigned long *ap, *bp;-
121-
122 ;-
123 ;-
124-
125 max = a->top;-
126 min = b->top;-
127 dif = max - min;-
128-
129 if (dif < 0
dif < 0Description
TRUEnever evaluated
FALSEevaluated 13895182 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-13895182
130 ERR_put_error(3,(115),(100),__FILE__,139);-
131 return
never executed: return 0;
0;
never executed: return 0;
0
132 }-
133-
134 if (bn_wexpand(r, max) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13895182 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-13895182
135 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13895182 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-13895182
136 )-
137 return
never executed: return 0;
0;
never executed: return 0;
0
138-
139 ap = a->d;-
140 bp = b->d;-
141 rp = r->d;-
142-
143 borrow = bn_sub_words(rp, ap, bp, min);-
144 ap += min;-
145 rp += min;-
146-
147 while (dif
difDescription
TRUEevaluated 1173206 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 13895182 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
1173206-13895182
148 dif--;-
149 t1 = *(ap++);-
150 t2 = (t1 - borrow) & (0xffffffffffffffffL);-
151 *(rp++) = t2;-
152 borrow &= (t1 == 0);-
153 }
executed 1173206 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1173206
154-
155 while (max
maxDescription
TRUEevaluated 16205684 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 70161 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
&& *--
*--rp == 0Description
TRUEevaluated 2380663 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 13825021 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
rp == 0
*--rp == 0Description
TRUEevaluated 2380663 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 13825021 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
70161-16205684
156 max--;
executed 2380663 times by 2 tests: max--;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
2380663
157-
158 r->top = max;-
159 r->neg = 0;-
160 ;-
161-
162 return
executed 13895182 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 13895182 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
13895182
163}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2