OpenCoverage

bn_mont.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_mont.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5static int bn_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont);-
6-
7-
8int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,-
9 BN_MONT_CTX *mont, BN_CTX *ctx)-
10{-
11 int ret = bn_mul_mont_fixed_top(r, a, b, mont, ctx);-
12-
13 bn_correct_top(r);-
14 ;-
15-
16 return
executed 16868843 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 16868843 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
16868843
17}-
18-
19int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,-
20 BN_MONT_CTX *mont, BN_CTX *ctx)-
21{-
22 BIGNUM *tmp;-
23 int ret = 0;-
24 int num = mont->N.top;-
25-
26-
27 if (num > 1
num > 1Description
TRUEevaluated 19372441 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 56138 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& a->top == num
a->top == numDescription
TRUEevaluated 19180355 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 192086 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
&& b->top == num
b->top == numDescription
TRUEevaluated 19072833 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 107522 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
56138-19372441
28 if (bn_wexpand(r, num) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 19072833 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-19072833
29 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 19072833 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-19072833
30 )-
31 return
never executed: return 0;
0;
never executed: return 0;
0
32 if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)
bn_mul_mont(r-...mont->n0, num)Description
TRUEevaluated 19072833 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
) {
0-19072833
33 r->neg = a->neg ^ b->neg;-
34 r->top = num;-
35 r->flags |= 0;-
36 return
executed 19072833 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 19072833 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
19072833
37 }-
38 }
never executed: end of block
0
39-
40-
41 if ((
(a->top + b->top) > 2 * numDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 355745 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
a->top + b->top) > 2 * num
(a->top + b->top) > 2 * numDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 355745 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
1-355745
42 return
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
1
43-
44 BN_CTX_start(ctx);-
45 tmp = BN_CTX_get(ctx);-
46 if (tmp ==
tmp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 355745 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-355745
47 ((void *)0)
tmp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 355745 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-355745
48 )-
49 goto
never executed: goto err;
err;
never executed: goto err;
0
50-
51 ;-
52 if (a == b
a == bDescription
TRUEevaluated 66756 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 288989 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
66756-288989
53 if (!bn_sqr_fixed_top(tmp, a, ctx)
!bn_sqr_fixed_top(tmp, a, ctx)Description
TRUEnever evaluated
FALSEevaluated 66756 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-66756
54 goto
never executed: goto err;
err;
never executed: goto err;
0
55 }
executed 66756 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
66756
56 if (!bn_mul_fixed_top(tmp, a, b, ctx)
!bn_mul_fixed_...mp, a, b, ctx)Description
TRUEnever evaluated
FALSEevaluated 288989 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-288989
57 goto
never executed: goto err;
err;
never executed: goto err;
0
58 }
executed 288989 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
288989
59-
60-
61 if (!bn_from_montgomery_word(r, tmp, mont)
!bn_from_montg...(r, tmp, mont)Description
TRUEnever evaluated
FALSEevaluated 355745 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-355745
62 goto
never executed: goto err;
err;
never executed: goto err;
0
63-
64-
65-
66-
67 ret = 1;-
68 err:
code before this statement executed 355745 times by 2 tests: err:
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
355745
69 BN_CTX_end(ctx);-
70 return
executed 355745 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 355745 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
355745
71}-
72-
73-
74static int bn_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)-
75{-
76 BIGNUM *n;-
77 unsigned long *ap, *np, *rp, n0, v, carry;-
78 int nl, max, i;-
79 unsigned int rtop;-
80-
81 n = &(mont->N);-
82 nl = n->top;-
83 if (nl == 0
nl == 0Description
TRUEnever evaluated
FALSEevaluated 407757 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-407757
84 ret->top = 0;-
85 return
never executed: return 1;
1;
never executed: return 1;
0
86 }-
87-
88 max = (2 * nl);-
89 if (bn_wexpand(r, max) ==
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 407757 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-407757
90 ((void *)0)
bn_wexpand(r, ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 407757 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-407757
91 )-
92 return
never executed: return 0;
0;
never executed: return 0;
0
93-
94 r->neg ^= n->neg;-
95 np = n->d;-
96 rp = r->d;-
97-
98-
99 for (rtop = r->top, i = 0; i < max
i < maxDescription
TRUEevaluated 4633356 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 407757 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i++) {
407757-4633356
100 v = (unsigned long)0 - ((i - rtop) >> (8 * sizeof(rtop) - 1));-
101 rp[i] &= v;-
102 }
executed 4633356 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4633356
103-
104 r->top = max;-
105 r->flags |= 0;-
106 n0 = mont->n0[0];-
107-
108-
109-
110-
111-
112-
113 for (carry = 0, i = 0; i < nl
i < nlDescription
TRUEevaluated 2316678 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 407757 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i++, rp++) {
407757-2316678
114 v = bn_mul_add_words(rp, np, nl, (rp[0] * n0) & (0xffffffffffffffffL));-
115 v = (v + carry + rp[nl]) & (0xffffffffffffffffL);-
116 carry |= (v != rp[nl]);-
117 carry &= (v <= rp[nl]);-
118 rp[nl] = v;-
119 }
executed 2316678 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
2316678
120-
121 if (bn_wexpand(ret, nl) ==
bn_wexpand(ret...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 407757 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-407757
122 ((void *)0)
bn_wexpand(ret...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 407757 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-407757
123 )-
124 return
never executed: return 0;
0;
never executed: return 0;
0
125 ret->top = nl;-
126 ret->flags |= 0;-
127 ret->neg = r->neg;-
128-
129 rp = ret->d;-
130-
131-
132-
133-
134-
135 ap = &(r->d[nl]);-
136-
137 carry -= bn_sub_words(rp, ap, np, nl);-
138-
139-
140-
141-
142-
143 for (i = 0; i < nl
i < nlDescription
TRUEevaluated 2316678 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 407757 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i++) {
407757-2316678
144 rp[i] = (carry & ap[i]) | (~carry & rp[i]);-
145 ap[i] = 0;-
146 }
executed 2316678 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
2316678
147-
148 return
executed 407757 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 407757 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
407757
149}-
150-
151-
152int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,-
153 BN_CTX *ctx)-
154{-
155 int retn;-
156-
157 retn = bn_from_mont_fixed_top(ret, a, mont, ctx);-
158 bn_correct_top(ret);-
159 ;-
160-
161 return
executed 47264 times by 2 tests: return retn;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
retn;
executed 47264 times by 2 tests: return retn;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
47264
162}-
163-
164int bn_from_mont_fixed_top(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,-
165 BN_CTX *ctx)-
166{-
167 int retn = 0;-
168-
169 BIGNUM *t;-
170-
171 BN_CTX_start(ctx);-
172 if ((
(t = BN_CTX_get(ctx))Description
TRUEevaluated 52012 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
t = BN_CTX_get(ctx))
(t = BN_CTX_get(ctx))Description
TRUEevaluated 52012 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
&& BN_copy(t, a)
BN_copy(t, a)Description
TRUEevaluated 52012 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
) {
0-52012
173 retn = bn_from_montgomery_word(ret, t, mont);-
174 }
executed 52012 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
52012
175 BN_CTX_end(ctx);-
176 return
executed 52012 times by 2 tests: return retn;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
retn;
executed 52012 times by 2 tests: return retn;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
52012
177}-
178-
179int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,-
180 BN_CTX *ctx)-
181{-
182 return
executed 37581 times by 2 tests: return bn_mul_mont_fixed_top(r, a, &(mont->RR), mont, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
bn_mul_mont_fixed_top(r, a, &(mont->RR), mont, ctx);
executed 37581 times by 2 tests: return bn_mul_mont_fixed_top(r, a, &(mont->RR), mont, ctx);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
37581
183}-
184-
185BN_MONT_CTX *BN_MONT_CTX_new(void)-
186{-
187 BN_MONT_CTX *ret;-
188-
189 if ((
(ret = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 141614 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret = CRYPTO_malloc(sizeof(*ret), __FILE__, 232)) ==
(ret = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 141614 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-141614
190 ((void *)0)
(ret = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 141614 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-141614
191 ) {-
192 ERR_put_error(3,(149),((1|64)),__FILE__,233);-
193 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
194 ((void *)0)
never executed: return ((void *)0) ;
0
195 ;
never executed: return ((void *)0) ;
0
196 }-
197-
198 BN_MONT_CTX_init(ret);-
199 ret->flags = 0x01;-
200 return
executed 141614 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 141614 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
141614
201}-
202-
203void BN_MONT_CTX_init(BN_MONT_CTX *ctx)-
204{-
205 ctx->ri = 0;-
206 bn_init(&ctx->RR);-
207 bn_init(&ctx->N);-
208 bn_init(&ctx->Ni);-
209 ctx->n0[0] = ctx->n0[1] = 0;-
210 ctx->flags = 0;-
211}
executed 141614 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
141614
212-
213void BN_MONT_CTX_free(BN_MONT_CTX *mont)-
214{-
215 if (mont ==
mont == ((void *)0)Description
TRUEevaluated 218062 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 141614 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
141614-218062
216 ((void *)0)
mont == ((void *)0)Description
TRUEevaluated 218062 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 141614 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
141614-218062
217 )-
218 return;
executed 218062 times by 2 tests: return;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
218062
219 BN_clear_free(&mont->RR);-
220 BN_clear_free(&mont->N);-
221 BN_clear_free(&mont->Ni);-
222 if (mont->flags & 0x01
mont->flags & 0x01Description
TRUEevaluated 141614 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
)
0-141614
223 CRYPTO_free(mont, __FILE__, 260);
executed 141614 times by 2 tests: CRYPTO_free(mont, __FILE__, 260);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
141614
224}
executed 141614 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
141614
225-
226int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)-
227{-
228 int i, ret = 0;-
229 BIGNUM *Ri, *R;-
230-
231 if (BN_is_zero(mod)
BN_is_zero(mod)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 83602 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
1-83602
232 return
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
1
233-
234 BN_CTX_start(ctx);-
235 if ((
(Ri = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 83602 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
Ri = BN_CTX_get(ctx)) ==
(Ri = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 83602 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-83602
236 ((void *)0)
(Ri = BN_CTX_g...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 83602 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-83602
237 )-
238 goto
never executed: goto err;
err;
never executed: goto err;
0
239 R = &(mont->RR);-
240 if (!BN_copy(&(mont->N), mod)
!BN_copy(&(mont->N), mod)Description
TRUEnever evaluated
FALSEevaluated 83602 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-83602
241 goto
never executed: goto err;
err;
never executed: goto err;
0
242 if (BN_get_flags(mod, 0x04) != 0
BN_get_flags(mod, 0x04) != 0Description
TRUEevaluated 8536 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 75066 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
8536-75066
243 BN_set_flags(&(mont->N), 0x04);
executed 8536 times by 1 test: BN_set_flags(&(mont->N), 0x04);
Executed by:
  • libcrypto.so.1.1
8536
244 mont->N.neg = 0;-
245-
246-
247 {-
248 BIGNUM tmod;-
249 unsigned long buf[2];-
250-
251 bn_init(&tmod);-
252 tmod.d = buf;-
253 tmod.dmax = 2;-
254 tmod.neg = 0;-
255-
256 if (BN_get_flags(mod, 0x04) != 0
BN_get_flags(mod, 0x04) != 0Description
TRUEevaluated 8536 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 75066 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
8536-75066
257 BN_set_flags(&tmod, 0x04);
executed 8536 times by 1 test: BN_set_flags(&tmod, 0x04);
Executed by:
  • libcrypto.so.1.1
8536
258-
259 mont->ri = (BN_num_bits(mod) + ((8 * 8) - 1)) / (8 * 8) * (8 * 8);-
260 (BN_set_word((R),0));-
261 if (!(BN_set_bit(R, (8 * 8)))
!(BN_set_bit(R, (8 * 8)))Description
TRUEnever evaluated
FALSEevaluated 83602 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-83602
262 goto
never executed: goto err;
err;
never executed: goto err;
0
263-
264 buf[0] = mod->d[0];-
265 buf[1] = 0;-
266 tmod.top = buf[0] != 0
buf[0] != 0Description
TRUEevaluated 83563 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 39 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
? 1 : 0;
39-83563
267-
268 if (BN_is_one(&tmod)
BN_is_one(&tmod)Description
TRUEevaluated 6654 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 76948 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
6654-76948
269 (
executed 6654 times by 1 test: (BN_set_word((Ri),0));
Executed by:
  • libcrypto.so.1.1
BN_set_word((Ri),0));
executed 6654 times by 1 test: (BN_set_word((Ri),0));
Executed by:
  • libcrypto.so.1.1
6654
270 else if ((
(BN_mod_invers...== ((void *)0)Description
TRUEevaluated 445 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 76503 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
BN_mod_inverse(Ri, R, &tmod, ctx)) ==
(BN_mod_invers...== ((void *)0)Description
TRUEevaluated 445 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 76503 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
445-76503
271 ((void *)0)
(BN_mod_invers...== ((void *)0)Description
TRUEevaluated 445 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 76503 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
445-76503
272 )-
273 goto
executed 445 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 445 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
445
274 if (!BN_lshift(Ri, Ri, (8 * 8))
!BN_lshift(Ri, Ri, (8 * 8))Description
TRUEnever evaluated
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-83157
275 goto
never executed: goto err;
err;
never executed: goto err;
0
276 if (!BN_is_zero(Ri)
!BN_is_zero(Ri)Description
TRUEevaluated 76503 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 6654 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
6654-76503
277 if (!BN_sub_word(Ri, 1)
!BN_sub_word(Ri, 1)Description
TRUEnever evaluated
FALSEevaluated 76503 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-76503
278 goto
never executed: goto err;
err;
never executed: goto err;
0
279 }
executed 76503 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
else {
76503
280-
281 if (!BN_set_word(Ri, (0xffffffffffffffffL))
!BN_set_word(R...fffffffffffL))Description
TRUEnever evaluated
FALSEevaluated 6654 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-6654
282 goto
never executed: goto err;
err;
never executed: goto err;
0
283 }
executed 6654 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6654
284 if (!BN_div(Ri,
!BN_div(Ri, ((...i, &tmod, ctx)Description
TRUEnever evaluated
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-83157
285 ((void *)0)
!BN_div(Ri, ((...i, &tmod, ctx)Description
TRUEnever evaluated
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-83157
286 , Ri, &tmod, ctx)
!BN_div(Ri, ((...i, &tmod, ctx)Description
TRUEnever evaluated
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-83157
287 goto
never executed: goto err;
err;
never executed: goto err;
0
288-
289-
290-
291 mont->n0[0] = (
(Ri->top > 0)Description
TRUEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
Ri->top > 0)
(Ri->top > 0)Description
TRUEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
? Ri->d[0] : 0;
0-83157
292 mont->n0[1] = 0;-
293-
294 }-
295 (BN_set_word((&(mont->RR)),0));-
296 if (!BN_set_bit(&(mont->RR), mont->ri * 2)
!BN_set_bit(&(... mont->ri * 2)Description
TRUEnever evaluated
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-83157
297 goto
never executed: goto err;
err;
never executed: goto err;
0
298 if (!BN_div(
!BN_div( ((voi...nt->N)),(ctx))Description
TRUEnever evaluated
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-83157
299 ((void *)0)
!BN_div( ((voi...nt->N)),(ctx))Description
TRUEnever evaluated
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-83157
300 ,(&(mont->RR)),(&(mont->RR)),(&(mont->N)),(ctx))
!BN_div( ((voi...nt->N)),(ctx))Description
TRUEnever evaluated
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-83157
301 goto
never executed: goto err;
err;
never executed: goto err;
0
302-
303 for (i = mont->RR.top, ret = mont->N.top; i < ret
i < retDescription
TRUEevaluated 22425 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 83157 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
; i++)
22425-83157
304 mont->RR.d[i] = 0;
executed 22425 times by 1 test: mont->RR.d[i] = 0;
Executed by:
  • libcrypto.so.1.1
22425
305 mont->RR.top = ret;-
306 mont->RR.flags |= 0;-
307-
308 ret = 1;-
309 err:
code before this statement executed 83157 times by 2 tests: err:
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
83157
310 BN_CTX_end(ctx);-
311 return
executed 83602 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
ret;
executed 83602 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
83602
312}-
313-
314BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)-
315{-
316 if (to == from
to == fromDescription
TRUEnever evaluated
FALSEevaluated 58017 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-58017
317 return
never executed: return to;
to;
never executed: return to;
0
318-
319 if (!BN_copy(&(to->RR), &(from->RR))
!BN_copy(&(to-..., &(from->RR))Description
TRUEnever evaluated
FALSEevaluated 58017 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-58017
320 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
321 ((void *)0)
never executed: return ((void *)0) ;
0
322 ;
never executed: return ((void *)0) ;
0
323 if (!BN_copy(&(to->N), &(from->N))
!BN_copy(&(to->N), &(from->N))Description
TRUEnever evaluated
FALSEevaluated 58017 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-58017
324 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
325 ((void *)0)
never executed: return ((void *)0) ;
0
326 ;
never executed: return ((void *)0) ;
0
327 if (!BN_copy(&(to->Ni), &(from->Ni))
!BN_copy(&(to-..., &(from->Ni))Description
TRUEnever evaluated
FALSEevaluated 58017 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-58017
328 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
329 ((void *)0)
never executed: return ((void *)0) ;
0
330 ;
never executed: return ((void *)0) ;
0
331 to->ri = from->ri;-
332 to->n0[0] = from->n0[0];-
333 to->n0[1] = from->n0[1];-
334 return
executed 58017 times by 2 tests: return to;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
to;
executed 58017 times by 2 tests: return to;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
58017
335}-
336-
337BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock,-
338 const BIGNUM *mod, BN_CTX *ctx)-
339{-
340 BN_MONT_CTX *ret;-
341-
342 CRYPTO_THREAD_read_lock(lock);-
343 ret = *pmont;-
344 CRYPTO_THREAD_unlock(lock);-
345 if (ret
retDescription
TRUEevaluated 2376 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8871 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
2376-8871
346 return
executed 2376 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 2376 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
2376
347 ret = BN_MONT_CTX_new();-
348 if (ret ==
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8871 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8871
349 ((void *)0)
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8871 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8871
350 )-
351 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
352 ((void *)0)
never executed: return ((void *)0) ;
0
353 ;
never executed: return ((void *)0) ;
0
354 if (!BN_MONT_CTX_set(ret, mod, ctx)
!BN_MONT_CTX_s...ret, mod, ctx)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8849 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
22-8849
355 BN_MONT_CTX_free(ret);-
356 return
executed 22 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
executed 22 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
22
357 ((void *)0)
executed 22 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
22
358 ;
executed 22 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
22
359 }-
360-
361-
362 CRYPTO_THREAD_write_lock(lock);-
363 if (*
*pmontDescription
TRUEnever evaluated
FALSEevaluated 8849 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
pmont
*pmontDescription
TRUEnever evaluated
FALSEevaluated 8849 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-8849
364 BN_MONT_CTX_free(ret);-
365 ret = *pmont;-
366 }
never executed: end of block
else
0
367 *
executed 8849 times by 1 test: *pmont = ret;
Executed by:
  • libcrypto.so.1.1
pmont = ret;
executed 8849 times by 1 test: *pmont = ret;
Executed by:
  • libcrypto.so.1.1
8849
368 CRYPTO_THREAD_unlock(lock);-
369 return
executed 8849 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 8849 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
8849
370}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2