| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/ssl/bs_cbs.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | void | - | ||||||||||||||||||||||||
| 5 | CBS_init(CBS *cbs, const uint8_t *data, size_t len) | - | ||||||||||||||||||||||||
| 6 | { | - | ||||||||||||||||||||||||
| 7 | cbs->data = data; | - | ||||||||||||||||||||||||
| 8 | cbs->initial_len = len; | - | ||||||||||||||||||||||||
| 9 | cbs->len = len; | - | ||||||||||||||||||||||||
| 10 | } executed 5272 times by 10 tests: end of blockExecuted by:
| 5272 | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | void | - | ||||||||||||||||||||||||
| 13 | CBS_dup(const CBS *cbs, CBS *out) | - | ||||||||||||||||||||||||
| 14 | { | - | ||||||||||||||||||||||||
| 15 | CBS_init(out, CBS_data(cbs), CBS_len(cbs)); | - | ||||||||||||||||||||||||
| 16 | out->initial_len = cbs->initial_len; | - | ||||||||||||||||||||||||
| 17 | } executed 139 times by 6 tests: end of blockExecuted by:
| 139 | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | static int | - | ||||||||||||||||||||||||
| 20 | cbs_get(CBS *cbs, const uint8_t **p, size_t n) | - | ||||||||||||||||||||||||
| 21 | { | - | ||||||||||||||||||||||||
| 22 | if (cbs->len < n
| 41-12534 | ||||||||||||||||||||||||
| 23 | return executed 41 times by 3 tests: 0;return 0;Executed by:
executed 41 times by 3 tests: return 0;Executed by:
| 41 | ||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | *p = cbs->data; | - | ||||||||||||||||||||||||
| 26 | cbs->data += n; | - | ||||||||||||||||||||||||
| 27 | cbs->len -= n; | - | ||||||||||||||||||||||||
| 28 | return executed 12534 times by 10 tests: 1;return 1;Executed by:
executed 12534 times by 10 tests: return 1;Executed by:
| 12534 | ||||||||||||||||||||||||
| 29 | } | - | ||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||
| 31 | size_t | - | ||||||||||||||||||||||||
| 32 | CBS_offset(const CBS *cbs) | - | ||||||||||||||||||||||||
| 33 | { | - | ||||||||||||||||||||||||
| 34 | return executed 11 times by 1 test: cbs->initial_len - cbs->len;return cbs->initial_len - cbs->len;Executed by:
executed 11 times by 1 test: return cbs->initial_len - cbs->len;Executed by:
| 11 | ||||||||||||||||||||||||
| 35 | } | - | ||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||
| 37 | int | - | ||||||||||||||||||||||||
| 38 | CBS_skip(CBS *cbs, size_t len) | - | ||||||||||||||||||||||||
| 39 | { | - | ||||||||||||||||||||||||
| 40 | const uint8_t *dummy; | - | ||||||||||||||||||||||||
| 41 | return executed 148 times by 3 tests: cbs_get(cbs, &dummy, len);return cbs_get(cbs, &dummy, len);Executed by:
executed 148 times by 3 tests: return cbs_get(cbs, &dummy, len);Executed by:
| 148 | ||||||||||||||||||||||||
| 42 | } | - | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | const uint8_t * | - | ||||||||||||||||||||||||
| 45 | CBS_data(const CBS *cbs) | - | ||||||||||||||||||||||||
| 46 | { | - | ||||||||||||||||||||||||
| 47 | return executed 959 times by 7 tests: cbs->data;return cbs->data;Executed by:
executed 959 times by 7 tests: return cbs->data;Executed by:
| 959 | ||||||||||||||||||||||||
| 48 | } | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | size_t | - | ||||||||||||||||||||||||
| 51 | CBS_len(const CBS *cbs) | - | ||||||||||||||||||||||||
| 52 | { | - | ||||||||||||||||||||||||
| 53 | return executed 5934 times by 8 tests: cbs->len;return cbs->len;Executed by:
executed 5934 times by 8 tests: return cbs->len;Executed by:
| 5934 | ||||||||||||||||||||||||
| 54 | } | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | int | - | ||||||||||||||||||||||||
| 57 | CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) | - | ||||||||||||||||||||||||
| 58 | { | - | ||||||||||||||||||||||||
| 59 | free(*out_ptr); | - | ||||||||||||||||||||||||
| 60 | *out_ptr = | - | ||||||||||||||||||||||||
| 61 | ((void *)0) | - | ||||||||||||||||||||||||
| 62 | ; | - | ||||||||||||||||||||||||
| 63 | *out_len = 0; | - | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | if (cbs->len == 0
| 0-132 | ||||||||||||||||||||||||
| 66 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | if ((*
| 0-132 | ||||||||||||||||||||||||
| 69 | ((void *)0)
| 0-132 | ||||||||||||||||||||||||
| 70 | ) | - | ||||||||||||||||||||||||
| 71 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | memcpy(*out_ptr, cbs->data, cbs->len); | - | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | *out_len = cbs->len; | - | ||||||||||||||||||||||||
| 76 | return executed 132 times by 5 tests: 1;return 1;Executed by:
executed 132 times by 5 tests: return 1;Executed by:
| 132 | ||||||||||||||||||||||||
| 77 | } | - | ||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | int | - | ||||||||||||||||||||||||
| 80 | CBS_strdup(const CBS *cbs, char **out_ptr) | - | ||||||||||||||||||||||||
| 81 | { | - | ||||||||||||||||||||||||
| 82 | free(*out_ptr); | - | ||||||||||||||||||||||||
| 83 | *out_ptr = | - | ||||||||||||||||||||||||
| 84 | (__extension__ (__builtin_constant_p (
| 0-6 | ||||||||||||||||||||||||
| 85 | (const char *)cbs->data
| 0-6 | ||||||||||||||||||||||||
| 86 | )
| 0-6 | ||||||||||||||||||||||||
| 87 | (const char *)cbs->data
| 0 | ||||||||||||||||||||||||
| 88 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
| 89 | (const char *)cbs->data
| 0 | ||||||||||||||||||||||||
| 90 | ) == 1)
| 0 | ||||||||||||||||||||||||
| 91 | (const char *)cbs->data
| 0 | ||||||||||||||||||||||||
| 92 | ))[0] == '\0'
| 0 | ||||||||||||||||||||||||
| 93 | (const char *)cbs->data | - | ||||||||||||||||||||||||
| 94 | ) + 1; size_t __n = ( | - | ||||||||||||||||||||||||
| 95 | cbs->len | - | ||||||||||||||||||||||||
| 96 | ); char *__retval; if (__n < __len
never executed: __retval = (char *) malloc (__len); if (__retval != ((void *)0)__len = __n + 1;
| 0 | ||||||||||||||||||||||||
| 97 | (const char *)cbs->data | - | ||||||||||||||||||||||||
| 98 | , __len - 1); } never executed: __retval; })) : __strndup (end of block | 0 | ||||||||||||||||||||||||
| 99 | (const char *)cbs->data | - | ||||||||||||||||||||||||
| 100 | , | - | ||||||||||||||||||||||||
| 101 | cbs->len | - | ||||||||||||||||||||||||
| 102 | ))) | - | ||||||||||||||||||||||||
| 103 | ; | - | ||||||||||||||||||||||||
| 104 | return executed 6 times by 3 tests: (*out_ptr != return (*out_ptr != ((void *)0) );Executed by:
executed 6 times by 3 tests: return (*out_ptr != ((void *)0) );Executed by:
| 6 | ||||||||||||||||||||||||
| 105 | ((void *)0) executed 6 times by 3 tests: return (*out_ptr != ((void *)0) );Executed by:
| 6 | ||||||||||||||||||||||||
| 106 | ); executed 6 times by 3 tests: return (*out_ptr != ((void *)0) );Executed by:
| 6 | ||||||||||||||||||||||||
| 107 | } | - | ||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||
| 109 | int | - | ||||||||||||||||||||||||
| 110 | CBS_write_bytes(const CBS *cbs, uint8_t *dst, size_t dst_len, size_t *copied) | - | ||||||||||||||||||||||||
| 111 | { | - | ||||||||||||||||||||||||
| 112 | if (dst_len < cbs->len
| 0-361 | ||||||||||||||||||||||||
| 113 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | memmove(dst, cbs->data, cbs->len); | - | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | if (copied !=
| 73-288 | ||||||||||||||||||||||||
| 118 | ((void *)0)
| 73-288 | ||||||||||||||||||||||||
| 119 | ) | - | ||||||||||||||||||||||||
| 120 | * executed 73 times by 4 tests: copied = cbs->len;*copied = cbs->len;Executed by:
executed 73 times by 4 tests: *copied = cbs->len;Executed by:
| 73 | ||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | return executed 361 times by 5 tests: 1;return 1;Executed by:
executed 361 times by 5 tests: return 1;Executed by:
| 361 | ||||||||||||||||||||||||
| 123 | } | - | ||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | int | - | ||||||||||||||||||||||||
| 126 | CBS_contains_zero_byte(const CBS *cbs) | - | ||||||||||||||||||||||||
| 127 | { | - | ||||||||||||||||||||||||
| 128 | return executed 67 times by 4 tests: memchr(cbs->data, 0, cbs->len) != return memchr(cbs->data, 0, cbs->len) != ((void *)0) ;Executed by:
executed 67 times by 4 tests: return memchr(cbs->data, 0, cbs->len) != ((void *)0) ;Executed by:
| 67 | ||||||||||||||||||||||||
| 129 | ((void *)0) executed 67 times by 4 tests: return memchr(cbs->data, 0, cbs->len) != ((void *)0) ;Executed by:
| 67 | ||||||||||||||||||||||||
| 130 | ; executed 67 times by 4 tests: return memchr(cbs->data, 0, cbs->len) != ((void *)0) ;Executed by:
| 67 | ||||||||||||||||||||||||
| 131 | } | - | ||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | int | - | ||||||||||||||||||||||||
| 134 | CBS_mem_equal(const CBS *cbs, const uint8_t *data, size_t len) | - | ||||||||||||||||||||||||
| 135 | { | - | ||||||||||||||||||||||||
| 136 | if (len != cbs->len
| 1-270 | ||||||||||||||||||||||||
| 137 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | return executed 270 times by 4 tests: timingsafe_memcmp(cbs->data, data, len) == 0;return timingsafe_memcmp(cbs->data, data, len) == 0;Executed by:
executed 270 times by 4 tests: return timingsafe_memcmp(cbs->data, data, len) == 0;Executed by:
| 270 | ||||||||||||||||||||||||
| 140 | } | - | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | static int | - | ||||||||||||||||||||||||
| 143 | cbs_get_u(CBS *cbs, uint32_t *out, size_t len) | - | ||||||||||||||||||||||||
| 144 | { | - | ||||||||||||||||||||||||
| 145 | uint32_t result = 0; | - | ||||||||||||||||||||||||
| 146 | size_t i; | - | ||||||||||||||||||||||||
| 147 | const uint8_t *data; | - | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | if (len < 1
| 0-7138 | ||||||||||||||||||||||||
| 150 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||
| 152 | if (!cbs_get(cbs, &data, len)
| 6-7132 | ||||||||||||||||||||||||
| 153 | return executed 6 times by 2 tests: 0;return 0;Executed by:
executed 6 times by 2 tests: return 0;Executed by:
| 6 | ||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||
| 155 | for (i = 0; i < len
| 7132-14973 | ||||||||||||||||||||||||
| 156 | result <<= 8; | - | ||||||||||||||||||||||||
| 157 | result |= data[i]; | - | ||||||||||||||||||||||||
| 158 | } executed 14973 times by 9 tests: end of blockExecuted by:
| 14973 | ||||||||||||||||||||||||
| 159 | *out = result; | - | ||||||||||||||||||||||||
| 160 | return executed 7132 times by 9 tests: 1;return 1;Executed by:
executed 7132 times by 9 tests: return 1;Executed by:
| 7132 | ||||||||||||||||||||||||
| 161 | } | - | ||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | int | - | ||||||||||||||||||||||||
| 164 | CBS_get_u8(CBS *cbs, uint8_t *out) | - | ||||||||||||||||||||||||
| 165 | { | - | ||||||||||||||||||||||||
| 166 | const uint8_t *v; | - | ||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | if (!cbs_get(cbs, &v, 1)
| 2-3071 | ||||||||||||||||||||||||
| 169 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | *out = *v; | - | ||||||||||||||||||||||||
| 172 | return executed 3071 times by 7 tests: 1;return 1;Executed by:
executed 3071 times by 7 tests: return 1;Executed by:
| 3071 | ||||||||||||||||||||||||
| 173 | } | - | ||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||
| 175 | int | - | ||||||||||||||||||||||||
| 176 | CBS_get_u16(CBS *cbs, uint16_t *out) | - | ||||||||||||||||||||||||
| 177 | { | - | ||||||||||||||||||||||||
| 178 | uint32_t v; | - | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | if (!cbs_get_u(cbs, &v, 2)
| 4-4498 | ||||||||||||||||||||||||
| 181 | return executed 4 times by 2 tests: 0;return 0;Executed by:
executed 4 times by 2 tests: return 0;Executed by:
| 4 | ||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | *out = v; | - | ||||||||||||||||||||||||
| 184 | return executed 4498 times by 9 tests: 1;return 1;Executed by:
executed 4498 times by 9 tests: return 1;Executed by:
| 4498 | ||||||||||||||||||||||||
| 185 | } | - | ||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||
| 187 | int | - | ||||||||||||||||||||||||
| 188 | CBS_get_u24(CBS *cbs, uint32_t *out) | - | ||||||||||||||||||||||||
| 189 | { | - | ||||||||||||||||||||||||
| 190 | return executed 874 times by 4 tests: cbs_get_u(cbs, out, 3);return cbs_get_u(cbs, out, 3);Executed by:
executed 874 times by 4 tests: return cbs_get_u(cbs, out, 3);Executed by:
| 874 | ||||||||||||||||||||||||
| 191 | } | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | int | - | ||||||||||||||||||||||||
| 194 | CBS_get_u32(CBS *cbs, uint32_t *out) | - | ||||||||||||||||||||||||
| 195 | { | - | ||||||||||||||||||||||||
| 196 | return executed 60 times by 2 tests: cbs_get_u(cbs, out, 4);return cbs_get_u(cbs, out, 4);Executed by:
executed 60 times by 2 tests: return cbs_get_u(cbs, out, 4);Executed by:
| 60 | ||||||||||||||||||||||||
| 197 | } | - | ||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||
| 199 | int | - | ||||||||||||||||||||||||
| 200 | CBS_get_bytes(CBS *cbs, CBS *out, size_t len) | - | ||||||||||||||||||||||||
| 201 | { | - | ||||||||||||||||||||||||
| 202 | const uint8_t *v; | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | if (!cbs_get(cbs, &v, len)
| 30-2186 | ||||||||||||||||||||||||
| 205 | return executed 30 times by 2 tests: 0;return 0;Executed by:
executed 30 times by 2 tests: return 0;Executed by:
| 30 | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | CBS_init(out, v, len); | - | ||||||||||||||||||||||||
| 208 | return executed 2186 times by 7 tests: 1;return 1;Executed by:
executed 2186 times by 7 tests: return 1;Executed by:
| 2186 | ||||||||||||||||||||||||
| 209 | } | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | static int | - | ||||||||||||||||||||||||
| 212 | cbs_get_length_prefixed(CBS *cbs, CBS *out, size_t len_len) | - | ||||||||||||||||||||||||
| 213 | { | - | ||||||||||||||||||||||||
| 214 | uint32_t len; | - | ||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||
| 216 | if (!cbs_get_u(cbs, &len, len_len)
| 2-1694 | ||||||||||||||||||||||||
| 217 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | return executed 1694 times by 6 tests: CBS_get_bytes(cbs, out, len);return CBS_get_bytes(cbs, out, len);Executed by:
executed 1694 times by 6 tests: return CBS_get_bytes(cbs, out, len);Executed by:
| 1694 | ||||||||||||||||||||||||
| 220 | } | - | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | int | - | ||||||||||||||||||||||||
| 223 | CBS_get_u8_length_prefixed(CBS *cbs, CBS *out) | - | ||||||||||||||||||||||||
| 224 | { | - | ||||||||||||||||||||||||
| 225 | return executed 438 times by 6 tests: cbs_get_length_prefixed(cbs, out, 1);return cbs_get_length_prefixed(cbs, out, 1);Executed by:
executed 438 times by 6 tests: return cbs_get_length_prefixed(cbs, out, 1);Executed by:
| 438 | ||||||||||||||||||||||||
| 226 | } | - | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | int | - | ||||||||||||||||||||||||
| 229 | CBS_get_u16_length_prefixed(CBS *cbs, CBS *out) | - | ||||||||||||||||||||||||
| 230 | { | - | ||||||||||||||||||||||||
| 231 | return executed 1102 times by 6 tests: cbs_get_length_prefixed(cbs, out, 2);return cbs_get_length_prefixed(cbs, out, 2);Executed by:
executed 1102 times by 6 tests: return cbs_get_length_prefixed(cbs, out, 2);Executed by:
| 1102 | ||||||||||||||||||||||||
| 232 | } | - | ||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||
| 234 | int | - | ||||||||||||||||||||||||
| 235 | CBS_get_u24_length_prefixed(CBS *cbs, CBS *out) | - | ||||||||||||||||||||||||
| 236 | { | - | ||||||||||||||||||||||||
| 237 | return executed 156 times by 3 tests: cbs_get_length_prefixed(cbs, out, 3);return cbs_get_length_prefixed(cbs, out, 3);Executed by:
executed 156 times by 3 tests: return cbs_get_length_prefixed(cbs, out, 3);Executed by:
| 156 | ||||||||||||||||||||||||
| 238 | } | - | ||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | int | - | ||||||||||||||||||||||||
| 241 | CBS_get_any_asn1_element(CBS *cbs, CBS *out, unsigned int *out_tag, | - | ||||||||||||||||||||||||
| 242 | size_t *out_header_len) | - | ||||||||||||||||||||||||
| 243 | { | - | ||||||||||||||||||||||||
| 244 | return executed 70 times by 2 tests: cbs_get_any_asn1_element_internal(cbs, out, out_tag,return cbs_get_any_asn1_element_internal(cbs, out, out_tag, out_header_len, 1);Executed by:
executed 70 times by 2 tests: return cbs_get_any_asn1_element_internal(cbs, out, out_tag, out_header_len, 1);Executed by:
| 70 | ||||||||||||||||||||||||
| 245 | out_header_len, 1); executed 70 times by 2 tests: return cbs_get_any_asn1_element_internal(cbs, out, out_tag, out_header_len, 1);Executed by:
| 70 | ||||||||||||||||||||||||
| 246 | } | - | ||||||||||||||||||||||||
| 247 | int | - | ||||||||||||||||||||||||
| 248 | cbs_get_any_asn1_element_internal(CBS *cbs, CBS *out, unsigned int *out_tag, | - | ||||||||||||||||||||||||
| 249 | size_t *out_header_len, int strict) | - | ||||||||||||||||||||||||
| 250 | { | - | ||||||||||||||||||||||||
| 251 | uint8_t tag, length_byte; | - | ||||||||||||||||||||||||
| 252 | CBS header = *cbs; | - | ||||||||||||||||||||||||
| 253 | CBS throwaway; | - | ||||||||||||||||||||||||
| 254 | size_t len; | - | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | if (out ==
| 0-101 | ||||||||||||||||||||||||
| 257 | ((void *)0)
| 0-101 | ||||||||||||||||||||||||
| 258 | ) | - | ||||||||||||||||||||||||
| 259 | out = &throwaway; never executed: out = &throwaway; | 0 | ||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | if (!CBS_get_u8(&header, &tag)
| 0-101 | ||||||||||||||||||||||||
| 266 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | if ((
| 0-101 | ||||||||||||||||||||||||
| 270 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||
| 272 | if (out_tag !=
| 0-101 | ||||||||||||||||||||||||
| 273 | ((void *)0)
| 0-101 | ||||||||||||||||||||||||
| 274 | ) | - | ||||||||||||||||||||||||
| 275 | * executed 101 times by 2 tests: out_tag = tag;*out_tag = tag;Executed by:
executed 101 times by 2 tests: *out_tag = tag;Executed by:
| 101 | ||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||
| 277 | if ((
| 17-84 | ||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||
| 279 | len = ((size_t) length_byte) + 2; | - | ||||||||||||||||||||||||
| 280 | if (out_header_len !=
| 0-84 | ||||||||||||||||||||||||
| 281 | ((void *)0)
| 0-84 | ||||||||||||||||||||||||
| 282 | ) | - | ||||||||||||||||||||||||
| 283 | * executed 84 times by 2 tests: out_header_len = 2;*out_header_len = 2;Executed by:
executed 84 times by 2 tests: *out_header_len = 2;Executed by:
| 84 | ||||||||||||||||||||||||
| 284 | - | |||||||||||||||||||||||||
| 285 | } executed 84 times by 2 tests: else {end of blockExecuted by:
| 84 | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | const size_t num_bytes = length_byte & 0x7f; | - | ||||||||||||||||||||||||
| 288 | uint32_t len32; | - | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | if (num_bytes == 0x7f
| 0-17 | ||||||||||||||||||||||||
| 292 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | if (num_bytes == 0
| 6-11 | ||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||
| 297 | if (strict
| 1-10 | ||||||||||||||||||||||||
| 298 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||
| 301 | if ((
| 0-10 | ||||||||||||||||||||||||
| 302 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | if (out_header_len !=
| 0-10 | ||||||||||||||||||||||||
| 306 | ((void *)0)
| 0-10 | ||||||||||||||||||||||||
| 307 | ) | - | ||||||||||||||||||||||||
| 308 | * executed 10 times by 1 test: out_header_len = 2;*out_header_len = 2;Executed by:
executed 10 times by 1 test: *out_header_len = 2;Executed by:
| 10 | ||||||||||||||||||||||||
| 309 | return executed 10 times by 1 test: CBS_get_bytes(cbs, out, 2);return CBS_get_bytes(cbs, out, 2);Executed by:
executed 10 times by 1 test: return CBS_get_bytes(cbs, out, 2);Executed by:
| 10 | ||||||||||||||||||||||||
| 310 | } | - | ||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||
| 313 | if (num_bytes > 4
| 0-6 | ||||||||||||||||||||||||
| 314 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | if (!cbs_get_u(&header, &len32, num_bytes)
| 0-6 | ||||||||||||||||||||||||
| 317 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | if (len32 < 128
| 1-5 | ||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||
| 322 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||
| 324 | if ((
| 1-4 | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | len = len32; | - | ||||||||||||||||||||||||
| 329 | if (len + 2 + num_bytes < len
| 0-4 | ||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | len += 2 + num_bytes; | - | ||||||||||||||||||||||||
| 334 | if (out_header_len !=
| 0-4 | ||||||||||||||||||||||||
| 335 | ((void *)0)
| 0-4 | ||||||||||||||||||||||||
| 336 | ) | - | ||||||||||||||||||||||||
| 337 | * executed 4 times by 1 test: out_header_len = 2 + num_bytes;*out_header_len = 2 + num_bytes;Executed by:
executed 4 times by 1 test: *out_header_len = 2 + num_bytes;Executed by:
| 4 | ||||||||||||||||||||||||
| 338 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | return executed 88 times by 2 tests: CBS_get_bytes(cbs, out, len);return CBS_get_bytes(cbs, out, len);Executed by:
executed 88 times by 2 tests: return CBS_get_bytes(cbs, out, len);Executed by:
| 88 | ||||||||||||||||||||||||
| 341 | } | - | ||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | static int | - | ||||||||||||||||||||||||
| 344 | cbs_get_asn1(CBS *cbs, CBS *out, unsigned int tag_value, int skip_header) | - | ||||||||||||||||||||||||
| 345 | { | - | ||||||||||||||||||||||||
| 346 | size_t header_len; | - | ||||||||||||||||||||||||
| 347 | unsigned int tag; | - | ||||||||||||||||||||||||
| 348 | CBS throwaway; | - | ||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||
| 350 | if (out ==
| 0-70 | ||||||||||||||||||||||||
| 351 | ((void *)0)
| 0-70 | ||||||||||||||||||||||||
| 352 | ) | - | ||||||||||||||||||||||||
| 353 | out = &throwaway; never executed: out = &throwaway; | 0 | ||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||
| 355 | if (!CBS_get_any_asn1_element(cbs, out, &tag, &header_len)
| 5-65 | ||||||||||||||||||||||||
| 356 | tag != tag_value
| 2-63 | ||||||||||||||||||||||||
| 357 | return executed 7 times by 1 test: 0;return 0;Executed by:
executed 7 times by 1 test: return 0;Executed by:
| 7 | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | if (skip_header
| 0-63 | ||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||
| 361 | (( | - | ||||||||||||||||||||||||
| 362 | 0 | - | ||||||||||||||||||||||||
| 363 | ) ? (void) (0) : __assert_fail ( | - | ||||||||||||||||||||||||
| 364 | "0" | - | ||||||||||||||||||||||||
| 365 | , __FILE__, 351, __PRETTY_FUNCTION__)) | - | ||||||||||||||||||||||||
| 366 | ; | - | ||||||||||||||||||||||||
| 367 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 368 | } | - | ||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | return executed 63 times by 2 tests: 1;return 1;Executed by:
executed 63 times by 2 tests: return 1;Executed by:
| 63 | ||||||||||||||||||||||||
| 371 | } | - | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | int | - | ||||||||||||||||||||||||
| 374 | CBS_get_asn1(CBS *cbs, CBS *out, unsigned int tag_value) | - | ||||||||||||||||||||||||
| 375 | { | - | ||||||||||||||||||||||||
| 376 | return executed 70 times by 2 tests: cbs_get_asn1(cbs, out, tag_value, 1 );return cbs_get_asn1(cbs, out, tag_value, 1 );Executed by:
executed 70 times by 2 tests: return cbs_get_asn1(cbs, out, tag_value, 1 );Executed by:
| 70 | ||||||||||||||||||||||||
| 377 | } | - | ||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||
| 379 | int | - | ||||||||||||||||||||||||
| 380 | CBS_get_asn1_element(CBS *cbs, CBS *out, unsigned int tag_value) | - | ||||||||||||||||||||||||
| 381 | { | - | ||||||||||||||||||||||||
| 382 | return never executed: cbs_get_asn1(cbs, out, tag_value, 0 );return cbs_get_asn1(cbs, out, tag_value, 0 );never executed: return cbs_get_asn1(cbs, out, tag_value, 0 ); | 0 | ||||||||||||||||||||||||
| 383 | } | - | ||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | int | - | ||||||||||||||||||||||||
| 386 | CBS_peek_asn1_tag(const CBS *cbs, unsigned int tag_value) | - | ||||||||||||||||||||||||
| 387 | { | - | ||||||||||||||||||||||||
| 388 | if (CBS_len(cbs) < 1
| 14-29 | ||||||||||||||||||||||||
| 389 | return executed 14 times by 2 tests: 0;return 0;Executed by:
executed 14 times by 2 tests: return 0;Executed by:
| 14 | ||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | if ((
| 0-29 | ||||||||||||||||||||||||
| 396 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | return executed 29 times by 2 tests: CBS_data(cbs)[0] == tag_value;return CBS_data(cbs)[0] == tag_value;Executed by:
executed 29 times by 2 tests: return CBS_data(cbs)[0] == tag_value;Executed by:
| 29 | ||||||||||||||||||||||||
| 399 | } | - | ||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | int | - | ||||||||||||||||||||||||
| 403 | CBS_get_asn1_uint64(CBS *cbs, uint64_t *out) | - | ||||||||||||||||||||||||
| 404 | { | - | ||||||||||||||||||||||||
| 405 | CBS bytes; | - | ||||||||||||||||||||||||
| 406 | const uint8_t *data; | - | ||||||||||||||||||||||||
| 407 | size_t i, len; | - | ||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | if (!CBS_get_asn1(cbs, &bytes, (0x00 | 0x00 | 0x2))
| 1-23 | ||||||||||||||||||||||||
| 410 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||
| 412 | *out = 0; | - | ||||||||||||||||||||||||
| 413 | data = CBS_data(&bytes); | - | ||||||||||||||||||||||||
| 414 | len = CBS_len(&bytes); | - | ||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | if (len == 0
| 1-22 | ||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||
| 418 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||
| 420 | if ((
| 2-20 | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | if (data[0] == 0
| 1-15 | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||
| 428 | for (i = 0; i < len
| 18-56 | ||||||||||||||||||||||||
| 429 | if ((*
| 1-55 | ||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||
| 431 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | *out <<= 8; | - | ||||||||||||||||||||||||
| 434 | *out |= data[i]; | - | ||||||||||||||||||||||||
| 435 | } executed 55 times by 2 tests: end of blockExecuted by:
| 55 | ||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | return executed 18 times by 2 tests: 1;return 1;Executed by:
executed 18 times by 2 tests: return 1;Executed by:
| 18 | ||||||||||||||||||||||||
| 438 | } | - | ||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | int | - | ||||||||||||||||||||||||
| 441 | CBS_get_optional_asn1(CBS *cbs, CBS *out, int *out_present, unsigned int tag) | - | ||||||||||||||||||||||||
| 442 | { | - | ||||||||||||||||||||||||
| 443 | if (CBS_peek_asn1_tag(cbs, tag)
| 18-22 | ||||||||||||||||||||||||
| 444 | if (!CBS_get_asn1(cbs, out, tag)
| 0-18 | ||||||||||||||||||||||||
| 445 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||
| 447 | *out_present = 1; | - | ||||||||||||||||||||||||
| 448 | } executed 18 times by 2 tests: else {end of blockExecuted by:
| 18 | ||||||||||||||||||||||||
| 449 | *out_present = 0; | - | ||||||||||||||||||||||||
| 450 | } executed 22 times by 2 tests: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||
| 451 | return executed 40 times by 2 tests: 1;return 1;Executed by:
executed 40 times by 2 tests: return 1;Executed by:
| 40 | ||||||||||||||||||||||||
| 452 | } | - | ||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||
| 454 | int | - | ||||||||||||||||||||||||
| 455 | CBS_get_optional_asn1_octet_string(CBS *cbs, CBS *out, int *out_present, | - | ||||||||||||||||||||||||
| 456 | unsigned int tag) | - | ||||||||||||||||||||||||
| 457 | { | - | ||||||||||||||||||||||||
| 458 | CBS child; | - | ||||||||||||||||||||||||
| 459 | int present; | - | ||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | if (!CBS_get_optional_asn1(cbs, &child, &present, tag)
| 0-14 | ||||||||||||||||||||||||
| 462 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||
| 464 | if (present
| 7 | ||||||||||||||||||||||||
| 465 | if (!CBS_get_asn1(&child, out, (0x00 | 0x00 | 0x4))
| 1-6 | ||||||||||||||||||||||||
| 466 | CBS_len(&child) != 0
| 0-6 | ||||||||||||||||||||||||
| 467 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 468 | } executed 6 times by 2 tests: else {end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 469 | CBS_init(out, | - | ||||||||||||||||||||||||
| 470 | ((void *)0) | - | ||||||||||||||||||||||||
| 471 | , 0); | - | ||||||||||||||||||||||||
| 472 | } executed 7 times by 2 tests: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 473 | if (out_present
| 1-12 | ||||||||||||||||||||||||
| 474 | * executed 12 times by 2 tests: out_present = present;*out_present = present;Executed by:
executed 12 times by 2 tests: *out_present = present;Executed by:
| 12 | ||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||
| 476 | return executed 13 times by 2 tests: 1;return 1;Executed by:
executed 13 times by 2 tests: return 1;Executed by:
| 13 | ||||||||||||||||||||||||
| 477 | } | - | ||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | int | - | ||||||||||||||||||||||||
| 480 | CBS_get_optional_asn1_uint64(CBS *cbs, uint64_t *out, unsigned int tag, | - | ||||||||||||||||||||||||
| 481 | uint64_t default_value) | - | ||||||||||||||||||||||||
| 482 | { | - | ||||||||||||||||||||||||
| 483 | CBS child; | - | ||||||||||||||||||||||||
| 484 | int present; | - | ||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | if (!CBS_get_optional_asn1(cbs, &child, &present, tag)
| 0-16 | ||||||||||||||||||||||||
| 487 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||
| 489 | if (present
| 6-10 | ||||||||||||||||||||||||
| 490 | if (!CBS_get_asn1_uint64(&child, out)
| 1-5 | ||||||||||||||||||||||||
| 491 | CBS_len(&child) != 0
| 0-5 | ||||||||||||||||||||||||
| 492 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 493 | } executed 5 times by 2 tests: else {end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 494 | *out = default_value; | - | ||||||||||||||||||||||||
| 495 | } executed 10 times by 2 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||
| 496 | return executed 15 times by 2 tests: 1;return 1;Executed by:
executed 15 times by 2 tests: return 1;Executed by:
| 15 | ||||||||||||||||||||||||
| 497 | } | - | ||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||
| 499 | int | - | ||||||||||||||||||||||||
| 500 | CBS_get_optional_asn1_bool(CBS *cbs, int *out, unsigned int tag, | - | ||||||||||||||||||||||||
| 501 | int default_value) | - | ||||||||||||||||||||||||
| 502 | { | - | ||||||||||||||||||||||||
| 503 | CBS child, child2; | - | ||||||||||||||||||||||||
| 504 | int present; | - | ||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | if (!CBS_get_optional_asn1(cbs, &child, &present, tag)
| 0-4 | ||||||||||||||||||||||||
| 507 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||
| 509 | if (present
| 1-3 | ||||||||||||||||||||||||
| 510 | uint8_t boolean; | - | ||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||
| 512 | if (!CBS_get_asn1(&child, &child2, (0x00 | 0x00 | 0x1))
| 0-3 | ||||||||||||||||||||||||
| 513 | CBS_len(&child2) != 1
| 0-3 | ||||||||||||||||||||||||
| 514 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||
| 516 | boolean = CBS_data(&child2)[0]; | - | ||||||||||||||||||||||||
| 517 | if (boolean == 0
| 1-2 | ||||||||||||||||||||||||
| 518 | * executed 1 time by 1 test: out = 0;*out = 0;Executed by:
executed 1 time by 1 test: *out = 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 519 | else if (boolean == 0xff
| 1 | ||||||||||||||||||||||||
| 520 | * executed 1 time by 1 test: out = 1;*out = 1;Executed by:
executed 1 time by 1 test: *out = 1;Executed by:
| 1 | ||||||||||||||||||||||||
| 521 | else | - | ||||||||||||||||||||||||
| 522 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | } else { | - | ||||||||||||||||||||||||
| 525 | *out = default_value; | - | ||||||||||||||||||||||||
| 526 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 527 | return executed 3 times by 1 test: 1;return 1;Executed by:
executed 3 times by 1 test: return 1;Executed by:
| 3 | ||||||||||||||||||||||||
| 528 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |