OpenCoverage

bn_mod.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_mod.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)-
3{-
4-
5-
6-
7-
8-
9 if (!(BN_div(
!(BN_div( ((vo...m),(d),(ctx)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4223126 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
2-4223126
10 ((void *)0)
!(BN_div( ((vo...m),(d),(ctx)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4223126 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
2-4223126
11 ,(r),(m),(d),(ctx)))
!(BN_div( ((vo...m),(d),(ctx)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4223126 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
2-4223126
12 return
executed 2 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 2 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
2
13 if (!r->neg
!r->negDescription
TRUEevaluated 4176445 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 46681 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
46681-4176445
14 return
executed 4176445 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 4176445 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4176445
15-
16 return
executed 46681 times by 2 tests: return (d->neg ? BN_sub : BN_add) (r, r, d);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
(d->neg
d->negDescription
TRUEevaluated 208 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 46473 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
? BN_sub : BN_add) (r, r, d);
executed 46681 times by 2 tests: return (d->neg ? BN_sub : BN_add) (r, r, d);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
208-46681
17}-
18-
19int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,-
20 BN_CTX *ctx)-
21{-
22 if (!BN_add(r, a, b)
!BN_add(r, a, b)Description
TRUEnever evaluated
FALSEevaluated 104 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-104
23 return
never executed: return 0;
0;
never executed: return 0;
0
24 return
executed 104 times by 2 tests: return BN_nnmod(r, r, m, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
BN_nnmod(r, r, m, ctx);
executed 104 times by 2 tests: return BN_nnmod(r, r, m, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
104
25}-
26int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,-
27 const BIGNUM *m)-
28{-
29 size_t i, ai, bi, mtop = m->top;-
30 unsigned long storage[1024 / (8 * 8)];-
31 unsigned long carry, temp, mask, *rp, *tp = storage;-
32 const unsigned long *ap, *bp;-
33-
34 if (bn_wexpand(r, mtop) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4337421 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-4337421
35 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4337421 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-4337421
36 )-
37 return
never executed: return 0;
0;
never executed: return 0;
0
38-
39 if (mtop > sizeof(storage) / sizeof(storage[0])
mtop > sizeof(...of(storage[0])Description
TRUEevaluated 1868 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4335553 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
1868-4335553
40 && (
(tp = CRYPTO_m...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1868 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
tp = CRYPTO_malloc(mtop * sizeof(unsigned long), __FILE__, 60)) ==
(tp = CRYPTO_m...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1868 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1868
41 ((void *)0)
(tp = CRYPTO_m...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1868 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1868
42 )-
43 return
never executed: return 0;
0;
never executed: return 0;
0
44-
45 ap = a->d !=
a->d != ((void *)0)Description
TRUEevaluated 4337421 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-4337421
46 ((void *)0)
a->d != ((void *)0)Description
TRUEevaluated 4337421 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-4337421
47 ? a->d : tp;-
48 bp = b->d !=
b->d != ((void *)0)Description
TRUEevaluated 4337123 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 298 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
298-4337123
49 ((void *)0)
b->d != ((void *)0)Description
TRUEevaluated 4337123 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 298 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
298-4337123
50 ? b->d : tp;-
51-
52 for (i = 0, ai = 0, bi = 0, carry = 0; i < mtop
i < mtopDescription
TRUEevaluated 27221631 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 4337421 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
;) {
4337421-27221631
53 mask = (unsigned long)0 - ((i - a->top) >> (8 * sizeof(i) - 1));-
54 temp = ((ap[ai] & mask) + carry) & (0xffffffffffffffffL);-
55 carry = (temp < carry);-
56-
57 mask = (unsigned long)0 - ((i - b->top) >> (8 * sizeof(i) - 1));-
58 tp[i] = ((bp[bi] & mask) + temp) & (0xffffffffffffffffL);-
59 carry += (tp[i] < temp);-
60-
61 i++;-
62 ai += (i - a->dmax) >> (8 * sizeof(i) - 1);-
63 bi += (i - b->dmax) >> (8 * sizeof(i) - 1);-
64 }
executed 27221631 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
27221631
65 rp = r->d;-
66 carry -= bn_sub_words(rp, tp, m->d, mtop);-
67 for (i = 0; i < mtop
i < mtopDescription
TRUEevaluated 27221631 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 4337421 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i++) {
4337421-27221631
68 rp[i] = (carry & tp[i]) | (~carry & rp[i]);-
69 ((volatile unsigned long *)tp)[i] = 0;-
70 }
executed 27221631 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
27221631
71 r->top = mtop;-
72 r->flags |= 0;-
73 r->neg = 0;-
74-
75 if (tp != storage
tp != storageDescription
TRUEevaluated 1868 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4335553 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
1868-4335553
76 CRYPTO_free(tp, __FILE__, 90);
executed 1868 times by 1 test: CRYPTO_free(tp, __FILE__, 90);
Executed by:
  • libcrypto.so.1.1
1868
77-
78 return
executed 4337421 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 4337421 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4337421
79}-
80-
81int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,-
82 const BIGNUM *m)-
83{-
84 int ret = bn_mod_add_fixed_top(r, a, b, m);-
85-
86 if (ret
retDescription
TRUEevaluated 4334680 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
)
0-4334680
87 bn_correct_top(r);
executed 4334680 times by 2 tests: bn_correct_top(r);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4334680
88-
89 return
executed 4334680 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 4334680 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4334680
90}-
91-
92int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,-
93 BN_CTX *ctx)-
94{-
95 if (!BN_sub(r, a, b)
!BN_sub(r, a, b)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-13
96 return
never executed: return 0;
0;
never executed: return 0;
0
97 return
executed 13 times by 1 test: return BN_nnmod(r, r, m, ctx);
Executed by:
  • libcrypto.so.1.1
BN_nnmod(r, r, m, ctx);
executed 13 times by 1 test: return BN_nnmod(r, r, m, ctx);
Executed by:
  • libcrypto.so.1.1
13
98}-
99int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,-
100 const BIGNUM *m)-
101{-
102 size_t i, ai, bi, mtop = m->top;-
103 unsigned long borrow, carry, ta, tb, mask, *rp;-
104 const unsigned long *ap, *bp;-
105-
106 if (bn_wexpand(r, mtop) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2374
107 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2374
108 )-
109 return
never executed: return 0;
0;
never executed: return 0;
0
110-
111 rp = r->d;-
112 ap = a->d !=
a->d != ((void *)0)Description
TRUEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2374
113 ((void *)0)
a->d != ((void *)0)Description
TRUEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2374
114 ? a->d : rp;-
115 bp = b->d !=
b->d != ((void *)0)Description
TRUEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2374
116 ((void *)0)
b->d != ((void *)0)Description
TRUEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2374
117 ? b->d : rp;-
118-
119 for (i = 0, ai = 0, bi = 0, borrow = 0; i < mtop
i < mtopDescription
TRUEevaluated 32678 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
;) {
2374-32678
120 mask = (unsigned long)0 - ((i - a->top) >> (8 * sizeof(i) - 1));-
121 ta = ap[ai] & mask;-
122-
123 mask = (unsigned long)0 - ((i - b->top) >> (8 * sizeof(i) - 1));-
124 tb = bp[bi] & mask;-
125 rp[i] = ta - tb - borrow;-
126 if (ta != tb
ta != tbDescription
TRUEevaluated 32635 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 43 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
43-32635
127 borrow = (ta < tb);
executed 32635 times by 1 test: borrow = (ta < tb);
Executed by:
  • libcrypto.so.1.1
32635
128-
129 i++;-
130 ai += (i - a->dmax) >> (8 * sizeof(i) - 1);-
131 bi += (i - b->dmax) >> (8 * sizeof(i) - 1);-
132 }
executed 32678 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
32678
133 ap = m->d;-
134 for (i = 0, mask = 0 - borrow, carry = 0; i < mtop
i < mtopDescription
TRUEevaluated 32678 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++) {
2374-32678
135 ta = ((ap[i] & mask) + carry) & (0xffffffffffffffffL);-
136 carry = (ta < carry);-
137 rp[i] = (rp[i] + ta) & (0xffffffffffffffffL);-
138 carry += (rp[i] < ta);-
139 }
executed 32678 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
32678
140 borrow -= carry;-
141 for (i = 0, mask = 0 - borrow, carry = 0; i < mtop
i < mtopDescription
TRUEevaluated 32678 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++) {
2374-32678
142 ta = ((ap[i] & mask) + carry) & (0xffffffffffffffffL);-
143 carry = (ta < carry);-
144 rp[i] = (rp[i] + ta) & (0xffffffffffffffffL);-
145 carry += (rp[i] < ta);-
146 }
executed 32678 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
32678
147-
148 r->top = mtop;-
149 r->flags |= 0;-
150 r->neg = 0;-
151-
152 return
executed 2374 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 2374 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
2374
153}-
154-
155-
156-
157-
158-
159int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,-
160 const BIGNUM *m)-
161{-
162 if (!BN_sub(r, a, b)
!BN_sub(r, a, b)Description
TRUEnever evaluated
FALSEevaluated 4650717 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-4650717
163 return
never executed: return 0;
0;
never executed: return 0;
0
164 if (r->neg
r->negDescription
TRUEevaluated 2309212 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 2341505 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
2309212-2341505
165 return
executed 2309212 times by 2 tests: return BN_add(r, r, m);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
BN_add(r, r, m);
executed 2309212 times by 2 tests: return BN_add(r, r, m);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
2309212
166 return
executed 2341505 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 2341505 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
2341505
167}-
168-
169-
170int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,-
171 BN_CTX *ctx)-
172{-
173 BIGNUM *t;-
174 int ret = 0;-
175-
176 ;-
177 ;-
178 ;-
179-
180 BN_CTX_start(ctx);-
181 if ((
(t = BN_CTX_ge...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3791466 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
t = BN_CTX_get(ctx)) ==
(t = BN_CTX_ge...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3791466 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-3791466
182 ((void *)0)
(t = BN_CTX_ge...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3791466 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-3791466
183 )-
184 goto
never executed: goto err;
err;
never executed: goto err;
0
185 if (a == b
a == bDescription
TRUEevaluated 3601883 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 189583 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
189583-3601883
186 if (!BN_sqr(t, a, ctx)
!BN_sqr(t, a, ctx)Description
TRUEnever evaluated
FALSEevaluated 3601883 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-3601883
187 goto
never executed: goto err;
err;
never executed: goto err;
0
188 }
executed 3601883 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
3601883
189 if (!BN_mul(t, a, b, ctx)
!BN_mul(t, a, b, ctx)Description
TRUEnever evaluated
FALSEevaluated 189583 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-189583
190 goto
never executed: goto err;
err;
never executed: goto err;
0
191 }
executed 189583 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
189583
192 if (!BN_nnmod(r, t, m, ctx)
!BN_nnmod(r, t, m, ctx)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3791465 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
1-3791465
193 goto
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1
194 ;-
195 ret = 1;-
196 err:
code before this statement executed 3791465 times by 2 tests: err:
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3791465
197 BN_CTX_end(ctx);-
198 return
executed 3791466 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 3791466 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3791466
199}-
200-
201int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)-
202{-
203 if (!BN_sqr(r, a, ctx)
!BN_sqr(r, a, ctx)Description
TRUEnever evaluated
FALSEevaluated 147879 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-147879
204 return
never executed: return 0;
0;
never executed: return 0;
0
205-
206 return
executed 147879 times by 2 tests: return BN_div( ((void *)0) ,(r),(r),(m),(ctx));
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
BN_div(
executed 147879 times by 2 tests: return BN_div( ((void *)0) ,(r),(r),(m),(ctx));
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
147879
207 ((void *)0)
executed 147879 times by 2 tests: return BN_div( ((void *)0) ,(r),(r),(m),(ctx));
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
147879
208 ,(r),(r),(m),(ctx));
executed 147879 times by 2 tests: return BN_div( ((void *)0) ,(r),(r),(m),(ctx));
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
147879
209}-
210-
211int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)-
212{-
213 if (!BN_lshift1(r, a)
!BN_lshift1(r, a)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
214 return
never executed: return 0;
0;
never executed: return 0;
0
215 ;-
216 return
never executed: return BN_nnmod(r, r, m, ctx);
BN_nnmod(r, r, m, ctx);
never executed: return BN_nnmod(r, r, m, ctx);
0
217}-
218-
219-
220-
221-
222-
223int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m)-
224{-
225 if (!BN_lshift1(r, a)
!BN_lshift1(r, a)Description
TRUEnever evaluated
FALSEevaluated 1775606 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-1775606
226 return
never executed: return 0;
0;
never executed: return 0;
0
227 ;-
228 if (BN_cmp(r, m) >= 0
BN_cmp(r, m) >= 0Description
TRUEevaluated 892578 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 883028 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
883028-892578
229 return
executed 892578 times by 2 tests: return BN_sub(r, r, m);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
BN_sub(r, r, m);
executed 892578 times by 2 tests: return BN_sub(r, r, m);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
892578
230 return
executed 883028 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 883028 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
883028
231}-
232-
233int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,-
234 BN_CTX *ctx)-
235{-
236 BIGNUM *abs_m = -
237 ((void *)0)-
238 ;-
239 int ret;-
240-
241 if (!BN_nnmod(r, a, m, ctx)
!BN_nnmod(r, a, m, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
242 return
never executed: return 0;
0;
never executed: return 0;
0
243-
244 if (m->neg
m->negDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
245 abs_m = BN_dup(m);-
246 if (abs_m ==
abs_m == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
247 ((void *)0)
abs_m == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
248 )-
249 return
never executed: return 0;
0;
never executed: return 0;
0
250 abs_m->neg = 0;-
251 }
never executed: end of block
0
252-
253 ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m));-
254 ;-
255-
256 BN_free(abs_m);-
257 return
never executed: return ret;
ret;
never executed: return ret;
0
258}-
259-
260-
261-
262-
263-
264int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m)-
265{-
266 if (r != a
r != aDescription
TRUEevaluated 783904 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 151159 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
151159-783904
267 if (BN_copy(r, a) ==
BN_copy(r, a) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 783904 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-783904
268 ((void *)0)
BN_copy(r, a) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 783904 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-783904
269 )-
270 return
never executed: return 0;
0;
never executed: return 0;
0
271 }
executed 783904 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
783904
272-
273 while (n > 0
n > 0Description
TRUEevaluated 1530937 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 935063 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
935063-1530937
274 int max_shift;-
275-
276-
277 max_shift = BN_num_bits(m) - BN_num_bits(r);-
278-
279-
280 if (max_shift < 0
max_shift < 0Description
TRUEnever evaluated
FALSEevaluated 1530937 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-1530937
281 ERR_put_error(3,(119),(110),__FILE__,294);-
282 return
never executed: return 0;
0;
never executed: return 0;
0
283 }-
284-
285 if (max_shift > n
max_shift > nDescription
TRUEevaluated 185297 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1345640 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
185297-1345640
286 max_shift = n;
executed 185297 times by 2 tests: max_shift = n;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
185297
287-
288 if (max_shift
max_shiftDescription
TRUEevaluated 836382 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 694555 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
694555-836382
289 if (!BN_lshift(r, r, max_shift)
!BN_lshift(r, r, max_shift)Description
TRUEnever evaluated
FALSEevaluated 836382 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-836382
290 return
never executed: return 0;
0;
never executed: return 0;
0
291 n -= max_shift;-
292 }
executed 836382 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else {
836382
293 if (!BN_lshift1(r, r)
!BN_lshift1(r, r)Description
TRUEnever evaluated
FALSEevaluated 694555 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-694555
294 return
never executed: return 0;
0;
never executed: return 0;
0
295 --n;-
296 }
executed 694555 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
694555
297-
298-
299-
300 if (BN_cmp(r, m) >= 0
BN_cmp(r, m) >= 0Description
TRUEevaluated 800324 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 730613 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
730613-800324
301 if (!BN_sub(r, r, m)
!BN_sub(r, r, m)Description
TRUEnever evaluated
FALSEevaluated 800324 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-800324
302 return
never executed: return 0;
0;
never executed: return 0;
0
303 }
executed 800324 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
800324
304 }
executed 1530937 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1530937
305 ;-
306-
307 return
executed 935063 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 935063 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
935063
308}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2