OpenCoverage

x_bignum.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/x_bignum.c
Switch to Source codePreprocessed file
LineSourceCount
1static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it);-
2static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it);-
3static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it);-
4-
5static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,-
6 const ASN1_ITEM *it);-
7static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,-
8 int utype, char *free_cont, const ASN1_ITEM *it);-
9static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,-
10 int utype, char *free_cont, const ASN1_ITEM *it);-
11static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,-
12 int indent, const ASN1_PCTX *pctx);-
13-
14static ASN1_PRIMITIVE_FUNCS bignum_pf = {-
15 -
16 ((void *)0)-
17 , 0,-
18 bn_new,-
19 bn_free,-
20 0,-
21 bn_c2i,-
22 bn_i2c,-
23 bn_print-
24};-
25-
26static ASN1_PRIMITIVE_FUNCS cbignum_pf = {-
27 -
28 ((void *)0)-
29 , 0,-
30 bn_secure_new,-
31 bn_free,-
32 0,-
33 bn_secure_c2i,-
34 bn_i2c,-
35 bn_print-
36};-
37-
38const ASN1_ITEM BIGNUM_it = {-
39 0x0, 2, -
40 ((void *)0)-
41 , 0, &bignum_pf, 0, "BIGNUM"-
42};-
43-
44const ASN1_ITEM CBIGNUM_it = {-
45 0x0, 2, -
46 ((void *)0)-
47 , 0, &cbignum_pf, 1, "CBIGNUM"-
48};-
49-
50static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it)-
51{-
52 *pval = (ASN1_VALUE *)BN_new();-
53 if (*
*pval != ((void *)0)Description
TRUEevaluated 71413 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
pval !=
*pval != ((void *)0)Description
TRUEevaluated 71413 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-71413
54 ((void *)0)
*pval != ((void *)0)Description
TRUEevaluated 71413 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-71413
55 )-
56 return
executed 71413 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 71413 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
71413
57 else-
58 return
never executed: return 0;
0;
never executed: return 0;
0
59}-
60-
61static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it)-
62{-
63 *pval = (ASN1_VALUE *)BN_secure_new();-
64 if (*
*pval != ((void *)0)Description
TRUEevaluated 67853 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
pval !=
*pval != ((void *)0)Description
TRUEevaluated 67853 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-67853
65 ((void *)0)
*pval != ((void *)0)Description
TRUEevaluated 67853 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-67853
66 )-
67 return
executed 67853 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 67853 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
67853
68 else-
69 return
never executed: return 0;
0;
never executed: return 0;
0
70}-
71-
72static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it)-
73{-
74 if (!*pval
!*pvalDescription
TRUEevaluated 12507 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 26575 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
12507-26575
75 return;
executed 12507 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
12507
76 if (it->size & 1
it->size & 1Description
TRUEevaluated 11936 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14639 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
11936-14639
77 BN_clear_free((BIGNUM *)*pval);
executed 11936 times by 1 test: BN_clear_free((BIGNUM *)*pval);
Executed by:
  • libcrypto.so.1.1
11936
78 else-
79 BN_free((BIGNUM *)*pval);
executed 14639 times by 2 tests: BN_free((BIGNUM *)*pval);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
14639
80 *pval = -
81 ((void *)0)-
82 ;-
83}
executed 26575 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
26575
84-
85static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,-
86 const ASN1_ITEM *it)-
87{-
88 BIGNUM *bn;-
89 int pad;-
90 if (!*pval
!*pvalDescription
TRUEevaluated 78 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 157537 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
78-157537
91 return
executed 78 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
-1;
executed 78 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
78
92 bn = (BIGNUM *)*pval;-
93-
94 if (BN_num_bits(bn) & 0x7
BN_num_bits(bn) & 0x7Description
TRUEevaluated 113499 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 44038 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
44038-113499
95 pad = 0;
executed 113499 times by 2 tests: pad = 0;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
113499
96 else-
97 pad = 1;
executed 44038 times by 1 test: pad = 1;
Executed by:
  • libcrypto.so.1.1
44038
98 if (cont
contDescription
TRUEevaluated 29283 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 128254 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
29283-128254
99 if (pad
padDescription
TRUEevaluated 8515 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 20768 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
8515-20768
100 *
executed 8515 times by 1 test: *cont++ = 0;
Executed by:
  • libcrypto.so.1.1
cont++ = 0;
executed 8515 times by 1 test: *cont++ = 0;
Executed by:
  • libcrypto.so.1.1
8515
101 BN_bn2bin(bn, cont);-
102 }
executed 29283 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
29283
103 return
executed 157537 times by 2 tests: return pad + ((BN_num_bits(bn)+7)/8);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
pad + ((BN_num_bits(bn)+7)/8);
executed 157537 times by 2 tests: return pad + ((BN_num_bits(bn)+7)/8);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
157537
104}-
105-
106static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,-
107 int utype, char *free_cont, const ASN1_ITEM *it)-
108{-
109 BIGNUM *bn;-
110-
111 if (*
*pval == ((void *)0)Description
TRUEevaluated 55930 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 64101 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
pval ==
*pval == ((void *)0)Description
TRUEevaluated 55930 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 64101 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
55930-64101
112 ((void *)0)
*pval == ((void *)0)Description
TRUEevaluated 55930 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 64101 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
55930-64101
113 && !bn_new(pval, it)
!bn_new(pval, it)Description
TRUEnever evaluated
FALSEevaluated 55930 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-55930
114 return
never executed: return 0;
0;
never executed: return 0;
0
115 bn = (BIGNUM *)*pval;-
116 if (!BN_bin2bn(cont, len, bn)
!BN_bin2bn(cont, len, bn)Description
TRUEnever evaluated
FALSEevaluated 120031 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
0-120031
117 bn_free(pval, it);-
118 return
never executed: return 0;
0;
never executed: return 0;
0
119 }-
120 return
executed 120031 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 120031 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
120031
121}-
122-
123static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,-
124 int utype, char *free_cont, const ASN1_ITEM *it)-
125{-
126 if (!*pval
!*pvalDescription
TRUEevaluated 29853 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 28997 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
28997-29853
127 bn_secure_new(pval, it);
executed 29853 times by 1 test: bn_secure_new(pval, it);
Executed by:
  • libcrypto.so.1.1
29853
128 return
executed 58850 times by 1 test: return bn_c2i(pval, cont, len, utype, free_cont, it);
Executed by:
  • libcrypto.so.1.1
bn_c2i(pval, cont, len, utype, free_cont, it);
executed 58850 times by 1 test: return bn_c2i(pval, cont, len, utype, free_cont, it);
Executed by:
  • libcrypto.so.1.1
58850
129}-
130-
131static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,-
132 int indent, const ASN1_PCTX *pctx)-
133{-
134 if (!BN_print(out, *(BIGNUM **)pval)
!BN_print(out,...IGNUM **)pval)Description
TRUEnever evaluated
FALSEevaluated 11205 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-11205
135 return
never executed: return 0;
0;
never executed: return 0;
0
136 if (BIO_puts(out, "\n") <= 0
BIO_puts(out, "\n") <= 0Description
TRUEnever evaluated
FALSEevaluated 11205 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-11205
137 return
never executed: return 0;
0;
never executed: return 0;
0
138 return
executed 11205 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 11205 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
11205
139}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2