Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/x_long.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||||||||
10 | static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||||||||
11 | - | |||||||||||||||||||
12 | static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); | - | ||||||||||||||||||
13 | static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); | - | ||||||||||||||||||
14 | static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); | - | ||||||||||||||||||
15 | - | |||||||||||||||||||
16 | static ASN1_PRIMITIVE_FUNCS long_pf = { | - | ||||||||||||||||||
17 | - | |||||||||||||||||||
18 | ((void *)0) | - | ||||||||||||||||||
19 | , 0, | - | ||||||||||||||||||
20 | long_new, | - | ||||||||||||||||||
21 | long_free, | - | ||||||||||||||||||
22 | long_free, | - | ||||||||||||||||||
23 | long_c2i, | - | ||||||||||||||||||
24 | long_i2c, | - | ||||||||||||||||||
25 | long_print | - | ||||||||||||||||||
26 | }; | - | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | const ASN1_ITEM LONG_it = { | - | ||||||||||||||||||
29 | .itype = 0x0, | - | ||||||||||||||||||
30 | .utype = 2, | - | ||||||||||||||||||
31 | .templates = | - | ||||||||||||||||||
32 | ((void *)0) | - | ||||||||||||||||||
33 | , | - | ||||||||||||||||||
34 | .tcount = 0, | - | ||||||||||||||||||
35 | .funcs = &long_pf, | - | ||||||||||||||||||
36 | .size = 0x7fffffffL, | - | ||||||||||||||||||
37 | .sname = "LONG", | - | ||||||||||||||||||
38 | }; | - | ||||||||||||||||||
39 | - | |||||||||||||||||||
40 | const ASN1_ITEM ZLONG_it = { | - | ||||||||||||||||||
41 | .itype = 0x0, | - | ||||||||||||||||||
42 | .utype = 2, | - | ||||||||||||||||||
43 | .templates = | - | ||||||||||||||||||
44 | ((void *)0) | - | ||||||||||||||||||
45 | , | - | ||||||||||||||||||
46 | .tcount = 0, | - | ||||||||||||||||||
47 | .funcs = &long_pf, | - | ||||||||||||||||||
48 | .size = 0, | - | ||||||||||||||||||
49 | .sname = "ZLONG", | - | ||||||||||||||||||
50 | }; | - | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | static int | - | ||||||||||||||||||
53 | long_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||||||||
54 | { | - | ||||||||||||||||||
55 | *(long *)pval = it->size; | - | ||||||||||||||||||
56 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
57 | } | - | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | static void | - | ||||||||||||||||||
60 | long_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||||||||
61 | { | - | ||||||||||||||||||
62 | *(long *)pval = it->size; | - | ||||||||||||||||||
63 | } executed 126 times by 1 test: end of block Executed by:
| 126 | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | static int | - | ||||||||||||||||||
66 | long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, | - | ||||||||||||||||||
67 | const ASN1_ITEM *it) | - | ||||||||||||||||||
68 | { | - | ||||||||||||||||||
69 | long ltmp; | - | ||||||||||||||||||
70 | unsigned long utmp; | - | ||||||||||||||||||
71 | int clen, pad, i; | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | char *cp = (char *)pval; | - | ||||||||||||||||||
74 | - | |||||||||||||||||||
75 | - | |||||||||||||||||||
76 | memcpy(<mp, cp, sizeof(long)); | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | if (ltmp == it->size
| 60-378 | ||||||||||||||||||
79 | return executed 378 times by 1 test: -1;return -1; Executed by:
executed 378 times by 1 test: return -1; Executed by:
| 378 | ||||||||||||||||||
80 | - | |||||||||||||||||||
81 | - | |||||||||||||||||||
82 | - | |||||||||||||||||||
83 | - | |||||||||||||||||||
84 | if (ltmp < 0
| 0-60 | ||||||||||||||||||
85 | utmp = -ltmp - 1; never executed: utmp = -ltmp - 1; | 0 | ||||||||||||||||||
86 | else | - | ||||||||||||||||||
87 | utmp = ltmp; executed 60 times by 2 tests: utmp = ltmp; Executed by:
| 60 | ||||||||||||||||||
88 | clen = BN_num_bits_word(utmp); | - | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | if (!(clen & 0x7)
| 0-60 | ||||||||||||||||||
91 | pad = 1; executed 60 times by 2 tests: pad = 1; Executed by:
| 60 | ||||||||||||||||||
92 | else | - | ||||||||||||||||||
93 | pad = 0; never executed: pad = 0; | 0 | ||||||||||||||||||
94 | - | |||||||||||||||||||
95 | - | |||||||||||||||||||
96 | clen = (clen + 7) >> 3; | - | ||||||||||||||||||
97 | - | |||||||||||||||||||
98 | if (cont
| 15-45 | ||||||||||||||||||
99 | if (pad
| 0-15 | ||||||||||||||||||
100 | * executed 15 times by 2 tests: cont++ = (*cont++ = (ltmp < 0) ? 0xff : 0; Executed by:
executed 15 times by 2 tests: *cont++ = (ltmp < 0) ? 0xff : 0; Executed by:
| 0-15 | ||||||||||||||||||
101 | for (i = clen - 1; i >= 0
| 14-15 | ||||||||||||||||||
102 | cont[i] = (unsigned char)(utmp & 0xff); | - | ||||||||||||||||||
103 | if (ltmp < 0
| 0-14 | ||||||||||||||||||
104 | cont[i] ^= 0xff; never executed: cont[i] ^= 0xff; | 0 | ||||||||||||||||||
105 | utmp >>= 8; | - | ||||||||||||||||||
106 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
107 | } executed 15 times by 2 tests: end of block Executed by:
| 15 | ||||||||||||||||||
108 | return executed 60 times by 2 tests: clen + pad;return clen + pad; Executed by:
executed 60 times by 2 tests: return clen + pad; Executed by:
| 60 | ||||||||||||||||||
109 | } | - | ||||||||||||||||||
110 | - | |||||||||||||||||||
111 | static int | - | ||||||||||||||||||
112 | long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, | - | ||||||||||||||||||
113 | char *free_cont, const ASN1_ITEM *it) | - | ||||||||||||||||||
114 | { | - | ||||||||||||||||||
115 | int neg, i; | - | ||||||||||||||||||
116 | long ltmp; | - | ||||||||||||||||||
117 | unsigned long utmp = 0; | - | ||||||||||||||||||
118 | char *cp = (char *)pval; | - | ||||||||||||||||||
119 | if (len > (int)sizeof(long)
| 0-79 | ||||||||||||||||||
120 | ERR_put_error(13,(0xfff),(128),__FILE__,176); | - | ||||||||||||||||||
121 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
122 | } | - | ||||||||||||||||||
123 | - | |||||||||||||||||||
124 | if (len
| 0-79 | ||||||||||||||||||
125 | neg = 1; never executed: neg = 1; | 0 | ||||||||||||||||||
126 | else | - | ||||||||||||||||||
127 | neg = 0; executed 79 times by 5 tests: neg = 0; Executed by:
| 79 | ||||||||||||||||||
128 | utmp = 0; | - | ||||||||||||||||||
129 | for (i = 0; i < len
| 79-93 | ||||||||||||||||||
130 | utmp <<= 8; | - | ||||||||||||||||||
131 | if (neg
| 0-93 | ||||||||||||||||||
132 | utmp |= cont[i] ^ 0xff; never executed: utmp |= cont[i] ^ 0xff; | 0 | ||||||||||||||||||
133 | else | - | ||||||||||||||||||
134 | utmp |= cont[i]; executed 93 times by 5 tests: utmp |= cont[i]; Executed by:
| 93 | ||||||||||||||||||
135 | } | - | ||||||||||||||||||
136 | ltmp = (long)utmp; | - | ||||||||||||||||||
137 | if (neg
| 0-79 | ||||||||||||||||||
138 | ltmp++; | - | ||||||||||||||||||
139 | ltmp = -ltmp; | - | ||||||||||||||||||
140 | } never executed: end of block | 0 | ||||||||||||||||||
141 | if (ltmp == it->size
| 0-79 | ||||||||||||||||||
142 | ERR_put_error(13,(0xfff),(128),__FILE__,198); | - | ||||||||||||||||||
143 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
144 | } | - | ||||||||||||||||||
145 | memcpy(cp, <mp, sizeof(long)); | - | ||||||||||||||||||
146 | return executed 79 times by 5 tests: 1;return 1; Executed by:
executed 79 times by 5 tests: return 1; Executed by:
| 79 | ||||||||||||||||||
147 | } | - | ||||||||||||||||||
148 | - | |||||||||||||||||||
149 | static int | - | ||||||||||||||||||
150 | long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, | - | ||||||||||||||||||
151 | const ASN1_PCTX *pctx) | - | ||||||||||||||||||
152 | { | - | ||||||||||||||||||
153 | return never executed: BIO_printf(out, "%ld\n", *(long *)pval);return BIO_printf(out, "%ld\n", *(long *)pval); never executed: return BIO_printf(out, "%ld\n", *(long *)pval); | 0 | ||||||||||||||||||
154 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |