OpenCoverage

bn_print.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_print.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#include <stdio.h>-
11#include "internal/ctype.h"-
12#include <limits.h>-
13#include "internal/cryptlib.h"-
14#include <openssl/buffer.h>-
15#include "bn_lcl.h"-
16-
17static const char Hex[] = "0123456789ABCDEF";-
18-
19/* Must 'OPENSSL_free' the returned data */-
20char *BN_bn2hex(const BIGNUM *a)-
21{-
22 int i, j, v, z = 0;-
23 char *buf;-
24 char *p;-
25-
26 if (BN_is_zero(a))
BN_is_zero(a)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1728 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5-1728
27 return OPENSSL_strdup("0");
executed 5 times by 1 test: return CRYPTO_strdup("0", __FILE__, 27);
Executed by:
  • libcrypto.so.1.1
5
28 buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2);-
29 if (buf == NULL) {
buf == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1728 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1728
30 BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE);-
31 goto err;
never executed: goto err;
0
32 }-
33 p = buf;-
34 if (a->neg)
a->negDescription
TRUEevaluated 733 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 995 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
733-995
35 *p++ = '-';
executed 733 times by 1 test: *p++ = '-';
Executed by:
  • libcrypto.so.1.1
733
36 for (i = a->top - 1; i >= 0; i--) {
i >= 0Description
TRUEevaluated 7472 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1728 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1728-7472
37 for (j = BN_BITS2 - 8; j >= 0; j -= 8) {
j >= 0Description
TRUEevaluated 59776 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7472 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7472-59776
38 /* strip leading zeros */-
39 v = (int)((a->d[i] >> j) & 0xff);-
40 if (z || v != 0) {
zDescription
TRUEevaluated 47804 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11972 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
v != 0Description
TRUEevaluated 1728 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10244 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1728-47804
41 *p++ = Hex[v >> 4];-
42 *p++ = Hex[v & 0x0f];-
43 z = 1;-
44 }
executed 49532 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
49532
45 }
executed 59776 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
59776
46 }
executed 7472 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
7472
47 *p = '\0';-
48 err:
code before this statement executed 1728 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
1728
49 return buf;
executed 1728 times by 1 test: return buf;
Executed by:
  • libcrypto.so.1.1
1728
50}-
51-
52/* Must 'OPENSSL_free' the returned data */-
53char *BN_bn2dec(const BIGNUM *a)-
54{-
55 int i = 0, num, ok = 0, n, tbytes;-
56 char *buf = NULL;-
57 char *p;-
58 BIGNUM *t = NULL;-
59 BN_ULONG *bn_data = NULL, *lp;-
60 int bn_data_num;-
61-
62 /*--
63 * get an upper bound for the length of the decimal integer-
64 * num <= (BN_num_bits(a) + 1) * log(2)-
65 * <= 3 * BN_num_bits(a) * 0.101 + log(2) + 1 (rounding error)-
66 * <= 3 * BN_num_bits(a) / 10 + 3 * BN_num_bits / 1000 + 1 + 1-
67 */-
68 i = BN_num_bits(a) * 3;-
69 num = (i / 10 + i / 1000 + 1) + 1;-
70 tbytes = num + 3; /* negative and terminator and one spare? */-
71 bn_data_num = num / BN_DEC_NUM + 1;-
72 bn_data = OPENSSL_malloc(bn_data_num * sizeof(BN_ULONG));-
73 buf = OPENSSL_malloc(tbytes);-
74 if (buf == NULL || bn_data == NULL) {
buf == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 18302 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
bn_data == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 18302 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-18302
75 BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE);-
76 goto err;
never executed: goto err;
0
77 }-
78 if ((t = BN_dup(a)) == NULL)
(t = BN_dup(a)) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 18302 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-18302
79 goto err;
never executed: goto err;
0
80-
81 p = buf;-
82 lp = bn_data;-
83 if (BN_is_zero(t)) {
BN_is_zero(t)Description
TRUEevaluated 1160 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17142 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1160-17142
84 *p++ = '0';-
85 *p++ = '\0';-
86 } else {
executed 1160 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1160
87 if (BN_is_negative(t))
BN_is_negative(t)Description
TRUEevaluated 1906 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 15236 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1906-15236
88 *p++ = '-';
executed 1906 times by 1 test: *p++ = '-';
Executed by:
  • libcrypto.so.1.1
1906
89-
90 while (!BN_is_zero(t)) {
!BN_is_zero(t)Description
TRUEevaluated 35612 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17142 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
17142-35612
91 if (lp - bn_data >= bn_data_num)
lp - bn_data >= bn_data_numDescription
TRUEnever evaluated
FALSEevaluated 35612 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-35612
92 goto err;
never executed: goto err;
0
93 *lp = BN_div_word(t, BN_DEC_CONV);-
94 if (*lp == (BN_ULONG)-1)
*lp == (unsigned long)-1Description
TRUEnever evaluated
FALSEevaluated 35612 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-35612
95 goto err;
never executed: goto err;
0
96 lp++;-
97 }
executed 35612 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
35612
98 lp--;-
99 /*-
100 * We now have a series of blocks, BN_DEC_NUM chars in length, where-
101 * the last one needs truncation. The blocks need to be reversed in-
102 * order.-
103 */-
104 n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT1, *lp);-
105 if (n < 0)
n < 0Description
TRUEnever evaluated
FALSEevaluated 17142 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-17142
106 goto err;
never executed: goto err;
0
107 p += n;-
108 while (lp != bn_data) {
lp != bn_dataDescription
TRUEevaluated 18470 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17142 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
17142-18470
109 lp--;-
110 n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT2, *lp);-
111 if (n < 0)
n < 0Description
TRUEnever evaluated
FALSEevaluated 18470 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-18470
112 goto err;
never executed: goto err;
0
113 p += n;-
114 }
executed 18470 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
18470
115 }
executed 17142 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
17142
116 ok = 1;-
117 err:
code before this statement executed 18302 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
18302
118 OPENSSL_free(bn_data);-
119 BN_free(t);-
120 if (ok)
okDescription
TRUEevaluated 18302 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-18302
121 return buf;
executed 18302 times by 1 test: return buf;
Executed by:
  • libcrypto.so.1.1
18302
122 OPENSSL_free(buf);-
123 return NULL;
never executed: return ((void *)0) ;
0
124}-
125-
126int BN_hex2bn(BIGNUM **bn, const char *a)-
127{-
128 BIGNUM *ret = NULL;-
129 BN_ULONG l = 0;-
130 int neg = 0, h, m, i, j, k, c;-
131 int num;-
132-
133 if (a == NULL || *a == '\0')
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8393 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
*a == '\0'Description
TRUEnever evaluated
FALSEevaluated 8393 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-8393
134 return 0;
never executed: return 0;
0
135-
136 if (*a == '-') {
*a == '-'Description
TRUEevaluated 1796 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6597 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
1796-6597
137 neg = 1;-
138 a++;-
139 }
executed 1796 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1796
140-
141 for (i = 0; i <= INT_MAX / 4 && ossl_isxdigit(a[i]); i++)
i <= 0x7fffffff / 4Description
TRUEevaluated 803016 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
(ossl_ctype_ch...(a[i]), 0x10))Description
TRUEevaluated 794623 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 8393 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-803016
142 continue;
executed 794623 times by 2 tests: continue;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
794623
143-
144 if (i == 0 || i > INT_MAX / 4)
i == 0Description
TRUEnever evaluated
FALSEevaluated 8393 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
i > 0x7fffffff / 4Description
TRUEnever evaluated
FALSEevaluated 8393 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-8393
145 goto err;
never executed: goto err;
0
146-
147 num = i + neg;-
148 if (bn == NULL)
bn == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8393 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-8393
149 return num;
never executed: return num;
0
150-
151 /* a is the start of the hex digits, and it is 'i' long */-
152 if (*bn == NULL) {
*bn == ((void *)0)Description
TRUEevaluated 8181 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 212 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
212-8181
153 if ((ret = BN_new()) == NULL)
(ret = BN_new(...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8181 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-8181
154 return 0;
never executed: return 0;
0
155 } else {
executed 8181 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
8181
156 ret = *bn;-
157 BN_zero(ret);-
158 }
executed 212 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
212
159-
160 /* i is the number of hex digits */-
161 if (bn_expand(ret, i * 4) == NULL)
bn_expand(ret,...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8393 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-8393
162 goto err;
never executed: goto err;
0
163-
164 j = i; /* least significant 'hex' */-
165 m = 0;-
166 h = 0;-
167 while (j > 0) {
j > 0Description
TRUEevaluated 53559 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 8393 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
8393-53559
168 m = (BN_BYTES * 2 <= j) ? BN_BYTES * 2 : j;
(8 * 2 <= j)Description
TRUEevaluated 47141 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 6418 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
6418-47141
169 l = 0;-
170 for (;;) {-
171 c = a[j - m];-
172 k = OPENSSL_hexchar2int(c);-
173 if (k < 0)
k < 0Description
TRUEnever evaluated
FALSEevaluated 794623 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-794623
174 k = 0; /* paranoia */
never executed: k = 0;
0
175 l = (l << 4) | k;-
176-
177 if (--m <= 0) {
--m <= 0Description
TRUEevaluated 53559 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 741064 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
53559-741064
178 ret->d[h++] = l;-
179 break;
executed 53559 times by 2 tests: break;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
53559
180 }-
181 }
executed 741064 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
741064
182 j -= BN_BYTES * 2;-
183 }
executed 53559 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
53559
184 ret->top = h;-
185 bn_correct_top(ret);-
186-
187 *bn = ret;-
188 bn_check_top(ret);-
189 /* Don't set the negative flag if it's zero. */-
190 if (ret->top != 0)
ret->top != 0Description
TRUEevaluated 8282 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 111 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
111-8282
191 ret->neg = neg;
executed 8282 times by 2 tests: ret->neg = neg;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
8282
192 return num;
executed 8393 times by 2 tests: return num;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
8393
193 err:-
194 if (*bn == NULL)
*bn == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
195 BN_free(ret);
never executed: BN_free(ret);
0
196 return 0;
never executed: return 0;
0
197}-
198-
199int BN_dec2bn(BIGNUM **bn, const char *a)-
200{-
201 BIGNUM *ret = NULL;-
202 BN_ULONG l = 0;-
203 int neg = 0, i, j;-
204 int num;-
205-
206 if (a == NULL || *a == '\0')
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
*a == '\0'Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-44
207 return 0;
never executed: return 0;
0
208 if (*a == '-') {
*a == '-'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 41 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-41
209 neg = 1;-
210 a++;-
211 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3
212-
213 for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)
i <= 0x7fffffff / 4Description
TRUEevaluated 1130 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(ossl_ctype_ch...((a[i]), 0x4))Description
TRUEevaluated 1086 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1130
214 continue;
executed 1086 times by 1 test: continue;
Executed by:
  • libcrypto.so.1.1
1086
215-
216 if (i == 0 || i > INT_MAX / 4)
i == 0Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
i > 0x7fffffff / 4Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-44
217 goto err;
never executed: goto err;
0
218-
219 num = i + neg;-
220 if (bn == NULL)
bn == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-44
221 return num;
never executed: return num;
0
222-
223 /*-
224 * a is the start of the digits, and it is 'i' long. We chop it into-
225 * BN_DEC_NUM digits at a time-
226 */-
227 if (*bn == NULL) {
*bn == ((void *)0)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 35 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
9-35
228 if ((ret = BN_new()) == NULL)
(ret = BN_new(...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9
229 return 0;
never executed: return 0;
0
230 } else {
executed 9 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
9
231 ret = *bn;-
232 BN_zero(ret);-
233 }
executed 35 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
35
234-
235 /* i is the number of digits, a bit of an over expand */-
236 if (bn_expand(ret, i * 4) == NULL)
bn_expand(ret,...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-44
237 goto err;
never executed: goto err;
0
238-
239 j = BN_DEC_NUM - i % BN_DEC_NUM;-
240 if (j == BN_DEC_NUM)
j == 19Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 42 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-42
241 j = 0;
executed 2 times by 1 test: j = 0;
Executed by:
  • libcrypto.so.1.1
2
242 l = 0;-
243 while (--i >= 0) {
--i >= 0Description
TRUEevaluated 1086 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 44 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
44-1086
244 l *= 10;-
245 l += *a - '0';-
246 a++;-
247 if (++j == BN_DEC_NUM) {
++j == 19Description
TRUEevaluated 89 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 997 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
89-997
248 if (!BN_mul_word(ret, BN_DEC_CONV)
!BN_mul_word(r...0000000000UL))Description
TRUEnever evaluated
FALSEevaluated 89 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-89
249 || !BN_add_word(ret, l))
!BN_add_word(ret, l)Description
TRUEnever evaluated
FALSEevaluated 89 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-89
250 goto err;
never executed: goto err;
0
251 l = 0;-
252 j = 0;-
253 }
executed 89 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
89
254 }
executed 1086 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1086
255-
256 bn_correct_top(ret);-
257 *bn = ret;-
258 bn_check_top(ret);-
259 /* Don't set the negative flag if it's zero. */-
260 if (ret->top != 0)
ret->top != 0Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8-36
261 ret->neg = neg;
executed 36 times by 1 test: ret->neg = neg;
Executed by:
  • libcrypto.so.1.1
36
262 return num;
executed 44 times by 1 test: return num;
Executed by:
  • libcrypto.so.1.1
44
263 err:-
264 if (*bn == NULL)
*bn == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
265 BN_free(ret);
never executed: BN_free(ret);
0
266 return 0;
never executed: return 0;
0
267}-
268-
269int BN_asc2bn(BIGNUM **bn, const char *a)-
270{-
271 const char *p = a;-
272-
273 if (*p == '-')
*p == '-'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5-9
274 p++;
executed 5 times by 1 test: p++;
Executed by:
  • libcrypto.so.1.1
5
275-
276 if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) {
p[0] == '0'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
p[1] == 'X'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
p[1] == 'x'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-8
277 if (!BN_hex2bn(bn, p + 2))
!BN_hex2bn(bn, p + 2)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
278 return 0;
never executed: return 0;
0
279 } else {
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3
280 if (!BN_dec2bn(bn, p))
!BN_dec2bn(bn, p)Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
281 return 0;
never executed: return 0;
0
282 }
executed 11 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
11
283 /* Don't set the negative flag if it's zero. */-
284 if (*a == '-' && (*bn)->top != 0)
*a == '-'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(*bn)->top != 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-9
285 (*bn)->neg = 1;
executed 4 times by 1 test: (*bn)->neg = 1;
Executed by:
  • libcrypto.so.1.1
4
286 return 1;
executed 14 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
14
287}-
288-
289# ifndef OPENSSL_NO_STDIO-
290int BN_print_fp(FILE *fp, const BIGNUM *a)-
291{-
292 BIO *b;-
293 int ret;-
294-
295 if ((b = BIO_new(BIO_s_file())) == NULL)
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
296 return 0;
never executed: return 0;
0
297 BIO_set_fp(b, fp, BIO_NOCLOSE);-
298 ret = BN_print(b, a);-
299 BIO_free(b);-
300 return ret;
never executed: return ret;
0
301}-
302# endif-
303-
304int BN_print(BIO *bp, const BIGNUM *a)-
305{-
306 int i, j, v, z = 0;-
307 int ret = 0;-
308-
309 if ((a->neg) && BIO_write(bp, "-", 1) != 1)
(a->neg)Description
TRUEnever evaluated
FALSEevaluated 11205 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
BIO_write(bp, "-", 1) != 1Description
TRUEnever evaluated
FALSEnever evaluated
0-11205
310 goto end;
never executed: goto end;
0
311 if (BN_is_zero(a) && BIO_write(bp, "0", 1) != 1)
BN_is_zero(a)Description
TRUEevaluated 331 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10874 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
BIO_write(bp, "0", 1) != 1Description
TRUEnever evaluated
FALSEevaluated 331 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10874
312 goto end;
never executed: goto end;
0
313 for (i = a->top - 1; i >= 0; i--) {
i >= 0Description
TRUEevaluated 30388 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11205 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
11205-30388
314 for (j = BN_BITS2 - 4; j >= 0; j -= 4) {
j >= 0Description
TRUEevaluated 486208 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 30388 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
30388-486208
315 /* strip leading zeros */-
316 v = (int)((a->d[i] >> j) & 0x0f);-
317 if (z || v != 0) {
zDescription
TRUEevaluated 346049 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 140159 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
v != 0Description
TRUEevaluated 10874 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 129285 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
10874-346049
318 if (BIO_write(bp, &Hex[v], 1) != 1)
BIO_write(bp, &Hex[v], 1) != 1Description
TRUEnever evaluated
FALSEevaluated 356923 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-356923
319 goto end;
never executed: goto end;
0
320 z = 1;-
321 }
executed 356923 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
356923
322 }
executed 486208 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
486208
323 }
executed 30388 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
30388
324 ret = 1;-
325 end:
code before this statement executed 11205 times by 1 test: end:
Executed by:
  • libcrypto.so.1.1
11205
326 return ret;
executed 11205 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
11205
327}-
328-
329char *BN_options(void)-
330{-
331 static int init = 0;-
332 static char data[16];-
333-
334 if (!init) {
!initDescription
TRUEnever evaluated
FALSEnever evaluated
0
335 init++;-
336#ifdef BN_LLONG-
337 BIO_snprintf(data, sizeof(data), "bn(%zu,%zu)",-
338 sizeof(BN_ULLONG) * 8, sizeof(BN_ULONG) * 8);-
339#else-
340 BIO_snprintf(data, sizeof(data), "bn(%zu,%zu)",-
341 sizeof(BN_ULONG) * 8, sizeof(BN_ULONG) * 8);-
342#endif-
343 }
never executed: end of block
0
344 return data;
never executed: return data;
0
345}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2