Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/x_bignum.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
2 | static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
3 | static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
4 | - | |||||||||||||
5 | static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, | - | ||||||||||||
6 | const ASN1_ITEM *it); | - | ||||||||||||
7 | static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, | - | ||||||||||||
8 | int utype, char *free_cont, const ASN1_ITEM *it); | - | ||||||||||||
9 | static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, | - | ||||||||||||
10 | int utype, char *free_cont, const ASN1_ITEM *it); | - | ||||||||||||
11 | static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, | - | ||||||||||||
12 | int indent, const ASN1_PCTX *pctx); | - | ||||||||||||
13 | - | |||||||||||||
14 | static 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 | - | |||||||||||||
26 | static 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 | - | |||||||||||||
38 | const ASN1_ITEM BIGNUM_it = { | - | ||||||||||||
39 | 0x0, 2, | - | ||||||||||||
40 | ((void *)0) | - | ||||||||||||
41 | , 0, &bignum_pf, 0, "BIGNUM" | - | ||||||||||||
42 | }; | - | ||||||||||||
43 | - | |||||||||||||
44 | const ASN1_ITEM CBIGNUM_it = { | - | ||||||||||||
45 | 0x0, 2, | - | ||||||||||||
46 | ((void *)0) | - | ||||||||||||
47 | , 0, &cbignum_pf, 1, "CBIGNUM" | - | ||||||||||||
48 | }; | - | ||||||||||||
49 | - | |||||||||||||
50 | static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
51 | { | - | ||||||||||||
52 | *pval = (ASN1_VALUE *)BN_new(); | - | ||||||||||||
53 | if (*
| 0-71413 | ||||||||||||
54 | ((void *)0)
| 0-71413 | ||||||||||||
55 | ) | - | ||||||||||||
56 | return executed 71413 times by 2 tests: 1;return 1; Executed by:
executed 71413 times by 2 tests: return 1; Executed by:
| 71413 | ||||||||||||
57 | else | - | ||||||||||||
58 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
59 | } | - | ||||||||||||
60 | - | |||||||||||||
61 | static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
62 | { | - | ||||||||||||
63 | *pval = (ASN1_VALUE *)BN_secure_new(); | - | ||||||||||||
64 | if (*
| 0-67853 | ||||||||||||
65 | ((void *)0)
| 0-67853 | ||||||||||||
66 | ) | - | ||||||||||||
67 | return executed 67853 times by 1 test: 1;return 1; Executed by:
executed 67853 times by 1 test: return 1; Executed by:
| 67853 | ||||||||||||
68 | else | - | ||||||||||||
69 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
70 | } | - | ||||||||||||
71 | - | |||||||||||||
72 | static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
73 | { | - | ||||||||||||
74 | if (!*pval
| 12507-26575 | ||||||||||||
75 | return; executed 12507 times by 1 test: return; Executed by:
| 12507 | ||||||||||||
76 | if (it->size & 1
| 11936-14639 | ||||||||||||
77 | BN_clear_free((BIGNUM *)*pval); executed 11936 times by 1 test: BN_clear_free((BIGNUM *)*pval); Executed by:
| 11936 | ||||||||||||
78 | else | - | ||||||||||||
79 | BN_free((BIGNUM *)*pval); executed 14639 times by 2 tests: BN_free((BIGNUM *)*pval); Executed by:
| 14639 | ||||||||||||
80 | *pval = | - | ||||||||||||
81 | ((void *)0) | - | ||||||||||||
82 | ; | - | ||||||||||||
83 | } executed 26575 times by 2 tests: end of block Executed by:
| 26575 | ||||||||||||
84 | - | |||||||||||||
85 | static 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
| 78-157537 | ||||||||||||
91 | return executed 78 times by 1 test: -1;return -1; Executed by:
executed 78 times by 1 test: return -1; Executed by:
| 78 | ||||||||||||
92 | bn = (BIGNUM *)*pval; | - | ||||||||||||
93 | - | |||||||||||||
94 | if (BN_num_bits(bn) & 0x7
| 44038-113499 | ||||||||||||
95 | pad = 0; executed 113499 times by 2 tests: pad = 0; Executed by:
| 113499 | ||||||||||||
96 | else | - | ||||||||||||
97 | pad = 1; executed 44038 times by 1 test: pad = 1; Executed by:
| 44038 | ||||||||||||
98 | if (cont
| 29283-128254 | ||||||||||||
99 | if (pad
| 8515-20768 | ||||||||||||
100 | * executed 8515 times by 1 test: cont++ = 0;*cont++ = 0; Executed by:
executed 8515 times by 1 test: *cont++ = 0; Executed by:
| 8515 | ||||||||||||
101 | BN_bn2bin(bn, cont); | - | ||||||||||||
102 | } executed 29283 times by 2 tests: end of block Executed by:
| 29283 | ||||||||||||
103 | return executed 157537 times by 2 tests: pad + ((BN_num_bits(bn)+7)/8);return pad + ((BN_num_bits(bn)+7)/8); Executed by:
executed 157537 times by 2 tests: return pad + ((BN_num_bits(bn)+7)/8); Executed by:
| 157537 | ||||||||||||
104 | } | - | ||||||||||||
105 | - | |||||||||||||
106 | static 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 (*
| 55930-64101 | ||||||||||||
112 | ((void *)0)
| 55930-64101 | ||||||||||||
113 | && !bn_new(pval, it)
| 0-55930 | ||||||||||||
114 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
115 | bn = (BIGNUM *)*pval; | - | ||||||||||||
116 | if (!BN_bin2bn(cont, len, bn)
| 0-120031 | ||||||||||||
117 | bn_free(pval, it); | - | ||||||||||||
118 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
119 | } | - | ||||||||||||
120 | return executed 120031 times by 2 tests: 1;return 1; Executed by:
executed 120031 times by 2 tests: return 1; Executed by:
| 120031 | ||||||||||||
121 | } | - | ||||||||||||
122 | - | |||||||||||||
123 | static 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
| 28997-29853 | ||||||||||||
127 | bn_secure_new(pval, it); executed 29853 times by 1 test: bn_secure_new(pval, it); Executed by:
| 29853 | ||||||||||||
128 | return executed 58850 times by 1 test: bn_c2i(pval, cont, len, utype, free_cont, it);return bn_c2i(pval, cont, len, utype, free_cont, it); Executed by:
executed 58850 times by 1 test: return bn_c2i(pval, cont, len, utype, free_cont, it); Executed by:
| 58850 | ||||||||||||
129 | } | - | ||||||||||||
130 | - | |||||||||||||
131 | static 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)
| 0-11205 | ||||||||||||
135 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
136 | if (BIO_puts(out, "\n") <= 0
| 0-11205 | ||||||||||||
137 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
138 | return executed 11205 times by 1 test: 1;return 1; Executed by:
executed 11205 times by 1 test: return 1; Executed by:
| 11205 | ||||||||||||
139 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |